<?php

/**
 * This is the model class for table "contable.cuentas_consolidada_2015".
 *
 * The followings are the available columns in table 'contable.cuentas_consolidada_2015':
 * @property integer $id
 * @property string $descripcion
 * @property integer $idpadre
 * @property boolean $valido
 * @property string $fecharegistro
 * @property integer $usuario_registro
 * @property string $codigo_cuenta
 * @property string $naturaleza
 * @property integer $esactivo
 * @property integer $tiene_aux
 * @property integer $grupo_aux
 * @property integer $titulo_mov
 * @property integer $nivel
 * @property integer $grupo_cuenta
 * @property boolean $blnborrado
 * @property integer $cta_banco
 * @property boolean $cta_prestamo
 * @property boolean $cta_int_x_cobr
 * @property boolean $cta_ing_x_int
 * @property string $referencia
 * @property integer $digitos_padre
 * @property integer $id_referencia
 * @property string $cuenta
 * @property integer $digitos
 * @property double $monto_prueba
 */
class CuentasConsolidada2015 extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		//return 'contable.cuentas_consolidada_2015';
                return 'contable.cuentas_consolidada';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('idpadre, usuario_registro, esactivo, tiene_aux, grupo_aux, titulo_mov, nivel, grupo_cuenta, cta_banco, digitos_padre, id_referencia, digitos', 'numerical', 'integerOnly'=>true),
			array('monto_prueba', 'numerical'),
			array('naturaleza', 'length', 'max'=>10),
			array('descripcion, valido, fecharegistro, codigo_cuenta, blnborrado, cta_prestamo, cta_int_x_cobr, cta_ing_x_int, referencia, cuenta', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, descripcion, idpadre, valido, fecharegistro, usuario_registro, codigo_cuenta, naturaleza, esactivo, tiene_aux, grupo_aux, titulo_mov, nivel, grupo_cuenta, blnborrado, cta_banco, cta_prestamo, cta_int_x_cobr, cta_ing_x_int, referencia, digitos_padre, id_referencia, cuenta, digitos, monto_prueba', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    'cuenta_padre' => array(self::BELONGS_TO, 'CuentasConsolidada', 'idpadre'),
                    'grupo' => array(self::BELONGS_TO, 'GrupoCuentas', 'grupo_cuenta'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'descripcion' => 'Descripcion',
			'idpadre' => 'Idpadre',
			'valido' => 'Valido',
			'fecharegistro' => 'Fecharegistro',
			'usuario_registro' => 'Usuario Registro',
			'codigo_cuenta' => 'Codigo Cuenta',
			'naturaleza' => 'Naturaleza',
			'esactivo' => 'Esactivo',
			'tiene_aux' => 'Tiene Aux',
			'grupo_aux' => 'Grupo Aux',
			'titulo_mov' => 'Titulo Mov',
			'nivel' => 'Nivel',
			'grupo_cuenta' => 'Grupo Cuenta',
			'blnborrado' => 'Blnborrado',
			'cta_banco' => 'Cta Banco',
			'cta_prestamo' => 'Cta Prestamo',
			'cta_int_x_cobr' => 'Cta Int X Cobr',
			'cta_ing_x_int' => 'Cta Ing X Int',
			'referencia' => 'Referencia',
			'digitos_padre' => 'Digitos Padre',
			'id_referencia' => 'Id Referencia',
			'cuenta' => 'Cuenta',
			'digitos' => 'Digitos',
			'monto_prueba' => 'Monto Prueba',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('descripcion',$this->descripcion,true);
		$criteria->compare('idpadre',$this->idpadre);
		$criteria->compare('valido',$this->valido);
		$criteria->compare('fecharegistro',$this->fecharegistro,true);
		$criteria->compare('usuario_registro',$this->usuario_registro);
		$criteria->compare('codigo_cuenta',$this->codigo_cuenta,true);
		$criteria->compare('naturaleza',$this->naturaleza,true);
		$criteria->compare('esactivo',$this->esactivo);
		$criteria->compare('tiene_aux',$this->tiene_aux);
		$criteria->compare('grupo_aux',$this->grupo_aux);
		$criteria->compare('titulo_mov',$this->titulo_mov);
		$criteria->compare('nivel',$this->nivel);
		$criteria->compare('grupo_cuenta',$this->grupo_cuenta);
		$criteria->compare('blnborrado',$this->blnborrado);
		$criteria->compare('cta_banco',$this->cta_banco);
		$criteria->compare('cta_prestamo',$this->cta_prestamo);
		$criteria->compare('cta_int_x_cobr',$this->cta_int_x_cobr);
		$criteria->compare('cta_ing_x_int',$this->cta_ing_x_int);
		$criteria->compare('referencia',$this->referencia,true);
		$criteria->compare('digitos_padre',$this->digitos_padre);
		$criteria->compare('id_referencia',$this->id_referencia);
		$criteria->compare('cuenta',$this->cuenta,true);
		$criteria->compare('digitos',$this->digitos);
		$criteria->compare('monto_prueba',$this->monto_prueba);

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

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return CuentasConsolidada2015 the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
