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