<?php

/**
 * This is the model class for table "sidcai_beneficiario".
 *
 * The followings are the available columns in table 'sidcai_beneficiario':
 * @property integer $bene_codigo_pk
 * @property string $bene_razonsocial
 * @property string $bene_denominacioncomercial
 * @property integer $esta_codigo_fk
 * @property integer $muni_codigo_fk
 * @property integer $parr_codigo_fk
 * @property string $bene_direccion
 * @property string $bene_zonapostal
 * @property string $bene_telefono1
 * @property string $bene_telefono2
 * @property string $bene_fax
 * @property string $bene_celular
 * @property string $bene_descripcion
 * @property integer $repr_codigo_fk
 * @property string $bene_tipopersona
 * @property integer $esta_codigoestatus_fk
 * @property string $bene_adscrito
 * @property string $bene_fecharegistro
 * @property string $bene_fechaestatus
 * @property string $bene_fechamodif
 * @property integer $clas_codigo_fk
 * @property string $bene_ciudad
 * @property string $bene_rifcedula
 * @property string $bene_correoelectronico
 * @property string $bene_paginaweb
 * @property integer $audit_usua
 * @property integer $inst_codigo_fk
 * @property integer $tipo_codigo_fk
 *
 * The followings are the available model relations:
 * @property SidcaiInstitucion $instCodigoFk
 * @property SidcaiEstado $estaCodigoFk
 * @property SidcaiMunicipio $muniCodigoFk
 * @property SidcaiParroquia $parrCodigoFk
 * @property SidcaiClasificacionbeneficiario $clasCodigoFk
 * @property SidcaiTipobeneficiario $tipoCodigoFk
 * @property SidcaiRepresentantelegal $reprCodigoFk
 * @property SidcaiEstatus $estaCodigoestatusFk
 * @property SidcaiProyectobeneficiario[] $sidcaiProyectobeneficiarios
 * @property SidcaiDeclaracionActividad[] $sidcaiDeclaracionActividads
 * @property SidcaiTransferencia[] $sidcaiTransferencias
 * @property SidcaiCitabeneficiario[] $sidcaiCitabeneficiarios
 * @property SidcaiCuenta[] $sidcaiCuentas
 * @property SidcaiUsuario[] $sidcaiUsuarios
 */
class SidcaiBeneficiario extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sidcai_beneficiario';
	}

	/**
	 * @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('bene_razonsocial, esta_codigo_fk, muni_codigo_fk, parr_codigo_fk, bene_direccion, bene_telefono1, bene_tipopersona, esta_codigoestatus_fk, bene_fecharegistro, bene_fechaestatus, bene_ciudad, bene_rifcedula, tipo_codigo_fk', 'required'),
			array('esta_codigo_fk, muni_codigo_fk, parr_codigo_fk, repr_codigo_fk, esta_codigoestatus_fk, clas_codigo_fk, audit_usua, inst_codigo_fk, tipo_codigo_fk', 'numerical', 'integerOnly'=>true),
			array('bene_denominacioncomercial, bene_zonapostal, bene_telefono2, bene_fax, bene_celular, bene_descripcion, bene_adscrito, bene_fechamodif, bene_correoelectronico, bene_paginaweb', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('bene_codigo_pk, bene_razonsocial, bene_denominacioncomercial, esta_codigo_fk, muni_codigo_fk, parr_codigo_fk, bene_direccion, bene_zonapostal, bene_telefono1, bene_telefono2, bene_fax, bene_celular, bene_descripcion, repr_codigo_fk, bene_tipopersona, esta_codigoestatus_fk, bene_adscrito, bene_fecharegistro, bene_fechaestatus, bene_fechamodif, clas_codigo_fk, bene_ciudad, bene_rifcedula, bene_correoelectronico, bene_paginaweb, audit_usua, inst_codigo_fk, tipo_codigo_fk', '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(
			'instCodigoFk' => array(self::BELONGS_TO, 'SidcaiInstitucion', 'inst_codigo_fk'),
			'estaCodigoFk' => array(self::BELONGS_TO, 'SidcaiEstado', 'esta_codigo_fk'),
			'muniCodigoFk' => array(self::BELONGS_TO, 'SidcaiMunicipio', 'muni_codigo_fk'),
			'parrCodigoFk' => array(self::BELONGS_TO, 'SidcaiParroquia', 'parr_codigo_fk'),
			'clasCodigoFk' => array(self::BELONGS_TO, 'SidcaiClasificacionbeneficiario', 'clas_codigo_fk'),
			'tipoCodigoFk' => array(self::BELONGS_TO, 'SidcaiTipobeneficiario', 'tipo_codigo_fk'),
			'reprCodigoFk' => array(self::BELONGS_TO, 'SidcaiRepresentantelegal', 'repr_codigo_fk'),
			'estaCodigoestatusFk' => array(self::BELONGS_TO, 'SidcaiEstatus', 'esta_codigoestatus_fk'),
			'sidcaiProyectobeneficiarios' => array(self::HAS_MANY, 'SidcaiProyectobeneficiario', 'bene_codigo_fk'),
			'sidcaiDeclaracionActividads' => array(self::HAS_MANY, 'SidcaiDeclaracionActividad', 'bene_codigo_fk'),
			'sidcaiTransferencias' => array(self::HAS_MANY, 'SidcaiTransferencia', 'bene_codigo_fk'),
			'sidcaiCitabeneficiarios' => array(self::HAS_MANY, 'SidcaiCitabeneficiario', 'bene_codigo_fk'),
			'sidcaiCuentas' => array(self::HAS_MANY, 'SidcaiCuenta', 'bene_codigo_fk'),
			'sidcaiUsuarios' => array(self::MANY_MANY, 'SidcaiUsuario', 'sidcai_usuario_beneficiario(bene_codigo_fk, usua_codigo_fk)'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'bene_codigo_pk' => 'Bene Codigo Pk',
			'bene_razonsocial' => 'Bene Razonsocial',
			'bene_denominacioncomercial' => 'Bene Denominacioncomercial',
			'esta_codigo_fk' => 'Esta Codigo Fk',
			'muni_codigo_fk' => 'Muni Codigo Fk',
			'parr_codigo_fk' => 'Parr Codigo Fk',
			'bene_direccion' => 'Bene Direccion',
			'bene_zonapostal' => 'Bene Zonapostal',
			'bene_telefono1' => 'Bene Telefono1',
			'bene_telefono2' => 'Bene Telefono2',
			'bene_fax' => 'Bene Fax',
			'bene_celular' => 'Bene Celular',
			'bene_descripcion' => 'Bene Descripcion',
			'repr_codigo_fk' => 'Repr Codigo Fk',
			'bene_tipopersona' => 'Bene Tipopersona',
			'esta_codigoestatus_fk' => 'Esta Codigoestatus Fk',
			'bene_adscrito' => 'Bene Adscrito',
			'bene_fecharegistro' => 'Bene Fecharegistro',
			'bene_fechaestatus' => 'Bene Fechaestatus',
			'bene_fechamodif' => 'Bene Fechamodif',
			'clas_codigo_fk' => 'Clas Codigo Fk',
			'bene_ciudad' => 'Bene Ciudad',
			'bene_rifcedula' => 'Bene Rifcedula',
			'bene_correoelectronico' => 'Bene Correoelectronico',
			'bene_paginaweb' => 'Bene Paginaweb',
			'audit_usua' => 'Audit Usua',
			'inst_codigo_fk' => 'Inst Codigo Fk',
			'tipo_codigo_fk' => 'Tipo Codigo Fk',
		);
	}

	/**
	 * 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('bene_codigo_pk',$this->bene_codigo_pk);
		$criteria->compare('bene_razonsocial',$this->bene_razonsocial,true);
		$criteria->compare('bene_denominacioncomercial',$this->bene_denominacioncomercial,true);
		$criteria->compare('esta_codigo_fk',$this->esta_codigo_fk);
		$criteria->compare('muni_codigo_fk',$this->muni_codigo_fk);
		$criteria->compare('parr_codigo_fk',$this->parr_codigo_fk);
		$criteria->compare('bene_direccion',$this->bene_direccion,true);
		$criteria->compare('bene_zonapostal',$this->bene_zonapostal,true);
		$criteria->compare('bene_telefono1',$this->bene_telefono1,true);
		$criteria->compare('bene_telefono2',$this->bene_telefono2,true);
		$criteria->compare('bene_fax',$this->bene_fax,true);
		$criteria->compare('bene_celular',$this->bene_celular,true);
		$criteria->compare('bene_descripcion',$this->bene_descripcion,true);
		$criteria->compare('repr_codigo_fk',$this->repr_codigo_fk);
		$criteria->compare('bene_tipopersona',$this->bene_tipopersona,true);
		$criteria->compare('esta_codigoestatus_fk',$this->esta_codigoestatus_fk);
		$criteria->compare('bene_adscrito',$this->bene_adscrito,true);
		$criteria->compare('bene_fecharegistro',$this->bene_fecharegistro,true);
		$criteria->compare('bene_fechaestatus',$this->bene_fechaestatus,true);
		$criteria->compare('bene_fechamodif',$this->bene_fechamodif,true);
		$criteria->compare('clas_codigo_fk',$this->clas_codigo_fk);
		$criteria->compare('bene_ciudad',$this->bene_ciudad,true);
		$criteria->compare('bene_rifcedula',$this->bene_rifcedula,true);
		$criteria->compare('bene_correoelectronico',$this->bene_correoelectronico,true);
		$criteria->compare('bene_paginaweb',$this->bene_paginaweb,true);
		$criteria->compare('audit_usua',$this->audit_usua);
		$criteria->compare('inst_codigo_fk',$this->inst_codigo_fk);
		$criteria->compare('tipo_codigo_fk',$this->tipo_codigo_fk);

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