<?php

namespace modules\forms\models;

use frontend\models\Users;
use Yii;

use modules\activities\models\Activities;
use modules\custom\models\Accounts;
use yii\base\Model;
/**
 * This is the model class For table "dt035".
 *
 * @property string $id
 * @property string $actid
 * @property string $employee
 * @property string $jobtitle
 * @property string $safetycritical
 * @property string $item0yn
 * @property string $item0action
 * @property string $item1yn
 * @property string $item1action
 * @property string $item2yn
 * @property string $item2action
 * @property string $item3yn
 * @property string $item3action
 * @property string $item4yn
 * @property string $item4action
 * @property string $item5yn
 * @property string $item5action
 * @property string $item6yn
 * @property string $item6action
 * @property string $item7yn
 * @property string $item7action
 * @property string $item8yn
 * @property string $item8action
 * @property string $item9yn
 * @property string $item9action
 * @property string $item10yn
 * @property string $item10action
 * @property string $item11yn
 * @property string $item11action
 * @property string $item12yn
 * @property string $item12action
 * @property string $item13yn
 * @property string $item13action
 * @property string $item14yn
 * @property string $item14action
 * @property string $item15yn
 * @property string $item15action
 * @property string $item16yn
 * @property string $item16action
 * @property string $item17yn
 * @property string $item17action
 * @property string $item18yn
 * @property string $item18action
 * @property string $item19yn
 * @property string $item19action
 * @property string $item20yn
 * @property string $item20action
 * @property string $item21yn
 * @property string $item21action
 * @property string $item22yn
 * @property string $item22action
 * @property string $item23yn
 * @property string $item23action
 * @property string $item24yn
 * @property string $item24action
 * @property string $item25yn
 * @property string $item25action
 * @property string $item26yn
 * @property string $item26action
 * @property string $item27yn
 * @property string $item27action
 * @property string $item28yn
 * @property string $item28action
 * @property string $item29yn
 * @property string $item29action
 * @property string $item30yn
 * @property string $item30action
 * @property string $item31yn
 * @property string $item31action
 * @property string $item32yn
 * @property string $item32action
 * @property string $item33yn
 * @property string $item33action
 * @property string $item34yn
 * @property string $item34action
 * @property string $item35yn
 * @property string $item35action
 * @property string $item36yn
 * @property string $item36action
 * @property string $item37yn
 * @property string $item37action
 * @property string $item38yn
 * @property string $item38action
 * @property string $item39yn
 * @property string $item39action
 * @property string $item40yn
 * @property string $item40action
 * @property string $item41yn
 * @property string $item41action
 * @property string $item42yn
 * @property string $item42action
 * @property string $item43yn
 * @property string $item43action
 * @property string $item44yn
 * @property string $item44action
 * @property string $item45yn
 * @property string $item45action
 * @property string $item46yn
 * @property string $item46action
 * @property string $item47yn
 * @property string $item47action
 * @property string $item48yn
 * @property string $item48action
 * @property string $item49yn
 * @property string $item49action
 * @property string $item50yn
 * @property string $item50action
 * @property string $signature0
 * @property string $signature1
 * @property string $postheld
 * @property integer $created_at
 * @property integer $created_by
 * @property integer $updated_by
 * @property integer $updated_at
 */
class Dt035 extends  Model {

    public $id;
    public $actid;
    public $employee;
    public $jobtitle;
    public $safetycritical;
    public $item0yn;
    public $item0action;
    public $item1yn;
    public $item1action;
    public $item2yn;
    public $item2action;
    public $item3yn;
    public $item3action;
    public $item4yn;
    public $item4action;
    public $item5yn;
    public $item5action;
    public $item6yn;
    public $item6action;
    public $item7yn;
    public $item7action;
    public $item8yn;
    public $item8action;
    public $item9yn;
    public $item9action;
    public $item10yn;
    public $item10action;
    public $item11yn;
    public $item11action;
    public $item12yn;
    public $item12action;
    public $item13yn;
    public $item13action;
    public $item14yn;
    public $item14action;
    public $item15yn;
    public $item15action;
    public $item16yn;
    public $item16action;
    public $item17yn;
    public $item17action;
    public $item18yn;
    public $item18action;
    public $item19yn;
    public $item19action;
    public $item20yn;
    public $item20action;
    public $item21yn;
    public $item21action;
    public $item22yn;
    public $item22action;
    public $item23yn;
    public $item23action;
    public $item24yn;
    public $item24action;
    public $item25yn;
    public $item25action;
    public $item26yn;
    public $item26action;
    public $item27yn;
    public $item27action;
    public $item28yn;
    public $item28action;
    public $item29yn;
    public $item29action;
    public $item30yn;
    public $item30action;
    public $item31yn;
    public $item31action;
    public $item32yn;
    public $item32action;
    public $item33yn;
    public $item33action;
    public $item34yn;
    public $item34action;
    public $item35yn;
    public $item35action;
    public $item36yn;
    public $item36action;
    public $item37yn;
    public $item37action;
    public $item38yn;
    public $item38action;
    public $item39yn;
    public $item39action;
    public $item40yn;
    public $item40action;
    public $item41yn;
    public $item41action;
    public $item42yn;
    public $item42action;
    public $item43yn;
    public $item43action;
    public $item44yn;
    public $item44action;
    public $item45yn;
    public $item45action;
    public $item46yn;
    public $item46action;
    public $item47yn;
    public $item47action;
    public $item48yn;
    public $item48action;
    public $item49yn;
    public $item49action;
    public $item50yn;
    public $item50action;
    public $signature0;
    public $signature1;
    public $postheld;
    public $created_at;
    public $created_by;
    public $updated_by;
    public $created_by2;
    public $updated_by2;
    public $updated_at;
    public $deleted_by;
    public $deleted_at;
    public $date;
    public $assessor;
    public $deleted;
    public $relatedid;
    public $jobno;
    public $status;
    public $padno;
    
    public $printlayout = 'Landscape';
    public $form = 'DT035';
    public $formname = 'PPE and Equipment – Periodic Check (DT035)';
    
    public $createpath = '/forms/dt035/create';
    public $formType = 'Other';
    
    public $formLayout = '/dt035/_form.php';
    public $viewLayout = '@modules/forms/views/dt035/_view.php';/**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['actid', 'employee', 'jobtitle', 'item0yn', 'item0action', 'item1yn', 'item1action', 'item2yn', 'item2action', 'item3yn', 'item3action', 'item4yn', 'item4action', 'item5yn', 'item5action', 'item6yn', 'item6action', 'item7yn', 'item7action', 'item8yn', 'item8action', 'item9yn', 'item9action', 'item10yn', 'item10action', 'item11yn', 'item11action', 'item12yn', 'item12action', 'item13yn', 'item13action', 'item14yn', 'item14action', 'item15yn', 'item15action', 'item16yn', 'item16action', 'item17yn', 'item17action', 'item18yn', 'item18action', 'item19yn', 'item19action', 'item20yn', 'item20action', 'item21yn', 'item21action', 'item22yn', 'item22action', 'item23yn', 'item23action', 'item24yn', 'item24action', 'item25yn', 'item25action', 'item26yn', 'item26action', 'item27yn', 'item27action', 'item28yn', 'item28action', 'item29yn', 'item29action', 'item30yn', 'item30action', 'item31yn', 'item31action', 'item32yn', 'item32action', 'item33yn', 'item33action', 'item34yn', 'item34action', 'item35yn', 'item35action', 'item36yn', 'item36action', 'item37yn', 'item37action', 'item38yn', 'item38action', 'item39yn', 'item39action', 'item40yn', 'item40action', 'item41yn', 'item41action', 'item42yn', 'item42action', 'item43yn', 'item43action', 'item44yn', 'item44action', 'item45yn', 'item45action', 'item46yn', 'item46action', 'item47yn', 'item47action', 'item48yn', 'item48action', 'item49yn', 'item49action', 'item50yn', 'item50action', 'signature0', 'signature1', 'postheld', 'date','assessor'], 'string'],
			[['safetycritical'],'string', 'max' => 3],
			//Defaults
			[['deleted'], 'boolean'],
			[['created_at', 'updated_at', 'deleted_at'], 'safe'],
			[['created_by', 'updated_by','id'],'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'actid' => 'Actid',
            'employee' => 'Employee',
            'jobtitle' => 'Jobtitle',
            'safetycritical' => 'Safetycritical',
            'item0yn' => 'Hard Hat – Approved type with InLine logo',
            'item0action' => 'Item0action',
            'item1yn' => 'Safety glasses - Clear',
            'item1action' => 'Item1action',
            'item2yn' => 'Safety Glasses - Shaded',
            'item2action' => 'Item2action',
            'item3yn' => 'Versa flow System',
            'item3action' => 'Item3action',
            'item4yn' => 'Speed-glass System',
            'item4action' => 'Item4action',
            'item5yn' => 'Safety goggles – Clear High Impact',
            'item5action' => 'Item5action',
            'item6yn' => 'Safety goggles – Dark G5/6',
            'item6action' => 'Item6action',
            'item7yn' => 'Item7yn',
            'item7action' => 'Item7action',
            'item8yn' => $this->created_at && $this->created_at < 1517315151 ? 'Personal respirator' : 'Rucksack',
            'item8action' => 'Item8action',
            'item9yn' => $this->created_at && $this->created_at < 1517315151 ? 'Dust mask/s' : 'Thermometer',
            'item9action' => 'Item9action',
            'item10yn' => 'Safety gloves – rigger',
            'item10action' => 'Item10action',
            'item11yn' => 'Safety gloves – other',
            'item11action' => 'Item11action',
            'item12yn' => 'Welding gauntlets',
            'item12action' => 'Item12action',
            'item13yn' => 'Safety boots – Flame Retardant',
            'item13action' => 'Item13action',
            'item14yn' => 'Item14yn',
            'item14action' => 'Item14action',
            'item15yn' => 'Item15yn',
            'item15action' => 'Item15action',
            'item16yn' => 'Item16yn',
            'item16action' => 'Item16action',
            'item17yn' => 'Item17yn',
            'item17action' => 'Item17action',
            'item18yn' => 'Item18yn',
            'item18action' => 'Item18action',
            'item19yn' => 'Item19yn',
            'item19action' => 'Item19action',
            'item20yn' => 'Item20yn',
            'item20action' => 'Item20action',
            'item21yn' => 'Item21yn',
            'item21action' => 'Item21action',
            'item22yn' => 'Item22yn',
            'item22action' => 'Item22action',
            'item23yn' => 'Item23yn',
            'item23action' => 'Item23action',
            'item24yn' => 'Item24yn',
            'item24action' => 'Item24action',
            'item25yn' => 'Item25yn',
            'item25action' => 'Item25action',
            'item26yn' => 'T-Shirt/s',
            'item26action' => 'Item26action',
            'item27yn' => 'Body warmer – Flame Retardant',
            'item27action' => 'Item27action',
            'item28yn' => 'Foul weather jacket – Flame Retardant',
            'item28action' => 'Item28action',
            'item29yn' => 'Waterproof over trousers – Flame Retardant',
            'item29action' => 'Item29action',
            'item30yn' => 'Overall/s – Flame Retardant',
            'item30action' => 'Item30action',
            'item31yn' => 'Item31yn',
            'item31action' => 'Item31action',
            'item32yn' => 'Item32yn',
            'item32action' => 'Item32action',
            'item33yn' => 'Item33yn',
            'item33action' => 'Item33action',
            'item34yn' => 'Item34yn',
            'item34action' => 'Item34action',
            'item35yn' => 'Digital Tablet',
            'item35action' => 'Item35action',
            'item36yn' => 'Charger - Mains',
            'item36action' => 'Item36action',
            'item37yn' => 'Charger – In car',
            'item37action' => 'Item37action',
            'item38yn' => 'Item38yn',
            'item38action' => 'Item38action',
            'item39yn' => 'Item39yn',
            'item39action' => 'Item39action',
            'item40yn' => 'Item40yn',
            'item40action' => 'Item40action',
            'item41yn' => 'Item41yn',
            'item41action' => 'Item41action',
            'item42yn' => 'Item42yn',
            'item42action' => 'Item42action',
            'item43yn' => 'Item43yn',
            'item43action' => 'Item43action',
            'item44yn' => 'Item44yn',
            'item44action' => 'Item44action',
            'item45yn' => 'Item45yn',
            'item45action' => 'Item45action',
            'item46yn' => 'Item46yn',
            'item46action' => 'Item46action',
            'item47yn' => 'Item47yn',
            'item47action' => 'Item47action',
            'item48yn' => 'Item48yn',
            'item48action' => 'Item48action',
            'item49yn' => 'Item49yn',
            'item49action' => 'Item49action',
            'item50yn' => 'Item50yn',
            'item50action' => 'Item50action',
            'signature0' => 'Signature0',
            'signature1' => 'Signature1',
            'postheld' => 'Postheld',
            'created_at' => 'Created At',
            'created_by' => 'Created By',
            'updated_by' => 'Updated By',
            'updated_at' => 'Updated At',
        ];
    }


   	public function getActivity() {
		return Activities::findOne(['id' => $this->actid]);
	}
	public function getAccount()
	{
		return Accounts::findOne(['accountid' => $this->company])
		->Via('activity');
	} 
    public function getUser() {
        return User::findOne(['id' => $this->created_by]);
    }

    
    public function init(){
        if($this->actid){
            $activity = Activities::findOne(['id' => $this->actid]);
            //$this->actid = $activity->id;
            //$this->jobno = $activity->jobno;
            //$this->location = $activity->location;
            //$this->client = $activity->company;
            //$this->relatedid = $activity->relatedid;
        }   
        return parent::init();
    }
    public static function adminFormButtons($buttons, $model){
      $_this = new self();
        $buttons[$_this->formType]['items'][] = [
            'label' => $_this->formname,
            'url' => [$_this->createpath, 'actid' => $model->id],
            'linkOptions' =>  ['target'=>'_blank'],
        ];
        return $buttons;
    }
}
