<?php

class FuncionarioPerfil extends CActiveRecord
{
	
	public function tableName()
	{
		return 'funcionario_perfil';
	}

	
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('fun_rut', 'required'),
			array('fp_codigo, prf_codigo', 'numerical', 'integerOnly'=>true),
			array('fun_ip_conexion', 'length', 'max'=>20),
			array('fun_rut', 'length', 'max'=>12),
			array('fun_ultima_conexion', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('fp_codigo, fun_ultima_conexion, fun_ip_conexion, fun_rut, prf_codigo', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		return array(
		);
	}

	
	public function attributeLabels()
	{
		return array(
			'fp_codigo' => 'Fp Codigo',
			'fun_ultima_conexion' => 'Fun Ultima Conexion',
			'fun_ip_conexion' => 'Fun Ip Conexion',
			'fun_rut' => 'Fun Rut',
			'prf_codigo' => 'Prf Codigo',
		);
	}

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

		$criteria->compare('fp_codigo',$this->fp_codigo);
		$criteria->compare('fun_ultima_conexion',$this->fun_ultima_conexion,true);
		$criteria->compare('fun_ip_conexion',$this->fun_ip_conexion,true);
		$criteria->compare('fun_rut',$this->fun_rut,true);
		$criteria->compare('prf_codigo',$this->prf_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);
	}
}
