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

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

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

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

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

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

        <h1 class="pull-right">
            <a href="<?=$this->url('accounts-receivable');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?=$this->translate('返回应收账款列表')?></a>
            <?=$this->HelpUrl('accountsAddReceivable')?>
        </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->receivableInfo->getSalesOrderSn());?>
                                </div>
                            </div>

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

                            <div class="col-xs-3 form-group">
                                <div class="col-sm-12">
                                    <b class="text-green"><?=$this->translate('已收金额')?>：</b><?=$this->erpCurrencyFormat($this->receivableInfo->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->receivableInfo->getReceivableAmount() - $this->receivableInfo->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('receivableLogAmount')); ?>
                                <?= $this->formElementErrors($form->get('receivableLogAmount'), ['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('receivableLogTime')); ?>
                                    <?= $this->formElementErrors($form->get('receivableLogTime'), ['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('receivableLogUser')); ?>
                                <?= $this->formElementErrors($form->get('receivableLogUser'), ['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('receivableFile')); ?>
                                <?= $this->formElementErrors($form->get('receivableFile'), ['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('receivableInfo')); ?>
                                <?= $this->formElementErrors($form->get('receivableInfo'), ['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: {
                receivableLogAmount: {
                    required: true,
                    number: true,
                    min: 1
                },
                receivableLogTime: {
                    required: true
                },
                receivableLogUser: {
                    required: true
                }
            },
            messages: {
                receivableLogAmount: {
                    required: "<?=$this->translate('收款金额不能为空！')?>",
                    number: "<?=$this->translate('必须为数字！')?>",
                    min: "<?=$this->translate('收款金额最小为1！')?>"
                },
                receivableLogTime: {
                    required: "<?=$this->translate('收款日期不能为空！')?>"
                },
                receivableLogUser: {
                    required: "<?=$this->translate('收款人不能为空！')?>"
                }
            }
        });
    });

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