git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_IntranetNueva/trunk@13 77cfc57b-8ef4-1849-9df6-4a38aa5da120
176 lines
5.8 KiB
PHP
176 lines
5.8 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 $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
|
|
*
|
|
* The followings are the available model relations:
|
|
* @property CapacidadProfesional[] $capacidades
|
|
* @property CandidatoIdioma[] $idiomas
|
|
*/
|
|
class Candidato extends CActiveRecord
|
|
{
|
|
const GENERO_HOMBRE=0;
|
|
const GENERO_MUJER=1;
|
|
|
|
public $foto;
|
|
|
|
/**
|
|
* 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'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 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('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('dni, nombre, apellidos, email, telefono_fijo, telefono_movil, sexo, lugar_nacimiento, localidad', 'length', 'max'=>255),
|
|
array('fecha_nacimiento', 'safe'),
|
|
// The following rule is used by search().
|
|
// Please remove those attributes that should not be searched.
|
|
array('id, dni, nombre, apellidos, email, telefono_fijo, telefono_movil, sexo, fecha_nacimiento, lugar_nacimiento, localidad', '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, 'CapacidadProfesional', 'candidato_id'),
|
|
'idiomas' => array(self::HAS_MANY, 'CandidatoIdioma', 'candidato_id'),
|
|
'idiomasCount' => array(self::STAT, 'CandidatoIdioma', 'candidato_id'),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return array customized attribute labels (name=>label)
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return array(
|
|
'id' => 'ID',
|
|
'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',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 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('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->compare('sexo',$this->sexo,true);
|
|
$criteria->compare('fecha_nacimiento',$this->fecha_nacimiento,true);
|
|
$criteria->compare('lugar_nacimiento',$this->lugar_nacimiento,true);
|
|
|
|
return new CActiveDataProvider($this, array(
|
|
'criteria'=>$criteria,
|
|
));
|
|
}
|
|
|
|
protected function beforeValidate() {
|
|
if ($this->isNewRecord) {
|
|
$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();
|
|
}
|
|
} |