<?php
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\assets\My97DatePickerAsset;
use home\modules\reimbursement\models\Category;

My97DatePickerAsset::register($this);
$year = date("Y", time()-60*60*24*date("t"));
$month = date("m", time()-60*60*24*date("t"));
$allday = date("t", time()-60*60*24*date("t"));
$begin_time = date('Y-m-d', strtotime($year."-".$month."-1"));
$end_time = date('Y-m-d', time());
$action = isset($action) ? $action : $this->context->id . '/index';
$searchForm = ActiveForm::begin([ 'id' => 'search-form', 'action' => [$action], 'method' => 'get']);
$search = $model->search();
?>
<style type="text/css">
	.task-title-date .lefttitle, .task-title-date .rightfl{
		margin-right: 60px;
	}
</style>
<div class="task-title-date">
    <p class="lefttitle" style="margin-right: 10px;">
        视图：<a href="<?= Url::to([$this->context->id . '/index', 'map' => 'month']) ?>">本月</a>
        <a href="<?= Url::to([$this->context->id . '/index', 'map' => 'week']) ?>">本周</a>
        <?php if ($showVerify) : ?>
	        <a href="<?= Url::to([$this->context->id . '/index', 'type' => 'reim']) ?>">我的报销</a>
	        <a href="<?= Url::to([$this->context->id . '/index', 'type' => 'verify']) ?>">我的审核</a>
    	<?php endif; ?>
    	<a href="<?= Url::to([$this->context->id . '/index', 'type' => 'all']) ?>">全部报销</a>
        &nbsp;&nbsp;
        <p class="searchfl"> 
			<input placeholder="关键字" class="form-control fl date-form-control search-form" style="width: 10%" 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" style="width: 6%" name="search_field">
				<?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; ?>

			<select class="form-control  fl date-form-control search-form" style="width: 8%" name="category_id" >
	            <option value="">报销类别</option>
	            <?php echo Category::getDropDownTree(isset($get['category_id']) ? $get['category_id'] : ''); ?>
	        </select>

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

			<?php if (isset($search['isclearing'])) : ?>
			<select class="form-control fl date-form-control search-form" style="width:7%" name="isclearing">
				<option value="">结算状态</option>
				<?php foreach ($search['isclearing'] as $field => $name) : ?>
	                <option <?= (isset($get['isclearing']) && $get['isclearing'] != '' && ($get['isclearing'] == $field)) ? 'selected="selected"' : ''; ?> value="<?= $field ?>" ><?= $name ?></option>
	            <?php endforeach; ?>
			</select>
			<?php endif; ?>

            <span class="fl">&nbsp;从</span>
            <input type="text" id="reimbursement-begin_time" value="<?= isset($get['begin_time']) ? $get['begin_time'] : $begin_time ?>" class="form-control fl date-form-control search-form" style="width: 7%" name="begin_time" 
                               onfocus="WdatePicker({&quot;maxDate&quot;:&quot;#F{$dp.$D(\'reimbursement-end_time\')}&quot;,&quot;readOnly&quot;:true,&quot;dateFmt&quot;:&quot;yyyy-MM-dd&quot;})">

            <span class="fl">&nbsp;至</span>
            <input type="text" id="reimbursement-end_time" value="<?= isset($get['end_time']) ? $get['end_time'] : $end_time ?>" class="form-control fl date-form-control search-form" style="width: 7%" name="end_time" 
                               onfocus="WdatePicker({&quot;minDate&quot;:&quot;#F{$dp.$D(\'reimbursement-begin_time\')}&quot;,&quot;readOnly&quot;:true,&quot;dateFmt&quot;:&quot;yyyy-MM-dd&quot;})">
        <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>

		</p>
    </p>
</div>
<?php ActiveForm::end(); ?>