<?php

/**
 * This is the model class for table "contable.vsw_mayor_cuenta".
 *
 * The followings are the available columns in table 'contable.vsw_mayor_cuenta':
 * @property integer $id
 * @property string $fecha_comprobante
 * @property integer $numero
 * @property string $referencia
 * @property string $descripcion
 * @property string $fecha_referencia
 * @property integer $id_cuenta
 * @property integer $clv_comprobante
 * @property string $clv_auxiliar
 * @property integer $tipo_aux
 * @property string $monto_debe
 * @property string $monto_haber
 * @property boolean $blnborrado
 * @property string $fecha_creado
 * @property string $hora_create
 * @property integer $estatus_contab
 */
class MayorAnaliticoCuenta extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
    
        public $fecha_final;
        public $cuenta_hasta;
        public $tipo_rep;
        public $mov_auxiliar;
        public $sin_mov;
        public $sin_mov_saldo;
        public $salta_pag;
        public $descartar;
        public $tipo_informe;
        public $cant_imprime;
        public $header;
        public $cantidad;
        public $n_desde;
        public $n_hasta;
        public $detalla;
        public $repetir;
        public $nivel_balance;
        public $cod_cuenta;
        //public $tipo_informe;
	public function tableName()
	{
		return 'contable.vsw_mayor_cuenta';
	}
	public function primaryKey()
	{
		return 'id';
	}

	/**
	 * @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('id, numero, id_cuenta, clv_comprobante, estatus_contab', 'numerical', 'integerOnly'=>true),
			array('clv_auxiliar', 'length', 'max'=>12),
			//array('fecha_comprobante,fecha_final,id_cuenta', 'required'),
                        array('fecha_comprobante,fecha_final,id_cuenta', 'required','on' => 'busca_cuenta'),
			array('tipo_informe,header,fecha_final,repetir,cod_cuenta,nivel_balance,n_desde,detalla,n_hasta,cantidad,fecha_comprobante,descartar,cant_imprime,sin_mov,sin_mov_saldo,salta_pag, referencia, descripcion, fecha_referencia,cuenta_hasta, monto_debe, monto_haber, blnborrado, fecha_creado, hora_create', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, fecha_comprobante,header,cantidad,nivel_balance,tipo_informe,nombres,descartar,cant_imprime,sin_mov_saldo,salta_pag,tipo_rep,sin_mov,mov_auxiliar,fecha_final,cuenta_hasta, numero, referencia, descripcion, fecha_referencia, id_cuenta, clv_comprobante, clv_auxiliar, monto_debe, monto_haber, blnborrado, fecha_creado, hora_create, estatus_contab', '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' => array(self::BELONGS_TO, 'VistaAuxiliar', 'clv_auxiliar'),
                    'cuentamov' => array(self::BELONGS_TO, 'CuentasConsolidada', 'id_cuenta'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'fecha_comprobante' => 'Fecha inicial',
			'fecha_final' => 'Fecha final',
			'numero' => 'Numero',
			'referencia' => 'Referencia',
			'descripcion' => 'Descripcion',
			'fecha_referencia' => 'Fecha referencia',
			'id_cuenta' => 'Cuenta desde',
			'cuenta_hasta' => 'Cuenta hasta',
			'clv_comprobante' => 'Clv comprobante',
			'clv_auxiliar' => 'Código del auxiliar',
//			'tipo_aux' => 'Grupo auxiliar',
			'monto_debe' => 'Monto debe',
			'monto_haber' => 'Monto haber',
			'cant_imprime' => 'Cantidad a imprimir',
			'blnborrado' => 'Blnborrado',
			'fecha_creado' => 'Fecha creado',
			'hora_create' => 'Hora Create',
			'tipo_informe' => '<b>Tipo de informe</b>',
			'n_desde' => 'Número desde',
			'cod_cuenta' => 'Incluir código de cuenta',
			'nivel_balance' => 'Nivel balance',
			'n_hasta' => 'Número hasta',
			'estatus_contab' => 'Estatus contab.',
			'header' => 'Nombre de la compañia',
			'repetir' => 'Repetir títulos de asientos',
			'detalla' => 'Detallar descripción, asiento y fecha',
			'cantidad' => 'Cantidad de comprobantes',
			'sin_mov' => 'Incluye cuentas sin movimiento',
			'sin_mov_saldo' => 'Incluye cuentas sin movimiento con saldo inicial',
			'salta_pag' => 'Con saltos de página',
			'descartar' => 'Descartar saldos de períodos anteriores para cuentas de ganancias y pérdidas',
			'Cuenta hasta' => 'Cuenta hasta',
			'Cuenta Desde' => 'Cuenta desde',
		);
	}

	/**
	 * 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('fecha_comprobante',$this->fecha_comprobante,true);
		$criteria->compare('fecha_final',$this->fecha_final,true);
		$criteria->compare('numero',$this->numero);
		$criteria->compare('referencia',$this->referencia,true);
		$criteria->compare('descripcion',$this->descripcion,true);
		$criteria->compare('fecha_referencia',$this->fecha_referencia,true);
		$criteria->compare('id_cuenta',$this->id_cuenta);
		$criteria->compare('cuenta_hasta',$this->cuenta_hasta);
		$criteria->compare('clv_comprobante',$this->clv_comprobante);
		$criteria->compare('clv_auxiliar',$this->clv_auxiliar,true);
//		$criteria->compare('tipo_aux',$this->tipo_aux);
		$criteria->compare('monto_debe',$this->monto_debe,true);
		$criteria->compare('monto_haber',$this->monto_haber,true);
		$criteria->compare('blnborrado',$this->blnborrado);
		$criteria->compare('fecha_creado',$this->fecha_creado,true);
		$criteria->compare('hora_create',$this->hora_create,true);
		$criteria->compare('estatus_contab',$this->estatus_contab);
		$criteria->compare('tipo_rep',$this->tipo_rep);
		$criteria->compare('mov_auxiliar',$this->mov_auxiliar);
		$criteria->compare('sin_mov',$this->sin_mov);
		$criteria->compare('sin_mov_saldo',$this->sin_mov_saldo);
		$criteria->compare('salta_pag',$this->salta_pag);
		$criteria->compare('tipo_informe',$this->tipo_informe);
		$criteria->compare('cant_imprime',$this->cant_imprime);
		$criteria->compare('header',$this->header);
		$criteria->compare('cantidad',$this->cantidad);
		$criteria->compare('n_desde',$this->n_desde);
		$criteria->compare('n_hasta',$this->n_hasta);
		$criteria->compare('detalla',$this->detalla);
		$criteria->compare('repetir',$this->repetir);
		$criteria->compare('nivel_balance',$this->nivel_balance);
		$criteria->compare('cod_cuenta',$this->cod_cuenta);

		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 MayorAnaliticoCuenta the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
