diff --git a/www/protected/controllers/SearchController.php b/www/protected/controllers/SearchController.php index e7edf83..8ff11f5 100644 --- a/www/protected/controllers/SearchController.php +++ b/www/protected/controllers/SearchController.php @@ -27,6 +27,9 @@ class SearchController extends Controller { $doc->addField(Zend_Search_Lucene_Field::Text('nombre', CHtml::encode($candidato->nombre), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::Text('apellidos', CHtml::encode($candidato->apellidos), 'utf-8')); $doc->addField(Zend_Search_Lucene_Field::Text('n_identificacion', CHtml::encode($candidato->n_identificacion), 'utf-8')); + $doc->addField(Zend_Search_Lucene_Field::Text('email', CHtml::encode($candidato->email), 'utf-8')); + $doc->addField(Zend_Search_Lucene_Field::Text('estado', CHtml::encode($candidato->estado->descripcion), 'utf-8')); + echo "\tAdding: " . $candidato->id . "\n"; $index->addDocument($doc); } @@ -35,28 +38,55 @@ class SearchController extends Controller { } public function actionSearch() { + Yii::trace('Búsqueda', 'application.controllers.SearchController'); + + $term = ''; $results = array(); - - if (($term = Yii::app()->getRequest()->getParam('q', null)) !== null) { - if (str_word_count($term) == 1) $term .= '*'; - $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles)); - - try { - $results = $index->find($term); - $query = Zend_Search_Lucene_Search_QueryParser::parse($term); - } catch (Exception $e) { - if ($e instanceof Zend_Search_Lucene_Exception) { - Yii::app()->user->setFlash('error', Yii::t('profind', 'Indique un término de búsqueda de al menos 3 caracteres')); + $query = NULL; + + $formulario = new FormularioSearch; + + if (isset($_POST['FormularioSearch'])) { + $formulario->attributes = $_POST['FormularioSearch']; + if ($formulario->validate()) { + foreach ($formulario->attributes as $nombre => $valor) { + if (strlen($valor) > 0) { + if (strlen($term) > 0) + $term .= ' AND '; + + if (in_array($nombre, array('estado'))) { + $antes = '"'; + $despues = '"'; + } else { + $antes = ''; + $despues = '*'; + } + $term .= $nombre . ':' . $antes . $valor . $despues; + } } } - - $pages = new CPagination(count($results)); - $currentPage = Yii::app()->getRequest()->getQuery('page', 1); - $pages->pageSize = 10; - - $this->render('search', compact('results', 'term', 'query', 'pages', 'currentPage')); + } elseif (($term = Yii::app()->getRequest()->getParam('keyword', null)) !== null) { + if (str_word_count($term, 0) < 2) + $term .= '*'; } else throw new CHttpException(400, Yii::t('profind', 'Petición no válida')); + + $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles)); + + try { + $results = $index->find($term); + $query = Zend_Search_Lucene_Search_QueryParser::parse($term); + } catch (Exception $e) { + if ($e instanceof Zend_Search_Lucene_Exception) { + Yii::app()->user->setFlash('error', Yii::t('profind', 'Indique un término de búsqueda de al menos 3 caracteres')); + } + } + + $pages = new CPagination(count($results)); + $currentPage = Yii::app()->getRequest()->getQuery('page', 1); + $pages->pageSize = 10; + + $this->render('search', compact('formulario', 'results', 'term', 'query', 'pages', 'currentPage')); } } diff --git a/www/protected/extensions/SearchBlock/SearchBlock.php b/www/protected/extensions/SearchBlock/SearchBlock.php index 939eb17..c20bd6c 100644 --- a/www/protected/extensions/SearchBlock/SearchBlock.php +++ b/www/protected/extensions/SearchBlock/SearchBlock.php @@ -7,7 +7,7 @@ class SearchBlock extends CPortlet { protected function renderContent() { echo CHtml::beginForm(array('search/search'), 'get', array('class' => 'input-append')); - echo CHtml::textField('q', '', array( + echo CHtml::textField('keyword', '', array( 'placeholder' => Yii::t('profind', 'Buscar...'), 'class' => 'search_query input-medium') );?> diff --git a/www/protected/models/Candidato.php b/www/protected/models/Candidato.php index 8fe137b..e364343 100644 --- a/www/protected/models/Candidato.php +++ b/www/protected/models/Candidato.php @@ -51,8 +51,14 @@ class Candidato extends CActiveRecord { public $ficheroFotografia; public $fotografia; public $descripcionEstado; + public $salario_ini_search; + public $salario_fin_search; + public $idiomas_search; + public $titulaciones_search; + public $perfiles_search; private $_nombreCompleto; + /** @@ -141,6 +147,8 @@ class Candidato extends CActiveRecord { // Please remove those attributes that should not be searched. array('id, id_estado, estado, descripcionEstado, nombre, apellidos, nombreCompleto, n_identificacion, email, telefono_fijo, + salario_ini_search, salario_fin_search, idiomas_search, titulaciones_search, + perfiles_search, telefono_movil, sexo, fecha_nacimiento, lugar_nacimiento, localidad, carnet_conducir, vehiculo_propio, observaciones, salario_minimo, salario_maximo, procedencia, @@ -243,10 +251,11 @@ class Candidato extends CActiveRecord { // should not be searched. $criteria = new CDbCriteria; + $criteria->with = array(); if ($this->descripcionEstado) { $criteria->together = true; - $criteria->with = array('estado'); + array_push($criteria->with, 'estado'); $criteria->compare('estado.id', $this->id_estado, true); $criteria->compare('estado.descripcion', $this->descripcionEstado, true); } @@ -291,7 +300,50 @@ class Candidato extends CActiveRecord { $criteria->compare('t.modified_time', $this->modified_time, true); $criteria->compare('t.deleted_time', $this->deleted_time, true); + if ($this->salario_ini_search != '') + $criteria->addCondition(('t.salario_minimo >='. $this->salario_ini_search)); + if ($this->salario_fin_search != '') + $criteria->addCondition(('t.salario_minimo <='. $this->salario_fin_search)); + if (($this->idiomas_search != '') && ($this->idiomas_search[0] != '')){ + $criteria->together = true; + array_push($criteria->with, 'idiomas'); + $cadena = ''; + foreach ($this->idiomas_search as $idioma_search){ + if ($cadena != '') + $cadena = $cadena . ','; + $cadena = $cadena . "'" . $idioma_search . "'"; + } + $criteria->addCondition(('idiomas.idioma in ('. $cadena . ')')); + } + + if (($this->titulaciones_search != '') && ($this->titulaciones_search[0] != '')){ + $criteria->together = true; + array_push($criteria->with, 'titulaciones'); + $cadena = ''; + foreach ($this->titulaciones_search as $titulacion_search){ + if ($cadena != '') + $cadena = $cadena . ','; + $cadena = $cadena . "'" . $titulacion_search . "'"; + } + $criteria->addCondition(('titulaciones.titulacion in ('. $cadena . ')')); + } + + if (($this->perfiles_search != '') && ($this->perfiles_search[0] != '')){ + $criteria->together = true; + array_push($criteria->with, 'capacidadesProfesionales'); + $cadena = ''; + foreach ($this->perfiles_search as $perfil_search){ + if ($cadena != '') + $cadena = $cadena . ','; + $cadena = $cadena . "'" . $perfil_search . "'"; + } + $criteria->addCondition(('capacidadesProfesionales.id_capacidad in ('. $cadena . ')')); + } + + + + $sort = new CSort(); $sort->modelClass = 'Candidato'; $sort->attributes = array( diff --git a/www/protected/models/CandidatoDocumento.php b/www/protected/models/CandidatoDocumento.php index e3ccb42..1b23680 100644 --- a/www/protected/models/CandidatoDocumento.php +++ b/www/protected/models/CandidatoDocumento.php @@ -72,6 +72,8 @@ class CandidatoDocumento extends CActiveRecord { array('id_candidato', 'numerical', 'integerOnly' => true), array('titulo, nombre_fichero', 'length', 'max' => 255), array('titulo, nombre_fichero, fecha', 'safe'), + +// array('fecha', 'date', 'format' => 'dd/mm/yyyy'), array('ficheroDocumento', 'file', //'types' => 'pdf, doc, docx, txt, odt', @@ -132,7 +134,18 @@ class CandidatoDocumento extends CActiveRecord { )); } + protected function beforeSave() { +// $this->fecha = date('Y-m-d', CDateTimeParser::parse($this->fecha, Yii::app()->locale->dateFormat)); + return parent::beforeSave(); + } + + protected function afterFind() { +// $this->fecha = Yii::app()->dateFormatter->formatDateTime(CDateTimeParser::parse($this->fecha, 'yyyy-MM-dd'), 'medium', null); + return parent::afterFind(); + } + protected function afterSave() { +// $this->fecha = Yii::app()->dateFormatter->formatDateTime(CDateTimeParser::parse($this->fecha, 'yyyy-MM-dd'), 'medium', null); if ($this->isNewRecord) $this->guardarFicheroDocumento(); return parent::afterSave(); @@ -145,7 +158,7 @@ class CandidatoDocumento extends CActiveRecord { protected function afterConstruct() { // Valores por defecto - $this->fecha = date('Y-m-d H:i:s', time()); +// $this->fecha = date('yyyy-mm-dd', time()); return parent::afterConstruct(); } diff --git a/www/themes/profind/css/profind.css b/www/themes/profind/css/profind.css index 1e0348b..815aef9 100644 --- a/www/themes/profind/css/profind.css +++ b/www/themes/profind/css/profind.css @@ -1704,7 +1704,7 @@ label, input, button, select, textarea, select, textarea, input[type="text"], in } .sidebar_filters { - padding:30px 30px 20px; + padding:0 30px 20px; } .sidebar_filters h3 { diff --git a/www/themes/profind/views/candidato/__documentos.php b/www/themes/profind/views/candidato/__documentos.php index 8ed7bff..e2e7453 100644 --- a/www/themes/profind/views/candidato/__documentos.php +++ b/www/themes/profind/views/candidato/__documentos.php @@ -34,7 +34,7 @@ Yii::app()->clientScript->registerScript('js_datepicker', $js_datepicker, CClien 'model' => $documento, 'attribute' => "[$i]fecha", 'language' => 'es', - 'options' => array('showAnim' => 'fold', 'dateFormat' => 'dd/mm/yy'), + 'options' => array('showAnim' => 'fold', 'dateFormat' => 'dd/mm/yyyy'), 'htmlOptions' => array('class' => 'span12'), )); ?> @@ -77,7 +77,7 @@ Yii::app()->clientScript->registerScript('js_datepicker', $js_datepicker, CClien
+ +
+ + htmlFragmentHighlightMatches(CHtml::encode($results[$i]->email))); ?> + email)) : ?> + Email: + email)); ?> + +