autocompletion ameliorations
[platal.git] / templates / search / adv.form.tpl
index 33b9c01..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 avancée</h1>
+<h1>Recherche dans l'annuaire</h1>
 
-<p>[<a href="{rel}/search">Recherche simple</a>]</p>
-
-<form id="recherche" action="{rel}/search/adv" method="get">
+<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>]
+      </th>
+    </tr>
+    <tr>
       <td>Nom</td>
       <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="{$smarty.server.PHP_SELF}?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="{$smarty.server.PHP_SELF}?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>
@@ -80,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="javascript:document.forms.recherche.submit();">
+        <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>
-        <select name="region">
+      <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}
-        {if $smarty.request.country neq ""}
-        {geoloc_region country=$smarty.request.country region=$region}
-        {else}
-        <option value=""></option>
-        {/if}
-        </select>
+        {include file="search/adv.region.form.tpl" country=$smarty.request.country}
       </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="javascript:document.forms.recherche.submit();">
+        <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>
     </tr>
     <tr>
       <td></td>
-      <td>
-        <select name="diploma">
-          <option value="0"></option>
-          {section name=diploma loop=$choix_diplomas}
-          <option value="{$choix_diplomas[diploma]}" {if $smarty.request.diploma eq
-          $choix_diplomas[diploma]}selected="selected"{/if}>
-            {$choix_diplomas[diploma]}
-          </option>
-          {/section}
-        </select>
+      <td id="grade">
+        {include file="search/adv.grade.form.tpl" grade=$smarty.request.diploma}
       </td>
     </tr>
     <tr>
       <td>Commentaire contient</td>
       <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
     </tr>
+    <tr>
+      <td colspan="2" style="padding-top: 1.5em">
+        <div style="float: right">
+          <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
+        {/if}
+      </td>
+    </tr>
   </table>
-  {min_auth level='cookie'}
-  <p>
-    <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
-  </p>
-  {/min_auth}
 </form>
 <p class="center">
-  <script type="text/javascript">{literal}
-    function launch_form(url) {
-      var f = document.getElementById('recherche');
-      f.action = url;
-      f.submit();
-    }
-  {/literal}</script>
-  {if $use_map}
-    <input type="button" value="Voir les résultats sur une carte" onclick="launch_form('{rel}/geoloc/')"/>
-  {/if}
-  <input type="button" value="Chercher" onclick="launch_form('{rel}/search/adv')"/>
+  <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: *}