1 camarade looks better without an s.
[platal.git] / templates / search / adv.form.tpl
1 {**************************************************************************}
2 {*                                                                        *}
3 {*  Copyright (C) 2003-2008 Polytechnique.org                             *}
4 {*  http://opensource.polytechnique.org/                                  *}
5 {*                                                                        *}
6 {*  This program is free software; you can redistribute it and/or modify  *}
7 {*  it under the terms of the GNU General Public License as published by  *}
8 {*  the Free Software Foundation; either version 2 of the License, or     *}
9 {*  (at your option) any later version.                                   *}
10 {*                                                                        *}
11 {*  This program is distributed in the hope that it will be useful,       *}
12 {*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
13 {*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
14 {*  GNU General Public License for more details.                          *}
15 {*                                                                        *}
16 {*  You should have received a copy of the GNU General Public License     *}
17 {*  along with this program; if not, write to the Free Software           *}
18 {*  Foundation, Inc.,                                                     *}
19 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
20 {*                                                                        *}
21 {**************************************************************************}
22
23 <h1>Recherche dans l'annuaire</h1>
24
25 <script type="text/javascript">// <!--
26   var baseurl = platal_baseurl + "search/";
27   {literal}
28   // display an autocomplete row : blabla (nb of found matches)
29   function make_format_autocomplete(block) {
30     return function(row) {
31         regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
32
33         name = row[0].replace(regexp, '<strong>$1<\/strong>');
34
35         if (row[1] === "-1") {
36           return '...';
37         }
38
39         camarades = (row[1] > 1) ? "camarades" : "camarade";
40
41         return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + '&nbsp;' + camarades + '<\/em>';
42       };
43   }
44
45   // when changing country, open up region choice
46   function changeCountry(a2) {
47     $(".autocompleteTarget[@name='country']").attr('value',a2);
48
49     if (a2) {
50       $(".autocomplete[@name='countryTxt']").addClass('hidden_valid');
51
52       $("[@name='region']").parent().load(baseurl + 'list/region/', { country:a2 }, function() {
53           if ($("select[@name='region']").children("option").size() > 1) {
54             $("select[@name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}');
55
56             $("tr#region_ln").show();
57           } else {
58             $("select[@name='region']").attr('value', '');
59
60             $("tr#region_ln").hide();
61           }
62         });
63     } else {
64       $(".autocomplete[@name='countryTxt']").removeClass('hidden_valid');
65
66       $("select[@name='region']").attr('value', '');
67
68       $("tr#region_ln").hide();
69     }
70   }
71
72   // when changing school, open diploma choice
73   function changeSchool(schoolId) {
74     $(".autocompleteTarget[@name='school']").attr('value',schoolId);
75
76     if (schoolId) {
77       $(".autocomplete[@name='schoolTxt']").addClass('hidden_valid');
78
79       $("[@name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
80           if ($("select[@name='diploma']").children("option").size() > 1) {
81             $("select[@name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
82
83             $("tr#diploma_ln").show();
84           } else {
85             $("select[@name='diploma']").attr('value', '');
86
87             $("tr#diploma_ln").hide();
88           }
89         });
90     } else {
91       $(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
92
93       $("select[@name='diploma']").attr('value', '');
94
95       $("tr#diploma_ln").hide();
96     }
97   }
98
99   // when choosing autocomplete from list, must validate
100   function select_autocomplete(name) {
101       nameRealField = name.replace(/Txt$/, '');
102
103       // nothing to do if field is not a text field for a list
104       if (nameRealField == name)
105         return null;
106
107       // if changing country, might want to open region choice
108       if (nameRealField == 'country')
109         return function(i) {
110             changeCountry(i.extra[1]);
111           }
112
113       if (nameRealField == 'school')
114         return function(i) {
115             changeSchool(i.extra[1]);
116           }
117
118       // change field in list and display text field as valid
119       return function(i) {
120         nameRealField = this.field.replace(/Txt$/, '');
121
122         $(".autocompleteTarget[@name='"+nameRealField+"']").attr('value',i.extra[1]);
123
124         $(".autocomplete[@name='"+this.field+"']").addClass('hidden_valid');
125       }
126     }
127
128   $(document).ready(function() {
129       $(".autocompleteTarget").hide();
130       $(".autocomplete").show().each(function() {
131         targeted = $("../.autocompleteTarget",this)[0];
132
133         if (targeted && targeted.value) {
134           me = $(this);
135
136           $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
137             me.attr('value', textValue);
138             me.addClass('hidden_valid');
139           });
140         }
141
142         $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
143           selectOnly:1,
144           formatItem:make_format_autocomplete(this),
145           field:this.name,
146           onItemSelect:select_autocomplete(this.name),
147           matchSubset:0,
148           width:$(this).width()});
149         });
150
151       $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
152
153       $(".autocomplete[@name='countryTxt']").change(function() { changeCountry(''); });
154
155       changeCountry({/literal}'{$smarty.request.country}'{literal});
156
157       $(".autocomplete[@name='schoolTxt']").change(function() { changeSchool(''); });
158
159       changeSchool({/literal}'{$smarty.request.school}'{literal});
160
161       $(".autocompleteToSelect").each(function() {
162           var fieldName = $(this).attr('href');
163
164           $(this).attr('href', baseurl + 'list/'+fieldName).click(function() {
165               var oldval = $("input.autocompleteTarget[@name='"+fieldName+"']")[0].value;
166
167               $(".autocompleteTarget[@name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},
168                 function(selectBox) {
169                   $(".autocompleteTarget[@name='"+fieldName+"']").remove();
170                   $(".autocomplete[@name='"+fieldName+"Txt']").remove();
171                   $("select[@name='"+fieldName+"']").attr('value', oldval);
172                 });
173
174               return false;
175             });
176         }).parent().find('.autocomplete').change(function() {
177           // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used,
178           // to ensure that, we unset it
179           $(this).parent().find('.autocompleteTarget').val('');
180         });
181     });
182 -->
183 {/literal}</script>
184 <form id="recherche" action="search/adv" method="get">
185   <table class="bicol" cellpadding="3" summary="Recherche">
186     <tr>
187       <th colspan="2">
188         Recherche avancée [<a href="search">&lt;&lt;&lt;&nbsp;Recherche simple</a>]
189       </th>
190     </tr>
191     <tr>
192       <td>Nom</td>
193       <td>
194         <input type="hidden" name="rechercher" value="Chercher"/>
195         <input type="submit" style="display:none"/>
196         <input type="text" class="autocomplete" name="name" size="32" value="{$smarty.request.name}" />
197       </td>
198     </tr>
199     <tr>
200       <td>Prénom</td>
201       <td>
202         <input class="autocomplete" type="text" name="firstname" size="32" value="{$smarty.request.firstname}" />
203       </td>
204     </tr>
205     <tr>
206       <td>Surnom</td>
207       <td>
208         <input class="autocomplete" type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
209       </td>
210     </tr>
211     <tr>
212       <td>Promotion</td>
213       <td>
214         <select name="egal1">
215           <option value="=" {if $smarty.request.egal1 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
216           <option value="&gt;=" {if $smarty.request.egal1 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
217           <option value="&lt;=" {if $smarty.request.egal1 eq "&lt;="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
218         </select>
219         <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
220         &nbsp;et&nbsp;
221         <select name="egal2">
222           <option value="=" {if $smarty.request.egal2 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
223           <option value="&gt;=" {if $smarty.request.egal2 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
224           <option value="&lt;=" {if $smarty.request.egal2 neq "&gt;=" && $smarty.request.egal2 neq "="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
225         </select>
226         <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
227       </td>
228     </tr>
229     <tr>
230       <td>Sexe</td>
231       <td>
232         <table>
233           <tr>
234             <td style="width:100px">
235               <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">indifférent</label>
236             </td>
237             <td style="width:100px">
238               <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">homme</label>
239             </td>
240             <td style="width:100px">
241               <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">femme</label>
242             </td>
243           </tr>
244         </table>
245       </td>
246     </tr>
247     <tr>
248       <td>Sur Polytechnique.org</td>
249       <td>
250         <table>
251           <tr>
252             <td style="width:100px">
253               <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">indifférent</label>
254             </td>
255             <td style="width:100px">
256               <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">inscrit</label>
257             </td>
258             <td style="width:100px">
259               <input type="radio" name="subscriber" value="2" {if $smarty.request.subscriber eq 2}checked="checked"{/if} id="subscriber2"/><label for="subscriber2">non inscrit</label>
260             </td>
261           </tr>
262         </table>
263       </td>
264     </tr>
265     <tr>
266       <td>En vie</td>
267       <td>
268         <table>
269           <tr>
270             <td style="width:100px">
271               <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">indifférent</label>
272             </td>
273             <td style="width:100px">
274               <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">vivant</label>
275             </td>
276             <td style="width:100px">
277               <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>
278             </td>
279           </tr>
280         </table>
281       </td>
282     </tr>
283     <tr>
284       <td colspan="2">
285         <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
286         <label for="sdxn">Étendre par proximité sonore (uniquement sur nom et prénom).</label>
287       </td>
288     </tr>
289     <tr>
290       <th colspan="2">Géographie</th>
291     </tr>
292     <tr>
293       <td>Ville ou code postal</td>
294       <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
295     </tr>
296     <tr>
297       <td>Pays</td>
298       <td>
299         <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"
300                value="{$smarty.request.countryTxt}"/>
301         <input name="country" class="autocompleteTarget" type="hidden" value="{$smarty.request.country}"/>
302         <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
303       </td>
304     </tr>
305     <tr id="region_ln">
306       <td>Région ou département</td>
307       <td>
308         <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
309       </td>
310     </tr>
311     <tr>
312       <td colspan="2">
313       <label for="only_current"><input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current}  
314 checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont actuellement.</label></td>
315     </tr>
316     <tr>
317       <th colspan="2">Activité</th>
318     </tr>
319     <tr>
320       <td>Entreprise</td>
321       <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
322     </tr>
323     <tr>
324       <td>Fonction</td>
325       <td>
326         <input name="fonctionTxt" type="text" class="autocomplete" style="display:none" size="32"
327                value="{$smarty.request.fonctionTxt}"/>
328         <input name="fonction" class="autocompleteTarget" type="hidden" value="{$smarty.request.fonction}"/>
329         <a href="fonction" class="autocompleteToSelect">{icon name="table" title="Toutes les fonctions"}</a>
330       </td>
331     </tr>
332     <tr>
333       <td>Poste</td>
334       <td><input type="text" class="autocomplete" name="poste" size="32" value="{$smarty.request.poste}" /></td>
335     </tr>
336     <tr>
337       <td>Secteur</td>
338       <td>
339         <input name="secteurTxt" type="text" class="autocomplete" style="display:none" size="32"
340                value="{$smarty.request.secteurTxt}"/>
341         <input name="secteur" class="autocompleteTarget" type="hidden" value="{$smarty.request.secteur}"/>
342         <a href="secteur" class="autocompleteToSelect">{icon name="table" title="Tous les secteurs"}</a>
343       </td>
344     </tr>
345     <tr>
346       <td>CV contient</td>
347       <td><input type="text" name="cv" size="32" value="{$smarty.request.cv}" /></td>
348     </tr>
349     <tr>
350       <td colspan="2">
351         <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
352         <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
353       </td>
354     </tr>
355     <tr>
356       <th colspan="2">Divers</th>
357     </tr>
358     <tr>
359       <td>Nationalité</td>
360       <td>
361         <input name="nationaliteTxt" type="text" class="autocomplete" style="display:none" size="32"
362                value="{$smarty.request.nationaliteTxt}"/>
363         <input name="nationalite" class="autocompleteTarget" type="hidden" value="{$smarty.request.nationalite}"/>
364         <a href="nationalite" class="autocompleteToSelect">{icon name="table" title="Toutes les nationalités"}</a>
365       </td>
366     </tr>
367     <tr>
368       <td>Binet</td>
369       <td>
370         <input name="binetTxt" type="text" class="autocomplete" style="display:none" size="32"
371                value="{$smarty.request.binetTxt}"/>
372         <input name="binet" class="autocompleteTarget" type="hidden" value="{$smarty.request.binet}"/>
373         <a href="binet" class="autocompleteToSelect">{icon name="table" title="Tous les binets"}</a>
374       </td>
375     </tr>
376     <tr>
377       <td>Groupe X</td>
378       <td>
379         <input name="groupexTxt" type="text" class="autocomplete" style="display:none" size="32"
380                value="{$smarty.request.groupexTxt}"/>
381         <input name="groupex" class="autocompleteTarget" type="hidden" value="{$smarty.request.groupex}"/>
382         <a href="groupex" class="autocompleteToSelect">{icon name="table" title="Tous les groupes X"}</a>
383       </td>
384     </tr>
385     <tr>
386       <td>Section</td>
387       <td>
388         <input name="sectionTxt" type="text" class="autocomplete" style="display:none" size="32"
389                value="{$smarty.request.sectionTxt}"/>
390         <input name="section" class="autocompleteTarget" type="hidden" value="{$smarty.request.section}"/>
391         <a href="section" class="autocompleteToSelect">{icon name="table" title="Toutes les sections"}</a>
392       </td>
393     </tr>
394     <tr>
395       <td>Formation</td>
396       <td>
397         <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"
398                value="{$smarty.request.schoolTxt}"/>
399         <input name="school" class="autocompleteTarget" type="hidden" value="{$smarty.request.school}"/>
400         <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
401       </td>
402     </tr>
403     <tr id="diploma_ln">
404       <td>Diplôme</td>
405       <td>
406         <input name="diploma" type="hidden" size="32" value="{$smarty.request.diploma}"/>
407       </td>
408     </tr>
409     <tr>
410       <td>Commentaire contient</td>
411       <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
412     </tr>
413         {if $smarty.session.auth ge AUTH_COOKIE}
414     <tr>
415       <td colspan="2">
416           <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
417           <label for="order">Mettre les fiches modifiées récemment en premier.</label>
418       </td>
419     </tr>
420     <tr>
421       <td colspan="2">
422            <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
423            <label for="exact">Faire une recherche exacte.</label>
424       </td>
425     </tr>
426         {/if}
427     <tr><td colspan="2"></td></tr>
428     <tr>
429       <td colspan="2" style="text-align: center">
430           <input type="submit" value="Chercher" />
431       </td>
432     </tr>
433   </table>
434 </form>
435 <p>
436   <small><strong>N.B. :</strong> le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.</small>
437 </p>
438
439 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}