autocomplete, advanced search doesn't use combobox anymore
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 9 Apr 2007 22:25:17 +0000 (22:25 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 9 Apr 2007 22:25:17 +0000 (22:25 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1673 839d8a87-29fc-0310-9880-83ba4fa771e5

modules/search.php
templates/search/adv.form.tpl
templates/search/adv.grade.form.tpl
templates/search/adv.list.form.tpl [moved from templates/search/adv.region.form.tpl with 87% similarity]

index 7230aa7..651fe8f 100644 (file)
@@ -26,8 +26,6 @@ class SearchModule extends PLModule
         return array(
             'search'     => $this->make_hook('quick', AUTH_PUBLIC),
             'search/adv' => $this->make_hook('advanced', AUTH_COOKIE),
-            'search/ajax/region'  => $this->make_hook('region', AUTH_COOKIE, 'user', NO_AUTH),
-            'search/ajax/grade'   => $this->make_hook('grade',  AUTH_COOKIE, 'user', NO_AUTH),
             'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC),
             'search/autocomplete' => $this->make_hook('autocomplete', AUTH_COOKIE, 'user', NO_AUTH),
             'search/list' => $this->make_hook('list', AUTH_COOKIE, 'user', NO_AUTH),
@@ -52,9 +50,6 @@ class SearchModule extends PLModule
         global $page;
 
         $page->assign('formulaire',1);
-        $page->assign('choix_schools',
-                      XDB::iterator('SELECT id,text FROM applis_def ORDER BY text'));
-        $this->get_diplomas();
     }
 
     function get_diplomas($school = null)
@@ -109,9 +104,9 @@ class SearchModule extends PLModule
                 new ThrowError('il n\'existe personne correspondant à ces critères dans la base !');
             }
         } else {
-            $res = XDB::query("SELECT  MIN(diminutif), MAX(diminutif)
-                                 FROM  groupex.asso
-                                WHERE  cat = 'Promotions'");
+            $res = XDB::query("SELECT  MIN(`diminutif`), MAX(`diminutif`)
+                                 FROM  `groupex`.`asso`
+                                WHERE  `cat` = 'Promotions'");
             list($min, $max) = $res->fetchOneRow();
             $page->assign('promo_min', $min);
             $page->assign('promo_max', $max); 
@@ -159,23 +154,6 @@ class SearchModule extends PLModule
         $page->register_modifier('display_lines', 'display_lines');
     }
 
-    function handler_region(&$page, $country = null)
-    {
-        header('Content-Type: text/html; charset="UTF-8"');
-        require_once("geoloc.inc.php");
-        $page->ChangeTpl('search/adv.region.form.tpl', NO_SKIN);
-        $page->assign('region', "");
-        $page->assign('country', $country);
-    }
-
-    function handler_grade(&$page, $school = null)
-    {
-        header('Content-Type: text/html; charset="UTF-8"');
-        $page->ChangeTpl('search/adv.grade.form.tpl', NO_SKIN);
-        $page->assign('grade', '');
-        $this->get_diplomas($school);
-    }
-
     function handler_autocomplete(&$page, $type = null)
     {
         // Autocompletion : according to type required, return
@@ -185,11 +163,26 @@ class SearchModule extends PLModule
         //   result2|nb2
         //   ...
         header('Content-Type: text/plain; charset="UTF-8"');
-        $q = preg_replace(array('/\*+$/','/\*/'),array('','.*'),$_REQUEST['q']);
+        $q = preg_replace(
+                                               array(
+                                                               '/\*+$/', // always look for $q*
+                                                               '/([\^\$\[\]])/', // escape special regexp char
+                                                               '/\*/'), // replace joker by regexp joker
+                                               array(
+                                                               '',
+                                                               '\\\\\1',
+                                                               '.*'),
+                                               $_REQUEST['q']);
         if (!$q) exit();
 
                                // try to look in cached results        
-        $cache = XDB::query('SELECT result FROM search_autocomplete WHERE name = {?} AND query = {?} AND generated > NOW() - INTERVAL 1 DAY',
+        $cache = XDB::query('
+                                               SELECT `result`
+                                               FROM `search_autocomplete`
+                                               WHERE
+                                                               `name` = {?} AND
+                                                               `query` = {?} AND
+                                                               `generated` > NOW() - INTERVAL 1 DAY',
                        $type, $q);
         if ($res = $cache->fetchOneCell()) {
                        echo $res;
@@ -197,79 +190,139 @@ class SearchModule extends PLModule
         }
         
         // default search
-        $unique = 'user_id';
-        $db = 'auth_user_md5';
+        $unique = '`user_id`';
+        $db = '`auth_user_md5`';
         $realid = false;
         $beginwith = true;
+        $field2 = false;
+        $qsearch = $q;
         
         switch ($type) {
         case 'binetTxt':
-                                               $db = 'binets_def INNER JOIN binets_ins ON(binets_def.id = binets_ins.binet_id)';
-                                               $field='binets_def.text';
+                                               $db = '`binets_def` INNER JOIN
+                                                               `binets_ins` ON(`binets_def`.`id` = `binets_ins`.`binet_id`)';
+                                               $field='`binets_def`.`text`';
                                                if (strlen($q) > 2)
                                                                $beginwith = false;
-                                               $realid = 'binets_def.id';
+                                               $realid = '`binets_def`.`id`';
                                                break;
-        case 'city': $db = 'geoloc_city INNER JOIN adresses ON(geoloc_city.id = adresses.cityid)'; $unique='uid'; $field='geoloc_city.name'; break;
-        case 'entreprise': $db = 'entreprises'; $field = 'entreprise'; $unique='uid'; break;
-        case 'firstname':
-                                               $field = 'prenom';
+        case 'city':
+                                               $db = '`geoloc_city` INNER JOIN
+                                                               `adresses` ON(`geoloc_city`.`id` = `adresses`.`cityid`)';
+                                               $unique='`uid`';
+                                               $field='`geoloc_city`.`name`';
+                                               break;
+        case 'countryTxt':
+                                               $db = '`geoloc_pays` INNER JOIN
+                                                               `adresses` ON(`geoloc_pays`.`a2` = `adresses`.`country`)';
+                                               $unique='`uid`';
+                                               $field = '`geoloc_pays`.`pays`';
+                                               $field2 = '`geoloc_pays`.`country`';
+                                               $realid='`geoloc_pays`.`a2`';
+                                               break;
+        case 'entreprise':
+                                               $db = '`entreprises`';
+                                               $field = '`entreprise`';
+                                               $unique='`uid`';
+                                               break;
+        case '`firstname`':
+                                               $field = '`prenom`';
                                                $q = '(^|[ \\-])'.$q;
                                                $beginwith = false;
                                                break;
         case 'fonctionTxt':
-                       $db = 'fonctions_def INNER JOIN entreprises ON(entreprises.fonction = fonctions_def.id)';
-                       $field = 'fonction_fr';
-                       $unique = 'uid';
-                       $realid = 'fonctions_def.id';
+                       $db = '`fonctions_def` INNER JOIN
+                                                               `entreprises` ON(`entreprises`.`fonction` = `fonctions_def`.`id`)';
+                       $field = '`fonction_fr`';
+                       $unique = '`uid`';
+                       $realid = '`fonctions_def`.`id`';
+                                               $qsearch = '(^|[ /\\-])'.$q;
+                                               $beginwith = false;
                        break;
         case 'groupexTxt':
-                                               $db = 'groupesx_def INNER JOIN groupesx_ins ON(groupesx_def.id = groupesx_ins.gid)';
-                                               $field='groupesx_def.text';
+                                               $db = '`groupesx_def` INNER JOIN
+                                                               `groupesx_ins` ON(`groupesx_def`.`id` = `groupesx_ins`.`gid`)';
+                                               $field='`groupesx_def`.`text`';
                                                if (strlen($q) > 2)
                                                                $beginwith = false;
-                                               $realid = 'groupesx_def.id';
-                                               $unique = 'guid';
+                                               $realid = '`groupesx_def`.`id`';
+                                               $unique = '`guid`';
                                                break;
         case 'name':
-                                               $field = 'nom';
-                                               $q = '(^|[ \\-])'.$q;
+                                               $field = '`nom`';
+                                               $field2 = '`nom_usage`';
+                                               $qsearch = '(^|[ \\-])'.$q;
                                                $beginwith = false;
                                                break;
                case 'nationaliteTxt':
-                               $db = 'geoloc_pays INNER JOIN auth_user_md5 ON(geoloc_pays.a2 = auth_user_md5.nationalite)';
-                               $field = 'IF(geoloc_pays.nat=\'\', geoloc_pays.pays, geoloc_pays.nat)';
-                               $realid = 'geoloc_pays.a2';
+                               $db = '`geoloc_pays` INNER JOIN
+                                                               `auth_user_md5` ON(`geoloc_pays`.`a2` = `auth_user_md5`.`nationalite`)';
+                               $field = 'IF(`geoloc_pays`.`nat`=\'\',
+                                                               `geoloc_pays`.`pays`,
+                                                               `geoloc_pays`.`nat`)';
+                               $realid = '`geoloc_pays`.`a2`';
                                break;
-        case 'nickname': $field = 'profile_nick'; $db = 'auth_user_quick'; break;
-        case 'poste': $db = 'entreprises'; $field = 'poste'; $unique='uid'; break;
+        case 'nickname':
+                                               $field = '`profile_nick`';
+                                               $db = '`auth_user_quick`';
+                                               $qsearch = '(^|[ \\-])'.$q;
+                                               $beginwith = false;
+                                               break;
+        case 'poste':
+                                               $db = '`entreprises`';
+                                               $field = '`poste`';
+                                               $unique='`uid`';
+                                               break;
+                               case 'schoolTxt':
+                                               $db = '`applis_def` INNER JOIN
+                                                               `applis_ins` ON(`applis_def`.`id` = `applis_ins`.`aid`)';
+                                               $field='`applis_def`.`text`';
+                                               $unique = '`uid`';
+                                               $realid = '`applis_def`.`id`';
+                                               if (strlen($q) > 2)
+                                                               $beginwith = false;
+                                               break;
                case 'secteurTxt':
-                               $db = 'emploi_secteur INNER JOIN entreprises ON(entreprises.secteur = emploi_secteur.id)';
-                               $field = 'emploi_secteur.label';
-                               $realid = 'emploi_secteur.id';
-                               $unique = 'uid';
+                               $db = '`emploi_secteur` INNER JOIN
+                                                               `entreprises` ON(`entreprises`.`secteur` = `emploi_secteur`.`id`)';
+                               $field = '`emploi_secteur`.`label`';
+                               $realid = '`emploi_secteur`.`id`';
+                               $unique = '`uid`';
                                                $beginwith = false;
                                break;
                case 'sectionTxt':
-                               $db = 'sections INNER JOIN auth_user_md5 ON(auth_user_md5.section = sections.id)';
-                               $field = 'sections.text';
-                               $realid = 'sections.id';
+                               $db = '`sections` INNER JOIN 
+                                                               `auth_user_md5` ON(`auth_user_md5`.`section` = `sections`.`id`)';
+                               $field = '`sections`.`text`';
+                               $realid = '`sections`.`id`';
                                                $beginwith = false;
                                break;
         default: exit();
         }
 
+                               $field_select = $field;
+                               if ($field2) {
+                                               $field_select = 'IF('.$field.' REGEXP {?}, '.$field.', '.$field2.')';
+                               }
+                               
+                               if ($beginwith) {
+                                               $qsearch = '^'.$qsearch;
+                               }
         $list = XDB::iterator('
                                                SELECT
-                                                               '.$field.' AS field,
+                                                               '.$field_select.' AS field,
                                                                COUNT(DISTINCT '.$unique.') AS nb
                                                                '.($realid?(', '.$realid.' AS id'):'').'
                                                FROM '.$db.'
-                                               WHERE '.$field.' REGEXP {?}
-                                               GROUP BY '.$field.'
+                                               WHERE '.$field.' REGEXP {?}'.
+                                               ($field2?(' OR '.$field2.' REGEXP {?}'):'').'
+                                               GROUP BY '.$field_select.'
                                                ORDER BY nb DESC
                                                LIMIT 11',
-                                               ($beginwith?'^':'').$q);
+                                               $qsearch, 
+                                               $qsearch,
+                                               $qsearch,
+                                               $qsearch);
         $nbResults = 0;
         $res = "";
         while ($result = $list->next()) {
@@ -277,10 +330,17 @@ class SearchModule extends PLModule
             if ($nbResults == 11) {
                 $res .= '...|1'."\n";
             } else {
-                $res .= $result['field'].'|'.$result['nb'].(isset($result['id'])?('|'.$result['id']):'')."\n";
+                $res .= $result['field'].'|';
+                                                               $res .= $result['nb'];
+                                                               if (isset($result['id'])) {
+                                                                               $res  .= '|'.$result['id'];
+                                                               }
+                                                               $res .= "\n";
             }
         }
-        XDB::query('REPLACE INTO search_autocomplete VALUES ({?}, {?}, {?}, NOW())',
+        XDB::query('
+                                               REPLACE INTO `search_autocomplete`
+                                               VALUES ({?}, {?}, {?}, NOW())',
                        $type, $q, $res);
         echo $res;
         exit();
@@ -289,30 +349,55 @@ class SearchModule extends PLModule
     function handler_list(&$page, $type = null, $idVal = null)
     {
                // Give the list of all values possible of type and builds a select input for it
-                               $field = 'text';
-                               $id = 'id';
+                               $field = '`text`';
+                               $id = '`id`';
+                               $where = '';
+                               
                switch ($type) {
                case 'binet':
-                               $db = 'binets_def';
+                               $db = '`binets_def`';
+                               break;
+               case 'country':
+                               $db = '`geoloc_pays`';
+                               $field = '`pays`';
+                               $id = '`a2`';
+                       $page->assign('onchange', 'changeCountry(this.value)');
                                break;
                case 'fonction':
-                               $db = 'fonctions_def';
-                               $field = 'fonction_fr';
+                               $db = '`fonctions_def`';
+                               $field = '`fonction_fr`';
                                break;
+               case 'diploma':
+            header('Content-Type: text/xml; charset="UTF-8"');
+                   $this->get_diplomas();
+                   $page->changeTpl('search/adv.grade.form.tpl', NO_SKIN);
+                   return;
                case 'groupex':
-                               $db = 'groupesx_def';
+                               $db = '`groupesx_def`';
                                break;
                case 'nationalite':
-                               $db = 'geoloc_pays';
-                               $field = 'IF(nat=\'\', pays, nat)';
-                               $id = 'a2';
+                               $db = '`geoloc_pays`';
+                               $field = 'IF(`nat`=\'\', `pays`, `nat`)';
+                               $id = '`a2`';
+                               break;
+               case 'region':
+                   $db = '`geoloc_region`';
+                   $field = '`name`';
+            $id = '`region`'; 
+            if (isset($_REQUEST['country'])) {
+                $where .= ' WHERE `a2` = "'.$_REQUEST['country'].'"';
+            }
+                   break;
+               case 'school':
+                               $db = '`applis_def`';
+                       $page->assign('onchange', 'changeSchool(this.value)');
                                break;
                case 'section':
-                               $db = 'sections';
+                               $db = '`sections`';
                                break;
                case 'secteur':
-                               $db = 'emploi_secteur';
-                               $field = 'label';
+                               $db = '`emploi_secteur`';
+                               $field = '`label`';
                                break;
                default: exit();
                }
@@ -320,22 +405,17 @@ class SearchModule extends PLModule
                                header('Content-Type: text/plain; charset="UTF-8"');
                                $result = XDB::query('SELECT '.$field.' AS field FROM '.$db.' WHERE '.$id.' = {?} LIMIT 1',$idVal);
                                echo $result->fetchOneCell();
-               } else {
-                       header('Content-Type: text/xml; charset="UTF-8"');
-                               $list = XDB::iterator('
-                                               SELECT
-                                                               '.$field.' AS field,
-                                                               '.$id.' AS id
-                                               FROM '.$db.'
-                                               ORDER BY '.$field);
-                               echo '<select name="'.$type.'">';
-                               while ($result = $list->next()) {
-                                               echo '<option value="'.$result['id'].'">'.htmlspecialchars($result['field']).'</option>';
-                               }
-                               echo '</select>';
-                               }
-                                               
-               exit();
+                               exit();
+               }
+        header('Content-Type: text/xml; charset="UTF-8"');
+        $page->changeTpl('search/adv.list.form.tpl', NO_SKIN);
+        $page->assign('name', $type);
+               $page->assign('list', XDB::iterator('
+                               SELECT
+                                               '.$field.' AS field,
+                                               '.$id.' AS id
+                               FROM '.$db.$where.'
+                               ORDER BY '.$field));
     }
 }
 
index 76d289e..dbbb116 100644 (file)
 {javascript name="jquery.autocomplete"}
 <script type="text/javascript">{literal}
        // <!--
+       
+       // use same form to send to search or map
        function launch_form(url) {
          var f = document.getElementById('recherche');
          f.action = url;
          f.submit();
        }
+       
+       // display an autocomplete row : blabla (nb of found matches)
        function format_autocomplete(row) {
          if (row[1] == 1) {
            return row[0];
          }
          return row[0] + ' ('+ row[1] + ')';
        }
+       
+       // when changing country, open up region choice
+       function changeCountry(a2) {
+      $(".autocompleteTarget[@name='country']").attr('value',a2);
+         if (a2) {
+        $(".autocomplete[@name='countryTxt']").addClass('hidden_valid');
+        $("[@name='region']").parent().load('search/list/region/', { country:a2 }, function() {
+            if ($("select[@name='region']").children("option").size() > 1) {
+                   $("select[@name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}').show();
+               } else {
+                   $("select[@name='region']").attr('value', '').hide();
+               }
+        });
+         } else {
+        $(".autocomplete[@name='countryTxt']").removeClass('hidden_valid');
+           $("select[@name='region']").attr('value', '').hide();
+         }
+       }
+       
+       // when changing school, open diploma choice
+       function changeSchool(schoolId) {
+      $(".autocompleteTarget[@name='school']").attr('value',schoolId);
+         if (schoolId) {
+        $(".autocomplete[@name='schoolTxt']").addClass('hidden_valid');
+        $("[@name='diploma']").parent().load('search/list/diploma/', { school:schoolId }, function() {
+            if ($("select[@name='diploma']").children("option").size() > 1) {
+                   $("select[@name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
+               } else {
+                   $("select[@name='diploma']").attr('value', '').hide();
+               }
+        });
+         } else {
+        $(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
+           $("select[@name='diploma']").attr('value', '').hide();
+         }
+       }
+       
+       // when choosing autocomplete from list, must validate
        function select_autocomplete(name) {
          nameRealField = name.replace(/Txt$/, '');
+         // nothing to do if field is not a text field for a list
          if (nameRealField == name)
                return null;
+         // if changing country, might want to open region choice
+         if (nameRealField == 'country')
+               return function(i) {
+                 changeCountry(i.extra[1]);
+           }
+         if (nameRealField == 'school')
+               return function(i) {
+                 changeSchool(i.extra[1]);
+           }
+         // change field in list and display text field as valid
          return function(i) {
                nameRealField = this.field.replace(/Txt$/, '');
                $(".autocompleteTarget[@name='"+nameRealField+"']").attr('value',i.extra[1]);
                          width:$(this).width()});
            });
            $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
+           $(".autocomplete[@name='countryTxt']").change(function() { changeCountry(''); });
+           changeCountry({/literal}'{$smarty.request.country}'{literal});
+           $(".autocomplete[@name='schoolTxt']").change(function() { changeSchool(''); });
+           changeSchool({/literal}'{$smarty.request.school}'{literal});
            $(".autocompleteToSelect").each(function() {
                var fieldName = $(this).attr('href');
                $(this).attr('href','search/list/'+fieldName).click(function() {
         <select name="egal2">
           <option value="=" {if $smarty.request.egal2 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
           <option value="&gt;=" {if $smarty.request.egal2 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
-          <option value="&lt;=" {if $smarty.request.egal2 eq "&lt;="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
+          <option value="&lt;=" {if $smarty.request.egal2 neq "&gt;=" && $smarty.request.egal2 neq "="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
         </select>
         <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
       </td>
         <table>
           <tr>
             <td style="width:100px">
-              <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} />Indifférent
+              <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">Indifférent</label>
             </td>
             <td style="width:100px">
-              <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} />Homme
+              <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">Homme</label>
             </td>
             <td style="width:100px">
-              <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} />Femme
+              <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">Femme</label>
             </td>
           </tr>
         </table>
         <table>
           <tr>
             <td style="width:100px">
-              <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} />Indifférent
+              <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">Indifférent</label>
             </td>
             <td style="width:100px">
-              <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} />Inscrit
+              <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">Inscrit</label>
             </td>
             <td style="width:100px">
-              <input type="radio" name="subscriber" value="2" {if $smarty.request.subscriber eq 2}checked="checked"{/if} />Non inscrit
+              <input type="radio" name="subscriber" value="2" {if $smarty.request.subscriber eq 2}checked="checked"{/if} id="subscriber2"/><label for="subscriber2">Non inscrit</label>
             </td>
           </tr>
         </table>
         <table>
           <tr>
             <td style="width:100px">
-              <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} />Indifférent
+              <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">Indifférent</label>
             </td>
             <td style="width:100px">
-              <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} />Vivant
+              <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">Vivant</label>
             </td>
             <td style="width:100px">
-              <input type="radio" name="alive" value="2" {if $smarty.request.alive eq 2}checked="checked"{/if} />Décédé
+              <input type="radio" name="alive" value="2" {if $smarty.request.alive eq 2}checked="checked"{/if} id="alive2"/><label for="alive2">Décédé</label>
             </td>
           </tr>
         </table>
     <tr>
       <td>Pays</td>
       <td>
-        <select name="country" onchange="return Ajax.update_html('region', '{#globals.baseurl#}/search/ajax/region/' + this.value);">
-        {if $smarty.request.country}
-          {assign var="country" value=$smarty.request.country}
-        {else}
-          {assign var="country" value=""}
-        {/if}
-        {geoloc_country country=$country available=true}
-        </select>
+       <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"/>
+               <input name="country" class="autocompleteTarget" type="hidden" value="{$smarty.request.country}"/>
+               <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
       </td>
     </tr>
     <tr>
       <td>Région ou département</td>
-      <td id="region">
-        {if $smarty.request.region}
-          {assign var="region" value=$smarty.request.region}
-        {else}
-          {assign var="region" value=""}
-        {/if}
-        {include file="search/adv.region.form.tpl" country=$smarty.request.country}
+      <td>
+        <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
       </td>
     </tr>
     <tr>
@@ -256,8 +303,8 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
     </tr>
     <tr>
       <td colspan="2">
-        <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} />
-        chercher uniquement parmi les camarades se proposant comme référents
+        <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
+        <label for="only_referent">chercher uniquement parmi les camarades se proposant comme référents</label>
       </td>
     </tr>
     <tr>
@@ -298,20 +345,15 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
     <tr>
       <td>Formation</td>
       <td>
-        <select name="school" onchange="return Ajax.update_html('grade', '{#globals.baseurl#}/search/ajax/grade/' + this.value);">
-          <option value="0"></option>
-          {iterate item=cs from=$choix_schools}
-          <option value="{$cs.id}" {if $smarty.request.school eq $cs.id}selected="selected"{/if}>
-            {$cs.text|htmlspecialchars}
-          </option>
-          {/iterate}
-        </select>
+       <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"/>
+               <input name="school" class="autocompleteTarget" type="hidden" value="{$smarty.request.school}"/>
+               <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
       </td>
     </tr>
     <tr>
-      <td></td>
-      <td id="grade">
-        {include file="search/adv.grade.form.tpl" grade=$smarty.request.diploma}
+      <td>Diplôme</td>
+      <td>
+        <input name="diploma" type="hidden" size="32" value="{$smarty.request.diploma}"/>
       </td>
     </tr>
     <tr>
@@ -324,8 +366,8 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
           <input type="button" value="Chercher" onclick="launch_form('search/adv')"/>
         </div>
         {if $smarty.session.auth ge AUTH_COOKIE}
-          <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} />
-          mettre les fiches modifiées récemment en premier
+          <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
+          <label for="order">mettre les fiches modifiées récemment en premier</label>
         {/if}
       </td>
     </tr>
index 626578a..e7150c3 100644 (file)
@@ -21,9 +21,9 @@
 {**************************************************************************}
 
 <select name="diploma">
-<option value="0"></option>
+<option value=""> - </option>
 {section name=diploma loop=$choix_diplomas}
-<option value="{$choix_diplomas[diploma]}" {if $grade eq $choix_diplomas[diploma]}selected="selected"{/if}>
+<option value="{$choix_diplomas[diploma]}">
   {$choix_diplomas[diploma]}
 </option>
 {/section}
similarity index 87%
rename from templates/search/adv.region.form.tpl
rename to templates/search/adv.list.form.tpl
index 35b92b4..504d29b 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<select name="region">
-{if $country neq ""}
-  {geoloc_region country=$country region=$region available=true}
-{else}
-  <option value=""></option>
-{/if}
+<select name="{$name}"{if $onchange} onchange="{$onchange}"{/if}>
+    <option value=""> - </option>
+  {iterate from=$list item='option'}
+    <option value="{$option.id}">{$option.field|htmlspecialchars}</option>
+  {/iterate}
 </select>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}