<?php

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

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

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


$services = [];
$index = 0;
$services[$index]['class'] = 'yii\grid\SerialColumn';
$index++;
foreach ($model->services as $key => $value) {
    $services[$index]['attribute'] = $key;
    $services[$index]['label'] = $value;
    $index++;    
	if($index == 5 || $index == 6 || $index == 7)
        $services[$index]['format'] = 'date';
}
// print_r($services);
if(empty($model->repdate))
    $model->repdate = date('d-m-Y');

?>


<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' => 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, 'repdate', $template)->widget(DatePicker::classname(), ['options' => ['placeholder' => $model->getAttributeLabel("repdate")]]) ?>
                    
                    <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,							
                            'layout' => '<div class="box"><div class="box-header with-border"><b>Participant Age Range-wise Summary</b></div><div class="box-body">{items}</div><div class="box-footer clearfix"></div></div>',
                            // 'filterModel' => $searchModel,
                            'formatter' => ['class' => 'yii\i18n\Formatter','nullDisplay' => '-', 'dateFormat' => 'dd-MM-Y'], 
                            'options'=>['style' => 'white-space:nowrap;'],                         
                            'panel' => ['type' => GridView::TYPE_PRIMARY,'footer'=>false], 
                            'columns' => $services                            
                        ]); ?>
                    <?php endif; ?>
                </div>
                <!-- /.col-lg-6 (nested) -->
            </div>
            <!-- /.row (nested) -->
        </div>
        <!-- /.panel-body -->
    </div>
    <!-- /.panel -->
</div>