<?php

namespace app\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%contactareas}}".
 *
 * @property integer $contact_area_id
 * @property integer $contact_id
 * @property string $contact_area_survey
 * @property string $contact_area_part_id
 * @property string $contact_area_q1
 * @property integer $contact_area_q2
 * @property string $status
 * @property integer $create_time
 * @property integer $create_user
 * @property integer $update_time
 * @property integer $update_user
 * @property integer $record_date
 */
class Contactareas extends \yii\db\ActiveRecord
{
	/**
	 * @inheritdoc
	 */
    public static function tableName()
	{
		return '{{%contactareas}}';
	}

	/**
	 * @inheritdoc
	 */
	public function behaviors()
	{
		return [
			[
				'class' => TimestampBehavior::className(),
				'createdAtAttribute' => 'create_time',
				'updatedAtAttribute' => 'update_time',
				'value' => date('U'),
			]
		];
	}

	/**
	 * @inheritdoc
	 */
	public function rules()
	{
		return [
		     [['contact_area_survey', 'contact_area_part_id'], 'required', 'message' => 'Cannot be blank.'],
			// [['contact_id', 'contact_area_survey', 'contact_area_part_id', 'contact_area_q1', 'contact_area_q2', 'record_date'], 'required', 'message' => 'Cannot be blank.'],
			//[['contact_area_survey', 'contact_area_part_id', 'contact_area_q1', 'contact_area_q2'], 'required', 'message' => 'Cannot be blank.'],
			[['contact_id', 'contact_area_q2', 'create_time', 'create_user', 'update_time', 'update_user', 'record_date'], 'integer'],
			[['contact_area_survey', 'contact_area_part_id'], 'string', 'max' => 11],
			[['contact_area_q2'], 'string', 'max' => 6],
			[['contact_area_q2'], 'string', 'length' => 6, 'notEqual' => 'Must be {length} digits'],
			[['contact_area_q2'], 'number', 'min' => 0, 'tooSmall' => 'Negative value not allowed'],
			[['contact_area_q1'], 'string', 'max' => 100],
			[['visit_code'], 'string'],
			[['status'], 'string', 'max' => 1],
			[['record_date'], 'default', 'value' => strtotime(date('Y/m/d'))],
		];
	}

	/**
	 * @inheritdoc
	 */
	public function attributeLabels()
	{
		return [
			'contact_area_id' => Yii::t('app', 'Contact Area ID'),
			'contact_id' => Yii::t('app', 'Contact ID'),
			'visit_code' => Yii::t('app', 'Visit'),
			'contact_area_survey' => Yii::t('app', 'Contact Area Survey'),
			'contact_area_part_id' => Yii::t('app', 'Contact Area Part ID'),
			'contact_area_q1' => Yii::t('app', 'Area of city where client often hangs out (meets partners, buys/uses drugs)'),
			'contact_area_q2' => Yii::t('app', 'Pincode where client hangs out'),
			'status' => Yii::t('app', 'Status'),
			'create_time' => Yii::t('app', 'Create Time'),
			'create_user' => Yii::t('app', 'Create User'),
			'update_time' => Yii::t('app', 'Update Time'),
			'update_user' => Yii::t('app', 'Update User'),
			'record_date' => Yii::t('app', 'Record Date'),
		];
	}
}
