<?php
use yii\helpers\Url;
use yii\helpers\Html;
use common\models\User;
use yii\widgets\ActiveForm;
use qcbase\models\Department;
use home\assets\ModalAsset;
use common\assets\ArtDialogAsset;
use yii\helpers\StringHelper;

/* @var $this yii\web\View */

$this->title = '选择项目';

$assetUrl = $this->getAssetManager()->getBundle(ModalAsset::className())->baseUrl;
$this->registerJsFile($assetUrl.'/js/link.select.js', ['depends' => [ModalAsset::className(), ArtDialogAsset::className()]]);
?>

<div class="modal-window" >
	
	<?php $searchForm = ActiveForm::begin([ 'id' => 'search-form', 'action' => '', 'method' => 'get']); ?>
		<div class="dialog-search fix rel">
				<span class="fl">关键字：</span>
				<input name="keywords" value="<?= (isset($get['keywords']))?Html::encode($get['keywords']):'' ?>" type="text" class="f12 form-control fl  dialog-search-control">
				<select name="search_field" class=" f12 form-control fl dialog-search-control">
					<option <?= (isset($get['search_field']) && $get['search_field'] == 'name')?'selected="selected"':'' ?> value="name">合同名称</option>
					<option <?= (isset($get['search_field']) && $get['search_field'] == 'contract_no')?'selected="selected"':'' ?> value="contract_no">合同编号</option>
				</select>
				<select name="cat_id" class=" f12 form-control fl dialog-search-control">
					<option value="">---所属分类---</option>
					<?= \home\modules\sale\models\Category::getDropDownTree((isset($get['cat_id']))?$get['cat_id']:'') ?>
				</select>

				<button class="btn btn-primary fl dialog-btn" type="submit">搜索</button>
		</div>
	<?php ActiveForm::end(); ?>

	<form method="post" action="" class="dialog-form" id="main-form">
		<table class="table task-table dialog-table">
			<tbody>
				<tr>
					<th width="140" style="padding-left:10px;">编号</th>
					<th >合同名称</th>
					<th >分类</th>
					<th >签订时间</th>
					<th width="80">状态</th>
					<th width="50">操作</th>
				</tr>
				<?php if (empty($models)) : ?>
				<tr><td colspan="6" class="tac red" style="text-align: center;">没有任何数据...</td></tr>
				<?php else : ?>
				<?php foreach($models as $model) : ?>
				<tr  title="双击选择此列" class="select-tr">
					<td style="padding-left:10px;"><?= $model['contract_no'] ?></td>
                    <td title="<?=$model['name']?>"><?= !empty($model['name'])? StringHelper::truncate($model['name'], 15):''?></td>
					<td><?= $model['category']['name'] ?></td>
					<td><?= date('Y-m-d',$model['signing_time']) ?></td>
					<td><?= $model['status_name'] ?></td>
					<td>
						<a class="select" data-id="<?= $model['contract_no'] ?>" data-name="<?= $model['name'] ?>" href="javascript:;" title="单击选择" >选择</a>
					</td>
				</tr>
				<?php endforeach; ?>
				<?php endif; ?>
			</tbody>
		</table>
	</form>

	<div class="pages">
        <?php if ($pages->totalCount != 0) : ?><span class="pagetotal">共<em><?= $pages->totalCount ?></em>条记录<em><?= $pages->page + 1 ?>/<?= $pages->pageCount ?></em>页 </span><?php endif; ?>
        <?= \yii\widgets\LinkPager::widget(['pagination' => $pages, 'prevPageLabel' => '上一页','nextPageLabel' => '下一页', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页']); ?>
    </div>

</div>
