<div class="header_menu">
    <div class="container">
        <div class="header-nav clearfix">
            <?php echo $this->partial('shop/layout/headerMenu'); ?>
        </div>
    </div>
</div>
</div>
<div class="container breadcrumbs">
    <a href="<?php echo $this->url('shop'); ?>"><?php echo $this->translate('首页'); ?></a>
    <span class="sep">/</span><span><?php echo $this->translate('现金充值'); ?></span>
</div>
<div class="container">
    <div class="uc-full-box">
        <div class="row">
            <div class="span4">
                <?php echo $this->partial('shop/partial/home/leftMenu'); ?>
            </div>
            <div class="span16">
                <div class="xm-line-box uc-box uc-order-detail-box">
                    <div class="box-hd">
                        <h3 class="title">
                            <?php echo $this->translate('现金充值'); ?>
                        </h3>
                        <?php echo $this->partial('shop/partial/home/rechargeMenu'); ?>
                    </div>
                    <div class="box-bd">
                        <?php if(isset($this->userRechargeInfo)) { ?>
                            <form name="" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label"><?php echo $this->translate('充值金额'); ?>：</label>
                                    <div class="controls">
                                        <?php echo $this->shopCurrency['symbol']; ?>
                                        <input type="text" name="rechargeNum" value="<?php echo $this->userRechargeInfo->getRechargeNum(); ?>" id="input-amount" readonly class="form-control">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><?php echo $this->translate('支付方式'); ?>：</label>
                                    <div class="controls">
                                        <label class="inline">
                                            <input type="radio" name="paymentMethod" value="<?php echo $this->userRechargeInfo->getPayCode(); ?>" checked>
                                            <?php echo $this->userRechargeInfo->getPayName(); ?>
                                        </label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><?php echo $this->translate('存入金额'); ?>：</label>
                                    <div class="controls">
                                        <?php echo $this->baseCurrency['symbol']; ?>
                                        <input type="text" name="amount" value="<?php echo $this->userRechargeInfo->getBaseRechargeNum(); ?>" id="input-amount" readonly class="form-control">
                                    </div>
                                </div>
                                <div class="offset3">
                                    <a href="<?php echo $this->url('home-user-balance', ['action' => 'continueUserRecharge', 'id' => $this->userRechargeInfo->getRechargeId()]); ?>" class="btn btn-primary"><?php echo $this->translate('继续支付'); ?></a>
                                    &nbsp;&nbsp;
                                    <a href="<?php echo $this->url('home-user-balance', ['action' => 'deleteUserRecharge', 'id' => $this->userRechargeInfo->getRechargeId()]); ?>" class="btn btn-danger"><?php echo $this->translate('删除该充值记录'); ?></a>
                                </div>
                            </form>
                        <?php } else {
                            $form = $this->form;
                            $form->prepare();

                            $form->setAttributes(['class' => 'form-horizontal']);
                            $form->get('rechargeNum')->setAttributes(['class' => 'form-control', 'oninput' => 'changeBaseRecharge();']);
                            $form->get('payCode')->setAttributes(['class' => 'form-control']);
                            ?>
                            <?php echo $this->form()->openTag($form); ?>
                            <?php echo $this->formElement($form->get('shopCsrf')); ?>
                            <?php echo $this->formElementErrors($form->get('shopCsrf'), ['class'=>'error-message']); ?>

                            <div class="control-group">
                                <label class="control-label"><?php echo $this->translate('充值金额'); ?>：</label>
                                <div class="controls">
                                    <?php echo $this->shopCurrency['symbol']; ?>
                                    <?php echo $this->formElement($form->get('rechargeNum')); ?>
                                    <?php echo $this->formElementErrors($form->get('rechargeNum'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label"><?php echo $this->translate('选择支付'); ?>：</label>
                                <div class="controls">
                                    <?php $defaultPaymentCode = ''; if($this->paymentList) foreach ($this->paymentList as $paymentKey => $paymentValue) { ?>
                                        <label>
                                            <input type="radio" name="payCode" value="<?php echo $paymentValue['editAction']; ?>" <?php if (($defaultPaymentCode && $defaultPaymentCode == $paymentValue['editAction']) || (!$defaultPaymentCode && $paymentKey == 0)) echo 'checked'; ?>>
                                            <img src="<?php echo $this->basePath($paymentValue['paymentLogo']['content']); ?>" style="border:1px solid #D7D7D7; margin-left:8px;">
                                        </label>
                                    <?php } ?>
                                    <?php echo $this->formElementErrors($form->get('payCode'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label"><?php echo $this->translate('存入金额'); ?>：</label>
                                <div class="controls">
                                    <?php echo $this->baseCurrency['symbol']; ?>
                                    <input type="text" name="amount" value="0" id="input-amount" readonly class="form-control">
                                </div>
                            </div>
                            <div class="offset3">
                                <button class="btn btn-primary" type="submit"><?php echo $this->translate('点击充值'); ?></button>
                            </div>
                            <?php echo $this->form()->closeTag(); ?>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php if(!isset($this->userRechargeInfo)) { ?>
    <script type="text/javascript">

        function changeBaseRecharge() {
            let rechargeNum = $('#rechargeNum').val();
            let baseRechargeNum = accDiv(rechargeNum, <?php echo $this->shopCurrency['rate']; ?>);
            $('#input-amount').val(advFormatNumber(baseRechargeNum, 2));
        }
    </script>
<?php } ?>