<?php

/**
 * This is the model class for table "configuracion.estructura_archivo_banco".
 *
 * The followings are the available columns in table 'configuracion.estructura_archivo_banco':
 * @property integer $id
 * @property string $id_param_bancos
 * @property string $encabezado
 * @property string $cuerpo
 * @property boolean $st_formato_banco
 *
 * The followings are the available model relations:
 * @property ParamBancos $idParamBancos
 */
class EstructuraArchivoBanco extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'configuracion.estructura_archivo_banco';
	}

	/**
	 * @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('encabezado, cuerpo,id_banco_tipo_servicio ', 'required', 'on'=>'registro'),
			array('cantidad_registro', 'numerical', 'integerOnly'=>true),
			array('cantidad_registro, id_param_bancos, encabezado, cuerpo, st_formato_banco, id_banco_tipo_servicio', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, id_param_bancos, encabezado, cuerpo, st_formato_banco', '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(
			'idParamBancos' => array(self::BELONGS_TO, 'ParamBancos', 'id_param_bancos'),
			'idBancoTipoServicio' => array(self::BELONGS_TO, 'BancoTipoServicio', 'id_banco_tipo_servicio'),

		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_param_bancos' => 'Id Param Bancos',
			'encabezado' => 'Encabezado',
			'cuerpo' => 'Cuerpo',
			'st_formato_banco' => 'St Formato Banco',
			'id_banco_tipo_servicio' => 'Tipo de servicio',
			'cantidad_registro' => 'Cantidad de registro por archivo',
		);
	}

	/**
	 * 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('id_param_bancos',$this->id_param_bancos,true);
		$criteria->compare('encabezado',$this->encabezado,true);
		$criteria->compare('cuerpo',$this->cuerpo,true);
		$criteria->compare('st_formato_banco',$this->st_formato_banco);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	public function searchBanco($id)
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_param_bancos',$id);
		$criteria->compare('encabezado',$this->encabezado,true);
		$criteria->compare('cuerpo',$this->cuerpo,true);
		$criteria->compare('st_formato_banco',true);

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