<?php
use home\assets\MainAsset;
use yii\helpers\Url;
use home\modules\receivable\models\Receivable;
use yii\widgets\ActiveForm;
use yii\helpers\StringHelper;

/* @var $this \yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \home\modules\receivable\models\Receivable */

$this->title = '回款管理';
?>

<!--container-->
<div class="container manage-project fix">
  <?= $this->render('@home/views/site/_left-menu') ?>

    <!--manage-left -->
    <div class="manage-right">
        <div class="tab-column tab-manage">
            <div class="tab-right">
                <button title="新增回款" type="button" data-url='<?= Url::to([$this->context->id . '/create']) ?>' data-title='新增回款' data-width="560" data-height="360" class="btn btn-default btn-task open-dialog">
                   <i class="icon-plus"></i>
                </button>
            </div>
            <p class="caption">回款管理</p>
        </div>
        <?= \home\widgets\Alert::widget(); ?>
        <?= $this->render('_search', ['model' => $model, 'get' => $get]) ?>
        <?php $mainForm = ActiveForm::begin([ 'id' => 'main-form', 'action' => '']); ?>
        <table class="table task-table">
            <tr>
                <!-- <th width="60"><label style="font-weight:lighter" ><input type="checkbox" name="select_all" class="box-select-all" style="position:relative;top:2px;" /> 全选</label></th> -->
                <th width="15%">回款编号</th>
                <th width="22%">合同名称</th>
                <th width="13%">金额</th>
                <th width="12%">回款</th>
                <th width="10%">到款日期</th>
                <th width="120" align="center">操作</th>
            </tr>
            <?php if (empty($models)) : ?>
        		<tr><td colspan="8" class="tac red">还没有任何数据...</td></tr>
            	<?php else : ?>
              		<?php foreach ($models as $model) : ?>
                    <tr>
                        <!-- <td><input type="checkbox" name="delete[]" class="box-delete" value="<?= $model->rece_id ?>" /></td> -->
                  		<td>
                            <a target="_blank" href="<?= Url::to([$this->context->id . '/detail', 'id' => $model->rece_id]) ?>">
                                <?= $model->rece_no ?>
                            </a>
                        </td>
                  		<?php if (isset($model->contract->name)) : ?>
                            <td class='theleft-min' title="<?= $model->contract->name ?>">
                                <a target="_blank" href="<?= Url::to(['/contract/contract/detail', 'id' => $model->contract->contract_id]) ?>">
                                    <?= StringHelper::truncate($model->contract->name, 12) ?>
                                </a>
                            </td>
                        <?php else : ?>
                            <td class='theleft-min' title="暂无数据">
                                <!-- <a target="_blank" class="gray" href="javascript:;">暂无数据</a> -->
                            </td>
                        <?php endif; ?>
                  		<td class='theright-min'><?= isset($model->contract->money) ? number_format($model->contract->money, 2 , '.' , ',') : '' ?></td>
                  		<td class='theright-min'><?= number_format($model->rece_money, 2 , '.' , ',') ?></td>
                  		<td><?= date('Y-m-d', $model->to_date) ?></td>
                        <td align="center" >
                            <?php if (Receivable::readAccess('receivable/receivable/detail')) : ?>
                                <a href="<?= Url::to([$this->context->id . '/detail', 'id' => $model->rece_id]) ?>">详情</a>
                            <?php else : ?>
                                <a href="javascript:;" class="gray" title="当前没有查看详情权限">详情</a>
                            <?php endif; ?>

                            <?php if (Receivable::readAccess('receivable/receivable/view')) : ?>
                                <a href="javascript:;" class="open-dialog"  data-url="<?= Url::to([$this->context->id .'/view', 'id' => $model->rece_id]) ?>" data-title='编辑回款' data-width="560" data-height="360">编辑</a>
                            <?php else : ?>
                                <a href="javascript:;" class="gray" title="当前没有编辑权限">编辑</a>
                            <?php endif; ?>

                            <?php if (Receivable::readAccess('receivable/receivable/delete')) : ?>
                                <a class="link-delete" href="<?= Url::to([$this->context->id . '/delete', 'id' => $model->rece_id]) ?>">删除</a>
                            <?php else : ?>
                                <a href="javascript:;" class="gray" title="当前没有删除权限">删除</a>
                            <?php endif; ?>
                        </td>
              		</tr>
            	<?php endforeach; ?>
        	<?php endif; ?>
        </table>
        <!-- <div class="tab-column tab-manage">
            <button type="button" class="btn btn-default btn-task batch-delete" data-url="<?= Url::to([$this->context->id.'/delete']) ?>" >
                <a href="javascript:;">删除</a>
            </button>
        </div> -->
        <?php ActiveForm::end(); ?>
        <div class="pages">
        <span class="pagetotal">共<em><?= $pages->totalCount ?></em>条记录<em><?= $pages->page + 1 ?>/<?= $pages->pageCount ?></em>页 </span>
            <?= \yii\widgets\LinkPager::widget(['pagination' => $pages, 'prevPageLabel' => '上一页','nextPageLabel' => '下一页', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页']); ?>
        </div>
    </div>
    <!--manage-right--> 
</div>
<!--container-->