/protected/modules/carrera/models/ActividadIngreso.php
PHP | 146 lines | 90 code | 16 blank | 40 comment | 8 complexity | 63c53f65ebb83ab940c4d669607a96fc MD5 | raw file
Possible License(s): BSD-3-Clause
- <?php
- /**
- * This is the model class for table "tbl_actividadingreso".
- *
- * The followings are the available columns in table 'tbl_actividadingreso':
- * @property integer $actividadingreso_id
- * @property string $actividadingreso_nombre
- * @property string $actividadingreso_creado
- * @property string $actividadingreso_creado_usuario_id
- * @property string $actividadingreso_modificado
- * @property string $actividadingreso_modificado_usuario_id
- * @property integer $actividadingreso_estado_id
- */
- class ActividadIngreso extends CActiveRecord
- {
- /**
- * Returns the static model of the specified AR class.
- * @return ActividadIngreso the static model class
- */
- public static function model($className=__CLASS__)
- {
- return parent::model($className);
- }
- /**
- * @return string the associated database table name
- */
- public function tableName()
- {
- return 'tbl_actividadingreso';
- }
- /**
- * @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('actividadingreso_nombre, actividadingreso_estado_id', 'required'),
- array('actividadingreso_estado_id', 'numerical', 'integerOnly'=>true),
- array('actividadingreso_nombre', 'length', 'max'=>100),
- array('actividadingreso_creado_usuario_id, actividadingreso_modificado_usuario_id', 'length', 'max'=>20),
- array('actividadingreso_nombre', 'unique'),
- // The following rule is used by search().
- // Please remove those attributes that should not be searched.
- array('actividadingreso_id, actividadingreso_nombre, actividadingreso_creado, actividadingreso_creado_usuario_id, actividadingreso_modificado, actividadingreso_modificado_usuario_id, actividadingreso_estado_id', '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(
- 'actividadingreso_id' => t('ID','nucleo_etiqueta'),
- 'actividadingreso_nombre' => t('Nombre','nucleo_etiqueta'),
- 'actividadingreso_creado' => 'Actividadingreso Creado',
- 'actividadingreso_creado_usuario_id' => 'Actividadingreso Creado Usuario',
- 'actividadingreso_modificado' => 'Actividadingreso Modificado',
- 'actividadingreso_modificado_usuario_id' => 'Actividadingreso Modificado Usuario',
- 'actividadingreso_estado_id' => 'Actividadingreso Estado',
- );
- }
- /**
- * Retrieves a list of models based on the current search/filter conditions.
- * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
- */
- public function search()
- {
- // Warning: Please modify the following code to remove attributes that
- // should not be searched.
- $criteria=new CDbCriteria;
- $criteria->compare('actividadingreso_id',$this->actividadingreso_id);
- $criteria->compare('actividadingreso_nombre',trim($this->actividadingreso_nombre),true);
- $criteria->compare('actividadingreso_creado',$this->actividadingreso_creado,true);
- $criteria->compare('actividadingreso_creado_usuario_id',$this->actividadingreso_creado_usuario_id,true);
- $criteria->compare('actividadingreso_modificado',$this->actividadingreso_modificado,true);
- $criteria->compare('actividadingreso_modificado_usuario_id',$this->actividadingreso_modificado_usuario_id,true);
-
-
- if(!user()->isSuperuser)
- {
- $criteria->addCondition('actividadingreso_estado_id <> ' .AplicacionVariables::ESTADO_ELIMINADO_ID);
- }
- return new CActiveDataProvider($this, array(
- 'criteria'=>$criteria,
- ));
- }
-
- protected function afterFind()
- {
- $this->actividadingreso_creado = ($this->actividadingreso_creado != '0000-00-00 00:00:00' && !is_null($this->actividadingreso_creado))?date('d/m/Y H:i:s', strtotime(str_replace('-','/',$this->actividadingreso_creado))):'';
- $this->actividadingreso_modificado = ($this->actividadingreso_modificado != '0000-00-00 00:00:00' && !is_null($this->actividadingreso_modificado))?date('d/m/Y H:i:s', strtotime(str_replace('-','/',$this->actividadingreso_modificado))):'';
- return TRUE;
- }
-
- protected function beforeSave()
- {
- if(!$this->isNewRecord)
- {
- if($this->actividadingreso_creado == '')
- {
- $this->actividadingreso_creado = new CDbExpression('NOW()');
- }
- else
- {
- $this->actividadingreso_creado = date('Y-m-d H:i:s', strtotime(str_replace('/','-',$this->actividadingreso_creado)));
- }
- $this->actividadingreso_creado_usuario_id = user()->getId();
- }
- else
- {
- $this->actividadingreso_modificado = new CDbExpression('NOW()');
- $this->actividadingreso_modificado_usuario_id = user()->getId();
- }
- return TRUE;
- }
-
- public function getActividadesIngresosIdNombreActivo()
- {
- $criteria = new CDbCriteria();
- $criteria->select = "actividadingreso_id, actividadingreso_nombre";
- return $this->findAll($criteria);
-
- }
-
- }