5521a003b21ca8bfab264f009a0bb70830b4eb90
[platal.git] / templates / search / adv.form.tpl
1 {**************************************************************************}
2 {*                                                                        *}
3 {*  Copyright (C) 2003-2010 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 '&hellip;';
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     } else {
79       $(".autocomplete[name='schoolTxt']").removeClass('hidden_valid');
80     }
81
82     $("[name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
83         $("select[name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
84       });
85   }
86
87   // when choosing a job term in tree, hide tree and set job term field
88   function searchForJobTerm(treeid, jtid, full_name) {
89     $(".term_tree").remove();
90     $("input[name='jobtermTxt']").val(full_name).addClass("hidden_valid").show();
91     $("input[name='jobterm']").val(jtid);
92   }
93
94   // when choosing autocomplete from list, must validate
95   function select_autocomplete(name) {
96       nameRealField = name.replace(/Txt$/, '');
97
98       // nothing to do if field is not a text field for a list
99       if (nameRealField == name)
100         return null;
101
102       // if changing country, might want to open region choice
103       if (nameRealField == 'country')
104         return function(i) {
105             changeCountry(i.extra[1]);
106           }
107
108       if (nameRealField == 'school')
109         return function(i) {
110             changeSchool(i.extra[1]);
111           }
112
113       // change field in list and display text field as valid
114       return function(i) {
115         nameRealField = this.field.replace(/Txt$/, '');
116
117         $(".autocompleteTarget[name='"+nameRealField+"']").attr('value',i.extra[1]);
118
119         $(".autocomplete[name='"+this.field+"']").addClass('hidden_valid');
120       }
121     }
122
123   $(document).ready(function() {
124       $(".autocompleteTarget").hide();
125       $(".autocomplete").show().each(function() {
126         targeted = $("../.autocompleteTarget",this)[0];
127
128         if (targeted && targeted.value) {
129           me = $(this);
130
131           $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
132             me.attr('value', textValue);
133             me.addClass('hidden_valid');
134           });
135         }
136
137         $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
138           selectOnly:1,
139           formatItem:make_format_autocomplete(this),
140           field:this.name,
141           onItemSelect:select_autocomplete(this.name),
142           matchSubset:0,
143           width:$(this).width()});
144         });
145
146       $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
147
148       $(".autocomplete[name='countryTxt']").change(function() { changeCountry(''); });
149
150       changeCountry({/literal}'{$smarty.request.country}'{literal});
151
152       $(".autocomplete[name='schoolTxt']").change(function() { changeSchool(''); });
153
154       changeSchool({/literal}'{$smarty.request.school}'{literal});
155
156       $(".autocompleteToSelect").each(function() {
157           var fieldName = $(this).attr('href');
158
159           $(this).attr('href', baseurl + 'list/'+fieldName).click(function() {
160               var oldval = $("input.autocompleteTarget[name='"+fieldName+"']")[0].value;
161
162               $(".autocompleteTarget[name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},
163                 function(selectBox) {
164                   $(".autocompleteTarget[name='"+fieldName+"']").remove();
165                   $(".autocomplete[name='"+fieldName+"Txt']").remove();
166                   $("select[name='"+fieldName+"']").attr('value', oldval);
167                 });
168
169               return false;
170             });
171         }).parent().find('.autocomplete').change(function() {
172           // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used,
173           // to ensure that, we unset it
174           $(this).parent().find('.autocompleteTarget').val('');
175         });
176     });
177 -->
178 {/literal}</script>
179 <p class="center">[<a href="search">Revenir à la recherche simple</a>]</p>
180 <form id="recherche" action="search/adv" method="get">
181   <table class="bicol" cellpadding="3" summary="Recherche">
182     <tr>
183       <th colspan="2">
184         Recherche avancée
185       </th>
186     </tr>
187     <tr>
188       <td>Nom, prénom, surnom...</td>
189       <td>
190         <input type="hidden" name="rechercher" value="Chercher"/>
191         <input type="submit" style="display:none"/>
192         <input type="text" name="name" size="32" value="{$smarty.request.name}" />
193       </td>
194     </tr>
195     <tr>
196       <td>Promotion</td>
197       <td>
198         <select name="egal1">
199           <option value="=" {if $smarty.request.egal1 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
200           <option value="&gt;=" {if $smarty.request.egal1 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
201           <option value="&lt;=" {if $smarty.request.egal1 eq "&lt;="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
202         </select>
203         <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
204         &nbsp;et&nbsp;
205         <select name="egal2">
206           <option value="=" {if $smarty.request.egal2 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
207           <option value="&gt;=" {if $smarty.request.egal2 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
208           <option value="&lt;=" {if $smarty.request.egal2 neq "&gt;=" && $smarty.request.egal2 neq "="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
209         </select>
210         <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
211       </td>
212     </tr>
213     <tr>
214       <td>Sexe</td>
215       <td>
216         <table>
217           <tr>
218             <td style="width:100px">
219               <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">indifférent</label>
220             </td>
221             <td style="width:100px">
222               <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">homme</label>
223             </td>
224             <td style="width:100px">
225               <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">femme</label>
226             </td>
227           </tr>
228         </table>
229       </td>
230     </tr>
231     <tr>
232       <td>Sur Polytechnique.org</td>
233       <td>
234         <table>
235           <tr>
236             <td style="width:100px">
237               <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">indifférent</label>
238             </td>
239             <td style="width:100px">
240               <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">inscrit</label>
241             </td>
242             <td style="width:100px">
243               <input type="radio" name="subscriber" value="2" {if $smarty.request.subscriber eq 2}checked="checked"{/if} id="subscriber2"/><label for="subscriber2">non inscrit</label>
244             </td>
245           </tr>
246         </table>
247       </td>
248     </tr>
249     <tr>
250       <td>En vie</td>
251       <td>
252         <table>
253           <tr>
254             <td style="width:100px">
255               <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">indifférent</label>
256             </td>
257             <td style="width:100px">
258               <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">vivant</label>
259             </td>
260             <td style="width:100px">
261               <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>
262             </td>
263           </tr>
264         </table>
265       </td>
266     </tr>
267     <tr>
268       <td colspan="2">
269         <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
270         <label for="sdxn">Étendre par proximité sonore (uniquement sur nom et prénom).</label>
271       </td>
272     </tr>
273     <tr>
274       <th colspan="2">Géographie</th>
275     </tr>
276     <tr>
277       <td>Ville ou code postal</td>
278       <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
279     </tr>
280     <tr>
281       <td>Pays</td>
282       <td>
283         <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"
284                value="{$smarty.request.countryTxt}"/>
285         <input name="country" class="autocompleteTarget" type="hidden" value="{$smarty.request.country}"/>
286         <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
287       </td>
288     </tr>
289     <tr id="region_ln">
290       <td>Région ou département</td>
291       <td>
292         <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
293       </td>
294     </tr>
295     <tr>
296       <td colspan="2">
297         <label for="only_current">
298           <input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current} checked="checked"{/if}/>
299           Chercher uniquement les adresses où les camarades sont actuellement.
300         </label>
301       </td>
302     </tr>
303     <tr>
304       <th colspan="2">Activité</th>
305     </tr>
306     <tr>
307       <td>Entreprise</td>
308       <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
309     </tr>
310     <tr>
311       <td>Description</td>
312       <td><input type="text" class="autocomplete" name="description" size="32" value="{$smarty.request.description}" /></td>
313     </tr>
314     <tr>
315       <td>Mots-clefs</td>
316       <td>
317         <input name="jobtermTxt" type="text" class="autocomplete{if $smarty.request.jobterm} hidden_valid{/if}" style="display:none" size="32"
318                value="{$smarty.request.jobtermTxt}"/>
319         <input name="jobterm" class="autocompleteTarget" type="hidden" value="{$smarty.request.jobterm}"/>
320         <a href="jobterm" class="autocompleteToSelect">{icon name="table" title="Tous les mots-clefs"}</a>
321       </td>
322     </tr>
323     <tr>
324       <td>CV contient</td>
325       <td><input type="text" name="cv" size="32" value="{$smarty.request.cv}" /></td>
326     </tr>
327     <tr>
328       <td colspan="2">
329         <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
330         <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
331       </td>
332     </tr>
333     <tr>
334       <th colspan="2">Divers</th>
335     </tr>
336     <tr>
337       <td>Nationalité</td>
338       <td>
339         <input name="nationaliteTxt" type="text" class="autocomplete" style="display:none" size="32"
340                value="{$smarty.request.nationaliteTxt}"/>
341         <input name="nationalite" class="autocompleteTarget" type="hidden" value="{$smarty.request.nationalite}"/>
342         <a href="nationalite" class="autocompleteToSelect">{icon name="table" title="Toutes les nationalités"}</a>
343       </td>
344     </tr>
345     <tr>
346       <td>Binet</td>
347       <td>
348         <input name="binetTxt" type="text" class="autocomplete" style="display:none" size="32"
349                value="{$smarty.request.binetTxt}"/>
350         <input name="binet" class="autocompleteTarget" type="hidden" value="{$smarty.request.binet}"/>
351         <a href="binet" class="autocompleteToSelect">{icon name="table" title="Tous les binets"}</a>
352       </td>
353     </tr>
354     <tr>
355       <td>Groupe X</td>
356       <td>
357         <input name="groupexTxt" type="text" class="autocomplete" style="display:none" size="32"
358                value="{$smarty.request.groupexTxt}"/>
359         <input name="groupex" class="autocompleteTarget" type="hidden" value="{$smarty.request.groupex}"/>
360         <a href="groupex" class="autocompleteToSelect">{icon name="table" title="Tous les groupes X"}</a>
361       </td>
362     </tr>
363     <tr>
364       <td>Section</td>
365       <td>
366         <input name="sectionTxt" type="text" class="autocomplete" style="display:none" size="32"
367                value="{$smarty.request.sectionTxt}"/>
368         <input name="section" class="autocompleteTarget" type="hidden" value="{$smarty.request.section}"/>
369         <a href="section" class="autocompleteToSelect">{icon name="table" title="Toutes les sections"}</a>
370       </td>
371     </tr>
372     <tr>
373       <td>Formation</td>
374       <td>
375         <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"
376                value="{$smarty.request.schoolTxt}"/>
377         <input name="school" class="autocompleteTarget" type="hidden" value="{$smarty.request.school}"/>
378         <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
379       </td>
380     </tr>
381     <tr>
382       <td>Diplôme</td>
383       <td>
384         <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
385       </td>
386     </tr>
387     <tr>
388       <td>Commentaire contient</td>
389       <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
390     </tr>
391     <tr>
392       <td>Numéro de téléphone</td>
393       <td><input type="text" name="phone_number" size="32" value="{$smarty.request.phone_number}"/></td>
394     </tr>
395     <tr>
396       <td style="vertical-align: middle">
397         <span>Networking et sites webs</span>
398       </td>
399       <td>
400         <table>
401           <tr>
402             <td style="padding-left: 0px;">
403               <input type="text" name="networking_address" size="32" value="{$smarty.request.networking_address}" />
404             </td>
405             <td>
406               <input type="text" name="networking_typeTxt" class="autocomplete" size="10" value="{$smarty.request.networking_typeTxt}" />
407               <input name="networking_type" class="autocompleteTarget" type="hidden" value="{$smarty.request.networking_type}"/>
408               <a href="networking_type" class="autocompleteToSelect">{icon name="table" title="Tous les types d'adresse"}</a>
409             </td>
410           </tr>
411         </table>
412       </td>
413     </tr>
414         {if $smarty.session.auth ge AUTH_COOKIE}
415     <tr>
416       <td colspan="2">
417           <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
418           <label for="order">Mettre les fiches modifiées récemment en premier.</label>
419       </td>
420     </tr>
421     <tr>
422       <td colspan="2">
423            <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
424            <label for="exact">Faire une recherche exacte.</label>
425       </td>
426     </tr>
427         {/if}
428     <tr><td colspan="2"></td></tr>
429     <tr>
430       <td colspan="2" style="text-align: center">
431           <input type="submit" value="Chercher" />
432       </td>
433     </tr>
434   </table>
435 </form>
436 <p>
437   <small><strong>N.B.&nbsp;:</strong> le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.</small>
438 </p>
439
440 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}