<?php

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

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

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

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

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

	public function rules() {
		return array(
			array('COD_DESCRICAO', 'length', 'max'=>80),
			array('COD_SITUACAO', 'length', 'max'=>1),
			array('COD_DESCRICAO, COD_SITUACAO', 'default', 'setOnEmpty' => true, 'value' => null),
			array('COD_IDCONDPAGTO, COD_DESCRICAO, COD_SITUACAO', 'safe', 'on'=>'search'),
			array('COD_DESCRICAO', 'required'),
		);
	}

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

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

	public function attributeLabels() {
		return array(
			'COD_IDCONDPAGTO' 	=> 'Código',
			'COD_DESCRICAO' 	=> 'Descrição',
			'COD_SITUACAO' 		=> 'Situação',
		);
	}

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

		$criteria->compare('COD_IDCONDPAGTO', $this->COD_IDCONDPAGTO);
		$criteria->compare('COD_DESCRICAO', utf8_decode($this->COD_DESCRICAO), true);
		$criteria->compare('COD_SITUACAO', $this->COD_SITUACAO, true);

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