<?php

/**
 * This is the model base class for the table "setores".
 * 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 "Setores".
 *
 * Columns in table "setores" available as properties of the model,
 * and there are no model relations.
 *
 * @property integer $SET_IDSETOR
 * @property string $SET_DESCRICAO
 *
 */
class Setores extends GxActiveRecord {

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

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

	public static function label($n = 1) {
		return Yii::t('app', 'Setores|Setores', $n);
	}

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

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

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

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

	public function attributeLabels() {
		return array(
			'SET_IDSETOR' 	=> 'Código',
			'SET_DESCRICAO' => 'Descricão',
		);
	}

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

		$criteria->compare('SET_IDSETOR', $this->SET_IDSETOR);
		$criteria->compare('SET_DESCRICAO', utf8_decode($this->SET_DESCRICAO), true);

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