- Grid de candidatos
- Crear un candidato - Eliminar un candidato git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@69 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
This commit is contained in:
parent
bdf9c1c41b
commit
723c1aa190
BIN
www/images/candidate_photo.jpg
Normal file
BIN
www/images/candidate_photo.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -35,6 +35,8 @@ $configSpecific = array(
|
||||
'password' => '',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
'emulatePrepare' => true,
|
||||
'enableProfiling' => true,
|
||||
'enableParamLogging' => true,
|
||||
),
|
||||
'mail' => array(
|
||||
|
||||
@ -55,8 +55,7 @@ class CandidatoController extends Controller {
|
||||
// $this->performAjaxValidation($model);
|
||||
|
||||
if (isset($_POST['Candidato'])) {
|
||||
$candidato->attributes = $_POST['Candidato'];
|
||||
if ($candidato->save())
|
||||
if ($this->saveModel($candidato))
|
||||
$this->redirect(array('index'));
|
||||
}
|
||||
|
||||
@ -76,128 +75,8 @@ class CandidatoController extends Controller {
|
||||
// $this->performAjaxValidation($candidato);
|
||||
|
||||
if (isset($_POST['Candidato'])) {
|
||||
Yii::trace(CVarDumper::dumpAsString($_POST));
|
||||
|
||||
// Candidato
|
||||
$candidato->attributes = $_POST['Candidato'];
|
||||
$ficheroFotografia = CUploadedFile::getInstance($candidato, 'ficheroFotografia');
|
||||
$quitarFotografia = Yii::app()->request->getParam('quitar_fotografia', '0');
|
||||
|
||||
// Titulaciones del candidato
|
||||
$listaTitulacionesBorrar = $candidato->titulaciones;
|
||||
if (isset($_POST['CandidatoTitulacion'])) {
|
||||
$listaTitulaciones = array();
|
||||
foreach ($_POST['CandidatoTitulacion'] as $titulacion) {
|
||||
$candidatoTitulacion = new CandidatoTitulacion();
|
||||
$candidatoTitulacion->titulacion = $titulacion;
|
||||
$candidatoTitulacion->candidato_id = $candidato->id;
|
||||
$listaTitulaciones[] = $candidatoTitulacion;
|
||||
}
|
||||
$candidato->titulaciones = $listaTitulaciones;
|
||||
}
|
||||
|
||||
// Idiomas del candidato
|
||||
$listaIdiomasBorrar = array();
|
||||
if (isset($_POST['CandidatoIdioma'])) {
|
||||
$listaIdiomas = array();
|
||||
foreach ($_POST['CandidatoIdioma'] as $key => $idioma) {
|
||||
if ($idioma['id'])
|
||||
$candidatoIdioma = CandidatoIdioma::model()->findByPk($idioma['id']);
|
||||
else
|
||||
$candidatoIdioma = new CandidatoIdioma();
|
||||
$candidatoIdioma->attributes = $idioma;
|
||||
$candidatoIdioma->candidato_id = $candidato->id;
|
||||
|
||||
if ($idioma['_borrar'])
|
||||
$listaIdiomasBorrar[] = $candidatoIdioma;
|
||||
else
|
||||
$listaIdiomas[] = $candidatoIdioma;
|
||||
}
|
||||
$candidato->idiomas = $listaIdiomas;
|
||||
}
|
||||
|
||||
// Guardar los datos
|
||||
$errores = array();
|
||||
$transaccion = Yii::app()->db->beginTransaction();
|
||||
try {
|
||||
Yii::trace('Guardando el candidato', 'application.controllers.CandidatoController');
|
||||
if (!$candidato->save()) {
|
||||
$errores = array_merge($errores, $candidato->getErrors());
|
||||
throw new CException('Error al guardar el candidato');
|
||||
}
|
||||
|
||||
if (($quitarFotografia == '1') && ($candidato->fotografia->tieneFotografia())) {
|
||||
Yii::trace('Eliminando la fotografía del candidato', 'application.controllers.CandidatoController');
|
||||
$candidato->fotografia->eliminarFotografia();
|
||||
}
|
||||
|
||||
if ($ficheroFotografia) {
|
||||
Yii::trace('Guardando la fotografía del candidato', 'application.controllers.CandidatoController');
|
||||
$candidato->fotografia->guardarFotografia($ficheroFotografia);
|
||||
}
|
||||
|
||||
// Titulaciones
|
||||
if (!empty($listaTitulacionesBorrar)) {
|
||||
Yii::trace('Eliminando titulaciones marcadas para borrar', 'application.controllers.CandidatoController');
|
||||
foreach ($listaTitulacionesBorrar as $candidatoTitulacion) {
|
||||
if (!$candidatoTitulacion->delete()) {
|
||||
$errores = array_merge($errores, $candidatoTitulacion->getErrors());
|
||||
throw new CException('Error al eliminar una titulación del candidato');
|
||||
}
|
||||
}
|
||||
$listaTitulacionesBorrar = NULL;
|
||||
}
|
||||
if (!empty($candidato->titulaciones)) {
|
||||
Yii::trace('Guardando la lista de titulaciones', 'application.controllers.CandidatoController');
|
||||
foreach ($candidato->titulaciones as $candidatoTitulacion) {
|
||||
if (!$candidatoTitulacion->save()) {
|
||||
$errores = array_merge($errores, $candidatoTitulacion->getErrors());
|
||||
throw new CException('Error al guardar una titulación del candidato');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Idiomas
|
||||
if (!empty($listaIdiomasBorrar)) {
|
||||
Yii::trace('Eliminando idiomas marcados para borrar', 'application.controllers.CandidatoController');
|
||||
foreach ($listaIdiomasBorrar as $candidatoIdioma) {
|
||||
Yii::trace('Eliminando idioma... ', 'application.controllers.CandidatoController');
|
||||
Yii::trace(CVarDumper::dumpAsString($candidatoIdioma->attributes), 'application.controllers.CandidatoController');
|
||||
if (!$candidatoIdioma->delete()) {
|
||||
$errores = array_merge($errores, $candidatoIdioma->getErrors());
|
||||
throw new CException('Error al eliminar un idioma del candidato');
|
||||
}
|
||||
}
|
||||
$listaIdiomasBorrar = NULL;
|
||||
}
|
||||
if (!empty($candidato->idiomas)) {
|
||||
Yii::trace('Guardando la lista de idiomas', 'application.controllers.CandidatoController');
|
||||
foreach ($candidato->idiomas as $candidatoIdioma) {
|
||||
if (!$candidatoIdioma->save()) {
|
||||
$errores = array_merge($errores, $candidatoIdioma->getErrors());
|
||||
throw new CException('Error al guardar un idioma del candidato');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$transaccion->commit();
|
||||
|
||||
Yii::trace('Candidato guardado', 'application.controllers.CandidatoController');
|
||||
Yii::app()->user->setFlash('success', Yii::t('profind', 'Se ha actualizado el candidato'));
|
||||
if ($this->saveModel($candidato))
|
||||
$this->redirect(array('index'));
|
||||
} catch (Exception $e) {
|
||||
Yii::trace($e->getMessage(), 'application.controllers.CandidatoController');
|
||||
|
||||
$transaccion->rollBack();
|
||||
Yii::app()->user->setFlash('error', Yii::t('profind', 'Se ha producido un error al actualizar el candidato'));
|
||||
|
||||
if (YII_DEBUG) {
|
||||
$resultado = array();
|
||||
foreach ($errores as $campo => $mensaje)
|
||||
$resultado[$campo] = $mensaje;
|
||||
Yii::trace(CVarDumper::dumpAsString($resultado), 'application.controllers.CandidatoController');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->render('update', array(
|
||||
@ -229,24 +108,25 @@ class CandidatoController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a particular model.
|
||||
* If deletion is successful, the browser will be redirected to the 'admin' page.
|
||||
* @param integer $id the ID of the model to be deleted
|
||||
* @brief Elimina un candidato.
|
||||
* @param integer $id el ID del candidato a eliminar
|
||||
*/
|
||||
public function actionDelete($id) {
|
||||
if (Yii::app()->request->isPostRequest) {
|
||||
// we only allow deletion via POST request
|
||||
Yii::trace('Eliminar el candidato', 'application.controllers.CandidatoController');
|
||||
|
||||
$this->loadModel($id)->delete();
|
||||
$this->borrarFoto($id);
|
||||
Yii::app()->user->setFlash('success', "Candidato eliminardo correctamente.");
|
||||
Yii::app()->user->setFlash('success', "Candidato eliminado correctamente.");
|
||||
|
||||
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
|
||||
if (!isset($_GET['ajax']))
|
||||
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
|
||||
}
|
||||
else
|
||||
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
|
||||
throw new CHttpException(400, Yii::t('profind', 'Petición no válida'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Lista todos los candidatos
|
||||
*
|
||||
@ -262,27 +142,6 @@ class CandidatoController extends Controller {
|
||||
'candidatos' => $candidatos));
|
||||
}
|
||||
|
||||
public function actionHistorial($id) {
|
||||
$this->layout = '//layouts/candidato';
|
||||
$this->render('historial', array(
|
||||
'model' => $this->loadModel($id),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages all models.
|
||||
*/
|
||||
public function actionAdmin() {
|
||||
$model = new Candidato('search');
|
||||
$model->unsetAttributes(); // clear any default values
|
||||
if (isset($_GET['Candidato']))
|
||||
$model->attributes = $_GET['Candidato'];
|
||||
|
||||
$this->render('admin', array(
|
||||
'model' => $model,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devuelve los datos del candidato con id $id.
|
||||
* Si el candidato no existe, se lanza una excepción HTTP 404
|
||||
@ -297,6 +156,138 @@ class CandidatoController extends Controller {
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Guarda los datos de un candidato $candidato a partir de $_POST
|
||||
* @param Candidato $candidato instancia del candidato
|
||||
* @return bool
|
||||
*/
|
||||
private function saveModel($candidato) {
|
||||
if (!isset($_POST['Candidato'])) {
|
||||
throw new CHttpException(405, Yii::t('profind', 'Método no permitido.'));
|
||||
}
|
||||
Yii::trace(CVarDumper::dumpAsString($_POST));
|
||||
|
||||
// Candidato
|
||||
$candidato->attributes = $_POST['Candidato'];
|
||||
$ficheroFotografia = CUploadedFile::getInstance($candidato, 'ficheroFotografia');
|
||||
$quitarFotografia = Yii::app()->request->getParam('quitar_fotografia', '0');
|
||||
|
||||
// Titulaciones del candidato
|
||||
$listaTitulacionesBorrar = $candidato->titulaciones;
|
||||
if (isset($_POST['CandidatoTitulacion'])) {
|
||||
$listaTitulaciones = array();
|
||||
foreach ($_POST['CandidatoTitulacion'] as $titulacion) {
|
||||
$candidatoTitulacion = new CandidatoTitulacion();
|
||||
$candidatoTitulacion->titulacion = $titulacion;
|
||||
$candidatoTitulacion->candidato_id = $candidato->id;
|
||||
$listaTitulaciones[] = $candidatoTitulacion;
|
||||
}
|
||||
$candidato->titulaciones = $listaTitulaciones;
|
||||
}
|
||||
|
||||
// Idiomas del candidato
|
||||
$listaIdiomasBorrar = array();
|
||||
if (isset($_POST['CandidatoIdioma'])) {
|
||||
$listaIdiomas = array();
|
||||
foreach ($_POST['CandidatoIdioma'] as $key => $idioma) {
|
||||
if ($idioma['id'])
|
||||
$candidatoIdioma = CandidatoIdioma::model()->findByPk($idioma['id']);
|
||||
else
|
||||
$candidatoIdioma = new CandidatoIdioma();
|
||||
$candidatoIdioma->attributes = $idioma;
|
||||
$candidatoIdioma->candidato_id = $candidato->id;
|
||||
|
||||
if ($idioma['_borrar'])
|
||||
$listaIdiomasBorrar[] = $candidatoIdioma;
|
||||
else
|
||||
$listaIdiomas[] = $candidatoIdioma;
|
||||
}
|
||||
$candidato->idiomas = $listaIdiomas;
|
||||
}
|
||||
|
||||
// Guardar los datos
|
||||
$errores = array();
|
||||
$transaccion = Yii::app()->db->beginTransaction();
|
||||
try {
|
||||
Yii::trace('Guardando el candidato', 'application.controllers.CandidatoController');
|
||||
if (!$candidato->save()) {
|
||||
$errores = array_merge($errores, $candidato->getErrors());
|
||||
throw new CException('Error al guardar el candidato');
|
||||
}
|
||||
|
||||
if (($quitarFotografia == '1') && ($candidato->fotografia->tieneFotografia())) {
|
||||
Yii::trace('Eliminando la fotografía del candidato', 'application.controllers.CandidatoController');
|
||||
$candidato->fotografia->eliminarFotografia();
|
||||
}
|
||||
|
||||
if ($ficheroFotografia) {
|
||||
Yii::trace('Guardando la fotografía del candidato', 'application.controllers.CandidatoController');
|
||||
$candidato->fotografia->guardarFotografia($ficheroFotografia);
|
||||
}
|
||||
|
||||
// Titulaciones
|
||||
if (!empty($listaTitulacionesBorrar)) {
|
||||
Yii::trace('Eliminando titulaciones marcadas para borrar', 'application.controllers.CandidatoController');
|
||||
foreach ($listaTitulacionesBorrar as $candidatoTitulacion) {
|
||||
if (!$candidatoTitulacion->delete()) {
|
||||
$errores = array_merge($errores, $candidatoTitulacion->getErrors());
|
||||
throw new CException('Error al eliminar una titulación del candidato');
|
||||
}
|
||||
}
|
||||
$listaTitulacionesBorrar = NULL;
|
||||
}
|
||||
if (!empty($candidato->titulaciones)) {
|
||||
Yii::trace('Guardando la lista de titulaciones', 'application.controllers.CandidatoController');
|
||||
foreach ($candidato->titulaciones as $candidatoTitulacion) {
|
||||
if (!$candidatoTitulacion->save()) {
|
||||
$errores = array_merge($errores, $candidatoTitulacion->getErrors());
|
||||
throw new CException('Error al guardar una titulación del candidato');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Idiomas
|
||||
if (!empty($listaIdiomasBorrar)) {
|
||||
Yii::trace('Eliminando idiomas marcados para borrar', 'application.controllers.CandidatoController');
|
||||
foreach ($listaIdiomasBorrar as $candidatoIdioma) {
|
||||
Yii::trace('Eliminando idioma... ', 'application.controllers.CandidatoController');
|
||||
Yii::trace(CVarDumper::dumpAsString($candidatoIdioma->attributes), 'application.controllers.CandidatoController');
|
||||
if (!$candidatoIdioma->delete()) {
|
||||
$errores = array_merge($errores, $candidatoIdioma->getErrors());
|
||||
throw new CException('Error al eliminar un idioma del candidato');
|
||||
}
|
||||
}
|
||||
$listaIdiomasBorrar = NULL;
|
||||
}
|
||||
if (!empty($candidato->idiomas)) {
|
||||
Yii::trace('Guardando la lista de idiomas', 'application.controllers.CandidatoController');
|
||||
foreach ($candidato->idiomas as $candidatoIdioma) {
|
||||
if (!$candidatoIdioma->save()) {
|
||||
$errores = array_merge($errores, $candidatoIdioma->getErrors());
|
||||
throw new CException('Error al guardar un idioma del candidato');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$transaccion->commit();
|
||||
Yii::trace('Candidato guardado', 'application.controllers.CandidatoController');
|
||||
Yii::app()->user->setFlash('success', Yii::t('profind', 'Se ha actualizado el candidato'));
|
||||
return TRUE;
|
||||
} catch (Exception $e) {
|
||||
Yii::trace($e->getMessage(), 'application.controllers.CandidatoController');
|
||||
$transaccion->rollBack();
|
||||
Yii::app()->user->setFlash('error', Yii::t('profind', 'Se ha producido un error al actualizar el candidato'));
|
||||
|
||||
if (YII_DEBUG) {
|
||||
$resultado = array();
|
||||
foreach ($errores as $campo => $mensaje)
|
||||
$resultado[$campo] = $mensaje;
|
||||
Yii::trace(CVarDumper::dumpAsString($resultado), 'application.controllers.CandidatoController');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
274
www/protected/helpers/TimeHelper.php
Normal file
274
www/protected/helpers/TimeHelper.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @class TimeHelper
|
||||
* @brief Clase con funciones para tratamiento de fechas.
|
||||
*
|
||||
* @package application.helpers
|
||||
*/
|
||||
|
||||
class TimeHelper {
|
||||
|
||||
/**
|
||||
* Returns a nicely formatted date string for given Datetime string.
|
||||
*
|
||||
* @param string $dateString Datetime string
|
||||
* @param int $format Format of returned date
|
||||
* @return string Formatted date string
|
||||
*/
|
||||
public static function nice($dateString = null, $format = 'D, M jS Y, H:i') {
|
||||
|
||||
$date = ($dateString == null) ? time() : strtotime($dateString);
|
||||
return date($format, $date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted descriptive date string for given datetime string.
|
||||
*
|
||||
* If the given date is today, the returned string could be "Today, 6:54 pm".
|
||||
* If the given date was yesterday, the returned string could be "Yesterday, 6:54 pm".
|
||||
* If $dateString's year is the current year, the returned string does not
|
||||
* include mention of the year.
|
||||
*
|
||||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @return string Described, relative date string
|
||||
*/
|
||||
public static function niceShort($dateString = null) {
|
||||
$date = ($dateString == null) ? time() : strtotime($dateString);
|
||||
|
||||
$y = (self::isThisYear($date)) ? '' : ' Y';
|
||||
|
||||
if (self::isToday($date)) {
|
||||
$ret = sprintf('Hoy, %s', date("g:i a", $date));
|
||||
} elseif (self::wasYesterday($date)) {
|
||||
$ret = sprintf('Ayer, %s', date("g:i a", $date));
|
||||
} else {
|
||||
$ret = date("M jS{$y}, H:i", $date);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given date is today.
|
||||
*
|
||||
* @param string $date Unix timestamp
|
||||
* @return boolean True if date is today
|
||||
*/
|
||||
public static function isToday($date) {
|
||||
return date('Y-m-d', $date) == date('Y-m-d', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given date was yesterday
|
||||
*
|
||||
* @param string $date Unix timestamp
|
||||
* @return boolean True if date was yesterday
|
||||
*/
|
||||
public static function wasYesterday($date) {
|
||||
return date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given date is in this year
|
||||
*
|
||||
* @param string $date Unix timestamp
|
||||
* @return boolean True if date is in this year
|
||||
*/
|
||||
public static function isThisYear($date) {
|
||||
return date('Y', $date) == date('Y', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given date is in this week
|
||||
*
|
||||
* @param string $date Unix timestamp
|
||||
* @return boolean True if date is in this week
|
||||
*/
|
||||
public static function isThisWeek($date) {
|
||||
return date('W Y', $date) == date('W Y', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given date is in this month
|
||||
*
|
||||
* @param string $date Unix timestamp
|
||||
* @return boolean True if date is in this month
|
||||
*/
|
||||
public static function isThisMonth($date) {
|
||||
return date('m Y', $date) == date('m Y', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns either a relative date or a formatted date depending
|
||||
* on the difference between the current time and given datetime.
|
||||
* $datetime should be in a <i>strtotime</i>-parsable format, like MySQL's datetime datatype.
|
||||
*
|
||||
* Options:
|
||||
* 'format' => a fall back format if the relative time is longer than the duration specified by end
|
||||
* 'end' => The end of relative time telling
|
||||
*
|
||||
* Relative dates look something like this:
|
||||
* 3 weeks, 4 days ago
|
||||
* 15 seconds ago
|
||||
* Formatted dates look like this:
|
||||
* on 02/18/2004
|
||||
*
|
||||
* The returned string includes 'ago' or 'on' and assumes you'll properly add a word
|
||||
* like 'Posted ' before the function output.
|
||||
*
|
||||
* @param string $dateString Datetime string
|
||||
* @param array $options Default format if timestamp is used in $dateString
|
||||
* @return string Relative time string.
|
||||
*/
|
||||
function timeAgoInWords($dateTime, $options = array()) {
|
||||
$now = time();
|
||||
|
||||
$inSeconds = strtotime($dateTime);
|
||||
$backwards = ($inSeconds > $now);
|
||||
|
||||
$format = 'j/n/y';
|
||||
$end = '+1 month';
|
||||
|
||||
if (is_array($options)) {
|
||||
if (isset($options['format'])) {
|
||||
$format = $options['format'];
|
||||
unset($options['format']);
|
||||
}
|
||||
if (isset($options['end'])) {
|
||||
$end = $options['end'];
|
||||
unset($options['end']);
|
||||
}
|
||||
} else {
|
||||
$format = $options;
|
||||
}
|
||||
|
||||
if ($backwards) {
|
||||
$futureTime = $inSeconds;
|
||||
$pastTime = $now;
|
||||
} else {
|
||||
$futureTime = $now;
|
||||
$pastTime = $inSeconds;
|
||||
}
|
||||
$diff = $futureTime - $pastTime;
|
||||
|
||||
// If more than a week, then take into account the length of months
|
||||
if ($diff >= 604800) {
|
||||
$current = array();
|
||||
$date = array();
|
||||
|
||||
list($future['H'], $future['i'], $future['s'], $future['d'], $future['m'], $future['Y']) = explode('/', date('H/i/s/d/m/Y', $futureTime));
|
||||
|
||||
list($past['H'], $past['i'], $past['s'], $past['d'], $past['m'], $past['Y']) = explode('/', date('H/i/s/d/m/Y', $pastTime));
|
||||
$years = $months = $weeks = $days = $hours = $minutes = $seconds = 0;
|
||||
|
||||
if ($future['Y'] == $past['Y'] && $future['m'] == $past['m']) {
|
||||
$months = 0;
|
||||
$years = 0;
|
||||
} else {
|
||||
if ($future['Y'] == $past['Y']) {
|
||||
$months = $future['m'] - $past['m'];
|
||||
} else {
|
||||
$years = $future['Y'] - $past['Y'];
|
||||
$months = $future['m'] + ((12 * $years) - $past['m']);
|
||||
|
||||
if ($months >= 12) {
|
||||
$years = floor($months / 12);
|
||||
$months = $months - ($years * 12);
|
||||
}
|
||||
|
||||
if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) {
|
||||
$years--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($future['d'] >= $past['d']) {
|
||||
$days = $future['d'] - $past['d'];
|
||||
} else {
|
||||
$daysInPastMonth = date('t', $pastTime);
|
||||
$daysInFutureMonth = date('t', mktime(0, 0, 0, $future['m'] - 1, 1, $future['Y']));
|
||||
|
||||
if (!$backwards) {
|
||||
$days = ($daysInPastMonth - $past['d']) + $future['d'];
|
||||
} else {
|
||||
$days = ($daysInFutureMonth - $past['d']) + $future['d'];
|
||||
}
|
||||
|
||||
if ($future['m'] != $past['m']) {
|
||||
$months--;
|
||||
}
|
||||
}
|
||||
|
||||
if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) {
|
||||
$months = 11;
|
||||
$years--;
|
||||
}
|
||||
|
||||
if ($months >= 12) {
|
||||
$years = $years + 1;
|
||||
$months = $months - 12;
|
||||
}
|
||||
|
||||
if ($days >= 7) {
|
||||
$weeks = floor($days / 7);
|
||||
$days = $days - ($weeks * 7);
|
||||
}
|
||||
} else {
|
||||
$years = $months = $weeks = 0;
|
||||
$days = floor($diff / 86400);
|
||||
|
||||
$diff = $diff - ($days * 86400);
|
||||
|
||||
$hours = floor($diff / 3600);
|
||||
$diff = $diff - ($hours * 3600);
|
||||
|
||||
$minutes = floor($diff / 60);
|
||||
$diff = $diff - ($minutes * 60);
|
||||
$seconds = $diff;
|
||||
}
|
||||
$relativeDate = '';
|
||||
$diff = $futureTime - $pastTime;
|
||||
|
||||
if ($diff > abs($now - strtotime($end))) {
|
||||
$relativeDate = sprintf('el %s', date($format, $inSeconds));
|
||||
} else {
|
||||
if ($years > 0) {
|
||||
// years and months and days
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $years . ' ' . ($years == 1 ? 'año' : 'años');
|
||||
$relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' ' . ($months == 1 ? 'mes' : 'meses') : '';
|
||||
$relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . ($weeks == 1 ? 'semana' : 'semanas') : '';
|
||||
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . ($days == 1 ? 'día' : 'días') : '';
|
||||
} elseif (abs($months) > 0) {
|
||||
// months, weeks and days
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $months . ' ' . ($months == 1 ? 'mes' : 'meses');
|
||||
$relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . ($weeks == 1 ? 'semana' : 'semanas') : '';
|
||||
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . ($days == 1 ? 'día' : 'días') : '';
|
||||
} elseif (abs($weeks) > 0) {
|
||||
// weeks and days
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' ' . ($weeks == 1 ? 'semana' : 'semanas');
|
||||
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . ($days == 1 ? 'día' : 'días') : '';
|
||||
} elseif (abs($days) > 0) {
|
||||
// days and hours
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $days . ' ' . ($days == 1 ? 'día' : 'días');
|
||||
$relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' ' . ($hours == 1 ? 'hora' : 'horas') : '';
|
||||
} elseif (abs($hours) > 0) {
|
||||
// hours and minutes
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' ' . ($hours == 1 ? 'hora' : 'horas');
|
||||
$relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' ' . ($minutes == 1 ? 'minuto' : 'minutos') : '';
|
||||
} elseif (abs($minutes) > 0) {
|
||||
// minutes only
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' ' . ($minutes == 1 ? 'minuto' : 'minutos');
|
||||
} else {
|
||||
// seconds only
|
||||
$relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' ' . ($seconds == 1 ? 'segundo' : 'segundos');
|
||||
}
|
||||
|
||||
if (!$backwards) {
|
||||
$relativeDate = sprintf('hace %s', $relativeDate);
|
||||
}
|
||||
}
|
||||
return $relativeDate;
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,6 +4,7 @@ class m121014_170834_tbl_estados_candidatos extends CDbMigration {
|
||||
$this->createTable('tbl_estados_candidatos', array(
|
||||
'id' => 'pk',
|
||||
'descripcion' => 'string NOT NULL',
|
||||
'predeterminado' => 'boolean NOT NULL DEFAULT "0"' // tinyint(1)
|
||||
), 'ENGINE=InnoDB CHARSET=utf8');
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* @brief Modelo de la tabla "tbl_candidatos".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id_estado
|
||||
* @property integer $id_estado
|
||||
* @property string $n_identificacion
|
||||
* @property string $nombre
|
||||
* @property string $apellidos
|
||||
@ -33,15 +33,13 @@
|
||||
* @property string $ficheroFotografia
|
||||
* @property FotografiaPerfil $fotografia
|
||||
*
|
||||
* @property CandidatoCapacidad[] $capacidades
|
||||
* @property EstadoCandidato $estado
|
||||
* @property CandidatoIdioma[] $idiomas
|
||||
* @property CandidatoTitulacion[] $titulaciones
|
||||
* @property CandidatoDocumento[] $documentos
|
||||
*
|
||||
* @package application.models
|
||||
*
|
||||
*/
|
||||
|
||||
class Candidato extends CActiveRecord {
|
||||
|
||||
const GENERO_HOMBRE = 'Hombre';
|
||||
@ -50,51 +48,18 @@ class Candidato extends CActiveRecord {
|
||||
public $ficheroFotografia;
|
||||
public $fotografia;
|
||||
|
||||
public $capacidad_tecnica_search;
|
||||
public $idiomas_search;
|
||||
public $tecnologias_search;
|
||||
public $funciones_search;
|
||||
public $salario_ini_search;
|
||||
public $salario_fin_search;
|
||||
public $nombre_estado_search;
|
||||
public $nombreCompleto_search;
|
||||
private $_nombreCompleto;
|
||||
|
||||
/**
|
||||
* @brief Devuelve el nombre completo de un candidato.
|
||||
* @return string $nombreCompleto
|
||||
*/
|
||||
public function getNombreCompleto() {
|
||||
if (isset($this->nombreCompleto_search)) {
|
||||
return $this->nombreCompleto_search;
|
||||
}
|
||||
|
||||
$this->nombreCompleto_search = $this->nombre . ' ' . $this->apellidos;
|
||||
return $this->nombreCompleto_search;
|
||||
return $this->nombre . ' ' . $this->apellidos;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
public function setNombreCompleto($value) {
|
||||
$this->_nombreCompleto = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,6 +120,9 @@ class Candidato extends CActiveRecord {
|
||||
array('email', 'unique'),
|
||||
array('email', 'email'),
|
||||
|
||||
array('id_estado', 'numerical', 'integerOnly' => true),
|
||||
array('id_estado', 'default', 'value' => Candidato::darIdEstadoInicial()),
|
||||
|
||||
array('ficheroFotografia', 'file',
|
||||
'types' => 'jpg',
|
||||
'maxSize' => 1024 * 1024 * 1, // 1MB como máximo
|
||||
@ -163,8 +131,7 @@ class Candidato extends CActiveRecord {
|
||||
'allowEmpty' => 'true',
|
||||
),
|
||||
|
||||
array('salario_minimo, salario_maximo', 'numerical','allowEmpty' => 'true'),
|
||||
|
||||
array('salario_minimo, salario_maximo', 'numerical', 'allowEmpty' => 'true'),
|
||||
array('salario_minimo', 'default', 'value' => Yii::app()->params['salarios_candidatos']['salario_minimo']),
|
||||
array('salario_maximo', 'default', 'value' => Yii::app()->params['salarios_candidatos']['salario_maximo']),
|
||||
|
||||
@ -176,20 +143,16 @@ 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'),
|
||||
|
||||
|
||||
// The following rule is used by search().
|
||||
// Please remove those attributes that should not be searched.
|
||||
array('id, id_estado,
|
||||
nombre_estado_search, nombreCompleto_search, capacidad_tecnica_search,
|
||||
idiomas_search, salario_ini_search, salario_fin_search,
|
||||
tecnologias_search, funciones_search,
|
||||
array('id, id_estado, estado, nombre, apellidos, nombreCompleto,
|
||||
n_identificacion, email, telefono_fijo,
|
||||
telefono_movil, sexo, fecha_nacimiento, lugar_nacimiento,
|
||||
localidad, fecha_alta, usuario_alta,
|
||||
usuario_modificacion, carnet_conducir, vehiculo_propio,
|
||||
localidad, carnet_conducir, vehiculo_propio,
|
||||
observaciones, salario_minimo, salario_maximo, procedencia,
|
||||
disponibilidad_incorporacion, disponibilidad_entrevistas,
|
||||
disponibilidad_guardias, disponibilidad_viajar,
|
||||
@ -203,54 +166,59 @@ class Candidato extends CActiveRecord {
|
||||
*/
|
||||
public function relations() {
|
||||
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'),
|
||||
//'documentos' => array(self::HAS_MANY, 'CandidatoDocumento', 'candidato_id'),
|
||||
//'documentosCount' => array(self::STAT, 'CandidatoDocumento', 'candidato_id'),
|
||||
'estados' => array(self::BELONGS_TO, 'EstadoCandidato', 'id_estado'),
|
||||
'estado' => array(self::BELONGS_TO, 'EstadoCandidato', 'id_estado'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Busca el ID del estado inicial de un candidato.
|
||||
* @return integer
|
||||
*/
|
||||
public static function darIdEstadoInicial() {
|
||||
$estado = EstadoCandidato::model()->predeterminado()->find();
|
||||
if ($estado === null) {
|
||||
Yii::log('No se ha encontrado un estado inicial para el candidato', CLogger::LEVEL_ERROR, 'application.controller.CandidatoController');
|
||||
throw new CHttpException(500, Yii::t('profind', 'Error interno. No se ha encontrado un estado inicial para el candidato'));
|
||||
}
|
||||
return $estado->id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array customized attribute labels (name=>label)
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return array(
|
||||
'id' => 'ID',
|
||||
'id_estado' => 'ID estado',
|
||||
'nombre_estado_search' => 'Estado',
|
||||
'idiomas_search' => 'Idioma',
|
||||
'nombreApellidos' => 'Candidato',
|
||||
'foto' => 'Foto',
|
||||
'id_estado' => 'Estado',
|
||||
|
||||
'n_identificacion' => 'DNI/Pasaporte',
|
||||
'nombre' => 'Nombre',
|
||||
'apellidos' => 'Apellidos',
|
||||
'sexo' => 'Sexo',
|
||||
'localidad' => 'Localidad',
|
||||
'email' => 'Email',
|
||||
'telefono_fijo' => 'Teléfono fijo',
|
||||
'telefono_movil' => 'Teléfono móvil',
|
||||
'sexo' => 'Sexo',
|
||||
'fecha_nacimiento' => 'Fecha de nacimiento',
|
||||
'lugar_nacimiento' => 'Lugar de nacimiento',
|
||||
'localidad' => 'Localidad',
|
||||
'carnet_conducir' => 'Carnet de conducir',
|
||||
'vehiculo_propio' => 'Vehículo propio',
|
||||
'procedencia' => 'Procedencia',
|
||||
'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_search' => 'Candidato',
|
||||
'observaciones' => 'Observaciones',
|
||||
'tecnologias_search' => 'Tecnologías',
|
||||
'funciones_search' => 'Perfiles funcionales',
|
||||
'modified_time' => 'Modificación',
|
||||
);
|
||||
}
|
||||
|
||||
@ -262,116 +230,88 @@ class Candidato extends CActiveRecord {
|
||||
// Warning: Please modify the following code to remove attributes that
|
||||
// should not be searched.
|
||||
|
||||
$criteria=new CDbCriteria;
|
||||
$criteria = new CDbCriteria;
|
||||
|
||||
$criteria->with = array('estado');
|
||||
$criteria->together = true;
|
||||
|
||||
$criteria->compare('t.id', $this->id);
|
||||
|
||||
$criteria->compare('t.id_estado', $this->id_estado);
|
||||
//$criteria->compare('estado.descripcion', $this->estado, true);
|
||||
|
||||
$criteria->compare('t.n_identificacion', $this->n_identificacion, true);
|
||||
$criteria->compare('t.nombre', $this->nombre, true);
|
||||
$criteria->compare('t.apellidos', $this->apellidos, true);
|
||||
$criteria->compare('t.sexo', $this->sexo, true);
|
||||
$criteria->compare('t.localidad', $this->localidad, true);
|
||||
|
||||
$criteria->compare( 'concat(t.nombre, " ", t.apellidos)', $this->_nombreCompleto, true );
|
||||
|
||||
$criteria->compare('t.email', $this->email, true);
|
||||
$criteria->compare('t.telefono_fijo', $this->telefono_fijo, true);
|
||||
$criteria->compare('t.telefono_movil', $this->telefono_movil, true);
|
||||
|
||||
$criteria->compare('t.fecha_nacimiento', $this->fecha_nacimiento, true);
|
||||
$criteria->compare('t.lugar_nacimiento', $this->lugar_nacimiento, true);
|
||||
|
||||
$criteria->compare('t.carnet_conducir', $this->carnet_conducir, true);
|
||||
$criteria->compare('t.vehiculo_propio', $this->vehiculo_propio);
|
||||
|
||||
$criteria->compare('t.observaciones', $this->observaciones, true);
|
||||
|
||||
$criteria->compare('t.salario_minimo', $this->salario_minimo);
|
||||
$criteria->compare('t.salario_maximo', $this->salario_maximo);
|
||||
|
||||
$criteria->compare('t.procedencia', $this->procedencia, true);
|
||||
|
||||
$criteria->compare('t.disponibilidad_incorporacion', $this->disponibilidad_incorporacion, true);
|
||||
$criteria->compare('t.disponibilidad_entrevistas', $this->disponibilidad_entrevistas, true);
|
||||
$criteria->compare('t.disponibilidad_guardias', $this->disponibilidad_guardias, true);
|
||||
$criteria->compare('t.disponibilidad_viajar', $this->disponibilidad_viajar, true);
|
||||
$criteria->compare('t.disponibilidad_proyectos_internacionales', $this->disponibilidad_proyectos_internacionales, true);
|
||||
|
||||
$criteria->compare('t.created_time', $this->created_time, true);
|
||||
$criteria->compare('t.modified_time', $this->modified_time, true);
|
||||
$criteria->compare('t.deleted_time', $this->deleted_time, true);
|
||||
|
||||
$criteria->compare('id', $this->id);
|
||||
$criteria->compare('id_estado', $this->id_estado);
|
||||
$criteria->compare('n_identificacion', $this->n_identificacion, 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('localidad', $this->localidad, true);
|
||||
$criteria->compare('fecha_nacimiento', $this->fecha_nacimiento, true);
|
||||
$criteria->compare('lugar_nacimiento', $this->lugar_nacimiento, true);
|
||||
$criteria->compare('created_time', $this->created_time, true);
|
||||
$criteria->compare('modified_time', $this->modified_time, true);
|
||||
$criteria->compare('deleted_time', $this->deleted_time, true);
|
||||
$criteria->compare('carnet_conducir', $this->carnet_conducir, true);
|
||||
$criteria->compare('vehiculo_propio', $this->vehiculo_propio);
|
||||
$criteria->compare('observaciones', $this->observaciones, true);
|
||||
$criteria->compare('salario_minimo', $this->salario_minimo);
|
||||
$criteria->compare('salario_maximo', $this->salario_maximo);
|
||||
$criteria->compare('procedencia', $this->procedencia, true);
|
||||
$criteria->compare('disponibilidad_incorporacion', $this->disponibilidad_incorporacion, true);
|
||||
$criteria->compare('disponibilidad_entrevistas', $this->disponibilidad_entrevistas, true);
|
||||
$criteria->compare('disponibilidad_guardias', $this->disponibilidad_guardias, true);
|
||||
$criteria->compare('disponibilidad_viajar', $this->disponibilidad_viajar, true);
|
||||
$criteria->compare('disponibilidad_proyectos_internacionales', $this->disponibilidad_proyectos_internacionales, true);
|
||||
|
||||
$sort = new CSort();
|
||||
$sort->modelClass = 'Candidato';
|
||||
$sort->attributes = array(
|
||||
'*',
|
||||
'defaultOrder' => 'id',
|
||||
'nombreCompleto' => array(
|
||||
'asc' => 'concat(t.nombre, " ", t.apellidos)',
|
||||
'desc' => 'concat(t.nombre, " ", t.apellidos) desc',
|
||||
),
|
||||
);
|
||||
);
|
||||
return new CActiveDataProvider($this, array(
|
||||
'criteria'=>$criteria,
|
||||
//'sort' => $sort,
|
||||
));
|
||||
|
||||
// $sort = new CSort();
|
||||
// $sort->attributes = array(
|
||||
// 'defaultOrder' => '',
|
||||
// 'nombre_estado_search' => array(
|
||||
// 'asc' => 'estados.descripcion',
|
||||
// 'desc' => 'estados.descripcion DESC',
|
||||
// ),
|
||||
// 'fecha_modificacion' => array(
|
||||
// 'asc' => 't.fecha_modificacion',
|
||||
// 'desc' => 't.fecha_modificacion desc',
|
||||
// ),
|
||||
// 'nombreCompleto_search' => array(
|
||||
// 'asc' => 'concat(t.nombre, " ", t.apellidos)',
|
||||
// 'desc' => 'concat(t.nombre, " ", t.apellidos) desc',
|
||||
// ),
|
||||
// 'capacidad_tecnica_search' => array(
|
||||
// 'asc' => 'capacidades.perfil_tecnico_id',
|
||||
// 'desc' => 'capacidades.perfil_tecnico_id desc',
|
||||
// ),
|
||||
// );
|
||||
// echo $criteria->condition;
|
||||
// return new CActiveDataProvider($this, array(
|
||||
// 'criteria' => $criteria,
|
||||
// 'sort' => $sort,
|
||||
// ));
|
||||
}
|
||||
|
||||
protected function beforeValidate() {
|
||||
if ($this->isNewRecord) {
|
||||
$this->id_estado = 510;
|
||||
$this->created_time = date('Y-m-d H:i:s', time());
|
||||
} else {
|
||||
$this->modified_time = date('Y-m-d H:i:s', time());
|
||||
}
|
||||
|
||||
return parent::beforeValidate();
|
||||
'criteria' => $criteria,
|
||||
'sort' => $sort,
|
||||
));
|
||||
}
|
||||
|
||||
protected function beforeSave() {
|
||||
if ($this->isNewRecord)
|
||||
$this->created_time = date("Y-m-d H:i:s");
|
||||
|
||||
/*if (($this->estado === self::ESTADO_BORRADO) && ($this->deleted_time === NULL))
|
||||
/*if (($this->id_estado === self::ESTADO_BORRADO) && ($this->deleted_time === NULL))
|
||||
$this->deleted_time = date("Y-m-d H:i:s");*/
|
||||
|
||||
//PHP dates are displayed as dd/mm/yyyy
|
||||
//MYSQL dates are stored as yyyy-mm-dd
|
||||
if ($this->fecha_nacimiento != '') {
|
||||
$dateToMySQL = date('Y-m-d', CDateTimeParser::parse($this->fecha_nacimiento, Yii::app()->locale->dateFormat));
|
||||
$this->fecha_nacimiento = $dateToMySQL;
|
||||
}
|
||||
|
||||
return parent::beforeSave();
|
||||
}
|
||||
|
||||
|
||||
protected function afterFind() {
|
||||
parent::afterFind();
|
||||
$this->fotografia = new FotografiaPerfil();
|
||||
$this->fotografia->modelo = $this;
|
||||
|
||||
//PHP dates are displayed as dd/mm/yyyy
|
||||
//MYSQL dates are stored as yyyy-mm-dd
|
||||
|
||||
$dateToLocale = Yii::app()->dateFormatter->formatDateTime(CDateTimeParser::parse($this->fecha_nacimiento, 'yyyy-MM-dd'), 'medium', null);
|
||||
$this->fecha_nacimiento = $dateToLocale;
|
||||
|
||||
parent::afterFind();
|
||||
}
|
||||
|
||||
|
||||
protected function afterConstruct() {
|
||||
parent::afterConstruct();
|
||||
$this->fotografia = new FotografiaPerfil();
|
||||
$this->fotografia->modelo = $this;
|
||||
}
|
||||
|
||||
protected function afterSave() {
|
||||
parent::afterSave();
|
||||
if ($this->isNewRecord)
|
||||
@ -383,21 +323,14 @@ class Candidato extends CActiveRecord {
|
||||
$this->deleteUploadDir();
|
||||
}
|
||||
|
||||
protected function afterConstruct() {
|
||||
parent::afterConstruct();
|
||||
|
||||
$this->fotografia = new FotografiaPerfil();
|
||||
$this->fotografia->modelo = $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Devuelve el nombre del fichero por defecto cuando no se tiene imagen
|
||||
* @return string ruta
|
||||
*/
|
||||
public function getImagenDefault() {
|
||||
return 'user_photo.jpg';
|
||||
return 'candidate_photo.jpg';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Devuelve la ruta con los ficheros del usuario.
|
||||
* Incluye el separador de directorios al final de la ruta.
|
||||
@ -406,7 +339,7 @@ class Candidato extends CActiveRecord {
|
||||
public function getUploadPath() {
|
||||
return Yii::getPathOfAlias('application.uploads.candidatos') . DIRECTORY_SEPARATOR . $this->id . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Crea un directorio para almacenar ficheros del usuario
|
||||
* @return boolean
|
||||
@ -414,24 +347,26 @@ class Candidato extends CActiveRecord {
|
||||
private function createUploadDir() {
|
||||
$upload = $this->getUploadPath();
|
||||
|
||||
if(!is_dir($upload)) {
|
||||
if (!is_dir($upload)) {
|
||||
return mkdir($upload);
|
||||
}
|
||||
else return false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Elimina el directorio del usuario y todos sus ficheros
|
||||
* @return boolean
|
||||
*/
|
||||
private function deleteUploadDir() {
|
||||
$upload = $this->getUploadPath();
|
||||
|
||||
if(is_dir($upload))
|
||||
|
||||
if (is_dir($upload))
|
||||
return GHelper::recursiveRemoveDirectory($upload);
|
||||
else return false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
90
www/protected/models/EstadoCandidato.php
Normal file
90
www/protected/models/EstadoCandidato.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This is the model class for table "tbl_estados_candidatos".
|
||||
*
|
||||
* The followings are the available columns in table 'tbl_estados_candidatos':
|
||||
* @property integer $id
|
||||
* @property string $descripcion
|
||||
*/
|
||||
class EstadoCandidato extends CActiveRecord {
|
||||
|
||||
/**
|
||||
* Returns the static model of the specified AR class.
|
||||
* @param string $className active record class name.
|
||||
* @return EstadoCandidato 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_estados_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('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'),
|
||||
);
|
||||
}
|
||||
|
||||
public function scopes() {
|
||||
return array(
|
||||
'predeterminado' => array(
|
||||
'condition' => 'predeterminado = 1',
|
||||
'limit' => 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@ -34,7 +34,6 @@
|
||||
background: #48a6d2 !important;
|
||||
}
|
||||
|
||||
html body.sidebar_right div#maincontainer.clearfix header div.navbar div.navbar-inner div.container-fluid nav div.nav-collapse ul#yw0.nav li.active a i.icon-briefcase
|
||||
|
||||
.table thead th {background-color:#ebf2f6 !important}
|
||||
.dataTables_wrapper th.sorting_asc,.dataTables_wrapper th.sorting_desc {background-color:#d4e3eb !important}
|
||||
|
||||
.table thead th.sorting_asc, .table thead th.sorting_desc {background-color:#d4e3eb !important}
|
||||
|
||||
@ -102,7 +102,7 @@ h3 + .label {
|
||||
.ov_boxes .ov_text, .dshb_icoNav li a, .table th, .fc thead th {
|
||||
text-shadow: 1px 1px 0 #fff
|
||||
}
|
||||
.dataTables_wrapper .sorting_asc, .dataTables_wrapper .sorting_desc {
|
||||
.table thead th.sorting_asc, .table thead th.sorting_desc {
|
||||
text-shadow: 1px 1px 0 #eee
|
||||
}
|
||||
/* Bootstrap adjustments */
|
||||
|
||||
@ -1,56 +1,60 @@
|
||||
<?php //Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/datatables/js/jquery.dataTables.min.js', CClientScript::POS_END); ?>
|
||||
<?php //Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/datatables/extras/Scroller/media/js/Scroller.min.js', CClientScript::POS_END); ?>
|
||||
|
||||
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/grid.css'); ?>
|
||||
|
||||
<?php
|
||||
Yii::app()->clientScript->registerScript('init_grid', '
|
||||
$(document).ready(function() {
|
||||
|
||||
$row = $("<div class=\'row\'/>");
|
||||
$row.appendTo("#candidato-grid");
|
||||
|
||||
$column1 = $("<div class=\'span6\'/>");
|
||||
$column2 = $("<div class=\'span6\'/>");
|
||||
$column1.appendTo($row);
|
||||
$column2.appendTo($row);
|
||||
|
||||
$column1.append($("#candidato-grid .dataTables_info"));
|
||||
$column2.append($("#candidato-grid .pagination"));
|
||||
|
||||
$("#candidato-grid table").dataTable({
|
||||
"aaSorting": [[ 2, "asc" ]],
|
||||
//"bProcessing": true,
|
||||
//"bServerSide": true,
|
||||
//"sDom": "<\'row\'<\'span6\'l><\'span6\'f>r>t<\'row\'<\'span6\'i><\'span6\'p>>",
|
||||
});
|
||||
});'
|
||||
);
|
||||
?>
|
||||
|
||||
<?php
|
||||
$columnas = array(
|
||||
'id',
|
||||
'nombreCompleto',
|
||||
'email',
|
||||
//'id',
|
||||
array(
|
||||
'header' => Yii::t('intranet', 'Acciones'),
|
||||
'type' => 'html',
|
||||
'name' => 'nombreCompleto',
|
||||
'value' => 'CHtml::link(CHtml::encode($data->nombreCompleto), array("update", "id"=>$data->id));',
|
||||
'headerHtmlOptions' => array(
|
||||
'class' => 'sorting',
|
||||
),
|
||||
'cssClassExpression' => '',
|
||||
),
|
||||
array(
|
||||
'type' => 'html',
|
||||
'name' => 'id_estado',
|
||||
'value' => 'CHtml::encode($data->estado->descripcion);',
|
||||
'headerHtmlOptions' => array(
|
||||
'class' => 'sorting',
|
||||
),
|
||||
'cssClassExpression' => '',
|
||||
),
|
||||
array(
|
||||
'name' => 'email',
|
||||
'headerHtmlOptions' => array(
|
||||
'class' => 'sorting',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'raw',
|
||||
'name' => 'modified_time',
|
||||
'value' => '($data->modified_time === NULL) ? CHtml::tag("span", array("class"=>"nodata"), "Nunca") : TimeHelper::timeAgoInWords($data->modified_time);',
|
||||
'headerHtmlOptions' => array(
|
||||
'class' => 'sorting',
|
||||
),
|
||||
'cssClassExpression' => '"con1"',
|
||||
),
|
||||
array(
|
||||
'header' => Yii::t('profind', 'Acciones'),
|
||||
'class' => 'CButtonColumn',
|
||||
'headerHtmlOptions' => array(
|
||||
'style' => 'width:55px;',
|
||||
'class' => '',
|
||||
),
|
||||
'template' => '{update}{delete}',
|
||||
'template' => '{delete}',
|
||||
'buttons' => array(
|
||||
'delete' => array(
|
||||
'label' => Yii::t('profind', 'Eliminar'),
|
||||
//'visible' => '$data->canDelete',
|
||||
'imageUrl' => '',
|
||||
'options' => array(
|
||||
'class' => 'btn btn-small delete'
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'html',
|
||||
// 'name' => 'email',
|
||||
// 'value' => 'CHtml::mailto(CHtml::encode($data->email));',
|
||||
// 'headerHtmlOptions' => array(
|
||||
// 'class' => '',
|
||||
// ),
|
||||
// 'cssClassExpression' => '',
|
||||
// ),
|
||||
);
|
||||
|
||||
$gridView = $this->widget('zii.widgets.grid.CGridView', array(
|
||||
@ -65,174 +69,36 @@ $gridView = $this->widget('zii.widgets.grid.CGridView', array(
|
||||
'template' => '{items}{summary}{pager}',
|
||||
'emptyText' => Yii::t('profind', 'No hay candidatos'),
|
||||
'summaryCssClass' => 'dataTables_info',
|
||||
//'summaryText' => Yii::t('profind', 'Mostrando registros del {start} al {end} de {count} en total.'),
|
||||
'pagerCssClass' => 'dataTables_paginate paging_bootstrap_alt pagination',
|
||||
'pager' => array(
|
||||
'htmlOptions' => array('class' => ''),
|
||||
'header' => '',
|
||||
'hiddenPageCssClass' => 'disabled',
|
||||
//'cssFile' =>Yii::app()->theme->baseUrl."/css/style-of-pager.css",
|
||||
),
|
||||
), true);
|
||||
), true);
|
||||
?>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="heading">
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="#mbox_new" data-toggle="tab"><i class="splashy-document_letter_edit"></i> New message</a></li>
|
||||
<li class="active"><a href="#mbox_inbox" data-toggle="tab"><i class="splashy-mail_light_down"></i> Inbox</a></li>
|
||||
<li><a href="#mbox_outbox" data-toggle="tab"><i class="splashy-mail_light_up"></i> Outbox</a></li>
|
||||
<li><a href="#mbox_trash" data-toggle="tab"><i class="icon-adt_trash"></i> Trash</a></li>
|
||||
</ul>
|
||||
<h3 class="heading"><?php echo Yii::t('profind', 'BD Candidatos'); ?></h3>
|
||||
<div class="row-fluid sepH_b">
|
||||
<div class="span8">
|
||||
<div class="btn-group">
|
||||
<?php echo CHtml::link(CHtml::tag('i', array('class' => 'icon-plus'), '') . ' ' . Yii::t('profind', 'Nuevo candidato'),
|
||||
$this->createUrl('create'),
|
||||
array('class' => 'btn')
|
||||
); ?>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="span4">
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn"><i class="icon-th-large"></i> </button>
|
||||
<button class="btn"><i class="icon-th"></i> </button>
|
||||
<button class="btn active"><i class="icon-th-list"></i> </button>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<?php echo $gridView; ?>
|
||||
<?php echo $gridView; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div role="grid" class="dataTables_wrapper form-inline" id="dt_gal_wrapper">
|
||||
<div class="row"><div class="span6"><div class="dt_actions">
|
||||
<div class="btn-group">
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">Action <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a data-tableid="dt_gal" class="delete_rows_dt" href="#"><i class="icon-trash"></i> Delete</a></li>
|
||||
<li><a href="javascript:void(0)">Lorem ipsum</a></li>
|
||||
<li><a href="javascript:void(0)">Lorem ipsum</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dt_gal_length" class="dataTables_length">
|
||||
<label>Show <select name="dt_gal_length" size="1" aria-controls="dt_gal">
|
||||
<option value="10" selected="selected">10</option><option value="25">25</option>
|
||||
<option value="50">50</option><option value="100">100</option></select> entries</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<div class="dataTables_filter" id="dt_gal_filter">
|
||||
<label>Search: <input type="text" aria-controls="dt_gal"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="dt_gal" class="table table-bordered table-striped table_vam dataTable" aria-describedby="dt_gal_info">
|
||||
<thead>
|
||||
<tr role="row"><th class="table_checkbox sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 13px;" aria-label=""><input type="checkbox" data-tableid="dt_gal" class="select_rows" name="select_rows"></th><th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 60px;" aria-label="Image">Image</th><th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="dt_gal" rowspan="1" colspan="1" style="width: 484px;" aria-sort="ascending" aria-label="Name: activate to sort column descending">Name</th><th class="sorting" role="columnheader" tabindex="0" aria-controls="dt_gal" rowspan="1" colspan="1" style="width: 195px;" aria-label="Size: activate to sort column ascending">Size</th><th class="sorting" role="columnheader" tabindex="0" aria-controls="dt_gal" rowspan="1" colspan="1" style="width: 269px;" aria-label="Date: activate to sort column ascending">Date</th><th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 255px;" aria-label="Actions">Actions</th></tr>
|
||||
</thead>
|
||||
|
||||
<tbody role="alert" aria-live="polite" aria-relevant="all"><tr class="odd">
|
||||
<td class=" "><input type="checkbox" class="row_sel" name="row_sel"></td>
|
||||
<td style="width:60px" class=" ">
|
||||
<a class="cbox_single thumbnail cboxElement" title="Image 10" href="gallery/Image10.jpg">
|
||||
<img style="height:50px;width:50px" src="gallery/Image10_tn.jpg" alt="">
|
||||
</a>
|
||||
</td>
|
||||
<td class=" sorting_1">Lorem ipsum dolor sit<br><small>Image10.jpg</small></td>
|
||||
<td class=" ">200 KB</td>
|
||||
<td class=" ">28/06/2012</td>
|
||||
<td class=" ">
|
||||
<a title="Edit" class="sepV_a" href="#"><i class="icon-pencil"></i></a>
|
||||
<a title="View" class="sepV_a" href="#"><i class="icon-eye-open"></i></a>
|
||||
<a title="Delete" href="#"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr><tr class="even">
|
||||
<td class=" "><input type="checkbox" class="row_sel" name="row_sel"></td>
|
||||
<td style="width:60px" class=" ">
|
||||
<a class="cbox_single thumbnail cboxElement" title="Image 11" href="gallery/Image11.jpg">
|
||||
<img style="height:50px;width:50px" src="gallery/Image11_tn.jpg" alt="">
|
||||
</a>
|
||||
</td>
|
||||
<td class=" sorting_1">Lorem ipsum dolor sit<br><small>Image11.jpg</small></td>
|
||||
<td class=" ">210 KB</td>
|
||||
<td class=" ">27/06/2012</td>
|
||||
<td class=" ">
|
||||
<a title="Edit" class="sepV_a" href="#"><i class="icon-pencil"></i></a>
|
||||
<a title="View" class="sepV_a" href="#"><i class="icon-eye-open"></i></a>
|
||||
<a title="Delete" href="#"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr><tr class="odd">
|
||||
<td class=" "><input type="checkbox" class="row_sel" name="row_sel"></td>
|
||||
<td style="width:60px" class=" ">
|
||||
<a class="cbox_single thumbnail cboxElement" title="Image 12" href="gallery/Image12.jpg">
|
||||
<img style="height:50px;width:50px" src="gallery/Image12_tn.jpg" alt="">
|
||||
</a>
|
||||
</td>
|
||||
<td class=" sorting_1">Lorem ipsum dolor sit<br><small>Image12.jpg</small></td>
|
||||
<td class=" ">360 KB</td>
|
||||
<td class=" ">25/06/2012</td>
|
||||
<td class=" ">
|
||||
<a title="Edit" class="sepV_a" href="#"><i class="icon-pencil"></i></a>
|
||||
<a title="View" class="sepV_a" href="#"><i class="icon-eye-open"></i></a>
|
||||
<a title="Delete" href="#"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr><tr class="even">
|
||||
<td class=" "><input type="checkbox" class="row_sel" name="row_sel"></td>
|
||||
<td style="width:60px" class=" ">
|
||||
<a class="cbox_single thumbnail cboxElement" title="Image 13" href="gallery/Image13.jpg">
|
||||
<img style="height:50px;width:50px" src="gallery/Image13_tn.jpg" alt="">
|
||||
</a>
|
||||
</td>
|
||||
<td class=" sorting_1">Lorem ipsum dolor sit<br><small>Image13.jpg</small></td>
|
||||
<td class=" ">215 KB</td>
|
||||
<td class=" ">24/06/2012</td>
|
||||
<td class=" ">
|
||||
<a title="Edit" class="sepV_a" href="#"><i class="icon-pencil"></i></a>
|
||||
<a title="View" class="sepV_a" href="#"><i class="icon-eye-open"></i></a>
|
||||
<a title="Delete" href="#"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr><tr class="odd">
|
||||
<td class=" "><input type="checkbox" class="row_sel" name="row_sel"></td>
|
||||
<td style="width:60px" class=" ">
|
||||
<a class="cbox_single thumbnail cboxElement" title="Image 14" href="gallery/Image14.jpg">
|
||||
<img style="height:50px;width:50px" src="gallery/Image14_tn.jpg" alt="">
|
||||
</a>
|
||||
</td>
|
||||
<td class=" sorting_1">Lorem ipsum dolor sit<br><small>Image14.jpg</small></td>
|
||||
<td class=" ">650 KB</td>
|
||||
<td class=" ">24/06/2012</td>
|
||||
<td class=" ">
|
||||
<a title="Edit" class="sepV_a" href="#"><i class="icon-pencil"></i></a>
|
||||
<a title="View" class="sepV_a" href="#"><i class="icon-eye-open"></i></a>
|
||||
<a title="Delete" href="#"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr><tr class="even">
|
||||
<td class=" "><input type="checkbox" class="row_sel" name="row_sel"></td>
|
||||
<td style="width:60px" class=" ">
|
||||
<a class="cbox_single thumbnail cboxElement" title="Image 15" href="gallery/Image15.jpg">
|
||||
<img style="height:50px;width:50px" src="gallery/Image15_tn.jpg" alt="">
|
||||
</a>
|
||||
</td>
|
||||
<td class=" sorting_1">Lorem ipsum dolor sit<br><small>Image15.jpg</small></td>
|
||||
<td class=" ">428 KB</td>
|
||||
<td class=" ">23/06/2012</td>
|
||||
<td class=" ">
|
||||
<a title="Edit" class="sepV_a" href="#"><i class="icon-pencil"></i></a>
|
||||
<a title="View" class="sepV_a" href="#"><i class="icon-eye-open"></i></a>
|
||||
<a title="Delete" href="#"><i class="icon-trash"></i></a>
|
||||
</td>
|
||||
</tr></tbody></table>
|
||||
<div class="row">
|
||||
<div class="span6">
|
||||
<div class="dataTables_info" id="dt_gal_info">Showing 1 to 6 of 6 entries</div>
|
||||
|
||||
</div>
|
||||
<div class="span6">
|
||||
<div class="dataTables_paginate paging_bootstrap pagination">
|
||||
<ul>
|
||||
<li class="prev disabled"><a href="#">< Previous</a></li>
|
||||
<li class="active"><a href="#">1</a></li><li class="next disabled"><a href="#">Next > </a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -14,11 +14,6 @@
|
||||
|
||||
?>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<h3 class="heading"><?php echo Yii::t('profind', 'BD Candidatos'); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->renderPartial('_grid', array('candidatos' => $candidatos)); ?>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user