<?php

namespace app\models;

use Yii;
use yii\base\Model;
use app\base\Converter;
use app\models\Users;

/**
 * Followupreportcd is the model behind the contact form.
 */
class Followupreportcd extends Model
{
    public $repdate, $staff, $rep,$district;	
	public $report= [1 => 'Block-wise',2 => 'District-wise'];

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            [['repdate'], 'required'],
			[['staff', 'rep', 'district'], '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 [
            'Repate' => 'Date',            
            'district' => 'District',  
            'staff' => 'Staff', 
            'rep' => 'Report', 		
        ];
    }
	

}
