Se añade campo estado con su tabla auxiliar

git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_IntranetNueva/trunk@69 77cfc57b-8ef4-1849-9df6-4a38aa5da120
This commit is contained in:
roberto 2012-07-13 17:06:09 +00:00
parent 7391a027dc
commit 4b75305de7
4 changed files with 157 additions and 18 deletions

View File

@ -0,0 +1,23 @@
<?php
class m120713_172000_tbl_candidatos_estados extends CDbMigration
{
public function up()
{
$this->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;
}
}

View File

@ -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;

View File

@ -0,0 +1,86 @@
<?php
/**
* This is the model class for table "tbl_candidatos_estados".
*
* The followings are the available columns in table 'tbl_candidatos_estados':
* @property integer $id
* @property string $descripcion
*/
class CandidatoEstado extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return CandidatoEstado 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_candidatos_estados';
}
/**
* @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('descripcion', 'required'),
array('descripcion', 'length', 'max'=>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,
));
}
}

View File

@ -252,6 +252,30 @@ Yii::app()->clientScript->registerScript('wysiwyg', $script, CClientScript::POS_
</span>
</h3>
<div class="content nopadding">
<div class="padding1020">
<?php echo $form->labelEx($model,'estado'); ?>
<div class="marginleft150">
<?php
$lista = CHtml::listData(CandidatoEstado::model()->findAll(),'id', 'descripcion');
echo $form->dropDownList(
$model,
'id_estado',
$lista,
array(
'class'=>'mf',
));
?>
<?php echo $form->error($model,'id_estado', array('class'=>'errortext')); ?>
</div>
</div>
<div class="padding1020">
<?php echo $form->labelEx($model,'disponibilidad_incorporacion'); ?>
<div class="marginleft150">