<div class="content-wrapper">

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

        <h1 class="pull-right">
            <?php echo $this->HelpUrl('warehouseOrderList'); ?>
        </h1>

    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box erp-box">

                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <thead>
                            <tr class="erp-bg-thead">
                                <th width="10%"><?php echo $this->translate('入库单号'); ?>-<?php echo $this->translate('订单数：').$this->orderList->getTotalItemCount(); ?></th>
                                <th width="15%"><?php echo $this->translate('供应商'); ?></th>
                                <th width="10%"><?php echo $this->translate('联系人'); ?></th>
                                <th width="10%"><?php echo $this->translate('联系电话'); ?></th>
                                <th width="10%"><?php echo $this->translate('付款方式'); ?></th>
                                <th width="10%"><?php echo $this->translate('采购金额'); ?></th>
                                <th width="6%"><?php echo $this->translate('状态'); ?></th>
                                <th width="10%"><?php echo $this->translate('时间'); ?></th>
                                <th width="12%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            $sForm->get('p_order_state')->setEmptyOption('选择');
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <?php echo $this->formElement($sForm->get('warehouse_order_sn')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('warehouse_order_sn'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('supplier_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('supplier_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('supplier_contacts')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('supplier_contacts'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('supplier_phone')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('supplier_phone'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('payment_code')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('payment_code'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_amount')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_amount')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_amount'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_amount'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('p_order_state')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('p_order_state'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo  $this->formElement($sForm->get('start_time')); ?>
                                    </p>
                                    <div>
                                        <?php echo  $this->formElement($sForm->get('end_time')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_time'), ['class'=>'error-message']); ?>
                                    <?php echo $this->formElementErrors($sForm->get('end_time'), ['class'=>'error-message']); ?>
                                </td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php if(!empty(array_filter($sForm->getData()))) { ?>
                                        <a href="<?php echo $this->url('warehouse-order');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php } ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>

                            <?php if($this->orderList) foreach ($this->orderList as $order) {?>
                                <tr>
                                    <td><?php echo $this->escapeHtml($order->getWarehouseOrderSn()); ?></td>
                                    <td><?php echo $order->getOneOrder()->getOneSupplier()->getSupplierName(); ?></td>
                                    <td><?php echo $this->escapeHtml($order->getOneOrder()->getSupplierContacts()); ?></td>
                                    <td><?php echo $this->escapeHtml($order->getOneOrder()->getSupplierPhone()); ?></td>
                                    <td><?php echo $this->PurchaseHelper()->orderPayment($order->getWarehouseOrderPaymentCode()); ?></td>
                                    <td><?php echo $this->erpCurrencyFormat($order->getWarehouseOrderAmount()); ?></td>
                                    <td><?php echo $this->PurchaseHelper()->orderState($order->getWarehouseOrderState(), 2); ?></td>
                                    <td><?php echo date("Y-m-d H:i", $order->getCreateTime()); ?></td>
                                    <td>
                                        <a href="<?php echo $this->url('warehouse-order',
                                            ['action'=>'view', 'id'=>$order->getWarehouseOrderId()]); ?>"
                                           class="btn btn-xs btn-info"><i class="fa fa-info-circle"></i> <?php echo $this->translate('查看'); ?>
                                        </a>
                                        <?php if($order->getWarehouseOrderState() == 2) { ?>
                                            <a href="<?php echo $this->url('warehouse-order',
                                                ['action'=>'insertWarehouse', 'id'=>$order->getWarehouseOrderId()]); ?>" class="btn btn-xs btn-success"><i class="fa fa-check"></i> <?php echo $this->translate('入库'); ?></a>
                                            <a href="javascript:;" onclick="deleteConfirm('<?php echo $this->translate('您确实要取消该待入库单吗？'); ?>', '<?php echo $this->url('warehouse-order', ['action'=>'delete', 'id'=>$order->getWarehouseOrderId()], ['query' => ['qToken' => $this->common()->getCsrfValue()]]); ?>', 'false');" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i> <?php echo $this->translate('取消'); ?></a>
                                        <?php } ?>

                                    </td>
                                </tr>
                            <?php } ?>

                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->orderList, 'Sliding', 'layout/page', ['route' => 'warehouse-order']); ?>
                    </div>

                </div>

            </div>
        </div>

    </section>
</div>
<script type="text/javascript">
    laydate.render({elem: '#start_time'});
    laydate.render({elem: '#end_time'});
</script>