<?php

/**
 * This is the model base class for the table "rdm_causas".
 * 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 "RdmCausas".
 *
 * Columns in table "rdm_causas" available as properties of the model,
 * followed by relations of table "rdm_causas" available as properties of the model.
 *
 * @property integer $RDC_IDCAUSA
 * @property integer $RDC_IDRDM
 * @property string $RDC_CAUSA
 *
 * @property RdmAcao[] $Acoes
 * @property Rdm $Rdm
 */
class RdmCausas extends GxActiveRecord {

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

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

	public static function label($n = 1) {
		return 'RDM - Causas';
		return Yii::t('app', 'aaa|aaas', $n);
	}

	public static function representingColumn() {
		return 'RDC_CAUSA';
	}
	
	public function behaviors() {
    	return array('datetimeI18NBehavior' => array('class' => 'ext.DateTimeI18NBehavior'));
	}

	public function rules() {
		return array(
			array('RDC_IDRDM, RDC_CAUSA', 'required'),
			array('RDC_IDRDM', 'numerical', 'integerOnly'=>true),
			array('RDC_IDCAUSA, RDC_IDRDM, RDC_CAUSA', 'safe', 'on'=>'search'),
		);
	}

	public function relations() {
		return array(
			'Acoes' => array(self::HAS_MANY, 'RdmAcao', 'RDA_IDCAUSA'),
			'Rdm'	=> array(self::BELONGS_TO, 'Rdm', 'RDC_IDRDM'),
		);
	}

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

	public function attributeLabels() {
		return array(
			'RDC_IDCAUSA'	=> 'Código',
			'RDC_IDRDM'		=> 'RDM',
			'RDC_CAUSA'		=> 'Causa do Desvio',
			'Acoes'			=> 'Ações',
			'Rdm'			=> 'RDM',
		);
	}

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

		$criteria->compare('RDC_IDCAUSA', $this->RDC_IDCAUSA);
		$criteria->compare('RDC_IDRDM', $this->RDC_IDRDM);
		$criteria->compare('RDC_CAUSA', $this->RDC_CAUSA, true);

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