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

        <h1 class="pull-right">
            <a href="<?php echo $this->url('accounts-receivable');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回应收账款列表'); ?></a>
            <?php echo $this->HelpUrl('accountsAddReceivable'); ?>
        </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->receivableInfo->getSalesOrderSn());?>
                                </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->receivableInfo->getReceivableAmount());?>
                                </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->receivableInfo->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->receivableInfo->getReceivableAmount() - $this->receivableInfo->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('receivableLogAmount')); ?>
                                <?php echo $this->formElementErrors($form->get('receivableLogAmount'), ['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('receivableLogTime')); ?>
                                    <?php echo $this->formElementErrors($form->get('receivableLogTime'), ['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('receivableLogUser')); ?>
                                <?php echo $this->formElementErrors($form->get('receivableLogUser'), ['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('receivableFile')); ?>
                                <?php echo $this->formElementErrors($form->get('receivableFile'), ['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('receivableInfo')); ?>
                                <?php echo $this->formElementErrors($form->get('receivableInfo'), ['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: {
                receivableLogAmount: {
                    required: true,
                    number: true,
                    min: 1
                },
                receivableLogTime: {
                    required: true
                },
                receivableLogUser: {
                    required: true
                }
            },
            messages: {
                receivableLogAmount: {
                    required: "<?php echo $this->translate('收款金额不能为空！'); ?>",
                    number: "<?php echo $this->translate('必须为数字！'); ?>",
                    min: "<?php echo $this->translate('收款金额最小为1！'); ?>"
                },
                receivableLogTime: {
                    required: "<?php echo $this->translate('收款日期不能为空！'); ?>"
                },
                receivableLogUser: {
                    required: "<?php echo $this->translate('收款人不能为空！'); ?>"
                }
            }
        });
    });

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