<?php

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

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

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

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

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

	public function rules() {
		return array(
			array('LOC_DESCRICAO', 'length', 'max'=>20),
			array('LOC_DESCRICAO', 'default', 'setOnEmpty' => true, 'value' => null),
			array('LOC_IDLOCAL, LOC_DESCRICAO', 'safe', 'on'=>'search'),
		);
	}

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

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

	public function attributeLabels() {
		return array(
			'LOC_IDLOCAL' => 'Loc Idlocal',
			'LOC_DESCRICAO' => 'Loc Descricao',
		);
	}

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

		$criteria->compare('LOC_IDLOCAL', $this->LOC_IDLOCAL);
		$criteria->compare('LOC_DESCRICAO', $this->LOC_DESCRICAO, true);

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