<?php

class Funcionario extends CActiveRecord
{
	public function tableName()
	{
		return 'funcionario';
	}

	public function rules()
	{
		return array(
			array('fun_rut, fun_nombre, fun_ap_paterno, fun_ap_materno, fun_login, fun_clave, fun_email, fun_grado, fun_fecha_nac', 'required'),
			array('fun_ind_vigente, crg_codigo, est_codigo', 'numerical', 'integerOnly'=>true),
			array('fun_rut', 'length', 'max'=>12),
			array('fun_nombre, fun_ap_paterno, fun_ap_materno', 'length', 'max'=>200),
			array('fun_login, fun_clave, fun_email', 'length', 'max'=>100),
			array('fun_grado', 'length', 'max'=>5),
			array('fun_foto', 'length', 'max'=>500),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('fun_rut, fun_nombre, fun_ap_paterno, fun_ap_materno, fun_login, fun_clave, fun_email, fun_grado, fun_ind_vigente, fun_fecha_nac, fun_foto, crg_codigo, est_codigo', 'safe', 'on'=>'search'),
		);
	}

	public function relations()
	{
		return array(
		);
	}

	public function attributeLabels()
	{
		return array(
			'fun_rut' => 'Fun Rut',
			'fun_nombre' => 'Nombre',
			'fun_ap_paterno' => 'Fun Ap Paterno',
			'fun_ap_materno' => 'Fun Ap Materno',
			'fun_login' => 'Fun Login',
			'fun_clave' => 'Fun Clave',
			'fun_email' => 'Email',
			'fun_grado' => 'Fun Grado',
			'fun_ind_vigente' => 'Fun Ind Vigente',
			'fun_fecha_nac' => 'Fun Fecha Nac',
			'fun_foto' => 'Fun Foto',
			'crg_codigo' => 'Crg Codigo',
			'est_codigo' => 'Est Codigo',
		);
	}

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

		$criteria->compare('fun_rut',$this->fun_rut,true);
		$criteria->compare('fun_nombre',$this->fun_nombre,true);
		$criteria->compare('fun_ap_paterno',$this->fun_ap_paterno,true);
		$criteria->compare('fun_ap_materno',$this->fun_ap_materno,true);
		$criteria->compare('fun_login',$this->fun_login,true);
		$criteria->compare('fun_clave',$this->fun_clave,true);
		$criteria->compare('fun_email',$this->fun_email,true);
		$criteria->compare('fun_grado',$this->fun_grado,true);
		$criteria->compare('fun_ind_vigente',$this->fun_ind_vigente);
		$criteria->compare('fun_fecha_nac',$this->fun_fecha_nac,true);
		$criteria->compare('fun_foto',$this->fun_foto,true);
		$criteria->compare('crg_codigo',$this->crg_codigo);
		$criteria->compare('est_codigo',$this->est_codigo);

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

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

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