<?php

namespace app\models;

use Yii;
use yii\base\Model;

/**
 * ContactForm is the model behind the contact form.
 */
class Vaccrosstabreport extends Model
{
    public $reptype;
    public $type = [1 => 'Gender cum Age Wise', 2 => 'ID Proof cum Gender Wise', 3 => 'Beneficiary Type cum Gender Wise'];
	//, 4 => 'Gender cum Dose Analysis'
    public $district,$block,$rep,$dist;	
	public $report= [1 => 'Block-wise',2 => 'District-wise'];

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            
            [['reptype'], 'required'],
			[['district','block', 'rep','dist'], 'safe'],
			
			 [['rep'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {	
               return ($model->getUserrole() ==1);			 
			 }],
           
        ];
    }
	
	public function getUserrole()
	{
	    $sloc=Yii::$app->user->identity->signedin_loc;
		$suser=Yii::$app->user->identity->users_name;
		$Usermodel = Users::find()->where(['users_name' => $suser])->one();	   
		
        if ($Usermodel !== null) {		
         return $Usermodel->user_role;			
        } 
	}

    /**
     * @return array customized attribute labels
     */
    public function attributeLabels()
    {
        return [
            'reptype' => 'Report Name',   
            'district' => 'District',  	
            'block' => 'Block',  
            'rep' => 'Report', 
            'dist' => 'District', 			
        ];
    }
}
