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 widget('zii.widgets.jui.CJuiDatePicker', array( 'name' => 'CandidatoDocumento[{0}][fecha]', - 'value' => date('dd/mm/yy', time()), + 'value' => date('d/m/Y', time()), 'language' => 'es', 'options' => array('showAnim' => 'fold', 'dateFormat' => 'dd/mm/yy'), 'htmlOptions' => array('class' => 'span12 datepicker'), diff --git a/www/themes/profind/views/candidato/_form.php b/www/themes/profind/views/candidato/_form.php index ccaef37..8feb5c3 100644 --- a/www/themes/profind/views/candidato/_form.php +++ b/www/themes/profind/views/candidato/_form.php @@ -190,6 +190,22 @@ $form = $this->beginWidget('CActiveForm', array(
+
+ +
+ findAll(),'id', 'descripcion'); + echo $form->dropDownList( + $candidato, + 'id_estado', + $lista, + array( + 'class'=>'mf', + )); + ?> +
+
+
diff --git a/www/themes/profind/views/candidato/_grid.php b/www/themes/profind/views/candidato/_grid.php index 18ec79c..1a4a7cf 100644 --- a/www/themes/profind/views/candidato/_grid.php +++ b/www/themes/profind/views/candidato/_grid.php @@ -14,7 +14,7 @@ $columnas = array( ), array( 'type' => 'html', - 'name' => 'descripcionEstado', + 'name' => 'id_estado', 'value' => 'CHtml::encode($data->estado->descripcion);', 'filter' => CHtml::listData(EstadoCandidato::model()->findAll(), 'id', 'descripcion'), 'headerHtmlOptions' => array( @@ -59,9 +59,6 @@ $columnas = array( ), ); - - - $gridView = $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'candidato-grid', 'dataProvider' => $candidatos->search(), @@ -81,8 +78,18 @@ $gridView = $this->widget('zii.widgets.grid.CGridView', array( 'hiddenPageCssClass' => 'disabled', ), ), true); + + +Yii::app()->clientScript->registerScript('search', " +$('.search-button').click(function(){ + $('.search-form').toggle(); + return false; +}); +"); ?> + +

@@ -93,14 +100,29 @@ $gridView = $this->widget('zii.widgets.grid.CGridView', array( $this->createUrl('create'), array('class' => 'btn') ); ?> - 'icon-filter'), '') . ' ' . Yii::t('profind', 'Filtro'), '', + 'icon-filter'), '') . ' ' . Yii::t('profind', 'Filtro'), '', +// array( +// 'onclick' => '$("tr.filters").toggle(); $(this).toggleClass("active");', +// 'class' => 'btn active') +// ); + ?> + '$("tr.filters").toggle(); $(this).toggleClass("active");', - 'class' => 'btn active') - ); ?> + 'onclick' => '$(".search-form").toggle(); $(this).toggleClass("active");$("tr.filters").toggle();', + 'class' => 'btn') + ); ?>
+ + +
diff --git a/www/themes/profind/views/search/search.php b/www/themes/profind/views/search/search.php index d3f2c67..bf974fc 100644 --- a/www/themes/profind/views/search/search.php +++ b/www/themes/profind/views/search/search.php @@ -1,11 +1,14 @@ pageTitle = Yii::app()->name . ' - ' . Yii::t('profind', 'Resultados de la búsqueda'); -$this->breadcrumbs = array( - Yii::t('profind', 'Resultados de la búsqueda') -); + /** + * @var $this SearchController + */ + $this->pageTitle = Yii::app()->name . ' - ' . Yii::t('profind', 'Resultados de la búsqueda'); + $this->breadcrumbs = array( + Yii::t('profind', 'Resultados de la búsqueda') + ); + + // Sidebar + // echo $this->renderPartial('//sidebars/_search', array('formulario' => $formulario)); ?> @@ -16,7 +19,7 @@ $this->breadcrumbs = array(
-

+

@@ -39,7 +42,9 @@ $this->breadcrumbs = array( ?>
- +
+        
+        
@@ -55,7 +60,8 @@ $this->breadcrumbs = array(

highlightMatches(CHtml::encode($candidato->nombreCompleto)), + //$query->htmlFragmentHighlightMatches(CHtml::encode($candidato->nombreCompleto)), + CHtml::encode($candidato->nombreCompleto), array('candidato/update', 'id' => $candidato->id), array('class' => 'sepV_a') ); @@ -63,6 +69,13 @@ $this->breadcrumbs = array( estado->descripcion; ?>

+ + htmlFragmentHighlightMatches(CHtml::encode($results[$i]->email))); ?> + email)) : ?> + Email: + email)); ?> + +