<?php

class RevisarDoc extends CActiveRecord
{

	public $fun_rut2;

	public function tableName()
	{
		return 'revisar_doc';
	}

	public function rules()
	{
		return array(
			array('fun_rut', 'required'),
			array('doc_codigo, obs_codigo', 'numerical', 'integerOnly'=>true),
			array('revisar_estado', 'length', 'max'=>100),
			array('fun_rut', 'length', 'max'=>12),
			array('revisar_fecha', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('revisar_codigo, revisar_estado, revisar_fecha, doc_codigo, obs_codigo, fun_rut', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'funcionario' => array(self::BELONGS_TO, 'Funcionario', 'fun_rut'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'revisar_codigo' => 'Revisar Codigo',
			'revisar_estado' => 'Revisar Estado',
			'revisar_fecha' => 'Revisar Fecha',
			'doc_codigo' => 'Doc Codigo',
			'obs_codigo' => 'Obs Codigo',
			'fun_rut' => 'Revisor',
			'fun_rut2' => 'Revisor',
		);
	}

	public function search()
	{
		$criteria=new CDbCriteria;

		$criteria->compare('revisar_codigo',$this->revisar_codigo);
		$criteria->compare('revisar_estado',$this->revisar_estado,true);
		$criteria->compare('revisar_fecha',$this->revisar_fecha,true);
		$criteria->compare('doc_codigo',$this->doc_codigo);
		$criteria->compare('obs_codigo',$this->obs_codigo);
		$criteria->compare('fun_rut',$this->fun_rut,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	public function getDbConnection()
	{
		return Yii::app()->db_gd;
	}

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
