<div class="content-wrapper">

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

        <h1 class="pull-right">
            <?php echo $this->HelpUrl('receivablesList'); ?>
        </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('销售单号'); ?></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="10%"><?php echo $this->translate('已收金额'); ?></th>
                                <th width="10%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <?php echo $this->formElement($sForm->get('sales_order_sn')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('sales_order_sn'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('customer_name')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('customer_name'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('receivable_code')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('receivable_code'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('sales_start_amount')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('sales_end_amount')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('sales_start_amount'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('sales_end_amount'), ['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>
                                    <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('accounts-receivable');?>" 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->receivablesList) foreach ($this->receivablesList as $receivableValue) {?>
                                <tr>
                                    <td><?php echo $this->escapeHtml($receivableValue->getSalesOrderSn()); ?></td>
                                    <!--<td></td>-->
                                    <td><?php echo $this->escapeHtml($receivableValue->getCustomerName());?></td>
                                    <td><?php echo $this->escapeHtml($receivableValue->getReceivableCode());?>
                                        <?php /*echo $this->salesHelper()->orderReceivables($receivableValue->getReceivableCode()); */?></td>
                                    <td><?php echo $this->erpCurrencyFormat($receivableValue->getReceivableAmount()); ?></td>
                                    <td>
                                        <span <?php echo ($receivableValue->getReceivableAmount() == $receivableValue->getFinishAmount() ? 'class="text-green"' : ''); ?>><?php echo $this->erpCurrencyFormat($receivableValue->getFinishAmount()); ?></span>
                                        <?php if($receivableValue->getFinishAmount() != 0.0000) { ?>
                                            <a href="<?php echo $this->url('accounts-receivable',
                                                ['action'=>'receivableLog', 'id'=>$receivableValue->getReceivableId()]); ?>" title="<?php echo $this->translate('收款记录'); ?>"><i class="fa fa-book text-green"></i></a>
                                        <?php } ?>
                                    </td>
                                    <td>
                                        <?php if($receivableValue->getReceivableAmount() != $receivableValue->getFinishAmount()) { ?>
                                            <a href="<?php echo $this->url('accounts-receivable',
                                                ['action'=>'addReceivable', 'id'=>$receivableValue->getReceivableId()]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-usd"></i> <?php echo $this->translate('收款'); ?></a>
                                        <?php } ?>
                                        <a href="<?php echo $this->url('accounts-receivable',
                                            ['action'=>'show', 'id'=>$receivableValue->getReceivableId()]); ?>"
                                           class="btn btn-xs btn-info"><i class="fa fa-info-circle"></i> <?php echo $this->translate('查看'); ?>
                                        </a>
                                    </td>
                                </tr>
                            <?php } ?>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->receivablesList, 'Sliding', 'layout/page', ['route' => 'accounts-receivable']); ?>
                    </div>
                </div>

            </div>
        </div>

    </section>
</div>