<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">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <a href="<?php echo $this->url('finance-payable');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回应付账款列表'); ?></a>
            <?php echo $this->HelpUrl('financeAddPayable'); ?>
        </h1>
    </section>
    <?php echo $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"><?php echo $this->translate('付款处理'); ?></h3>
                    </div>

                    <div class="box-body">
                        <?php echo $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><?php echo $this->translate('采购单号'); ?>：</b><?php echo $this->escapeHtml($this->payableInfo->getPOrderSn());?>
                                </div>
                            </div>

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

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

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

                        </div>
                        <hr />

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('付款金额'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('payLogAmount')); ?>
                                <?php echo $this->formElementErrors($form->get('payLogAmount'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $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>
                                    <?php echo $this->formElement($form->get('payLogPaytime')); ?>
                                    <?php echo $this->formElementErrors($form->get('payLogPaytime'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('付款人'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('payLogUser')); ?>
                                <?php echo $this->formElementErrors($form->get('payLogUser'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('付款凭证'); ?></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('payFile')); ?>
                                <?php echo $this->formElementErrors($form->get('payFile'), ['class'=>'error-message']); ?>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php echo $this->translate('付款备注'); ?></label>
                            <div class="col-sm-8">
                                <?php echo $this->formElement($form->get('payLogInfo')); ?>
                                <?php echo $this->formElementErrors($form->get('payLogInfo'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

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


            </div>
        </div>

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

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

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