<?php

/**
 * This is the model class for table "v_p_credito_tienda".
 *
 * The followings are the available columns in table 'v_p_credito_tienda':
 * @property double $credito
 * @property integer $idcredito
 * @property string $fecha_aprobacion
 * @property integer $tipo_credito
 * @property integer $idtrabajador
 * @property integer $cedula
 * @property string $nombre
 * @property string $apellidos
 * @property integer $idunidad
 * @property integer $clvcuenta_cont
 */
class VMigraCreditoTienda extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'v_p_credito_tienda';
	}

	/**
	 * @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('idcredito, tipo_credito, idtrabajador, cedula, idunidad, clvcuenta_cont', 'numerical', 'integerOnly'=>true),
			array('credito', 'numerical'),
			array('nombre, apellidos', 'length', 'max'=>100),
			array('fecha_aprobacion.descripcion', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('credito, idcredito, fecha_aprobacion, tipo_credito, idtrabajador, cedula, nombre, apellidos, idunidad, clvcuenta_cont', '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(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'credito' => 'Credito',
			'idcredito' => 'Idcredito',
			'fecha_aprobacion' => 'Fecha Aprobacion',
			'tipo_credito' => 'Tipo Credito',
			'idtrabajador' => 'Idtrabajador',
			'cedula' => 'Cedula',
			'nombre' => 'Nombre',
			'apellidos' => 'Apellidos',
			'idunidad' => 'Idunidad',
			'clvcuenta_cont' => 'Clvcuenta Cont',
		);
	}

	/**
	 * 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('credito',$this->credito);
		$criteria->compare('idcredito',$this->idcredito);
		$criteria->compare('fecha_aprobacion',$this->fecha_aprobacion,true);
		$criteria->compare('tipo_credito',$this->tipo_credito);
		$criteria->compare('idtrabajador',$this->idtrabajador);
		$criteria->compare('cedula',$this->cedula);
		$criteria->compare('nombre',$this->nombre,true);
		$criteria->compare('apellidos',$this->apellidos,true);
		$criteria->compare('idunidad',$this->idunidad);
		$criteria->compare('clvcuenta_cont',$this->clvcuenta_cont);

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