From 723c1aa190556d397a9eb80c8983b38520b9493d Mon Sep 17 00:00:00 2001 From: david Date: Mon, 29 Oct 2012 17:12:01 +0000 Subject: [PATCH] - 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 --- www/images/candidate_photo.jpg | Bin 0 -> 12198 bytes www/protected/config/mode_development.php | 2 + .../controllers/CandidatoController.php | 295 +++++++++--------- www/protected/helpers/TimeHelper.php | 274 ++++++++++++++++ .../m121014_170834_tbl_estados_candidatos.php | 1 + www/protected/models/Candidato.php | 281 +++++++---------- www/protected/models/EstadoCandidato.php | 90 ++++++ www/themes/profind/css/azul.css | 5 +- www/themes/profind/css/profind.css | 2 +- www/themes/profind/views/candidato/_grid.php | 264 ++++------------ www/themes/profind/views/candidato/index.php | 5 - 11 files changed, 686 insertions(+), 533 deletions(-) create mode 100644 www/images/candidate_photo.jpg create mode 100644 www/protected/helpers/TimeHelper.php create mode 100644 www/protected/models/EstadoCandidato.php diff --git a/www/images/candidate_photo.jpg b/www/images/candidate_photo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..af73630cbfbc4bc20ecf8cd146e052756a443a21 GIT binary patch literal 12198 zcmeG?30PBCvo{37Du{yn5(9|PKytGuipVOcxBvmfiVevHq9K7KEP{1GtChA=aI3bi zprTNDh_=5=Yh6&R{asK*v@W35;#OAIYTn$N1QOg{-}~P8z3+P-zcV>!&di*dIdje# zu19xScN6J7Av8P`Az6@+F!+b)8YwLy+43X=iHJbF5d^V8tVw+kGPFqW4)N;P0A~lH z7=HAfo{-eb-oBS(uilQ1y-c$se?|A`t}?#tRt&#nOsmZDVU^58+@wNJ1>g#=+hQ$&y62u(YtUrr21K9oR7F zOtu`+2ek^ACh1E{U&Nxg6mF>ubaQu&Jd()fsPoPTS$h;kwKTR$HQat%_beV6yfRuA za>t8Ew!rH2q9J`Qlt3A|nRmo?2S0BH4yJO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l95MmHu}E literal 0 HcmV?d00001 diff --git a/www/protected/config/mode_development.php b/www/protected/config/mode_development.php index 3bc54b2..ac55eda 100644 --- a/www/protected/config/mode_development.php +++ b/www/protected/config/mode_development.php @@ -35,6 +35,8 @@ $configSpecific = array( 'password' => '', 'charset' => 'utf8', 'tablePrefix' => '', + 'emulatePrepare' => true, + 'enableProfiling' => true, 'enableParamLogging' => true, ), 'mail' => array( diff --git a/www/protected/controllers/CandidatoController.php b/www/protected/controllers/CandidatoController.php index 3bd1ddd..5f6d405 100644 --- a/www/protected/controllers/CandidatoController.php +++ b/www/protected/controllers/CandidatoController.php @@ -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; + } + } + } ?> \ No newline at end of file diff --git a/www/protected/helpers/TimeHelper.php b/www/protected/helpers/TimeHelper.php new file mode 100644 index 0000000..e0c0d55 --- /dev/null +++ b/www/protected/helpers/TimeHelper.php @@ -0,0 +1,274 @@ +strtotime-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; + } + +} \ No newline at end of file diff --git a/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php b/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php index d78934a..e2cd172 100644 --- a/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php +++ b/www/protected/migrations/m121014_170834_tbl_estados_candidatos.php @@ -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'); } diff --git a/www/protected/models/Candidato.php b/www/protected/models/Candidato.php index bb6ed14..4d8e1e2 100644 --- a/www/protected/models/Candidato.php +++ b/www/protected/models/Candidato.php @@ -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; } - + } ?> \ No newline at end of file diff --git a/www/protected/models/EstadoCandidato.php b/www/protected/models/EstadoCandidato.php new file mode 100644 index 0000000..507428b --- /dev/null +++ b/www/protected/models/EstadoCandidato.php @@ -0,0 +1,90 @@ + 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, + )); + } + +} \ No newline at end of file diff --git a/www/themes/profind/css/azul.css b/www/themes/profind/css/azul.css index d86b1b8..1f69e79 100644 --- a/www/themes/profind/css/azul.css +++ b/www/themes/profind/css/azul.css @@ -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} diff --git a/www/themes/profind/css/profind.css b/www/themes/profind/css/profind.css index 4c98d43..51afece 100644 --- a/www/themes/profind/css/profind.css +++ b/www/themes/profind/css/profind.css @@ -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 */ diff --git a/www/themes/profind/views/candidato/_grid.php b/www/themes/profind/views/candidato/_grid.php index 98223af..a217702 100644 --- a/www/themes/profind/views/candidato/_grid.php +++ b/www/themes/profind/views/candidato/_grid.php @@ -1,56 +1,60 @@ -clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/datatables/js/jquery.dataTables.min.js', CClientScript::POS_END); ?> -clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/datatables/extras/Scroller/media/js/Scroller.min.js', CClientScript::POS_END); ?> - clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/grid.css'); ?> -clientScript->registerScript('init_grid', ' - $(document).ready(function() { - - $row = $("
"); - $row.appendTo("#candidato-grid"); - - $column1 = $("
"); - $column2 = $("
"); - $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>>", - }); - });' -); -?> - 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); ?>
-
- +

+
+
+
+ 'icon-plus'), '') . ' ' . Yii::t('profind', 'Nuevo candidato'), + $this->createUrl('create'), + array('class' => 'btn') + ); ?> +
+
+
-
-
-
-
- +
- - -
-
-
-
-
- - -
-
-
- -
-
-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ImageNameSizeDateActions
- - - - Lorem ipsum dolor sit
Image10.jpg
200 KB28/06/2012 - - - -
- - - - Lorem ipsum dolor sit
Image11.jpg
210 KB27/06/2012 - - - -
- - - - Lorem ipsum dolor sit
Image12.jpg
360 KB25/06/2012 - - - -
- - - - Lorem ipsum dolor sit
Image13.jpg
215 KB24/06/2012 - - - -
- - - - Lorem ipsum dolor sit
Image14.jpg
650 KB24/06/2012 - - - -
- - - - Lorem ipsum dolor sit
Image15.jpg
428 KB23/06/2012 - - - -
-
-
-
Showing 1 to 6 of 6 entries
- -
-
- -
-
-
- -
-
\ No newline at end of file diff --git a/www/themes/profind/views/candidato/index.php b/www/themes/profind/views/candidato/index.php index c33f081..6277dbd 100644 --- a/www/themes/profind/views/candidato/index.php +++ b/www/themes/profind/views/candidato/index.php @@ -14,11 +14,6 @@ ?> -
-
-

-
-
renderPartial('_grid', array('candidatos' => $candidatos)); ?>