1 {**************************************************************************}
3 {* Copyright (C) 2003-2008 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 <script type="text/javascript">// <!--
26 var baseurl = platal_baseurl + "search/";
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');
33 name = row[0].replace(regexp, '<strong>$1<\/strong>');
35 if (row[1] === "-1") {
39 return name + '<em> - ' + row[1] + ' camarades<\/em>';
43 // when changing country, open up region choice
44 function changeCountry(a2) {
45 $(".autocompleteTarget[@name='country']").attr('value',a2);
48 $(".autocomplete[@name='countryTxt']").addClass('hidden_valid');
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}');
54 $("tr#region_ln").show();
56 $("select[@name='region']").attr('value', '');
58 $("tr#region_ln").hide();
62 $(".autocomplete[@name='countryTxt']").removeClass('hidden_valid');
64 $("select[@name='region']").attr('value', '');
66 $("tr#region_ln").hide();
70 // when changing school, open diploma choice
71 function changeSchool(schoolId) {
72 $(".autocompleteTarget[@name='school']").attr('value',schoolId);
75 $(".autocomplete[@name='schoolTxt']").addClass('hidden_valid');
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}');
81 $("tr#diploma_ln").show();
83 $("select[@name='diploma']").attr('value', '');
85 $("tr#diploma_ln").hide();
89 $(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
91 $("select[@name='diploma']").attr('value', '');
93 $("tr#diploma_ln").hide();
97 // when choosing autocomplete from list, must validate
98 function select_autocomplete(name) {
99 nameRealField = name.replace(/Txt$/, '');
101 // nothing to do if field is not a text field for a list
102 if (nameRealField == name)
105 // if changing country, might want to open region choice
106 if (nameRealField == 'country')
108 changeCountry(i.extra[1]);
111 if (nameRealField == 'school')
113 changeSchool(i.extra[1]);
116 // change field in list and display text field as valid
118 nameRealField = this.field.replace(/Txt$/, '');
120 $(".autocompleteTarget[@name='"+nameRealField+"']").attr('value',i.extra[1]);
122 $(".autocomplete[@name='"+this.field+"']").addClass('hidden_valid');
126 $(document).ready(function() {
127 $(".autocompleteTarget").hide();
128 $(".autocomplete").show().each(function() {
129 targeted = $("../.autocompleteTarget",this)[0];
131 if (targeted && targeted.value) {
134 $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
135 me.attr('value', textValue);
136 me.addClass('hidden_valid');
140 $(this).autocomplete(baseurl + "autocomplete/"+this.name,{
142 formatItem:make_format_autocomplete(this),
144 onItemSelect:select_autocomplete(this.name),
146 width:$(this).width()});
149 $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
151 $(".autocomplete[@name='countryTxt']").change(function() { changeCountry(''); });
153 changeCountry({/literal}'{$smarty.request.country}'{literal});
155 $(".autocomplete[@name='schoolTxt']").change(function() { changeSchool(''); });
157 changeSchool({/literal}'{$smarty.request.school}'{literal});
159 $(".autocompleteToSelect").each(function() {
160 var fieldName = $(this).attr('href');
162 $(this).attr('href', baseurl + 'list/'+fieldName).click(function() {
163 var oldval = $("input.autocompleteTarget[@name='"+fieldName+"']")[0].value;
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);
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('');
182 <form id="recherche" action="search/adv" method="get">
183 <table class="bicol" cellpadding="3" summary="Recherche">
186 Recherche avancée [<a href="search"><<< Recherche simple</a>]
192 <input type="hidden" name="rechercher" value="Chercher"/>
193 <input type="submit" style="display:none"/>
194 <input type="text" class="autocomplete" name="name" size="32" value="{$smarty.request.name}" />
200 <input class="autocomplete" type="text" name="firstname" size="32" value="{$smarty.request.firstname}" />
206 <input class="autocomplete" type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
212 <select name="egal1">
213 <option value="=" {if $smarty.request.egal1 eq "="}selected="selected"{/if}> = </option>
214 <option value=">=" {if $smarty.request.egal1 eq ">="}selected="selected"{/if}> >= </option>
215 <option value="<=" {if $smarty.request.egal1 eq "<="}selected="selected"{/if}> <= </option>
217 <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
219 <select name="egal2">
220 <option value="=" {if $smarty.request.egal2 eq "="}selected="selected"{/if}> = </option>
221 <option value=">=" {if $smarty.request.egal2 eq ">="}selected="selected"{/if}> >= </option>
222 <option value="<=" {if $smarty.request.egal2 neq ">=" && $smarty.request.egal2 neq "="}selected="selected"{/if}> <= </option>
224 <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
232 <td style="width:100px">
233 <input type="radio" name="woman" value="0" {if !$smarty.request.woman}checked="checked"{/if} id="woman0"/><label for="woman0">indifférent</label>
235 <td style="width:100px">
236 <input type="radio" name="woman" value="1" {if $smarty.request.woman eq 1}checked="checked"{/if} id="woman1"/><label for="woman1">homme</label>
238 <td style="width:100px">
239 <input type="radio" name="woman" value="2" {if $smarty.request.woman eq 2}checked="checked"{/if} id="woman2"/><label for="woman2">femme</label>
246 <td>Sur Polytechnique.org</td>
250 <td style="width:100px">
251 <input type="radio" name="subscriber" value="0" {if !$smarty.request.subscriber}checked="checked"{/if} id="subscriber0"/><label for="subscriber0">indifférent</label>
253 <td style="width:100px">
254 <input type="radio" name="subscriber" value="1" {if $smarty.request.subscriber eq 1}checked="checked"{/if} id="subscriber1"/><label for="subscriber1">inscrit</label>
256 <td style="width:100px">
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>
268 <td style="width:100px">
269 <input type="radio" name="alive" value="0" {if !$smarty.request.alive}checked="checked"{/if} id="alive0"/><label for="alive0">indifférent</label>
271 <td style="width:100px">
272 <input type="radio" name="alive" value="1" {if $smarty.request.alive eq 1}checked="checked"{/if} id="alive1"/><label for="alive1">vivant</label>
274 <td style="width:100px">
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>
283 <input type="checkbox" name="with_soundex" value="1" {if $smarty.request.with_soundex}checked="checked"{/if} id="sdxn" />
284 <label for="sdxn">Étendre par proximité sonore (uniquement sur nom et prénom).</label>
288 <th colspan="2">Géographie</th>
292 <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
297 <input name="countryTxt" type="text" class="autocomplete" style="display:none" size="32"
298 value="{$smarty.request.countryTxt}"/>
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>
304 <td>Région ou département</td>
306 <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
311 <label for="only_current"><input name="only_current" id="only_current" type="checkbox"{if $smarty.request.only_current}
312 checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont actuellement.</label></td>
315 <th colspan="2">Activité</th>
319 <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
324 <input name="fonctionTxt" type="text" class="autocomplete" style="display:none" size="32"
325 value="{$smarty.request.fonctionTxt}"/>
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>
332 <td><input type="text" class="autocomplete" name="poste" size="32" value="{$smarty.request.poste}" /></td>
337 <input name="secteurTxt" type="text" class="autocomplete" style="display:none" size="32"
338 value="{$smarty.request.secteurTxt}"/>
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>
345 <td><input type="text" name="cv" size="32" value="{$smarty.request.cv}" /></td>
349 <input type='checkbox' name='only_referent' {if $smarty.request.only_referent}checked='checked'{/if} id="only_referent"/>
350 <label for="only_referent">Chercher uniquement parmi les camarades se proposant comme référents.</label>
354 <th colspan="2">Divers</th>
359 <input name="nationaliteTxt" type="text" class="autocomplete" style="display:none" size="32"
360 value="{$smarty.request.nationaliteTxt}"/>
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>
368 <input name="binetTxt" type="text" class="autocomplete" style="display:none" size="32"
369 value="{$smarty.request.binetTxt}"/>
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>
377 <input name="groupexTxt" type="text" class="autocomplete" style="display:none" size="32"
378 value="{$smarty.request.groupexTxt}"/>
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>
386 <input name="sectionTxt" type="text" class="autocomplete" style="display:none" size="32"
387 value="{$smarty.request.sectionTxt}"/>
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>
395 <input name="schoolTxt" type="text" class="autocomplete" style="display:none" size="32"
396 value="{$smarty.request.schoolTxt}"/>
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>
404 <input name="diploma" type="hidden" size="32" value="{$smarty.request.diploma}"/>
408 <td>Commentaire contient</td>
409 <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
411 {if $smarty.session.auth ge AUTH_COOKIE}
414 <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
415 <label for="order">Mettre les fiches modifiées récemment en premier.</label>
419 <tr><td colspan="2"></td></tr>
421 <td colspan="2" style="text-align: center">
422 <input type="submit" value="Chercher" />
428 <small><strong>N.B. :</strong> le caractère joker * peut remplacer une ou plusieurs lettres dans les recherches.</small>
431 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}