<div class="content-wrapper">
    <?php
    $form = $this->form;
    $form->prepare();

    $form->get('payLogAmount')->setAttributes([
        'placeholder' => $this->translate('付款金额')
    ]);

    $form->get('payLogUser')->setAttributes([
        'placeholder' => $this->translate('付款人')
    ]);

    $form->get('payLogPaytime')->setAttributes([
        'placeholder' => $this->translate('付款时间')
    ]);

    $form->get('payLogInfo')->setAttributes([
        'placeholder' => $this->translate('付款备注信息')
    ]);

    ?>
    <section class="content-header">
        <?=$this->partial('layout/breadcrumb')?>

        <h1 class="pull-right">
            <a href="<?=$this->url('finance-payable');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?=$this->translate('返回应付账款列表')?></a>
            <?=$this->HelpUrl('financeAddPayable')?>
        </h1>
    </section>
    <?= $this->form()->openTag($form); ?>
    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?=$this->translate('付款处理')?></h3>
                    </div>

                    <div class="box-body">
                        <?=$this->formElementErrors($form->get('dberp_csrf'), ['class'=>'error-message']); ?>
                        <div class="row">
                            <div class="col-xs-3 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('采购单号')?>：</b><?=$this->escapeHtml($this->payableInfo->getPOrderSn());?>
                                </div>
                            </div>

                            <div class="col-xs-3 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('应付金额')?>：</b><?=$this->erpCurrencyFormat($this->payableInfo->getPaymentAmount());?>
                                </div>
                            </div>

                            <div class="col-xs-3 form-group">
                                <div class="col-sm-12">
                                    <b class="text-green"><?=$this->translate('已付金额')?>：</b><?=$this->erpCurrencyFormat($this->payableInfo->getFinishAmount());?>
                                </div>
                            </div>

                            <div class="col-xs-3 form-group">
                                <div class="col-sm-12">
                                    <b class="text-danger"><?=$this->translate('未付金额')?>：</b><?=$this->erpCurrencyFormat(($this->payableInfo->getPaymentAmount() - $this->payableInfo->getFinishAmount()));?>
                                </div>
                            </div>

                        </div>
                        <hr />

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=$this->translate('付款金额')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?= $this->formElement($form->get('payLogAmount')); ?>
                                <?= $this->formElementErrors($form->get('payLogAmount'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=$this->translate('付款日期')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-calendar"></i>
                                    </div>
                                    <?= $this->formElement($form->get('payLogPaytime')); ?>
                                    <?= $this->formElementErrors($form->get('payLogPaytime'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=$this->translate('付款人')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?= $this->formElement($form->get('payLogUser')); ?>
                                <?= $this->formElementErrors($form->get('payLogUser'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=$this->translate('付款凭证')?></label>
                            <div class="col-sm-3">
                                <?= $this->formElement($form->get('payFile')); ?>
                                <?= $this->formElementErrors($form->get('payFile'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?=$this->translate('付款备注')?></label>
                            <div class="col-sm-8">
                                <?= $this->formElement($form->get('payLogInfo')); ?>
                                <?= $this->formElementErrors($form->get('payLogInfo'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                    </div>
                    <div class="box-footer">
                        <?=$this->formElement($form->get('dberp_csrf')); ?>
                        <button type="submit" class="btn btn-primary col-md-offset-4"><i class="fa fa-check"></i> <?=$this->translate('保存付款信息')?></button>
                    </div>
                </div>


            </div>
        </div>

    </section>
    <?= $this->form()->closeTag(); ?>

</div>
<script>
    $(document).ready(function() {
        $("#<?=$form->getName()?>").validate({
            rules: {
                payLogAmount: {
                    required: true,
                    number: true,
                    min: 1
                },
                payLogPaytime: {
                    required: true
                },
                payLogUser: {
                    required: true
                }
            },
            messages: {
                payLogAmount: {
                    required: "<?=$this->translate('付款金额不能为空！')?>",
                    number: "<?=$this->translate('必须为数字！')?>",
                    min: "<?=$this->translate('付款金额最小为1！')?>"
                },
                payLogPaytime: {
                    required: "<?=$this->translate('付款日期不能为空！')?>"
                },
                payLogUser: {
                    required: "<?=$this->translate('付款人不能为空！')?>"
                }
            }
        });
    });

    laydate.render({
        elem: '#payLogPaytime'
        ,
        value: '<?=date("Y-m-d", time())?>'
    });
</script>