1 {**************************************************************************}
3 {* Copyright (C) 2003-2011 Polytechnique.org *}
4 {* http://opensource.polytechnique.org/ *}
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. *}
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. *}
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 *}
21 {**************************************************************************}
23 <h1>Recherche dans l'annuaire</h1>
25 {if hasPerm('edit_directory,admin') && t($suggestAddresses)}
26 <p class="center"><strong>Voulez-vous télécharger le <a href="{$globals->baseurl}/search/adv/addresses{$plset_args}">tableau des adresses postales</a> pour la recette précédente ?</strong></p>
29 <script type="text/javascript">// <!--
30 var baseurl = $.plURL("search/");
33 // display an autocomplete row : blabla (nb of found matches)
34 function make_format_autocomplete(block) {
35 return function(row) {
36 regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
38 name = row[0].htmlEntities().replace(regexp, '<strong>$1<\/strong>');
40 if (row[1] === "-1") {
44 if (row[1] === "-2") {
45 return '<em>aucun camarade trouvé pour '+row[0].htmlEntities()+'<\/em>';
48 camarades = (row[1] > 1) ? "camarades" : "camarade";
50 return name + '<em> - ' + row[1].htmlEntities() + ' ' + camarades + '<\/em>';
54 function setAddress(i, j, values)
56 var types = new Array('country', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality');
57 var prev_type = types[i];
58 var next_type = types[j];
59 var next_list = next_type + '_list';
62 $('tr#locality_text').hide()
63 $("select[name='localityTxt']").attr('value', '');
66 $("[name='" + next_type + "']").parent().load(baseurl + 'list/' + next_type, { previous:prev_type, value:values[i] }, function() {
67 if ($("select[name='" + next_type + "']").children("option").size() > 1) {
68 $("tr#" + next_list).show();
69 $("select[name='" + next_type + "']").attr('value', values[j]);
71 setAddress(j, j + 1, values);
74 $("tr#" + next_list).hide();
75 $("select[name='" + next_type + "']").attr('value', '');
77 setAddress(i, j + 1, values);
84 function displayNextAddressComponent(i, j, value)
86 var types = new Array('country', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality');
87 var prev_type = types[i];
88 var next_type = types[j];
89 var next_list = next_type + '_list';
92 $('tr#locality_text').hide()
93 $("select[name='localityTxt']").attr('value', '');
96 $("[name='" + next_type + "']").parent().load(baseurl + 'list/' + next_type, { previous:prev_type, value:value }, function() {
97 $("select[name='" + next_type + "']").attr('value', '');
98 if ($("select[name='" + next_type + "']").children("option").size() > 1) {
99 $("tr#" + next_list).show();
101 $("tr#" + next_list).hide();
103 displayNextAddressComponent(i, j + 1, value);
109 function changeAddressComponents(type, value)
111 var types = new Array('country', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality');
114 while (types[i] != type && i < 6) {
120 $("select[name='" + types[j] + "']").attr('value', '');
121 $("tr#" + types[j] + "_list").hide();
125 if (value != '' && i < 5) {
126 $("select[name='" + type + "']").attr('value', value);
127 displayNextAddressComponent(i, i + 1, value);
131 // when changing school, open diploma choice
132 function changeSchool(schoolId) {
133 $(".autocompleteTarget[name='school']").attr('value',schoolId);
136 $(".autocomplete[name='schoolTxt']").addClass('hidden_valid');
138 $(".autocomplete[name='schoolTxt']").removeClass('hidden_valid');
141 $("[name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
142 $("select[name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
146 // when checking/unchecking "only_referent", disable/enable some fields
147 function changeOnlyReferent() {
148 if ($("#only_referent").is(':checked')) {
149 $("input[name='entreprise']").attr('disabled', true);
151 $("input[name='entreprise']").removeAttr('disabled');
155 // when choosing a job term in tree, hide tree and set job term field
156 function searchForJobTerm(treeid, jtid, full_name) {
157 $(".term_tree").remove();
158 $("input[name='jobtermTxt']").val(full_name).addClass("hidden_valid").show();
159 $("input[name='jobterm']").val(jtid);
162 function cancel_autocomplete(field, realfield) {
163 $(".autocomplete[name='"+field+"']").removeClass('hidden_valid').val('').focus();
164 if (typeof(realfield) != "undefined") {
165 $(".autocompleteTarget[name='"+realfield+"']").val('');
170 // when choosing autocomplete from list, must validate
171 function select_autocomplete(name) {
172 nameRealField = name.replace(/Txt$/, '');
174 // nothing to do if field is not a text field for a list
175 if (nameRealField == name)
178 // When changing country or locality, open next address component.
179 if (nameRealField == 'country' || nameRealField == 'locality') {
181 nameRealField = name.replace(/Txt$/, '');
182 if (i.extra[0] < 0) {
183 cancel_autocomplete(name, nameRealField);
186 $("[name='" + nameRealField + "']").parent().load(baseurl + 'list/' + nameRealField, function() {
187 $("select[name='" + nameRealField + "']").attr('value', i.extra[1]);
189 changeAddressComponents(nameRealField, i.extra[1]);
193 if (nameRealField == 'school')
195 if (i.extra[0] < 0) {
196 cancel_autocomplete('schoolTxt', 'school');
199 changeSchool(i.extra[1]);
202 // change field in list and display text field as valid
204 nameRealField = this.field.replace(/Txt$/, '');
206 if (i.extra[0] < 0) {
207 cancel_autocomplete(this.field, nameRealField);
211 $(".autocompleteTarget[name='"+nameRealField+"']").attr('value',i.extra[1]);
213 $(".autocomplete[name='"+this.field+"']").addClass('hidden_valid');
218 $(".autocompleteTarget").hide();
219 $(".autocomplete").show().each(function() {
220 targeted = $("../.autocompleteTarget",this)[0];
222 if (targeted && targeted.value) {
225 $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
226 me.attr('value', textValue);
227 me.addClass('hidden_valid');
231 $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
233 formatItem:make_format_autocomplete(this),
235 onItemSelect:select_autocomplete(this.name),
237 width:$(this).width()});
240 $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
242 if ({/literal}'{$smarty.request.country}'{literal} != '') {
243 $("[name='country']").parent().load(baseurl + 'list/country', function() {
244 $("select[name='country']").attr('value', {/literal}'{$smarty.request.country}'{literal});
246 setAddress(0, 1, new Array({/literal}'{$smarty.request.country}'{literal},
247 {/literal}'{$smarty.request.administrative_area_level_1}'{literal},
248 {/literal}'{$smarty.request.administrative_area_level_2}'{literal},
249 {/literal}'{$smarty.request.administrative_area_level_3}'{literal},
250 {/literal}'{$smarty.request.locality}'{literal},
251 {/literal}'{$smarty.request.sublocality}'{literal})
254 var types = new Array('administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality');
255 for (var i = 0; i < 5; ++i) {
256 $("tr#" + types[i] + '_list').hide();
260 $(".autocomplete[name='schoolTxt']").change(function() { changeSchool(''); });
262 changeSchool({/literal}'{$smarty.request.school}'{literal});
264 $(".autocompleteToSelect").each(function() {
265 var fieldName = $(this).attr('href');
267 $(this).attr('href', baseurl + 'list/'+fieldName).click(function() {
268 var oldval = $("input.autocompleteTarget[name='"+fieldName+"']")[0].value;
270 $(".autocompleteTarget[name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},
271 function(selectBox) {
272 $(".autocompleteTarget[name='"+fieldName+"']").remove();
273 $(".autocomplete[name='"+fieldName+"Txt']").remove();
274 $("select[name='"+fieldName+"']").attr('value', oldval);
279 }).parent().find('.autocomplete').change(function() {
280 // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used,
281 // to ensure that, we unset it
282 $(this).parent().find('.autocompleteTarget').val('');
285 $("#only_referent").change(function() { changeOnlyReferent(); });
288 /** Regexps to wipe out from search queries */
289 var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&networking_type=0(&|$)/, /&[^&=]+=(&|$)/g ];
290 /** Uses javascript to clean form from all empty fields */
291 function cleanForm(f) {
292 var query = $(f).formSerialize();
294 for (var i in default_form_values) {
295 var reg = default_form_values[i];
296 if (typeof(reg) != "undefined") {
299 query = query.replace(reg, '$1');
300 } while (old_query != query);
303 query = query.replace(/^&*(.*)&*$/, '$1');
304 if (query == "rechercher=Chercher") {
305 alert("Aucun critère n'a été spécifié");
308 document.location = baseurl + 'adv?' + query;
313 <p class="center">[<a href="search">Revenir à la recherche simple</a>]</p>
314 <form id="recherche" action="search/adv" method="get" onsubmit="return cleanForm(this)">
315 <table class="bicol" cellpadding="3" summary="Recherche">
322 <td>Nom, prénom, surnom...</td>
324 <input type="hidden" name="rechercher" value="Chercher"/>
325 <input type="submit" style="display:none"/>
326 <input type="text" name="name" size="32" value="{$smarty.request.name}" />
327 <select name="name_type">
328 <option value="" {if $smarty.request.name_type eq ''}selected="selected"{/if}> - </option>
329 <option value="lastname" {if $smarty.request.name_type eq 'lastname'}selected="selected"{/if}>nom</option>
330 <option value="firstname" {if $smarty.request.name_type eq 'firstname'}selected="selected"{/if}>prénom</option>
331 <option value="nickname" {if $smarty.request.name_type eq 'nickname'}selected="selected"{/if}>surnom</option>
338 {include file="include/select_promo.tpl" promo_data=$smarty.request egal1="egal1" egal2="egal2" promo1="promo1" promo2="promo2" edu_type="edu_type"}
346 <td style="width:100px">
347 <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">indifférent</label>
349 <td style="width:100px">
350 <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">homme</label>
352 <td style="width:100px">
353 <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">femme</label>
360 <td>Sur Polytechnique.org</td>
364 <td style="width:100px">
365 <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">indifférent</label>
367 <td style="width:100px">
368 <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">inscrit</label>
370 <td style="width:100px">
371 <input type="radio" name="subscriber" value="2" {if $smarty.request.subscriber eq 2}checked="checked"{/if} id="subscriber2"/><label for="subscriber2">non inscrit</label>
378 <td>A une redirection active</td>
382 <td style="width:100px">
383 <input type="radio" name="has_email_redirect" value="0" {if !$smarty.request.has_email_redirect}checked="checked"{/if}
384 id="has_email_redirect0" /><label for="has_email_redirect0">indifférent</label>
386 <td style="width:100px">
387 <input type="radio" name="has_email_redirect" value="1" {if $smarty.request.has_email_redirect eq 1}checked="checked"{/if}
388 id="has_email_redirect1" /><label for="has_email_redirect1">oui</label>
390 <td style="width:100px">
391 <input type="radio" name="has_email_redirect" value="2" {if $smarty.request.has_email_redirect eq 2}checked="checked"{/if}
392 id="has_email_redirect2" /><label for="has_email_redirect2">non</label>
403 <td style="width:100px">
404 <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">indifférent</label>
406 <td style="width:100px">
407 <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">vivant</label>
409 <td style="width:100px">
410 <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>
418 <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
419 <label for="sdxn">Étendre par proximité sonore (uniquement sur nom et prénom).</label>
423 <th colspan="2">Géographie</th>
428 <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"
429 value="{$smarty.request.countryTxt}"/>
430 <input name="country" class="autocompleteTarget" type="hidden" value="{$smarty.request.country}"/>
431 <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
434 <tr id="administrative_area_level_1_list">
435 <td>Région, province, état…</td>
437 <input name="administrative_area_level_1" type="hidden" size="32" value="{$smarty.request.administrative_area_level_1}" />
440 <tr id="administrative_area_level_2_list">
441 <td>Département, comté…</td>
443 <input name="administrative_area_level_2" type="hidden" size="32" value="{$smarty.request.administrative_area_level_2}" />
446 <tr id="administrative_area_level_3_list">
447 <td>Canton…</td>
449 <input name="administrative_area_level_3" type="hidden" size="32" value="{$smarty.request.administrative_area_level_3}" />
452 <tr id="locality_text">
454 <td><input type="text" class="autocomplete" name="localityTxt" size="32" value="{$smarty.request.localityTxt}" /></td>
456 <tr id="locality_list">
459 <input name="locality" type="hidden" size="32" value="{$smarty.request.locality}" />
462 <tr id="sublocality_list">
463 <td>Arrondissement, quartier…</td>
465 <input name="sublocality" type="hidden" size="32" value="{$smarty.request.sublocality}" />
470 <label for="only_current">
471 <input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current} checked="checked"{/if}/>
472 Chercher uniquement les adresses actuelles.
477 <th colspan="2">Activité</th>
481 <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
485 <td><input type="text" class="autocomplete" name="jobdescription" size="32" value="{$smarty.request.jobdescription}" /></td>
490 <input name="jobtermTxt" type="text" class="autocomplete{if $smarty.request.jobterm} hidden_valid{/if}" style="display:none" size="32"
491 value="{$smarty.request.jobtermTxt}"/>
492 <input name="jobterm" class="autocompleteTarget" type="hidden" value="{$smarty.request.jobterm}"/>
493 <a href="jobterm" class="autocompleteToSelect">{icon name="table" title="Tous les mots-clefs"}</a>
496 {if hasPerm('directory_private')}
499 <td><input type="text" name="cv" size="32" value="{$smarty.request.cv}" /></td>
504 <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
505 <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
509 <th colspan="2">Divers</th>
514 <input name="nationaliteTxt" type="text" class="autocomplete" style="display:none" size="32"
515 value="{$smarty.request.nationaliteTxt}"/>
516 <input name="nationalite" class="autocompleteTarget" type="hidden" value="{$smarty.request.nationalite}"/>
517 <a href="nationalite" class="autocompleteToSelect">{icon name="table" title="Toutes les nationalités"}</a>
520 {if hasPerm('directory_private')}
524 <input name="binetTxt" type="text" class="autocomplete" style="display:none" size="32"
525 value="{$smarty.request.binetTxt}"/>
526 <input name="binet" class="autocompleteTarget" type="hidden" value="{$smarty.request.binet}"/>
527 <a href="binet" class="autocompleteToSelect">{icon name="table" title="Tous les binets"}</a>
534 <input name="groupexTxt" type="text" class="autocomplete" style="display:none" size="32"
535 value="{$smarty.request.groupexTxt}"/>
536 <input name="groupex" class="autocompleteTarget" type="hidden" value="{$smarty.request.groupex}"/>
537 <a href="groupex" class="autocompleteToSelect">{icon name="table" title="Tous les groupes X"}</a>
540 {if hasPerm('directory_private')}
544 <input name="sectionTxt" type="text" class="autocomplete" style="display:none" size="32"
545 value="{$smarty.request.sectionTxt}"/>
546 <input name="section" class="autocompleteTarget" type="hidden" value="{$smarty.request.section}"/>
547 <a href="section" class="autocompleteToSelect">{icon name="table" title="Toutes les sections"}</a>
554 <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"
555 value="{$smarty.request.schoolTxt}"/>
556 <input name="school" class="autocompleteTarget" type="hidden" value="{$smarty.request.school}"/>
557 <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
563 <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
567 <td>Corps d'origine</td>
569 <select name="origin_corps">
570 {foreach from=$origin_corps_list key=id item=corps}
571 <option value="{$id}" {if $smarty.request.origin_corps eq $id}selected="selected"{/if}>{$corps}</option>
577 <td>Corps actuel</td>
579 <select name="current_corps">
580 {foreach from=$current_corps_list key=id item=corps}
581 <option value="{$id}" {if $smarty.request.current_corps eq $id}selected="selected"{/if}>{$corps}</option>
589 <select name="corps_rank">
590 {foreach from=$corps_rank_list key=id item=corps}
591 <option value="{$id}" {if $smarty.request.corps_rank eq $id}selected="selected"{/if}>{$corps}</option>
597 <td>Commentaire contient</td>
598 <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
601 <td>Numéro de téléphone</td>
602 <td><input type="text" name="phone_number" size="32" value="{$smarty.request.phone_number}"/></td>
605 <td style="vertical-align: middle">
606 <span>Networking et sites webs</span>
611 <td style="padding-left: 0px;">
612 <input type="text" name="networking_address" size="32" value="{$smarty.request.networking_address}" />
615 <select name="networking_type">
616 {foreach from=$networking_types key=id item=network}
617 <option value="{$id}" {if $smarty.request.networking_type eq $id}selected="selected"{/if}>{$network}</option>
625 {if hasPerm('admin,edit_directory')}
627 <td>Matricule AX</td>
629 <textarea name="schoolid_ax" rows="10" cols="12">{$smarty.request.schoolid_ax}</textarea>
631 <i>Entrer une liste de matricules AX (un par ligne)</i>
634 {if $smarty.session.auth ge AUTH_COOKIE}
638 <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
639 <label for="order">Mettre les fiches modifiées récemment en premier.</label>
644 <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
645 <label for="exact">Faire une recherche exacte.</label>
649 <tr><td colspan="2"></td></tr>
651 <td colspan="2" style="text-align: center">
652 <input type="submit" value="Chercher" />
658 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}