git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_IntranetNueva/trunk@41 77cfc57b-8ef4-1849-9df6-4a38aa5da120
300 lines
12 KiB
PHP
300 lines
12 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This is the model class for table "tbl_candidatos".
|
|
*
|
|
* The followings are the available columns in table 'tbl_candidatos':
|
|
* @property integer $id
|
|
* @property string $estado
|
|
* @property string $dni
|
|
* @property string $nombre
|
|
* @property string $apellidos
|
|
* @property string $email
|
|
* @property string $telefono_fijo
|
|
* @property string $telefono_movil
|
|
* @property string $sexo
|
|
* @property string $fecha_nacimiento
|
|
* @property string $lugar_nacimiento
|
|
* @property datetime $fecha_alta
|
|
* @property datetime $fecha_modificacion
|
|
* @property integer $usuario_alta
|
|
* @property integer $usuario_modificacion
|
|
* @property string $carnet_conducir
|
|
* @property string $vehiculo_propio
|
|
* @property text $observaciones
|
|
* @property integer $salario_minimo
|
|
* @property integer $salario_maximo
|
|
* @property string $procedencia
|
|
* @property string $disponibilidad_incorporacion
|
|
* @property string $disponibilidad_entrevistas
|
|
* @property string $disponibilidad_guardias
|
|
* @property string $disponibilidad_viajar
|
|
* @property string $disponibilidad_proyectos_internacionales
|
|
*
|
|
* The followings are the available model relations:
|
|
* @property CandidatoCapacidad[] $capacidades
|
|
* @property CandidatoIdioma[] $idiomas
|
|
* @property CandidatoTitulacion[] $titulaciones
|
|
*/
|
|
class Candidato extends CActiveRecord
|
|
{
|
|
const GENERO_HOMBRE='Hombre';
|
|
const GENERO_MUJER='Mujer';
|
|
|
|
private $_nombreCompleto;
|
|
public $foto;
|
|
|
|
public $capacidad_tecnica_search;
|
|
public $capacidad_funcional_search;
|
|
|
|
/**
|
|
* Devuelve el nombre completo de un candidato.
|
|
* @return string $nombreCompleto
|
|
*/
|
|
public function getNombreCompleto()
|
|
{
|
|
if(isset($this->_nombreCompleto)) {
|
|
return $this->_nombreCompleto;
|
|
}
|
|
|
|
$this->_nombreCompleto = $this->nombre . ' ' . $this->apellidos;
|
|
return $this->_nombreCompleto;
|
|
}
|
|
|
|
public function setNombreCompleto($value)
|
|
{
|
|
$this->_nombreCompleto = $value;
|
|
}
|
|
|
|
public function getRangoSalarial() {
|
|
return Yii::app()->numberFormatter->formatCurrency($this->salario_minimo,'EUR') . ' - ' .
|
|
Yii::app()->numberFormatter->formatCurrency($this->salario_maximo,'EUR');
|
|
}
|
|
|
|
public function getTieneVehiculoPropio() {
|
|
return Yii::app()->format->boolean($this->vehiculo_propio);
|
|
}
|
|
|
|
public function getNombreLocalidad() {
|
|
return Poblacion::model()->findByPk($this->localidad)->poblacion;
|
|
}
|
|
|
|
public function getNombreCompletoLocalidad() {
|
|
$nombre = '';
|
|
$poblacion = Poblacion::model()->with('provincia')->findByPk($this->localidad);
|
|
if (isset($poblacion)) {
|
|
$nombre = $poblacion->poblacion;
|
|
if (isset($poblacion->provincia)) {
|
|
$nombre .= ' (' . $poblacion->provincia->provincia . ')';
|
|
}
|
|
}
|
|
return $nombre;
|
|
}
|
|
|
|
/**
|
|
* Devuelve la lista de géneros de un candidato.
|
|
* @return array lista de géneros permitidos
|
|
*/
|
|
public function getOpcionesGenero() {
|
|
return array(
|
|
self::GENERO_HOMBRE => 'Hombre',
|
|
self::GENERO_MUJER => 'Mujer'
|
|
);
|
|
}
|
|
|
|
public function getCssClassEstado() {
|
|
return "estado" . array_search($this->estado, $this->opcionesEstado);
|
|
}
|
|
|
|
/**
|
|
* Devuelve la lista de estados permitidos para un candidato.
|
|
* @return array lista de estados permitidos
|
|
*/
|
|
public function getOpcionesEstado() {
|
|
return array(
|
|
0 => 'Pendiente de clasificar',
|
|
1 => 'Rechazado por antecedentes',
|
|
2 => 'Rechazado por no cumplir requisitos mínimos',
|
|
3 => 'Rechazado por perfil no demandado',
|
|
4 => 'Disponible',
|
|
5 => 'Disponible asignado exclusivo',
|
|
6 => 'No disponible',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Returns the static model of the specified AR class.
|
|
* @param string $className active record class name.
|
|
* @return Candidato 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';
|
|
}
|
|
|
|
/**
|
|
* @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('nombre, apellidos', 'required'),
|
|
array('email', 'unique'),
|
|
array('email', 'email'),
|
|
array('foto', 'file',
|
|
'types'=>'jpg',
|
|
'maxSize'=>1024 * 1024 * 1, // 1MB como máximo
|
|
'tooLarge'=>'The file was larger than 1MB. Please upload a smaller file.',
|
|
'wrongType'=>'Please upload only images in the format JPG.',
|
|
'tooMany'=>'You can upload only 1 user photo.',
|
|
'allowEmpty'=>'true',
|
|
),
|
|
array('salario_minimo, salario_maximo', 'numerical',
|
|
'allowEmpty'=>'true'),
|
|
|
|
array('estado, dni, nombre, apellidos, email, telefono_fijo,
|
|
telefono_movil, sexo, lugar_nacimiento, localidad,
|
|
carnet_conducir, procedencia, disponibilidad_incorporacion,
|
|
disponibilidad_entrevistas, disponibilidad_guardias,
|
|
disponibilidad_viajar,
|
|
disponibilidad_proyectos_internacionales',
|
|
'length', 'max'=>255),
|
|
|
|
array('fecha_nacimiento, observaciones', 'safe'),
|
|
|
|
//array('fecha_nacimiento', 'date', 'allowEmpty'=>'true'),
|
|
|
|
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,
|
|
telefono_movil, sexo, fecha_nacimiento, lugar_nacimiento,
|
|
localidad, fecha_alta, usuario_alta, fecha_modificacion,
|
|
usuario_modificacion, carnet_conducir, vehiculo_propio,
|
|
observaciones, salario_minimo, salario_maximo, procedencia,
|
|
disponibilidad_incorporacion, disponibilidad_entrevistas,
|
|
disponibilidad_guardias, disponibilidad_viajar,
|
|
disponibilidad_proyectos_internacionales',
|
|
'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(
|
|
'capacidades' => array(self::HAS_MANY, 'CandidatoCapacidad', 'candidato_id'),
|
|
'capacidadesCount' => array(self::STAT, 'CandidatoCapacidad', 'candidato_id'),
|
|
'idiomas' => array(self::HAS_MANY, 'CandidatoIdioma', 'candidato_id'),
|
|
'idiomasCount' => array(self::STAT, 'CandidatoIdioma', 'candidato_id'),
|
|
'titulaciones' => array(self::HAS_MANY, 'CandidatoTitulacion', 'candidato_id'),
|
|
'titulacionesCount' => array(self::STAT, 'CandidatoTitulacion', 'candidato_id'),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return array customized attribute labels (name=>label)
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return array(
|
|
'id' => 'ID',
|
|
'estado' => 'Estado',
|
|
'nombreApellidos' => 'Candidato',
|
|
'foto' => 'Foto',
|
|
'dni' => 'DNI/Pasaporte',
|
|
'nombre' => 'Nombre',
|
|
'apellidos' => 'Apellidos',
|
|
'email' => 'Email',
|
|
'telefono_fijo' => 'Telefono fijo',
|
|
'telefono_movil' => 'Telefono móvil',
|
|
'sexo' => 'Sexo',
|
|
'fecha_nacimiento' => 'Fecha de nacimiento',
|
|
'lugar_nacimiento' => 'Lugar de nacimiento',
|
|
'localidad' => 'Localidad',
|
|
'fecha_modificacion' => 'Último cambio',
|
|
|
|
'carnet_conducir' => 'Carnet de conducir',
|
|
'vehiculo_propio' => 'Vehículo propio',
|
|
'observaciones' => 'Observaciones',
|
|
'salario_minimo' => 'Salario mínimo',
|
|
'salario_maximo' => 'Salario máximo',
|
|
'procedencia' => 'Procedencia',
|
|
'disponibilidad_incorporacion' => 'Disponibilidad de incorportación',
|
|
'disponibilidad_entrevistas' => 'Disponibilidad para entrevistas',
|
|
'disponibilidad_guardias' => 'Disponibilidad para guardias',
|
|
'disponibilidad_viajar' => 'Disponibilidad para viajar',
|
|
'disponibilidad_proyectos_internacionales' => 'Disponibilidad para proyectos internacionales',
|
|
|
|
'nombreCompleto' => 'Candidato',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 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->with = array('capacidades');//, 'capacidades.capacidadesFuncionales');
|
|
$criteria->together = true;
|
|
|
|
$criteria->compare('t.id',$this->id);
|
|
$criteria->compare('estado',$this->estado,true);
|
|
$criteria->compare('dni',$this->dni,true);
|
|
$criteria->compare('nombre',$this->nombre,true);
|
|
$criteria->compare('apellidos',$this->apellidos,true);
|
|
$criteria->compare('email',$this->email,true);
|
|
$criteria->compare('telefono_fijo',$this->telefono_fijo,true);
|
|
$criteria->compare('telefono_movil',$this->telefono_movil,true);
|
|
|
|
$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 );
|
|
$sort = new CSort;
|
|
$sort->defaultOrder = 'nombre, apellidos ASC';
|
|
|
|
return new CActiveDataProvider($this, array(
|
|
'criteria' => $criteria,
|
|
'sort' => $sort,
|
|
));
|
|
|
|
}
|
|
|
|
protected function beforeValidate() {
|
|
if ($this->isNewRecord) {
|
|
$this->estado = 'Pendiente de clasificar';
|
|
$this->fecha_alta = date('Y-m-d H:i:s', time());
|
|
$this->fecha_modificacion = $this->fecha_alta;
|
|
$this->usuario_alta = Yii::app()->user->id;
|
|
$this->usuario_modificacion = Yii::app()->user->id;
|
|
}
|
|
else {
|
|
$this->fecha_modificacion = date('Y-m-d H:i:s', time());
|
|
$this->usuario_modificacion = Yii::app()->user->id;
|
|
}
|
|
|
|
return parent::beforeValidate();
|
|
}
|
|
} |