/protected/modules/carrera/models/IngresoCurso.php
PHP | 151 lines | 88 code | 18 blank | 45 comment | 2 complexity | 6851b88cbf6c2d498b7d1d1fdba75c47 MD5 | raw file
Possible License(s): BSD-3-Clause
- <?php
- /**
- * This is the model class for table "tbl_ingresocurso".
- *
- * The followings are the available columns in table 'tbl_ingresocurso':
- * @property string $ingresocurso_id
- * @property string $ingresocurso_periodoingreso_id
- * @property integer $ingresocurso_programaacademico_id
- * @property string $ingresocurso_inicio
- * @property string $ingresocurso_fin
- * @property string $ingresocurso_descripcion
- * @property integer $ingresocurso_porcentajeaprobacion
- * @property string $ingresocurso_creado
- * @property string $ingresocurso_creado_usuario_id
- * @property string $ingresocurso_modificado
- * @property string $ingresocurso_modificado_usuario_id
- * @property integer $ingresocurso_estado_id
- */
- class IngresoCurso extends CActiveRecord
- {
- public $ingresocurso_cantidadcurso;
- /**
- * Returns the static model of the specified AR class.
- * @return IngresoCurso 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_ingresocurso';
- }
- /**
- * @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('ingresocurso_inicio, ingresocurso_fin, ingresocurso_descripcion, ingresocurso_porcentajeaprobacion, ingresocurso_estado_id', 'required'),
- array('ingresocurso_periodoingreso_id, ingresocurso_programaacademico_id, ingresocurso_inicio, ingresocurso_fin, ingresocurso_descripcion, ingresocurso_porcentajeaprobacion, ingresocurso_estado_id', 'required','on'=>'Guardar'),
-
- array('ingresocurso_programaacademico_id, ingresocurso_porcentajeaprobacion, ingresocurso_estado_id', 'numerical', 'integerOnly'=>true),
- array('ingresocurso_periodoingreso_id, ingresocurso_creado_usuario_id, ingresocurso_modificado_usuario_id', 'length', 'max'=>20),
- array('ingresocurso_descripcion', 'length', 'max'=>255),
- // The following rule is used by search().
- // Please remove those attributes that should not be searched.
- array('ingresocurso_id, ingresocurso_periodoingreso_id, ingresocurso_programaacademico_id, ingresocurso_inicio, ingresocurso_fin, ingresocurso_descripcion, ingresocurso_porcentajeaprobacion, ingresocurso_creado, ingresocurso_creado_usuario_id, ingresocurso_modificado, ingresocurso_modificado_usuario_id, ingresocurso_estado_id,ingresocurso_cantidadcurso', '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(
- 'programaAcademico' => array(self::BELONGS_TO, 'ProgramaAcademico', 'ingresocurso_programaacademico_id'),
- 'periodoIngreso' => array(self::BELONGS_TO, 'PeriodoIngreso', 'ingresocurso_periodoingreso_id'),
- 'usuarioCreador' => array(self::BELONGS_TO, 'Usuario', 'ingresocurso_creado_usuario_id'),
- 'usuarioModificador' => array(self::BELONGS_TO, 'Usuario', 'ingresocurso_modificado_usuario_id'),
- );
- }
- /**
- * @return array customized attribute labels (name=>label)
- */
- public function attributeLabels()
- {
- return array(
- 'ingresocurso_id' => t('ID','nucleo_etiqueta'),
- 'ingresocurso_periodoingreso_id' => t('Periodo Ingreso','nucleo_etiqueta'),
- 'ingresocurso_programaacademico_id' => t('Programa Academico','carrera_etiqueta'),
- 'ingresocurso_inicio' => t('Inicio','carrera_etiqueta'),
- 'ingresocurso_fin' => t('Fin','carrera_etiqueta'),
- 'ingresocurso_descripcion' => t('Descripcion','carrera_etiqueta'),
- 'ingresocurso_porcentajeaprobacion' => t('Procentaje de Aprobacion','carrera_etiqueta'),
- 'ingresocurso_creado' => 'Ingresocurso Creado',
- 'ingresocurso_creado_usuario_id' => 'Ingresocurso Creado Usuario',
- 'ingresocurso_modificado' => 'Ingresocurso Modificado',
- 'ingresocurso_modificado_usuario_id' => 'Ingresocurso Modificado Usuario',
- 'ingresocurso_estado_id' => 'Ingresocurso Estado',
-
- 'ingresocurso_cantidadcurso' => t('Cant. Cursos','carrera_etiqueta'),
-
- );
- }
- /**
- * 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('ingresocurso_id',$this->ingresocurso_id,true);
- $criteria->compare('ingresocurso_periodoingreso_id',$this->ingresocurso_periodoingreso_id,true);
- $criteria->compare('ingresocurso_programaacademico_id',$this->ingresocurso_programaacademico_id);
- $criteria->compare('ingresocurso_inicio',$this->ingresocurso_inicio,true);
- $criteria->compare('ingresocurso_fin',$this->ingresocurso_fin,true);
- $criteria->compare('ingresocurso_descripcion',$this->ingresocurso_descripcion,true);
- $criteria->compare('ingresocurso_porcentajeaprobacion',$this->ingresocurso_porcentajeaprobacion);
- $criteria->compare('ingresocurso_creado',$this->ingresocurso_creado,true);
- $criteria->compare('ingresocurso_creado_usuario_id',$this->ingresocurso_creado_usuario_id,true);
- $criteria->compare('ingresocurso_modificado',$this->ingresocurso_modificado,true);
- $criteria->compare('ingresocurso_modificado_usuario_id',$this->ingresocurso_modificado_usuario_id,true);
- $criteria->compare('ingresocurso_estado_id',$this->ingresocurso_estado_id);
-
- if(intval($this->ingresocurso_cantidadcurso) != 0)
- {
- $criteria->having = 'COUNT(ingresocurso_id) = ' .$this->ingresocurso_cantidadcurso;
- }
-
-
- $criteria->group = 'ingresocurso_periodoingreso_id,ingresocurso_programaacademico_id';
- $criteria->select = 'ingresocurso_periodoingreso_id,ingresocurso_programaacademico_id,COUNT(ingresocurso_id) as ingresocurso_cantidadcurso';
- return new CActiveDataProvider($this, array(
- 'criteria'=>$criteria,
- ));
- }
-
- protected function beforeSave()
- {
- $this->ingresocurso_inicio = date('Y-m-d', strtotime(str_replace('/','-',$this->ingresocurso_inicio)));
- $this->ingresocurso_fin = date('Y-m-d', strtotime(str_replace('/','-',$this->ingresocurso_fin)));
- return TRUE;
- }
-
- protected function afterFind()
- {
- $this->ingresocurso_inicio = date('d/m/Y', strtotime($this->ingresocurso_inicio));
- $this->ingresocurso_fin = date('d/m/Y', strtotime($this->ingresocurso_fin));
- return TRUE;
- }
-
-
- }