<?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\RiskbehaviorSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Riskbehavior');
$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="Riskbehavior-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
   <?= GridView::widget([
        'dataProvider' => $dataProvider,
         'filterModel' => $searchModel,
        'columns' => [
            
			// 'risk_behavior_id',
		//	'risk_behavior_survey',
			
			//'risk_behavior_loc',
			// 'risk_behavior_q1',
			// 'risk_behavior_q2',
			// 'risk_behavior_q3',
			// 'risk_behavior_q4',
			// 'risk_behavior_q5',
			// 'risk_behavior_q6',
			// 'risk_behavior_q7',
			// 'risk_behavior_q8',
			// 'status',
			// 'create_time:datetime',
			// 'create_user',
			// 'update_time:datetime',
			// 'update_user',
			['class' => 'yii\grid\SerialColumn',
			'contentOptions' => ['style' =>'width:50px;  min-width:50px;'],],
			
			[
					'attribute' => 'risk_behavior_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(["=", "visit_code", 1])->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>
