<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;

$action = isset($action) ? $action : $this->context->id . '/index';
$searchForm = ActiveForm::begin([ 'id' => 'search-form', 'action' => [$action], 'method' => 'get']);
$search = $model->search();
?>
<div class="task-title-date" >
	<p class="lefttitle" style="margin-right: 10px;">
		视图：
    	<a href="<?= Url::to([$this->context->id . '/index', 'type' => 'all']) ?>">全部申请单</a>
    	&nbsp;&nbsp;
    	关键字：
	</p>

		<input placeholder="关键字" class="form-control fl date-form-control search-form" value="<?= (isset($get['keywords'])) ? Html::encode($get['keywords']) : '' ?>" name="keywords" >
		<?php if (isset($search['keywords'])) : ?>
		<select class="form-control fl date-form-control search-form" name="search_field" style="width: 8%">
			<?php foreach ($search['keywords'] as $field => $name) : ?>
                <option <?= (isset($get['search_field']) && ($get['search_field'] == $field)) ? 'selected="selected"' : ''; ?> value="<?= $field ?>" ><?= $name ?></option>
            <?php endforeach; ?>
		</select>
		<?php endif; ?>

		<?php if (isset($search['isused'])) : ?>
		<select class="form-control fl date-form-control search-form" name="isused">
			<option value="">---使用状态---</option>
			<?php foreach ($search['isused'] as $field => $name) : ?>
                <option <?= (isset($get['isused']) && $get['isused'] != '' && ($get['isused'] == $field)) ? 'selected="selected"' : ''; ?> value="<?= $field ?>" ><?= $name ?></option>
            <?php endforeach; ?>
		</select>
		<?php endif; ?>

		<?php if (isset($search['status'])) : ?>
		<select class="form-control fl date-form-control search-form" name="status">
			<option value="">---审核状态---</option>
			<?php foreach ($search['status'] as $field => $name) : ?>
                <option <?= (isset($get['status']) && $get['status'] != '' && ($get['status'] == $field)) ? 'selected="selected"' : ''; ?> value="<?= $field ?>" ><?= $name ?></option>
            <?php endforeach; ?>
		</select>
		<?php endif; ?>

        <button type="submit" title="搜索"class="btn btn-primary fl btn-serch task-sou">
        <i class="icon-search"></i>
        </button>

        <button type="button" title="重置" class="btn btn-default fl btn-reset reset_search">
         <i class="icon-undo"></i>
        </button>
</div>
<?php ActiveForm::end(); ?>