diff --git a/www/protected/migrations/m120713_172000_tbl_candidatos_estados.php b/www/protected/migrations/m120713_172000_tbl_candidatos_estados.php new file mode 100644 index 0000000..6a6ca6e --- /dev/null +++ b/www/protected/migrations/m120713_172000_tbl_candidatos_estados.php @@ -0,0 +1,23 @@ +createTable('tbl_candidatos_estados', array( + 'id' => 'pk', + 'descripcion' => 'string NOT NULL', + )); + + $this->addColumn('tbl_candidatos', 'id_estado', 'integer'); + $this->dropColumn('tbl_candidatos', 'estado'); + } + + public function down() + { + $this->dropTable('tbl_candidatos_estados'); + $this->dropColumn('tbl_candidatos', 'id_estado'); + $this->addColumn('tbal_candidatos', 'estado', 'string'); + return false; + } +} \ No newline at end of file diff --git a/www/protected/models/Candidato.php b/www/protected/models/Candidato.php index 52aa846..02cd82f 100644 --- a/www/protected/models/Candidato.php +++ b/www/protected/models/Candidato.php @@ -5,7 +5,7 @@ * * The followings are the available columns in table 'tbl_candidatos': * @property integer $id - * @property string $estado + * @property integer $id_estado * @property string $dni * @property string $nombre * @property string $apellidos @@ -80,6 +80,12 @@ class Candidato extends CActiveRecord return Poblacion::model()->findByPk($this->localidad)->poblacion; } + public function getEstado() { + $_estado = CandidatoEstado::model()->findByPk($this->id_estado); + if ($_estado != null) + return $_estado->descripcion; + } + public function getNombreCompletoLocalidad() { $nombre = ''; $poblacion = Poblacion::model()->with('provincia')->findByPk($this->localidad); @@ -104,7 +110,7 @@ class Candidato extends CActiveRecord } public function getCssClassEstado() { - return "estado" . array_search($this->estado, $this->opcionesEstado); + return "estado" . array_search($this->id_estado, $this->opcionesEstado); } /** @@ -113,13 +119,13 @@ class Candidato extends CActiveRecord */ public function getOpcionesEstado() { return array( - 0 => 'Borrador', - 1 => 'Sin capacidades', - 2 => 'Rechazado', - 3 => 'Si más adelante', - 4 => 'En proceso: disponible', - 5 => 'En proceso: disponible asignado', - 6 => 'Otras provincias', + 0 => '510', + 1 => '511', + 2 => '520', + 3 => '530', + 4 => '540', + 5 => '560', + 6 => '600', ); } @@ -163,7 +169,7 @@ class Candidato extends CActiveRecord array('salario_minimo, salario_maximo', 'numerical', 'allowEmpty'=>'true'), - array('estado, dni, nombre, apellidos, email, telefono_fijo, + array('dni, nombre, apellidos, email, telefono_fijo, telefono_movil, sexo, lugar_nacimiento, localidad, carnet_conducir, procedencia, disponibilidad_incorporacion, disponibilidad_entrevistas, disponibilidad_guardias, @@ -171,15 +177,15 @@ class Candidato extends CActiveRecord disponibilidad_proyectos_internacionales', 'length', 'max'=>255), + array('id_estado', 'numerical', 'integerOnly'=>true), + array('fecha_nacimiento, observaciones', 'safe'), array('fecha_nacimiento', 'date', 'format'=>'dd/MM/yyyy'), - - array('estado', 'unsafe'), - + // The following rule is used by search(). // Please remove those attributes that should not be searched. - array('id, estado, dni, nombre, apellidos, email, telefono_fijo, + array('id, id_estado, dni, nombre, apellidos, email, telefono_fijo, telefono_movil, sexo, fecha_nacimiento, lugar_nacimiento, localidad, fecha_alta, usuario_alta, fecha_modificacion, usuario_modificacion, carnet_conducir, vehiculo_propio, @@ -217,7 +223,7 @@ class Candidato extends CActiveRecord { return array( 'id' => 'ID', - 'estado' => 'Estado', + 'id_estado' => 'Estado', 'nombreApellidos' => 'Candidato', 'foto' => 'Foto', 'dni' => 'DNI/Pasaporte', @@ -263,7 +269,7 @@ class Candidato extends CActiveRecord $criteria->together = true; $criteria->compare('t.id',$this->id); - $criteria->compare('estado',$this->estado,true); + $criteria->compare('id_estado',$this->id_estado); $criteria->compare('dni',$this->dni,true); $criteria->compare('nombre',$this->nombre,true); $criteria->compare('apellidos',$this->apellidos,true); @@ -271,7 +277,7 @@ class Candidato extends CActiveRecord $criteria->compare('telefono_fijo',$this->telefono_fijo,true); $criteria->compare('telefono_movil',$this->telefono_movil,true); - $criteria->addSearchCondition('concat(nombre, " ", apellidos)', $this->nombreCompleto); + $criteria->addSearchCondition('concat(nombre, " ", apellidos)', $this->nombreCompleto); $criteria->compare( 'capacidades.perfil_tecnico_id', $this->capacidad_tecnica_search, true ); //$criteria->compare( 'capacidades.capacidadesFuncionales.perfil_funcional_id', $this->capacidad_funcional_search, true ); @@ -287,7 +293,7 @@ class Candidato extends CActiveRecord protected function beforeValidate() { if ($this->isNewRecord) { - $this->estado = 'Pendiente de clasificar'; + $this->id_estado = 510; $this->fecha_alta = date('Y-m-d H:i:s', time()); $this->fecha_modificacion = $this->fecha_alta; $this->usuario_alta = Yii::app()->user->id; diff --git a/www/protected/models/CandidatoEstado.php b/www/protected/models/CandidatoEstado.php new file mode 100644 index 0000000..cb17569 --- /dev/null +++ b/www/protected/models/CandidatoEstado.php @@ -0,0 +1,86 @@ +255), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, descripcion', '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( + 'id' => 'ID', + 'descripcion' => 'Descripcion', + ); + } + + /** + * 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('id',$this->id); + $criteria->compare('descripcion',$this->descripcion,true); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +} \ No newline at end of file diff --git a/www/protected/views/candidato/_form.php b/www/protected/views/candidato/_form.php index b595ff3..a241a89 100644 --- a/www/protected/views/candidato/_form.php +++ b/www/protected/views/candidato/_form.php @@ -252,6 +252,30 @@ Yii::app()->clientScript->registerScript('wysiwyg', $script, CClientScript::POS_