<?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\Departments;
use app\models\Labresultsmaster;

/* @var $this yii\web\View */
/* @var $searchModel app\models\LabsamplerequestSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

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

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
 <?= GridView::widget([
        'dataProvider' => $dataProvider,
		'formatter' => ['class' => 'yii\i18n\Formatter','nullDisplay' => '-', 'dateFormat' => 'dd-MM-Y'],
        'filterModel' => $searchModel,
        'columns' => [
           // ['class' => 'yii\grid\SerialColumn'],

			// 'lab_smple_id',
			//'lab_smple_sur_id',
			//'lab_smple_part_id',
			//'lab_smple_acc_no',
			// 'lab_smple_tst_id',
			// 'lab_smple_spcmn_id',
			// 'lab_smple_spcmn_clctd',
			// 'lab_smple_date',
			/*[
				'attribute' => 'lab_smple_date',
				
				'format' => 'date',
			],
			[
				'attribute' => 'lab_smple_resultdate',
				'format' => 'date',
			],*/
			// 'lab_smple_result',
			// 'lab_smple_resultdate',
			// 'status',
			// 'create_time',
			// 'create_user',
			// 'update_time',
			// 'update_user',
			
			['class' => 'yii\grid\SerialColumn',
				'contentOptions' => ['style' => 'width:30px;  min-width:30px;']
			],
			
			[
			    'attribute' => 'lab_smple_part_id',			
				'contentOptions' => ['style' => 'width:160px;  min-width:100px;'],
			],
			
		 	[
			    'attribute' => 'lab_smple_acc_no',		
				'contentOptions' => ['style' => 'width:160px;  min-width:100px;'],
			],
			
		 	[
			    'attribute' => 'departments',
		 		'label' => 'Lab Test',
			    // 'value' => 'tests.lab_dept_code',
                'value' => function($model) {
                    return $model->tests->department->lab_dept_name;
                },
	            'filterType'=>GridView::FILTER_SELECT2,
	            'filter'=>ArrayHelper::map(Departments::find()->orderBy('lab_dept_name')->asArray()->all(), 'lab_dept_code', 'lab_dept_name'), 
	            'filterInputOptions'=>['placeholder'=>''],
				'contentOptions' => ['style' => 'width:160px;  min-width:100px;'],
			],
		
		 	[
				'attribute' => 'lab_smple_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' => 'lab_smple_resultdate',
					'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' => 'lab_smple_result',
		 		'label' => 'Test Result',
			     'value' => function($model) {
                      if($model->tests->lab_spot_test)
                        return $model->testresults->lab_result_name;									      
                      else
                        return $model->lab_smple_result;
                       },			
				'filterType'=>GridView::FILTER_SELECT2,
	            'filter'=>ArrayHelper::map(Labresultsmaster::find()->orderBy('lab_result_name')->asArray()->all(), 'lab_result_code', 'lab_result_name'), 
	            'filterInputOptions'=>['placeholder'=>''],
	            'contentOptions' => ['style' => 'width:250px;  min-width:200px;'],
			],
		
			
			 
			
			 
			 [
					'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']],
				],
				
            ['class' => 'app\behaviours\ActionColumns'],
        ],
    ]); ?>
</div>