<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use rmrevin\yii\fontawesome\FA;
use yii\widgets\Pjax;
use yii\helpers\ArrayHelper;
use app\models\Visitmaster;
/* @var $this yii\web\View */
/* @var $searchModel app\models\DepressionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Depression');
$this->params['breadcrumbs'][] = $this->title;
$this->params['menu'] = [
	['label' => FA::icon('plus fa-fw'), 'linkOptions' => ['class'=>'btn btn-default', 'title'=>'Create'], 'url' => ['create']],
];
?>
<div class="Depression-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
   <?= GridView::widget([
        'dataProvider' => $dataProvider,
         'filterModel' => $searchModel,
        'columns' => [
           ['class' => 'yii\grid\SerialColumn',
			'contentOptions' => ['style' =>'width:50px;  min-width:50px;'],],

			// 'depression_id',
		//	'depression_survey',
		//	'depression_part_id',
			//'depression_loc',
			// 'depression_q1',
			// 'depression_q2',
			// 'depression_q3',
			// 'depression_q4',
			// 'depression_q5',
			// 'depression_q6',
			// 'depression_q7',
			// 'depression_q8',
			// 'depression_q9',
			// 'depression_q10',
			// 'status',
			// 'create_time:datetime',
			// 'create_user',
			// 'update_time:datetime',
			// 'update_user',
			[
					'attribute' => 'depression_part_id',
					'contentOptions' => ['class' => 'col-md-2'],
			
			],
			
			[
					'attribute' => 'visit_code',
		            'label' => 'Visit',
		            'contentOptions' => ['class' => 'col-md-2'],
					'noWrap' => true,					
		            'filterType'=>GridView::FILTER_SELECT2,
		            'filter'=>ArrayHelper::map(Visitmaster::find()->where(['NOT', ['visit_interval' => null]])->andWhere(["status" => 1])->orderBy(['visit_code'=> SORT_DESC])->asArray()->all(), 'visit_code', 'visit_name'), 
		            'filterInputOptions'=>['placeholder'=>''],
	                'value' => function($data) {
                    return $data->getVisits($data->visit_code);
                },
				],
			[
					'attribute' => 'record_date',
					'format' => 'date',
					'contentOptions' => ['class' => 'col-md-3'],
					// 'contentOptions' => ['class' => 'col-md-1'],
		            'filterType'=>GridView::FILTER_DATE,
		            'filterWidgetOptions' => ['pluginOptions' => ['autoclose' => true, 'startDate' => '01-01-1900', 'endDate' => '0', 'format' => strtolower(Yii::$app->formatter->dateFormat), 'orientation' => 'bottom']],
				],

            ['class' => 'app\behaviours\ActionColumns'],
        ],
    ]); ?>
</div>
