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

    $form->get('warehouseOrderState')->setEmptyOption('选择状态');

    $form->get('warehouseOrderSn')->setAttributes([
        'placeholder' => $this->translate('入库单号')
    ]);

    $form->get('warehouseOrderInfo')->setAttributes([
        'placeholder' => $this->translate('入库备注')
    ]);
    ?>
    <?= $this->form()->openTag($form); ?>
    <section class="content-header">
        <?=$this->partial('layout/breadcrumb')?>

        <h1 class="pull-right">
            <a href="<?=$this->url('p-order');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?=$this->translate('返回采购单列表')?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?=$this->translate('验货入库')?></button>
            <?=$this->HelpUrl('warehouseOrderAdd')?>
        </h1>
    </section>

    <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-4 form-group">
                                <div class="col-sm-12">
                                    <?=$this->translate('入库单号')?><span class="must_add_value">*</span>
                                    <?= $this->formElement($form->get('warehouseOrderSn')); ?>
                                    <?= $this->formElementErrors($form->get('warehouseOrderSn'), ['class'=>'error-message']); ?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <?=$this->translate('仓库')?><span class="must_add_value">*</span>
                                    <?= $this->formElement($form->get('warehouseId')); ?>
                                    <?= $this->formElementErrors($form->get('warehouseId'), ['class'=>'error-message']); ?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <?=$this->translate('状态')?><span class="must_add_value">*</span>
                                    <?= $this->formElement($form->get('warehouseOrderState')); ?>
                                    <?= $this->formElementErrors($form->get('warehouseOrderState'), ['class'=>'error-message']); ?>
                                </div>
                            </div>

                        </div>

                        <div class="row">
                            <div class="col-xs-12 form-group">
                                <div class="col-sm-12">
                                    <?=$this->translate('入库备注')?>
                                    <?= $this->formElement($form->get('warehouseOrderInfo')); ?>
                                    <?= $this->formElementErrors($form->get('warehouseOrderInfo'), ['class'=>'error-message']); ?>
                                </div>
                            </div>
                        </div>

                        <hr />

                        <div class="row">
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('采购单号')?>：</b><?=$this->escapeHtml($this->orderInfo->getPOrderSn());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('供应商')?>：</b><?=$this->escapeHtml($this->orderInfo->getOneSupplier()->getSupplierName());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('付款方式')?>：</b><?=$this->PurchaseHelper()->orderPayment($this->orderInfo->getPaymentCode());?>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('供应商联系人')?>：</b><?=$this->escapeHtml($this->orderInfo->getSupplierContacts());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('供应商手机')?>：</b><?=$this->escapeHtml($this->orderInfo->getSupplierPhone());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('供应商座机')?>：</b><?=$this->escapeHtml($this->orderInfo->getSupplierTelephone());?>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-12 form-group">
                                <div class="col-sm-12">
                                    <b><?=$this->translate('备注')?>：</b><?=$this->escapeHtml($this->orderInfo->getPOrderInfo());?>
                                </div>
                            </div>
                        </div>

                        <div class="box-header">
                            <h4 class="box-title"><?=$this->translate('采购商品')?></h4>
                        </div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th width="15%"><?=$this->translate('商品编号')?></th>
                                    <th><?=$this->translate('商品名称')?></th>
                                    <th><?=$this->translate('商品规格')?></th>
                                    <th width="10%"><?=$this->translate('采购单价')?></th>
                                    <th width="10%"><?=$this->translate('采购数量')?></th>
                                    <th width="10%"><?=$this->translate('采购总价')?></th>
                                </tr>
                                </thead>
                                <?php foreach ($this->orderGoods as $goodsValue) { ?>
                                <tr>
                                    <td><?=$this->escapeHtml($goodsValue->getGoodsNumber())?></td>
                                    <td><?=$this->escapeHtml($goodsValue->getGoodsName())?></td>
                                    <td><?=$this->escapeHtml($goodsValue->getGoodsSpec())?></td>
                                    <td><?=$this->erpCurrencyFormat($goodsValue->getPGoodsPrice())?></td>
                                    <td><?=$goodsValue->getPGoodsBuyNum()?></td>
                                    <td><?=$this->erpCurrencyFormat($goodsValue->getPGoodsAmount())?></td>
                                </tr>
                                <?php } ?>
                            </table>
                        </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: {
                warehouseOrderSn: {
                    required: true
                },
                warehouseId: {
                    required: true,
                    min: 1
                },
                warehouseOrderState: {
                    required: true
                }
            },
            messages: {
                warehouseOrderSn: {
                    required: "<?=$this->translate('入库单号不能为空！')?>"
                },
                warehouseId: {
                    required: "<?=$this->translate('请选择仓库！')?>",
                    min: "<?=$this->translate('请选择仓库！')?>"
                },
                warehouseOrderState: {
                    required: "<?=$this->translate('请选择状态！')?>"
                }
            }
        });
    });
</script>