<?php

namespace app\controllers;

use Yii;
use yii\web\Response;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\widgets\ActiveForm;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use yii\data\ArrayDataProvider;

use app\base\Common;
use app\base\Converter;
use app\models\Counselor;
use app\models\Registration;
use app\models\Clientreport;

/**
 * IncentivereportController implements the CRUD actions for Patientcrosstabreport model.
 */
class IncentivereportController extends Controller
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'actions' => ['error'],
                        'allow' => true,
                    ],
                    [
                        'actions' => ['index'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
        ];
    }
			
	
		 
    /**
     * Lists all Arvmaster models.
     * @return mixed
     */
    public function actionIndex()
    {
        $model = new Clientreport();

         if ($model->load(Yii::$app->request->post()) || $model->load(Yii::$app->request->get())) {
                       
            if(!$model->validate()) {
                return $this->render('index', ['model' => $model]);
            } else {
                $dataProvider = Common::getIncentives($model->pid);
                // print_r($dataProvider->getModels());
                return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]);
            }
        }
        return $this->render('index', ['model' => $model]);
    }

}
