1 {**************************************************************************}
3 {* Copyright (C) 2003-2010 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 {javascript name=jquery.form}
31 <script type="text/javascript">// <!--
32 var baseurl = platal_baseurl + "search/";
34 String.prototype.htmlEntities = function () {
35 return this.replace(/&/g,'&').replace(new RegExp('<','g'),'<').replace(/>/g,'>');
37 // display an autocomplete row : blabla (nb of found matches)
38 function make_format_autocomplete(block) {
39 return function(row) {
40 regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
42 name = row[0].htmlEntities().replace(regexp, '<strong>$1<\/strong>');
44 if (row[1] === "-1") {
48 if (row[1] === "-2") {
49 return '<em>aucun camarade trouvé pour '+row[0].htmlEntities()+'<\/em>';
52 camarades = (row[1] > 1) ? "camarades" : "camarade";
54 return name + '<em> - ' + row[1].htmlEntities() + ' ' + camarades + '<\/em>';
58 // when changing country, open up region choice
59 function changeCountry(a2) {
60 $(".autocompleteTarget[name='country']").attr('value',a2);
63 $(".autocomplete[name='countryTxt']").addClass('hidden_valid');
65 $("[name='region']").parent().load(baseurl + 'list/region/', { country:a2 }, function() {
66 if ($("select[name='region']").children("option").size() > 1) {
67 $("select[name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}');
69 $("tr#region_ln").show();
71 $("select[name='region']").attr('value', '');
73 $("tr#region_ln").hide();
77 $(".autocomplete[name='countryTxt']").removeClass('hidden_valid');
79 $("select[name='region']").attr('value', '');
81 $("tr#region_ln").hide();
85 // when changing school, open diploma choice
86 function changeSchool(schoolId) {
87 $(".autocompleteTarget[name='school']").attr('value',schoolId);
90 $(".autocomplete[name='schoolTxt']").addClass('hidden_valid');
92 $(".autocomplete[name='schoolTxt']").removeClass('hidden_valid');
95 $("[name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
96 $("select[name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
100 // when choosing a job term in tree, hide tree and set job term field
101 function searchForJobTerm(treeid, jtid, full_name) {
102 $(".term_tree").remove();
103 $("input[name='jobtermTxt']").val(full_name).addClass("hidden_valid").show();
104 $("input[name='jobterm']").val(jtid);
107 function cancel_autocomplete(field, realfield) {
108 $(".autocomplete[name='"+field+"']").removeClass('hidden_valid').val('').focus();
109 if (typeof(realfield) != "undefined") {
110 $(".autocompleteTarget[name='"+realfield+"']").val('');
115 // when choosing autocomplete from list, must validate
116 function select_autocomplete(name) {
117 nameRealField = name.replace(/Txt$/, '');
119 // nothing to do if field is not a text field for a list
120 if (nameRealField == name)
123 // if changing country, might want to open region choice
124 if (nameRealField == 'country')
126 if (i.extra[0] < 0) {
127 cancel_autocomplete('countryTxt', 'country');
130 changeCountry(i.extra[1]);
133 if (nameRealField == 'school')
135 if (i.extra[0] < 0) {
136 cancel_autocomplete('schoolTxt', 'school');
139 changeSchool(i.extra[1]);
142 // change field in list and display text field as valid
144 nameRealField = this.field.replace(/Txt$/, '');
146 if (i.extra[0] < 0) {
147 cancel_autocomplete(this.field, nameRealField);
151 $(".autocompleteTarget[name='"+nameRealField+"']").attr('value',i.extra[1]);
153 $(".autocomplete[name='"+this.field+"']").addClass('hidden_valid');
157 $(document).ready(function() {
158 $(".autocompleteTarget").hide();
159 $(".autocomplete").show().each(function() {
160 targeted = $("../.autocompleteTarget",this)[0];
162 if (targeted && targeted.value) {
165 $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
166 me.attr('value', textValue);
167 me.addClass('hidden_valid');
171 $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
173 formatItem:make_format_autocomplete(this),
175 onItemSelect:select_autocomplete(this.name),
177 width:$(this).width()});
180 $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
182 $(".autocomplete[name='countryTxt']").change(function() { changeCountry(''); });
184 changeCountry({/literal}'{$smarty.request.country}'{literal});
186 $(".autocomplete[name='schoolTxt']").change(function() { changeSchool(''); });
188 changeSchool({/literal}'{$smarty.request.school}'{literal});
190 $(".autocompleteToSelect").each(function() {
191 var fieldName = $(this).attr('href');
193 $(this).attr('href', baseurl + 'list/'+fieldName).click(function() {
194 var oldval = $("input.autocompleteTarget[name='"+fieldName+"']")[0].value;
196 $(".autocompleteTarget[name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{},
197 function(selectBox) {
198 $(".autocompleteTarget[name='"+fieldName+"']").remove();
199 $(".autocomplete[name='"+fieldName+"Txt']").remove();
200 $("select[name='"+fieldName+"']").attr('value', oldval);
205 }).parent().find('.autocomplete').change(function() {
206 // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used,
207 // to ensure that, we unset it
208 $(this).parent().find('.autocompleteTarget').val('');
211 /** Regexps to wipe out from search queries */
212 var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&networking_type=0(&|$)/, /&[^&=]+=(&|$)/g ];
213 /** Uses javascript to clean form from all empty fields */
214 function cleanForm(f) {
215 var query = $(f).formSerialize();
217 for (var i in default_form_values) {
218 var reg = default_form_values[i];
219 if (typeof(reg) != "undefined") {
222 query = query.replace(reg, '$1');
223 } while (old_query != query);
226 query = query.replace(/^&*(.*)&*$/, '$1');
227 if (query == "rechercher=Chercher") {
228 alert("Aucun critère n'a été spécifié");
231 document.location = baseurl + 'adv?' + query;
236 <p class="center">[<a href="search">Revenir à la recherche simple</a>]</p>
237 <form id="recherche" action="search/adv" method="get" onsubmit="return cleanForm(this)">
238 <table class="bicol" cellpadding="3" summary="Recherche">
245 <td>Nom, prénom, surnom...</td>
247 <input type="hidden" name="rechercher" value="Chercher"/>
248 <input type="submit" style="display:none"/>
249 <input type="text" name="name" size="32" value="{$smarty.request.name}" />
255 <script type="text/javascript">/*<![CDATA[*/
257 function updatepromofields(egal1) {
259 f.egal2.disabled = f.promo2.disabled = egal1.value == '=';
260 f.egal2.readOnly = true;
261 if (f.egal1.value == '>=') {
262 f.egal2.value = '<=';
264 f.egal2.value = '>=';
267 $(document).ready(function() { updatepromofields($('select[name=egal1]')[0]); });
270 <select name="egal1" onchange="updatepromofields(this)" style="text-align:center">
271 <option value="=" {if $smarty.request.egal1 eq "="}selected="selected"{/if}> = </option>
272 <option value=">=" {if $smarty.request.egal1 eq ">="}selected="selected"{/if}> >= </option>
273 <option value="<=" {if $smarty.request.egal1 eq "<="}selected="selected"{/if}> <= </option>
275 <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
277 <input type="text" name="egal2" size="1" style="text-align:center" value="{if t($smarty.request.egal2) eq '<'}<{else}>{/if}" readonly="readonly" />
278 <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
286 <td style="width:100px">
287 <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">indifférent</label>
289 <td style="width:100px">
290 <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">homme</label>
292 <td style="width:100px">
293 <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">femme</label>
300 <td>Sur Polytechnique.org</td>
304 <td style="width:100px">
305 <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">indifférent</label>
307 <td style="width:100px">
308 <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">inscrit</label>
310 <td style="width:100px">
311 <input type="radio" name="subscriber" value="2" {if $smarty.request.subscriber eq 2}checked="checked"{/if} id="subscriber2"/><label for="subscriber2">non inscrit</label>
322 <td style="width:100px">
323 <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">indifférent</label>
325 <td style="width:100px">
326 <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">vivant</label>
328 <td style="width:100px">
329 <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>
337 <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
338 <label for="sdxn">Étendre par proximité sonore (uniquement sur nom et prénom).</label>
342 <th colspan="2">Géographie</th>
345 <td>Ville ou code postal</td>
346 <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
351 <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"
352 value="{$smarty.request.countryTxt}"/>
353 <input name="country" class="autocompleteTarget" type="hidden" value="{$smarty.request.country}"/>
354 <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
358 <td>Région ou département</td>
360 <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
365 <label for="only_current">
366 <input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current} checked="checked"{/if}/>
367 Chercher uniquement les adresses où les camarades sont actuellement.
372 <th colspan="2">Activité</th>
376 <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
380 <td><input type="text" class="autocomplete" name="description" size="32" value="{$smarty.request.description}" /></td>
385 <input name="jobtermTxt" type="text" class="autocomplete{if $smarty.request.jobterm} hidden_valid{/if}" style="display:none" size="32"
386 value="{$smarty.request.jobtermTxt}"/>
387 <input name="jobterm" class="autocompleteTarget" type="hidden" value="{$smarty.request.jobterm}"/>
388 <a href="jobterm" class="autocompleteToSelect">{icon name="table" title="Tous les mots-clefs"}</a>
391 {if hasPerm('directory_private')}
394 <td><input type="text" name="cv" size="32" value="{$smarty.request.cv}" /></td>
399 <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
400 <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
404 <th colspan="2">Divers</th>
409 <input name="nationaliteTxt" type="text" class="autocomplete" style="display:none" size="32"
410 value="{$smarty.request.nationaliteTxt}"/>
411 <input name="nationalite" class="autocompleteTarget" type="hidden" value="{$smarty.request.nationalite}"/>
412 <a href="nationalite" class="autocompleteToSelect">{icon name="table" title="Toutes les nationalités"}</a>
415 {if hasPerm('directory_private')}
419 <input name="binetTxt" type="text" class="autocomplete" style="display:none" size="32"
420 value="{$smarty.request.binetTxt}"/>
421 <input name="binet" class="autocompleteTarget" type="hidden" value="{$smarty.request.binet}"/>
422 <a href="binet" class="autocompleteToSelect">{icon name="table" title="Tous les binets"}</a>
429 <input name="groupexTxt" type="text" class="autocomplete" style="display:none" size="32"
430 value="{$smarty.request.groupexTxt}"/>
431 <input name="groupex" class="autocompleteTarget" type="hidden" value="{$smarty.request.groupex}"/>
432 <a href="groupex" class="autocompleteToSelect">{icon name="table" title="Tous les groupes X"}</a>
435 {if hasPerm('directory_private')}
439 <input name="sectionTxt" type="text" class="autocomplete" style="display:none" size="32"
440 value="{$smarty.request.sectionTxt}"/>
441 <input name="section" class="autocompleteTarget" type="hidden" value="{$smarty.request.section}"/>
442 <a href="section" class="autocompleteToSelect">{icon name="table" title="Toutes les sections"}</a>
449 <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"
450 value="{$smarty.request.schoolTxt}"/>
451 <input name="school" class="autocompleteTarget" type="hidden" value="{$smarty.request.school}"/>
452 <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
458 <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
462 <td>Commentaire contient</td>
463 <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
466 <td>Numéro de téléphone</td>
467 <td><input type="text" name="phone_number" size="32" value="{$smarty.request.phone_number}"/></td>
470 <td style="vertical-align: middle">
471 <span>Networking et sites webs</span>
476 <td style="padding-left: 0px;">
477 <input type="text" name="networking_address" size="32" value="{$smarty.request.networking_address}" />
480 <select name="networking_type">
481 {foreach from=$networking_types key=id item=network}
482 <option value="{$id}" {if $smarty.request.networking_type eq $id}selected="selected"{/if}>{$network}</option>
490 {if $smarty.session.auth ge AUTH_COOKIE}
493 <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
494 <label for="order">Mettre les fiches modifiées récemment en premier.</label>
499 <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
500 <label for="exact">Faire une recherche exacte.</label>
504 <tr><td colspan="2"></td></tr>
506 <td colspan="2" style="text-align: center">
507 <input type="submit" value="Chercher" />
513 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}