<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\data\SqlDataProvider;

use app\base\Common;
use kartik\grid\GridView;
use kartik\widgets\DatePicker;
use rmrevin\yii\fontawesome\FA;

$this->title = Yii::t('app', Common::getMenuname());
$this->params['breadcrumbs'][] = $this->title;
?>


<div class="attandance-form">
    <h1><?= Html::encode($this->title) ?></h1>
    <div class="panel panel-default">
        <div class="panel-heading">
            
        </div>
        <div class="panel-body">
            <div class="row">
                <div class="col-lg-12">
                    <?php
                        // $form = ActiveForm::begin(['enableAjaxValidation' => true, 'options' => ['class' => 'form-horizontal']]);
                        $form = ActiveForm::begin(['enableAjaxValidation' => false, 'action' => ['index'], 'method' => 'get', 'options' => ['class' => 'form-horizontal']]);
                        $template = [
                            'labelOptions' => ['class' => 'form-label'],
                            'template' => '<div class="col-sm-5">{label}{hint}</div><div class="col-sm-4">{input}{error}</div>',
                        ];
                    ?>
                    <?= $form->field($model, 'frmdate', $template)->widget(DatePicker::classname(), ['options' => ['placeholder' => $model->getAttributeLabel("frmdate")]]) ?>
                    <?= $form->field($model, 'todate', $template)->widget(DatePicker::classname(), ['options' => ['placeholder' => $model->getAttributeLabel("todate")]]) ?>
                    <div class="form-group">
                        <div class="col-sm-offset-5 col-sm-7">
                            <?= Html::submitButton(Yii::t('app', 'Go'), ['class' =>'btn btn-success']) ?>
                        </div>
                    </div>
					<?php ActiveForm::end(); ?>
                    <?php if(isset($dataProvider)) : ?>
                        <?= GridView::widget([
                            'dataProvider' => $dataProvider,
                            'formatter' => ['class' => 'yii\i18n\Formatter','nullDisplay' => '-', 'dateFormat' => 'dd-MM-Y','datetimeFormat' => 'dd-MM-Y hh:mm:ss'], 
                            'options'=>['style' => 'white-space:nowrap;'],                         
                            'panel' => ['type' => GridView::TYPE_PRIMARY,'afterOptions'=>['class'=>'grid_panel_remove']], 
                            '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'],
                                'lab_smple_part_id',
                                'lab_smple_acc_no',
                                [
                                    'attribute' => 'departments',
                                    'label' => 'Lab Test',
                                    // 'value' => 'tests.department.lab_dept_name',
                                    'value' => function($model) {
                                        return $model->tests->department->lab_dept_name;
                                    },
                                ],
                                [
                                    'attribute' => 'lab_smple_date',
                                    'format' => 'date',
                                ],
                                [
                                    'attribute' => 'record_date',
                                    'format' => 'date',
                                ],
                                // ['class' => 'app\behaviours\ActionColumns'],
                            ],
                            // 'columns' => [
                            //  ['class' => 'yii\grid\SerialColumn'],
                            //  [
                            //      'attribute'=>'0',
                            //      'label'=>$model->services[0],
                            //  ],
                            //  [
                            //      'attribute' => 'reg_date',
                            //      // 'label'=>'Age Range',
                            //  ],
                            //  [
                            //      'attribute' => 'date',
                            //      // 'label'=>'Male',
                            //  ],
                            //  [
                            //      'attribute' => 'Gender',
                            //      // 'label'=>'Female',
                            //  ],
                            //  [
                            //      'attribute' => 'corfrm_q4',
                            //      // 'label'=>'Hijra',
                            //  ],
                            // ],
                        ]); ?>
                    <?php endif; ?>
                    
                </div>
                <!-- /.col-lg-6 (nested) -->
            </div>
            <!-- /.row (nested) -->
        </div>
        <!-- /.panel-body -->
    </div>
    <!-- /.panel -->
</div>