<?php

namespace app\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%contactpartners}}".
 *
 * @property integer $contact_partner_id
 * @property integer $contact_id
 * @property string $contact_partner_survey
 * @property string $contact_partner_part_id
 * @property string $contact_partner_q1
 * @property string $contact_partner_q2
 * @property string $contact_partner_q3
 * @property string $contact_partner_q4
 * @property string $status
 * @property integer $create_time
 * @property integer $create_user
 * @property integer $update_time
 * @property integer $update_user
 * @property integer $record_date
 */
class Contactpartners extends \yii\db\ActiveRecord
{
	/**
	 * @inheritdoc
	 */
    public static function tableName()
	{
		return '{{%contactpartners}}';
	}

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

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

	/**
	 * @inheritdoc
	 */
	public function attributeLabels()
	{
		return [
			'contact_partner_id' => Yii::t('app', 'Contact Partner ID'),
			'contact_id' => Yii::t('app', 'Contact ID'),
			'visit_code' => Yii::t('app', 'Visit'),
			'contact_partner_survey' => Yii::t('app', 'Contact Partner Survey'),
			'contact_partner_part_id' => Yii::t('app', 'Contact Partner Part ID'),
			'contact_partner_q1' => Yii::t('app', 'Name of personal contact'),
			'contact_partner_q2' => Yii::t('app', 'Address of this personal contact'),
			'contact_partner_q3' => Yii::t('app', 'Mobile phone number for this contact'),
			'contact_partner_q4' => Yii::t('app', 'Nick name'),
			'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'),
		];
	}
}
