<?php

use app\base\Common;
use yii\helpers\Html;
use kartik\grid\GridView;
use app\models\Registration;
use app\models\Regngoupdate;
use rmrevin\yii\fontawesome\FA;
use yii\helpers\ArrayHelper;

$RModel = new Registration();
$RSModel = new Regngoupdate();
// print_r(Registration::corfrm_q12);
/* @var $this yii\web\View */
/* @var $searchModel app\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Registrations');
$this->params['breadcrumbs'][] = $this->title;
$this->params['menu'] = [
	['label' => FA::icon('align-justify fa-fw'), 'linkOptions' => ['class'=>'btn btn-default', 'title'=>'List'], 'url' => ['/'.Yii::$app->controller->id]],
];
?>
<div class="registration-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'],

				[
					'attribute' => 'corfrm_pid',
					//'contentOptions' => ['class' => 'col-md-2'],
					'contentOptions' => ['style' => 'width:130px;  min-width:130px;'],
	                // 'format' => 'raw',
				],
				[
					'attribute' => 'corfrm_q12',
					'label' => 'Client HIV Status',
					// 'contentOptions' => ['class' => 'col-md-1'],
	                // 'format' => 'raw',
	                'noWrap' => true,
		            'filterType'=>GridView::FILTER_SELECT2,
		            'filter'=>$RModel->q12, 
		            'filterInputOptions'=>['placeholder'=>''],
	                'value'=> function($data) {
	                    return $data->getClientHIVStatus("raw");
	                }
				],
				
				[
					'attribute' => 'corfrm_q13',
					'label' => 'Client Status',
					// 'contentOptions' => ['class' => 'col-md-1'],
	                'noWrap' => true,
		            'filterType'=>GridView::FILTER_SELECT2,
		            'filter'=>$RModel->q13, 
		            'filterInputOptions'=>['placeholder'=>''],
					'contentOptions' => ['style' => 'width:200px;  min-width:150px;'],
	                'value' => function($data) {
	                    return $data->getClientStatus();
	                }
				],
			[
				'attribute' => 'corfrm_q11',
				'label' => 'NGO Name',			
                'value' => function($data) {
                    return $data->getNGO($data->corfrm_q11);
                },
	            'filterType'=>GridView::FILTER_SELECT2,
	            'filter'=>ArrayHelper::map(Registration::find()->orderBy('corfrm_q11')->asArray()->all(), 'corfrm_q11', 'corfrm_q11'), 
	            'filterInputOptions'=>['placeholder'=>''],
				'contentOptions' => ['style' => 'width:200px;  min-width:150px;'],
			],
			[
					'attribute' => 'corfrm_q2',
					'label' => 'Contact Number',	
					'contentOptions' => ['style' => 'width:130px;  min-width:130px;'],
	       
			],
			
			
			/*
			[
				'attribute' => 'pidtype',
				'label' => 'Participate Program',
				'contentOptions' => ['style' => 'width:200px;  min-width:150px;'],	
				'noWrap' => true,
				'value' => function($data) {						
	                   return $data->getPidtype();
	                },	
		            'filterType'=>GridView::FILTER_SELECT2,
		            'filter'=>$RSModel->qtype, 					
		            'filterInputOptions'=>['placeholder'=>''],
	              		
			],
			*/
		   [
					'attribute' => 'record_date',
					'format' => 'date',
					'contentOptions' => ['style' =>'width:270px;  min-width:100px;'],
					// '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']],
			],
			[
				'attribute' => 'Pidtype',
				'label' => 'Participate Program',
				'contentOptions' => ['class' => 'col-md-2'],				
			],

	         ['class' => 'app\behaviours\ActionColumns',
			  'contentOptions' => ['class' => 'col-md-1'],
			 'template'=> '{view} {update}',
			 'buttons'=> [
                'update'=> function($url,$model) {
                    return Html::a( '<span class="glyphicon glyphicon-pencil"></span>', $url); 
                },              
            ],
           
        ],
	        ],
	    ]);
    ?>
</div>