<?php

/**
 * This is the model base class for the table "funcoes".
 * DO NOT MODIFY THIS FILE! It is automatically generated by giix.
 * If any changes are necessary, you must set or override the required
 * property or method in class "Funcoes".
 *
 * Columns in table "funcoes" available as properties of the model,
 * and there are no model relations.
 *
 * @property integer $FNS_IDFUNCAO
 * @property string $FNS_DESCRICAO
 * @property string $FNS_SITUACAO
 *
 */
class Funcoes extends GxActiveRecord {

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

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

	public static function label($n = 1) {
		return Yii::t('app', 'Função|Funções', $n);
	}

	public static function representingColumn() {
		return 'FNS_DESCRICAO';
	}

	public function rules() {
		return array(
			array('FNS_DESCRICAO', 'length', 'max'=>50),
			array('FNS_SITUACAO', 'length', 'max'=>1),
			array('FNS_DESCRICAO,FNS_SITUACAO', 'required'),
			array('FNS_DESCRICAO, FNS_SITUACAO', 'default', 'setOnEmpty' => true, 'value' => null),
			array('FNS_IDFUNCAO, FNS_DESCRICAO, FNS_SITUACAO', 'safe', 'on'=>'search'),
		);
	}

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

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

	public function attributeLabels() {
		return array(
			'FNS_IDFUNCAO' 	=> 'Código',
			'FNS_DESCRICAO' => 'Descrição',
			'FNS_SITUACAO' 	=> 'Situação',
		);
	}

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

		$criteria->compare('FNS_IDFUNCAO', $this->FNS_IDFUNCAO);
		$criteria->compare('FNS_DESCRICAO', utf8_decode($this->FNS_DESCRICAO), true);
		$criteria->compare('FNS_SITUACAO', $this->FNS_SITUACAO, true);

		return new CActiveDataProvider($this, array(
				'criteria' => $criteria,
				'sort' => array(
		            'defaultOrder'=> 'FNS_DESCRICAO ASC',
	 	        ),
	 	        'pagination' => array(    
	                'pageSize' => 20,
				)
			)
		);
	}
}