<?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;
use app\base\Converter;
use kartik\select2\Select2;

$sdistrict=Yii::$app->user->identity->district;

$Staffnames= Common::getStaffnamesRep();

$model->repdate = date('d-m-Y');

$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-4">{label}{hint}</div><div class="col-sm-4">{input}{error}</div>',
                        ];
                         $htemplate = [
							'options' => ['tag' => false],
							'template' => '{input}'
						];	
                    ?>
					 <?= $form->field($model, 'district', $template)->textInput(['value' => $sdistrict,'readonly' => true]) ?>	
					 <?php if($model->getUserrole() ==1) : ?>	
					   <?= $form->field($model, 'rep', $template)->radioList($model->report,['separator'=>'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'])?>	
                     <?php endif; ?>	
					 
					<?= $form->field($model, 'repdate', $htemplate)->hiddenInput()->label("") ?>
                						
				    <?= $form->field($model, 'staff', $template)->widget(Select2::classname(), [	    
									'data' => $Staffnames,
									'options' => ['placeholder' => 'Select Staff Name'],
									'pluginOptions' => ['allowClear' => true ],
					 ]); ?>	
									
					
                    <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'],
							'options'=>['style' => 'white-space:nowrap;'], 
                            'panel' => [                                
							    'type' => GridView::TYPE_PRIMARY,
							    'heading' => "<b>$title</b>",
                                'footer'=>false
                            ],
				
                            'columns' => [
                           ['class' => 'yii\grid\SerialColumn'],
           
			    [
				  'attribute' => 'beneficiary_name',				
				  'label' => 'Name',
                ],
			 	'mobile_number',
				
				 [
				  'attribute' => 'cowin_beneficiary_id',				
				  'label' => 'Beneficiary Id',
                 ],
		  ],
				   ]); ?>
                    <?php endif; ?>
                    
                </div>
                <!-- /.col-lg-6 (nested) -->
            </div>
            <!-- /.row (nested) -->
        </div>
        <!-- /.panel-body -->
    </div>
    <!-- /.panel -->
</div>