Merge commit 'origin/master' into fusionax
[platal.git] / templates / search / adv.form.tpl
index e79c017..d996c69 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2007 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2009 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 
 <h1>Recherche dans l'annuaire</h1>
 
-{javascript name="jquery"}
-{javascript name="jquery.autocomplete"}
-<script type="text/javascript">// <!-- 
-        var baseurl = platal_baseurl + "search/";
-        {literal}
-        // display an autocomplete row&nbsp;: blabla (nb of found matches)
-        function make_format_autocomplete(block) {
-          return function(row) {
-              regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
-              name = row[0].replace(regexp, '<strong>$1</strong>');
-              if (row[1] == 1) {
-                return name;
-              }
-              return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;'+ row[1] + ' camarades</em>';
-            };
+<script type="text/javascript">// <!--
+  var baseurl = platal_baseurl + "search/";
+  {literal}
+  // display an autocomplete row : blabla (nb of found matches)
+  function make_format_autocomplete(block) {
+    return function(row) {
+        regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
+
+        name = row[0].replace(regexp, '<strong>$1<\/strong>');
+
+        if (row[1] === "-1") {
+          return '...';
         }
-        
-        // 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(baseurl + 'list/region/', { country:a2 }, function() {
-              if ($("select[@name='region']").children("option").size() > 1) {
-                $("select[@name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}');
-                $("tr#region_ln").show();
-              } else {
-                $("select[@name='region']").attr('value', '');
-                $("tr#region_ln").hide();
-              }
-            });
+
+        camarades = (row[1] > 1) ? "camarades" : "camarade";
+
+        return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + '&nbsp;' + camarades + '<\/em>';
+      };
+  }
+
+  // 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(baseurl + 'list/region/', { country:a2 }, function() {
+          if ($("select[@name='region']").children("option").size() > 1) {
+            $("select[@name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}');
+
+            $("tr#region_ln").show();
           } else {
-            $(".autocomplete[@name='countryTxt']").removeClass('hidden_valid');
             $("select[@name='region']").attr('value', '');
+
             $("tr#region_ln").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(baseurl + 'list/diploma/', { school:schoolId }, function() {
-              if ($("select[@name='diploma']").children("option").size() > 1) {
-                $("select[@name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
-                $("tr#diploma_ln").show();
-              } else {
-                $("select[@name='diploma']").attr('value', '');
-                $("tr#diploma_ln").hide();
-              }
-            });
-          } else {
-            $(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
-            $("select[@name='diploma']").attr('value', '');
-            $("tr#diploma_ln").hide();
+        });
+    } else {
+      $(".autocomplete[@name='countryTxt']").removeClass('hidden_valid');
+
+      $("select[@name='region']").attr('value', '');
+
+      $("tr#region_ln").hide();
+    }
+  }
+
+  // when changing school, open diploma choice
+  function changeSchool(schoolId) {
+    $(".autocompleteTarget[@name='school']").attr('value',schoolId);
+
+    if (schoolId) {
+      $(".autocomplete[@name='schoolTxt']").addClass('hidden_valid');
+    } else {
+      $(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
+    }
+
+    $("[@name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
+        $("select[@name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
+      });
+  }
+
+  // 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]);
           }
-        }
-        
-        // 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]);
-              $(".autocomplete[@name='"+this.field+"']").addClass('hidden_valid');
-            }
+
+      if (nameRealField == 'school')
+        return function(i) {
+            changeSchool(i.extra[1]);
           }
-          $(document).ready(function() {
-            $(".autocompleteTarget").hide();
-            $(".autocomplete").show().each(function() {
-              targeted = $("../.autocompleteTarget",this)[0];
-              if (targeted && targeted.value) {
-                me = $(this);
-                $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
-                  me.attr('value', textValue);
-                  me.addClass('hidden_valid');
-                });
-              }
-              $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
-                selectOnly:1,
-                formatItem:make_format_autocomplete(this),
-                field:this.name,
-                onItemSelect:select_autocomplete(this.name),
-                matchSubset:0,
-                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', baseurl + 'list/'+fieldName).click(function() {
-                  var oldval = $("input.autocompleteTarget[@name='"+fieldName+"']")[0].value;
-                  $(".autocompleteTarget[@name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},function(selectBox) {
-                    $(".autocompleteTarget[@name='"+fieldName+"']").remove();
-                    $(".autocomplete[@name='"+fieldName+"Txt']").remove();
-                    $("select[@name='"+fieldName+"']").attr('value', oldval);
-                  });
-                  return false;
+
+      // 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]);
+
+        $(".autocomplete[@name='"+this.field+"']").addClass('hidden_valid');
+      }
+    }
+
+  $(document).ready(function() {
+      $(".autocompleteTarget").hide();
+      $(".autocomplete").show().each(function() {
+        targeted = $("../.autocompleteTarget",this)[0];
+
+        if (targeted && targeted.value) {
+          me = $(this);
+
+          $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
+            me.attr('value', textValue);
+            me.addClass('hidden_valid');
+          });
+        }
+
+        $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
+          selectOnly:1,
+          formatItem:make_format_autocomplete(this),
+          field:this.name,
+          onItemSelect:select_autocomplete(this.name),
+          matchSubset:0,
+          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', baseurl + 'list/'+fieldName).click(function() {
+              var oldval = $("input.autocompleteTarget[@name='"+fieldName+"']")[0].value;
+
+              $(".autocompleteTarget[@name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},
+                function(selectBox) {
+                  $(".autocompleteTarget[@name='"+fieldName+"']").remove();
+                  $(".autocomplete[@name='"+fieldName+"Txt']").remove();
+                  $("select[@name='"+fieldName+"']").attr('value', oldval);
                 });
-              });
+
+              return false;
             });
-        -->
+        }).parent().find('.autocomplete').change(function() {
+          // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used,
+          // to ensure that, we unset it
+          $(this).parent().find('.autocompleteTarget').val('');
+        });
+    });
+-->
 {/literal}</script>
 <form id="recherche" action="search/adv" method="get">
   <table class="bicol" cellpadding="3" summary="Recherche">
           <option value="&lt;=" {if $smarty.request.egal1 eq "&lt;="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
         </select>
         <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
-        &nbsp;ET&nbsp;
+        &nbsp;et&nbsp;
         <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>
         <table>
           <tr>
             <td style="width:100px">
-              <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">Indifférent</label>
+              <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} id="woman1"/><label for="woman1">Homme</label>
+              <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} id="woman2"/><label for="woman2">Femme</label>
+              <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>
       </td>
     </tr>
     <tr>
-      <td>Sur polytechnique.org</td>
+      <td>Sur Polytechnique.org</td>
       <td>
         <table>
           <tr>
             <td style="width:100px">
-              <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">Indifférent</label>
+              <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} id="subscriber1"/><label for="subscriber1">Inscrit</label>
+              <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} id="subscriber2"/><label for="subscriber2">Non inscrit</label>
+              <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} id="alive0"/><label for="alive0">Indifférent</label>
+              <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} id="alive1"/><label for="alive1">Vivant</label>
+              <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} id="alive2"/><label for="alive2">Décédé</label>
+              <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 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>
+        <label for="sdxn">Ã\89tendre par proximité sonore (uniquement sur nom et prénom).</label>
       </td>
     </tr>
     <tr>
       <th colspan="2">Géographie</th>
     </tr>
     <tr>
-      <td>Ville</td>
+      <td>Ville ou code postal</td>
       <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
     </tr>
     <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>
+checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont actuellement.</label></td>
     </tr>
     <tr>
       <th colspan="2">Activité</th>
@@ -291,8 +318,8 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
       </td>
     </tr>
     <tr>
-      <td>Poste</td>
-      <td><input type="text" class="autocomplete" name="poste" size="32" value="{$smarty.request.poste}" /></td>
+      <td>Description</td>
+      <td><input type="text" class="autocomplete" name="description" size="32" value="{$smarty.request.description}" /></td>
     </tr>
     <tr>
       <td>Secteur</td>
@@ -310,7 +337,7 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
     <tr>
       <td colspan="2">
         <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>
+        <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
       </td>
     </tr>
     <tr>
@@ -361,10 +388,10 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
         <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
       </td>
     </tr>
-    <tr id="diploma_ln">
+    <tr>
       <td>Diplôme</td>
       <td>
-        <input name="diploma" type="hidden" size="32" value="{$smarty.request.diploma}"/>
+        <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
       </td>
     </tr>
     <tr>
@@ -372,20 +399,52 @@ checked="checked"{/if}/>chercher uniquement les adresses où les camarades sont
       <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="submit" value="Chercher" />
-        </div>
+      <td>Numéro de téléphone</td>
+      <td><input type="text" name="phone_number" size="32" value="{$smarty.request.phone_number}"/></td>
+    </tr>
+    <tr>
+      <td style="vertical-align: middle">
+        <span>Networking et sites webs</span>
+      </td>
+      <td>
+        <table>
+          <tr>
+            <td style="padding-left: 0px;">
+              <input type="text" name="networking_address" size="32" value="{$smarty.request.networking_address}" />
+            </td>
+            <td>
+              <input type="text" name="networking_typeTxt" class="autocomplete" size="10" value="{$smarty.request.networking_typeTxt}" />
+              <input name="networking_type" class="autocompleteTarget" type="hidden" value="{$smarty.request.networking_type}"/>
+              <a href="networking_type" class="autocompleteToSelect">{icon name="table" title="Tous les types d'adresse"}</a>
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
         {if $smarty.session.auth ge AUTH_COOKIE}
+    <tr>
+      <td colspan="2">
           <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>
+          <label for="order">Mettre les fiches modifiées récemment en premier.</label>
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2">
+           <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
+           <label for="exact">Faire une recherche exacte.</label>
+      </td>
+    </tr>
         {/if}
+    <tr><td colspan="2"></td></tr>
+    <tr>
+      <td colspan="2" style="text-align: center">
+          <input type="submit" value="Chercher" />
       </td>
     </tr>
   </table>
 </form>
 <p>
-  <strong>N.B.</strong> Le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.
+  <small><strong>N.B. :</strong> le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.</small>
 </p>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}