<?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\Converter;

$this->title = 'Incentive Summary Report';
$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 == 2)
        $services[$index]['format'] = 'date';
}
if(empty($model->frmdate))
    $model->frmdate = date('d-m-Y');
if(empty($model->todate))
    $model->todate = date('d-m-Y');
*/
if(empty($model->asondate))
    $model->asondate = 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>',
                        ];
                    ?>
                    <?php // $form->field($model, 'frmdate', $template)->widget(DatePicker::classname(), ['options' => ['placeholder' => $model->getAttributeLabel("frmdate")]]) ?>
                    <?php // $form->field($model, 'todate', $template)->widget(DatePicker::classname(), ['options' => ['placeholder' => $model->getAttributeLabel("todate")]]) ?>
					
					<?= $form->field($model, 'asondate', $template)->widget(DatePicker::classname(), ['options' => ['placeholder' => $model->getAttributeLabel("asondate")]]) ?>
                    <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>',
                            'formatter' => ['class' => 'yii\i18n\Formatter','nullDisplay' => '-', 'dateFormat' => 'dd-MM-Y','datetimeFormat' => 'dd-MM-Y hh:mm:ss'], 
                            'options'=>['style' => 'white-space:nowrap;'],                         
                            'panel' => ['heading'=>'Incentive Summary Report','type' => GridView::TYPE_PRIMARY,'afterOptions'=>['class'=>'grid_panel_remove']],
                         	'showFooter' => true,					
                              'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
			 
			 [
               'attribute'=>'pid', 
			  
               			   
            ],	
			 
			 
			 [
				'header' => 'Registration Date',				
				'format' => 'date',
				//'contentOptions' => ['style' =>'width:100px;  min-width:100px;'],
				'value'=> function ($model) {
					return $model->getRegdate($model->pid);
				},
				
			],
			 
			 [
				'header' => 'Screening Date',				
				'format' => 'date',
				//'contentOptions' => ['style' =>'width:100px;  min-width:100px;'],
				'value'=> function ($model) {
					return $model->getScrdate($model->pid);
				},
				'footer' =>"Total"
			],
			
			[
				'header' => 'Pre-ART <br> Incentive',		
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"prtart");
				},
				'footer' =>$preartsum

			],
			
			[
				'header' => 'ART Initiation <br> Incentive',		
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"artinit");
				},
				'footer' =>$artinitsum
			],
			
			[
				'header' => 'ART Refill <br> Incentive',		
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"artref");
				},
				'footer' =>$artrefsum
			],
			
			[
				'header' => 'Motivational Counseling <br> Incentive',
              				
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"mot");
				},
				'footer' =>$motsum 
			],
			
			[
				'header' => 'Total <br> Earned',	
                'contentOptions' => ['style' =>'color:green;font-weight:bold;'],				
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"totearned");
				},
				'footer' =>$totalearnedsum 
			],
			
			[
				'header' => 'Total <br> Paid',	
                'contentOptions' => ['style' =>'color:red;font-weight:bold;'],					
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"totpaid");
				},
				'footer' =>$totalpaidsum 
			],
			
			[
				'header' => 'Total <br> Balance',
                 'contentOptions' => ['style' =>'font-weight:bold;'],					
				'value'=> function ($model) {
				 return $model->getInc($model->pid,"totbal");
				},
				'footer' =>$totalbalsum 
			],
			
			[  
    		   'header' => 'Contact <br> Number',
               'attribute'=>'contact', 
			  
               			   
            ],	
			[
			'header'=>' Contact Number  <br> When Registration',
             'attribute' => 'regcontact',        
            ],
						
          ],  
            			 
                        ]); ?>
                    <?php endif; ?>
                </div>
                <!-- /.col-lg-6 (nested) -->
            </div>
            <!-- /.row (nested) -->
        </div>
        <!-- /.panel-body -->
    </div>
    <!-- /.panel -->
</div>