Clean url in advanced search. Closes #1177
[platal.git] / templates / search / adv.form.tpl
CommitLineData
0337d704 1{**************************************************************************}
2{* *}
9f5bd98e 3{* Copyright (C) 2003-2010 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
21fb012b
PC
25{javascript name=jquery.form}
26
f06a6d2b
OLF
27<script type="text/javascript">// <!--
28 var baseurl = platal_baseurl + "search/";
29 {literal}
30 // display an autocomplete row : blabla (nb of found matches)
31 function make_format_autocomplete(block) {
32 return function(row) {
33 regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
f1de811f 34
231c87d0 35 name = row[0].replace(regexp, '<strong>$1<\/strong>');
f1de811f 36
b3ec63d5 37 if (row[1] === "-1") {
6e828e47 38 return '&hellip;';
66f2b6b3 39 }
f1de811f 40
8a28e579
SJ
41 camarades = (row[1] > 1) ? "camarades" : "camarade";
42
43 return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + '&nbsp;' + camarades + '<\/em>';
f06a6d2b
OLF
44 };
45 }
f1de811f 46
f06a6d2b
OLF
47 // when changing country, open up region choice
48 function changeCountry(a2) {
1bdd08a7 49 $(".autocompleteTarget[name='country']").attr('value',a2);
f1de811f 50
f06a6d2b 51 if (a2) {
1bdd08a7 52 $(".autocomplete[name='countryTxt']").addClass('hidden_valid');
f1de811f 53
1bdd08a7
SJ
54 $("[name='region']").parent().load(baseurl + 'list/region/', { country:a2 }, function() {
55 if ($("select[name='region']").children("option").size() > 1) {
56 $("select[name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}');
f1de811f 57
f06a6d2b 58 $("tr#region_ln").show();
66f2b6b3 59 } else {
1bdd08a7 60 $("select[name='region']").attr('value', '');
f1de811f 61
bac1e60a 62 $("tr#region_ln").hide();
66f2b6b3 63 }
f06a6d2b
OLF
64 });
65 } else {
1bdd08a7 66 $(".autocomplete[name='countryTxt']").removeClass('hidden_valid');
f1de811f 67
1bdd08a7 68 $("select[name='region']").attr('value', '');
f1de811f 69
f06a6d2b
OLF
70 $("tr#region_ln").hide();
71 }
72 }
f1de811f 73
f06a6d2b
OLF
74 // when changing school, open diploma choice
75 function changeSchool(schoolId) {
1bdd08a7 76 $(".autocompleteTarget[name='school']").attr('value',schoolId);
f1de811f 77
f06a6d2b 78 if (schoolId) {
1bdd08a7 79 $(".autocomplete[name='schoolTxt']").addClass('hidden_valid');
f06a6d2b 80 } else {
1bdd08a7 81 $(".autocomplete[name='schoolTxt']").removeClass('hidden_valid');
f06a6d2b 82 }
f9817768 83
96d80a35
VZ
84 $("[name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
85 $("select[name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
f9817768 86 });
f06a6d2b 87 }
f1de811f 88
3ac45f10
PC
89 // when choosing a job term in tree, hide tree and set job term field
90 function searchForJobTerm(treeid, jtid, full_name) {
91 $(".term_tree").remove();
92 $("input[name='jobtermTxt']").val(full_name).addClass("hidden_valid").show();
93 $("input[name='jobterm']").val(jtid);
94 }
95
f06a6d2b
OLF
96 // when choosing autocomplete from list, must validate
97 function select_autocomplete(name) {
98 nameRealField = name.replace(/Txt$/, '');
f1de811f 99
f06a6d2b
OLF
100 // nothing to do if field is not a text field for a list
101 if (nameRealField == name)
102 return null;
f1de811f 103
f06a6d2b
OLF
104 // if changing country, might want to open region choice
105 if (nameRealField == 'country')
106 return function(i) {
107 changeCountry(i.extra[1]);
66f2b6b3 108 }
f1de811f 109
f06a6d2b
OLF
110 if (nameRealField == 'school')
111 return function(i) {
112 changeSchool(i.extra[1]);
113 }
f1de811f 114
f06a6d2b
OLF
115 // change field in list and display text field as valid
116 return function(i) {
117 nameRealField = this.field.replace(/Txt$/, '');
f1de811f 118
1bdd08a7 119 $(".autocompleteTarget[name='"+nameRealField+"']").attr('value',i.extra[1]);
f1de811f 120
1bdd08a7 121 $(".autocomplete[name='"+this.field+"']").addClass('hidden_valid');
f06a6d2b
OLF
122 }
123 }
f1de811f 124
f06a6d2b
OLF
125 $(document).ready(function() {
126 $(".autocompleteTarget").hide();
127 $(".autocomplete").show().each(function() {
128 targeted = $("../.autocompleteTarget",this)[0];
f1de811f 129
f06a6d2b
OLF
130 if (targeted && targeted.value) {
131 me = $(this);
f1de811f 132
f06a6d2b
OLF
133 $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
134 me.attr('value', textValue);
135 me.addClass('hidden_valid');
136 });
137 }
f1de811f 138
f06a6d2b
OLF
139 $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
140 selectOnly:1,
141 formatItem:make_format_autocomplete(this),
142 field:this.name,
143 onItemSelect:select_autocomplete(this.name),
144 matchSubset:0,
145 width:$(this).width()});
146 });
f1de811f 147
f06a6d2b 148 $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
f1de811f 149
1bdd08a7 150 $(".autocomplete[name='countryTxt']").change(function() { changeCountry(''); });
f1de811f 151
f06a6d2b 152 changeCountry({/literal}'{$smarty.request.country}'{literal});
f1de811f 153
1bdd08a7 154 $(".autocomplete[name='schoolTxt']").change(function() { changeSchool(''); });
f1de811f 155
f06a6d2b 156 changeSchool({/literal}'{$smarty.request.school}'{literal});
f1de811f 157
f06a6d2b
OLF
158 $(".autocompleteToSelect").each(function() {
159 var fieldName = $(this).attr('href');
f1de811f 160
f06a6d2b 161 $(this).attr('href', baseurl + 'list/'+fieldName).click(function() {
1bdd08a7 162 var oldval = $("input.autocompleteTarget[name='"+fieldName+"']")[0].value;
f1de811f 163
1bdd08a7 164 $(".autocompleteTarget[name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},
f06a6d2b 165 function(selectBox) {
1bdd08a7
SJ
166 $(".autocompleteTarget[name='"+fieldName+"']").remove();
167 $(".autocomplete[name='"+fieldName+"Txt']").remove();
168 $("select[name='"+fieldName+"']").attr('value', oldval);
66f2b6b3 169 });
f1de811f 170
f06a6d2b 171 return false;
66f2b6b3 172 });
7d7b287c
OLF
173 }).parent().find('.autocomplete').change(function() {
174 // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used,
175 // to ensure that, we unset it
176 $(this).parent().find('.autocompleteTarget').val('');
f06a6d2b
OLF
177 });
178 });
21fb012b
PC
179/** Regexps to wipe out from search queries */
180var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&[^&=]+=(&|$)/g ];
181/** Uses javascript to clean form from all empty fields */
182function cleanForm(f) {
183 var query = $(f).formSerialize();
184 var old_query;
185 for each (var reg in default_form_values) if (typeof(reg) != "undefined") {
186 do {
187 old_query = query;
188 query = query.replace(reg, '$1');
189 } while (old_query != query);
190 }
191 query = query.replace(/^&*(.*)&*$/, '$1');
192 if (query == "") {
193 alert("Aucun critère n'a été spécifié");
194 return false;
195 }
196 document.location = f.action + '?' + query;
197 return false;
198}
f06a6d2b 199-->
a94040d2 200{/literal}</script>
ba50f03d 201<p class="center">[<a href="search">Revenir à la recherche simple</a>]</p>
21fb012b 202<form id="recherche" action="search/adv" method="get" onsubmit="return cleanForm(this)">
0337d704 203 <table class="bicol" cellpadding="3" summary="Recherche">
204 <tr>
1f17ab93 205 <th colspan="2">
ba50f03d 206 Recherche avancée
1f17ab93 207 </th>
208 </tr>
209 <tr>
6443c93d 210 <td>Nom, prénom, surnom...</td>
0337d704 211 <td>
66f2b6b3 212 <input type="hidden" name="rechercher" value="Chercher"/>
213 <input type="submit" style="display:none"/>
6443c93d 214 <input type="text" name="name" size="32" value="{$smarty.request.name}" />
0337d704 215 </td>
216 </tr>
217 <tr>
218 <td>Promotion</td>
219 <td>
220 <select name="egal1">
221 <option value="=" {if $smarty.request.egal1 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
222 <option value="&gt;=" {if $smarty.request.egal1 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
223 <option value="&lt;=" {if $smarty.request.egal1 eq "&lt;="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
224 </select>
225 <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
e803ded5 226 &nbsp;et&nbsp;
0337d704 227 <select name="egal2">
228 <option value="=" {if $smarty.request.egal2 eq "="}selected="selected"{/if}>&nbsp;=&nbsp;</option>
229 <option value="&gt;=" {if $smarty.request.egal2 eq "&gt;="}selected="selected"{/if}>&nbsp;&gt;=&nbsp;</option>
f6818108 230 <option value="&lt;=" {if $smarty.request.egal2 neq "&gt;=" && $smarty.request.egal2 neq "="}selected="selected"{/if}>&nbsp;&lt;=&nbsp;</option>
0337d704 231 </select>
232 <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
233 </td>
234 </tr>
235 <tr>
236 <td>Sexe</td>
237 <td>
238 <table>
239 <tr>
240 <td style="width:100px">
e803ded5 241 <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">indifférent</label>
0337d704 242 </td>
243 <td style="width:100px">
e803ded5 244 <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">homme</label>
0337d704 245 </td>
246 <td style="width:100px">
e803ded5 247 <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">femme</label>
0337d704 248 </td>
249 </tr>
250 </table>
251 </td>
252 </tr>
253 <tr>
e803ded5 254 <td>Sur Polytechnique.org</td>
0337d704 255 <td>
256 <table>
257 <tr>
258 <td style="width:100px">
e803ded5 259 <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">indifférent</label>
0337d704 260 </td>
261 <td style="width:100px">
e803ded5 262 <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">inscrit</label>
0337d704 263 </td>
264 <td style="width:100px">
e803ded5 265 <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 266 </td>
267 </tr>
268 </table>
269 </td>
270 </tr>
271 <tr>
272 <td>En vie</td>
273 <td>
274 <table>
275 <tr>
276 <td style="width:100px">
e803ded5 277 <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">indifférent</label>
0337d704 278 </td>
279 <td style="width:100px">
e803ded5 280 <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">vivant</label>
0337d704 281 </td>
282 <td style="width:100px">
e803ded5 283 <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 284 </td>
285 </tr>
286 </table>
287 </td>
288 </tr>
289 <tr>
56670b6a 290 <td colspan="2">
b16476f7 291 <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
e803ded5 292 <label for="sdxn">Étendre par proximité sonore (uniquement sur nom et prénom).</label>
b16476f7 293 </td>
20ac3913 294 </tr>
b16476f7 295 <tr>
296 <th colspan="2">Géographie</th>
56670b6a 297 </tr>
298 <tr>
91610ef5 299 <td>Ville ou code postal</td>
df87518a 300 <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
0337d704 301 </tr>
302 <tr>
303 <td>Pays</td>
304 <td>
b0691e10
FB
305 <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"
306 value="{$smarty.request.countryTxt}"/>
66f2b6b3 307 <input name="country" class="autocompleteTarget" type="hidden" value="{$smarty.request.country}"/>
308 <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
0337d704 309 </td>
310 </tr>
bac1e60a 311 <tr id="region_ln">
a7de4ef7 312 <td>Région ou département</td>
f6818108 313 <td>
314 <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
0337d704 315 </td>
316 </tr>
317 <tr>
b16476f7 318 <td colspan="2">
aab2ffdd
SJ
319 <label for="only_current">
320 <input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current} checked="checked"{/if}/>
321 Chercher uniquement les adresses où les camarades sont actuellement.
322 </label>
323 </td>
b16476f7 324 </tr>
325 <tr>
a7de4ef7 326 <th colspan="2">Activité</th>
0337d704 327 </tr>
328 <tr>
329 <td>Entreprise</td>
838cc16a 330 <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
0337d704 331 </tr>
332 <tr>
c7139c07
SJ
333 <td>Description</td>
334 <td><input type="text" class="autocomplete" name="description" size="32" value="{$smarty.request.description}" /></td>
0337d704 335 </tr>
336 <tr>
3ac45f10 337 <td>Mots-clefs</td>
0337d704 338 <td>
3ac45f10
PC
339 <input name="jobtermTxt" type="text" class="autocomplete{if $smarty.request.jobterm} hidden_valid{/if}" style="display:none" size="32"
340 value="{$smarty.request.jobtermTxt}"/>
341 <input name="jobterm" class="autocompleteTarget" type="hidden" value="{$smarty.request.jobterm}"/>
342 <a href="jobterm" class="autocompleteToSelect">{icon name="table" title="Tous les mots-clefs"}</a>
0337d704 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">
f6818108 351 <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
e803ded5 352 <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
0337d704 353 </td>
354 </tr>
355 <tr>
356 <th colspan="2">Divers</th>
357 </tr>
358 <tr>
a7de4ef7 359 <td>Nationalité</td>
0337d704 360 <td>
b0691e10
FB
361 <input name="nationaliteTxt" type="text" class="autocomplete" style="display:none" size="32"
362 value="{$smarty.request.nationaliteTxt}"/>
66f2b6b3 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>
0337d704 365 </td>
366 </tr>
367 <tr>
368 <td>Binet</td>
369 <td>
b0691e10
FB
370 <input name="binetTxt" type="text" class="autocomplete" style="display:none" size="32"
371 value="{$smarty.request.binetTxt}"/>
66f2b6b3 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>
0337d704 374 </td>
375 </tr>
376 <tr>
377 <td>Groupe X</td>
378 <td>
b0691e10
FB
379 <input name="groupexTxt" type="text" class="autocomplete" style="display:none" size="32"
380 value="{$smarty.request.groupexTxt}"/>
66f2b6b3 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>
0337d704 383 </td>
384 </tr>
385 <tr>
386 <td>Section</td>
387 <td>
b0691e10
FB
388 <input name="sectionTxt" type="text" class="autocomplete" style="display:none" size="32"
389 value="{$smarty.request.sectionTxt}"/>
66f2b6b3 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>
0337d704 392 </td>
393 </tr>
394 <tr>
395 <td>Formation</td>
396 <td>
b0691e10
FB
397 <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"
398 value="{$smarty.request.schoolTxt}"/>
66f2b6b3 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>
0337d704 401 </td>
402 </tr>
90b6b819 403 <tr>
f6818108 404 <td>Diplôme</td>
405 <td>
90b6b819 406 <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
0337d704 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>
14256b08 413 <tr>
93f3f260
GB
414 <td>Numéro de téléphone</td>
415 <td><input type="text" name="phone_number" size="32" value="{$smarty.request.phone_number}"/></td>
416 </tr>
417 <tr>
92c3f9e5
GB
418 <td style="vertical-align: middle">
419 <span>Networking et sites webs</span>
14256b08
GB
420 </td>
421 <td>
92c3f9e5
GB
422 <table>
423 <tr>
424 <td style="padding-left: 0px;">
425 <input type="text" name="networking_address" size="32" value="{$smarty.request.networking_address}" />
426 </td>
427 <td>
428 <input type="text" name="networking_typeTxt" class="autocomplete" size="10" value="{$smarty.request.networking_typeTxt}" />
429 <input name="networking_type" class="autocompleteTarget" type="hidden" value="{$smarty.request.networking_type}"/>
430 <a href="networking_type" class="autocompleteToSelect">{icon name="table" title="Tous les types d'adresse"}</a>
431 </td>
432 </tr>
433 </table>
14256b08
GB
434 </td>
435 </tr>
1f17ab93 436 {if $smarty.session.auth ge AUTH_COOKIE}
e803ded5
SJ
437 <tr>
438 <td colspan="2">
f6818108 439 <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
e803ded5
SJ
440 <label for="order">Mettre les fiches modifiées récemment en premier.</label>
441 </td>
442 </tr>
b8c2ada6
SJ
443 <tr>
444 <td colspan="2">
445 <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
446 <label for="exact">Faire une recherche exacte.</label>
447 </td>
448 </tr>
1f17ab93 449 {/if}
e803ded5
SJ
450 <tr><td colspan="2"></td></tr>
451 <tr>
452 <td colspan="2" style="text-align: center">
453 <input type="submit" value="Chercher" />
1f17ab93 454 </td>
455 </tr>
0337d704 456 </table>
cb4a0b71 457</form>
0337d704 458<p>
6bb2f79a 459 <small><strong>N.B.&nbsp;:</strong> le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.</small>
0337d704 460</p>
461
a7de4ef7 462{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}