autocompletion ameliorations
[platal.git] / templates / search / adv.form.tpl
index 1578e35..6027b17 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2006 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2007 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 <h1>Recherche dans l'annuaire</h1>
 
 <form id="recherche" action="search/adv" method="get">
+  {javascript name="jquery"}
+  {javascript name="jquery.autocomplete"}
   <script type="text/javascript">{literal}
     function launch_form(url) {
       var f = document.getElementById('recherche');
       f.action = url;
       f.submit();
     }
+    function format_autocomplete(row) {
+      if (row[1] == 1) {
+        return row[0];
+      }
+      return row[0] + ' ('+ row[1] + ')';
+    }
+    $(document).ready(function() {
+      $(".autocomplete").each(function() {
+        $(this).autocomplete("search/autocomplete/"+this.name,{selectOnly:1,formatItem:format_autocomplete,matchSubset:0,width:$(this).width()});
+      });
+    });
   {/literal}</script>
   <table class="bicol" cellpadding="3" summary="Recherche">
     <tr>
       <th colspan="2">
-        Recherche avancée [<a href="search">&lt;&lt;&lt;&nbsp;Recherche simple</a>]
+        Recherche avancée [<a href="search">&lt;&lt;&lt;&nbsp;Recherche simple</a>]
       </th>
     </tr>
     <tr>
       <td>
        <input type="hidden" name="rechercher" value="Chercher"/>
        <input type="submit" style="display:none"/>
-        <input type="text" name="name" size="32" value="{$smarty.request.name}" />
-        {if $smarty.request.name && !$with_soundex && $smarty.request.recherche}
-        <a class='smaller' href="search/adv?with_soundex=1&amp;{$url_args}">
-          étendre par proximité sonore
-        </a>
-        {/if}
+        <input type="text" class="autocomplete" name="name" size="32" value="{$smarty.request.name}" />
       </td>
     </tr>
     <tr>
-      <td>Prénom</td>
+      <td>Prénom</td>
       <td>
-        <input type="text" name="firstname" size="32" value="{$smarty.request.firstname}" />
-        {if $smarty.request.firstname && !$with_soundex && $smarty.request.recherche}
-        <a class='smaller' href="search/adv?with_soundex=1&amp;{$url_args}">
-          étendre par proximité sonore
-        </a>
-        {/if}
+        <input class="autocomplete" type="text" name="firstname" size="32" value="{$smarty.request.firstname}" />
       </td>
     </tr>
     <tr>
       <td>Surnom</td>
       <td>
-        <input type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
+        <input class="autocomplete" type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
       </td>
     </tr>
     <tr>
@@ -90,7 +93,7 @@
         <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} />Indifférent
             </td>
             <td style="width:100px">
               <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} />Homme
         <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} />Indifférent
             </td>
             <td style="width:100px">
               <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} />Inscrit
         <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} />Indifférent
             </td>
             <td style="width:100px">
               <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} />Vivant
             </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} />Décédé
             </td>
           </tr>
         </table>
       </td>
     </tr>
     <tr>
-      <th colspan="2">Géographie</th>
+      <td colspan="2">
+        <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
+        <label for="sdxn">étendre par proximité sonore (uniquement sur nom et prénom)</label>
+      </td>
     </tr>
     <tr>
-      <td colspan="2">
-      <label for="only_current"><input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current} checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont actuellement.</label></td>
+      <th colspan="2">Géographie</th>
     </tr>
     <tr>
       <td>Ville</td>
     <tr>
       <td>Pays</td>
       <td>
-        <select name="country" onchange="return Ajax.update_html('region', '{$platal->ns}search/ajax/region/' + this.value);">
+        <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}
+        {geoloc_country country=$country available=true}
         </select>
       </td>
     </tr>
     <tr>
-      <td>Région ou département</td>
+      <td>Région ou département</td>
       <td id="region">
         {if $smarty.request.region}
           {assign var="region" value=$smarty.request.region}
       </td>
     </tr>
     <tr>
-      <th colspan="2">Activité</th>
+      <td colspan="2">
+      <label for="only_current"><input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current}  
+checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont actuellement.</label></td>
+    </tr>
+    <tr>
+      <th colspan="2">Activité</th>
     </tr>
     <tr>
       <td>Entreprise</td>
-      <td><input type="text" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
+      <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
     </tr>
     <tr>
       <td>Fonction</td>
     <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
+        chercher uniquement parmi les camarades se proposant comme référents
       </td>
     </tr>
     <tr>
       <th colspan="2">Divers</th>
     </tr>
     <tr>
-      <td>Nationalité</td>
+      <td>Nationalité</td>
       <td>
         <select name="nationalite">
           {iterate from=$choix_nats item=cn}
         <option value="0"></option>
         {iterate item=cb from=$choix_binets}
           <option value="{$cb.id}" {if $smarty.request.binet eq $cb.id}selected="selected"{/if}>
-            {$cb.text}
+            {$cb.text|htmlspecialchars}
           </option>
         {/iterate}
         </select>
     <tr>
       <td>Formation</td>
       <td>
-        <select name="school" onchange="return Ajax.update_html('grade', '{$platal->ns}search/ajax/grade/' + this.value);">
+        <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}
+            {$cs.text|htmlspecialchars}
           </option>
           {/iterate}
         </select>
         </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
+          mettre les fiches modifiées récemment en premier
         {/if}
       </td>
     </tr>
   </table>
 </form>
 <p class="center">
-  <input type="button" value="Voir les résultats sur une carte" onclick="launch_form('geoloc/')"/>
+  <input type="button" value="Voir les résultats sur une carte" onclick="launch_form('geoloc/')"/>
 </p>
 <p>
-  <strong>N.B.</strong> Le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.
+  <strong>N.B.</strong> Le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.
 </p>
 
-{* vim:set et sw=2 sts=2 sws=2: *}
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}