index.php 17.6 KB
Newer Older
Feu's avatar
Feu committed
1
2
3
4
5
6
7
8
<?php

$topdir = "./../";
require_once($topdir. "include/site.inc.php");
require_once($topdir. "include/cts/sqltable.inc.php");
require_once($topdir. "include/cts/user.inc.php");
require_once($topdir. "include/cts/gallery.inc.php");
require_once($topdir. "include/cts/special.inc.php");
Feu's avatar
wip    
Feu committed
9
require_once($topdir. "include/entities/uv.inc.php");
slopez's avatar
slopez committed
10
11
require_once($topdir . "include/entities/ville.inc.php");
require_once($topdir . "include/entities/pays.inc.php");
Feu's avatar
Feu committed
12
13
14
15
16
17
18
19
20

$site = new site ();

$site->allow_only_logged_users("matmatronch");

if ( !$site->user->ae )
{
  $site->start_page("matmatronch","MatMaTronch");
  $cts = new contents("Accès limité");
Feu's avatar
wip    
Feu committed
21
  $cts->add_paragraph("L'accès à la recherche avancée du matmatronch est réservée aux cotisants AE.");
Feu's avatar
Feu committed
22
  $site->add_contents($cts);
23
  $site->end_page();
Feu's avatar
Feu committed
24
25
26
27
28
  exit();
}

$GLOBALS["utbm_roles"][""]="Tous";
$GLOBALS["utbm_departements"][""]="Tous";
Feu's avatar
Feu committed
29
$semestre = (date("m") > 6 ? "A" : "P") . date("y");
Feu's avatar
Feu committed
30
31
32

$is_admin = ( $site->user->is_in_group("gestion_ae") || $site->user->is_asso_role ( 27, 1 ));

Feu's avatar
wip    
Feu committed
33
34
$info = new contents("Mat'Matronch");
$info->add_paragraph("Le Mat'Matronch donne enfin un nom a un visage, le numero de portable du binome fantome, l'adresse de ce confrere que l'on recherche tant depuis cette fameuse soiree ...");
Feu's avatar
wip    
Feu committed
35
36

$list = new itemlist("Voir aussi");
pedrov's avatar
pedrov committed
37
$list->add("<a href=\"javascript:window.external.AddSearchProvider('http://ae.utbm.fr/matmatronch/matmatronch.xml');\">Extension Firefox</a>");
Feu's avatar
wip    
Feu committed
38
$list->add("La version mobile : <a href=\"http://ae.utbm.fr/i/\">http://ae.utbm.fr/i/</a> <a href=\"".$topdir."iinfo.php\">Informations</a>");
Feu's avatar
wip    
Feu committed
39
$info->add($list,true);
Feu's avatar
wip    
Feu committed
40

Feu's avatar
wip    
Feu committed
41
42
43
$list = new itemlist("Aide");
$list->add("<a href=\"".$topdir."article.php?name=docs:matmatronch\">Matmatronch</a>");
$list->add("<a href=\"".$topdir."article.php?name=docs:profil\">Profil personnel</a>");
Feu's avatar
wip    
Feu committed
44
45
$info->add($list,true);

Feu's avatar
wip    
Feu committed
46
47
48
49
$site->add_box("mmtinfo",$info);

$site->set_side_boxes("right",array("mmtinfo"),"mmt2_right");

Feu's avatar
fix    
Feu committed
50
$site->add_css("css/mmt.css");
Feu's avatar
Feu committed
51
52
$site->start_page("matmatronch","MatMaTronch");
$cts = new contents("Recherche Mat'Matronch");
Feu's avatar
wip    
Feu committed
53
$uv = new uv($site->db);
Feu's avatar
Feu committed
54

Feu's avatar
wip    
Feu committed
55
$jours = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche");
Feu's avatar
wip    
Feu committed
56
$heures = array(8=>8,9=>9,10=>10,11=>11,13=>13,14=>14,15=>15,16=>16,17=>17,18=>18,19=>19);
Feu's avatar
wip    
Feu committed
57

Feu's avatar
fix    
Feu committed
58
if ( $_REQUEST["action"] == "search" || $_REQUEST["action"] == "simplesearch" )
Feu's avatar
Feu committed
59
60
61
{
  $elements = array();
  $order = "ORDER BY `nom_utl`,`prenom_utl`";
62

Feu's avatar
fix    
Feu committed
63
  $params="";
64

Feu's avatar
fix    
Feu committed
65
66
67
68
69
70
71
72
73
  if ( $_REQUEST["pattern"] )
  {
    $pattern = stdentity::_fsearch_prepare_sql_pattern($_REQUEST["pattern"]);
    $elements[] =
      "( CONCAT(`prenom_utl`,' ',`nom_utl`) REGEXP '^".$pattern."' " .
      "OR CONCAT(`nom_utl`,' ',`prenom_utl`) REGEXP '^".$pattern."'  " .
      "OR (`surnom_utbm`!='' AND `surnom_utbm` REGEXP '^".$pattern."'))";
    $params.="&pattern=".rawurlencode($_REQUEST["pattern"]);
  }
74

Feu's avatar
Feu committed
75
  if ( $_REQUEST["nom"] )
Feu's avatar
fix    
Feu committed
76
  {
Feu's avatar
Feu committed
77
    $elements[] = "`nom_utl` REGEXP '". stdentity::_fsearch_prepare_sql_pattern($_REQUEST["nom"])."'";
Feu's avatar
fix    
Feu committed
78
79
    $params.="&nom=".rawurlencode($_REQUEST["nom"]);
  }
80

Feu's avatar
Feu committed
81
  if ( $_REQUEST["prenom"] )
Feu's avatar
fix    
Feu committed
82
  {
Feu's avatar
Feu committed
83
    $elements[] = "`prenom_utl` REGEXP '". stdentity::_fsearch_prepare_sql_pattern($_REQUEST["prenom"])."'";
Feu's avatar
fix    
Feu committed
84
85
    $params.="&prenom=".rawurlencode($_REQUEST["prenom"]);
  }
86

Feu's avatar
Feu committed
87
88
89
  if ( $_REQUEST["surnom"] )
  {
    $p = stdentity::_fsearch_prepare_sql_pattern($_REQUEST["surnom"]);
Ayolo's avatar
Ayolo committed
90
91
    $elements[] = "(`surnom_utbm` REGEXP '$p')";
    $order = "ORDER BY `surnom_utbm`,`nom_utl`,`prenom_utl`";
Feu's avatar
fix    
Feu committed
92
    $params.="&surnom=".rawurlencode($_REQUEST["surnom"]);
Feu's avatar
Feu committed
93
  }
94

Feu's avatar
Feu committed
95
  if ( $_REQUEST["date_naissance"] > 1 )
Feu's avatar
fix    
Feu committed
96
  {
Feu's avatar
Feu committed
97
    $elements[] = "`date_naissance_utl`='".date("Y-m-d",$_REQUEST["date_naissance"])."'";
Feu's avatar
fix    
Feu committed
98
99
    $params.="&date_naissance=".rawurlencode($_REQUEST["date_naissance"]);
  }
100

Feu's avatar
Feu committed
101
  if ( $_REQUEST["sexe"] && $_REQUEST["sexe"] > 0 )
Feu's avatar
fix    
Feu committed
102
  {
Feu's avatar
Feu committed
103
    $elements[] = "`sexe_utl`='".mysql_escape_string($_REQUEST["sexe"])."'";
Feu's avatar
fix    
Feu committed
104
105
    $params.="&sexe=".rawurlencode($_REQUEST["sexe"]);
  }
106

Feu's avatar
Feu committed
107
  if ( $_REQUEST["role"] )
Feu's avatar
fix    
Feu committed
108
  {
Feu's avatar
Feu committed
109
    $elements[] = "`role_utbm`='".mysql_escape_string($_REQUEST["role"])."'";
Feu's avatar
fix    
Feu committed
110
111
    $params.="&role=".rawurlencode($_REQUEST["role"]);
  }
112

Feu's avatar
Feu committed
113
  if ( $_REQUEST["departement"] )
Feu's avatar
fix    
Feu committed
114
  {
Feu's avatar
Feu committed
115
    $elements[] = "`departement_utbm`='".mysql_escape_string($_REQUEST["departement"])."'";
Feu's avatar
fix    
Feu committed
116
117
    $params.="&departement=".rawurlencode($_REQUEST["departement"]);
  }
118

Feu's avatar
Feu committed
119
  if ( $_REQUEST["semestre"] && $_REQUEST["role"] == "etu" )
Feu's avatar
fix    
Feu committed
120
  {
121
    $elements[] = "`semestre_utbm`='".intval($_REQUEST["semestre"])."'";
Feu's avatar
fix    
Feu committed
122
123
    $params.="&semestre=".rawurlencode($_REQUEST["semestre"]);
  }
124

Feu's avatar
Feu committed
125
  if ( !empty($_REQUEST["promo"]) && $_REQUEST["promo"] > 0 )
Feu's avatar
fix    
Feu committed
126
  {
Feu's avatar
Feu committed
127
    $elements[] = "`promo_utbm`='".mysql_escape_string($_REQUEST["promo"])."'";
Feu's avatar
fix    
Feu committed
128
129
    $params.="&promo=".rawurlencode($_REQUEST["promo"]);
  }
130

Feu's avatar
Feu committed
131
132
133
  if ( !empty($_REQUEST["numtel"]) )
  {
    $tel = mysql_escape_string(telephone_userinput($_REQUEST["numtel"]));
Feu's avatar
fix    
Feu committed
134
    $elements[] = "(`tel_maison_utl`='$tel' OR `tel_portable_utl`='$tel')";
Feu's avatar
fix    
Feu committed
135
    $params.="&numtel=".rawurlencode($_REQUEST["numtel"]);
Feu's avatar
Feu committed
136
137
  }

slopez's avatar
slopez committed
138
  if( $_REQUEST['id_ville'] )
slopez's avatar
slopez committed
139
  {
140
141
142
143
144
    if (isset($_REQUEST['ville_parents']))
      $elements[] = "( `utilisateurs`.`id_ville`='".intval($_REQUEST['id_ville'])."'".
                    " OR `utl_etu`.`id_ville`='".intval($_REQUEST['id_ville'])."' )";
    else
      $elements[] = "`utilisateurs`.`id_ville`='".intval($_REQUEST['id_ville'])."'";
slopez's avatar
slopez committed
145
    $params.="&id_ville=".intval($_REQUEST['id_ville']);
slopez's avatar
slopez committed
146
147
148
149
    if( isset($_REQUEST['id_pays'] ) )
      $params.="&id_pays=".intval($_REQUEST['id_pays']);
  } elseif(isset($_REQUEST['id_pays'] ) ) {
    $params.="&id_pays=".intval($_REQUEST['id_pays']);
150
151
152
153
154
    if (isset($_REQUEST['ville_parents']))
      $elements[] = "( `utilisateurs`.`id_pays`='".intval($_REQUEST['id_pays'])."'".
                  " OR `utl_etu`.`id_pays`='".intval($_REQUEST['id_pays'])."' )";
    else
      $elements[] = "`utilisateurs`.`id_pays`='".intval($_REQUEST['id_pays'])."'";
slopez's avatar
slopez committed
155
156
  }

Feu's avatar
Feu committed
157
158
  if ( count($elements) > 0 )
  {
159

Feu's avatar
fix    
Feu committed
160
    if ( !isset($_REQUEST["inclus_ancien"]) &&  $_REQUEST["action"] != "simplesearch" )
Feu's avatar
Feu committed
161
      $elements[] = "`ancien_etudiant_utl`='0'";
Feu's avatar
fix    
Feu committed
162
163
    else
      $params.= "&inclus_ancien";
164

Feu's avatar
fix    
Feu committed
165
    if ( !isset($_REQUEST["inclus_nutbm"]) &&  $_REQUEST["action"] != "simplesearch" )
Feu's avatar
Feu committed
166
      $elements[] = "`utbm_utl`='1'";
Feu's avatar
fix    
Feu committed
167
168
    else
      $params.= "&inclus_nutbm";
169

170
171
172
173
    if ( !$is_admin && !$site->user->is_in_group("visu_cotisants") && $site->user->cotisant)
      $elements[] = "`publique_utl`>='1'";
    elseif ( !$is_admin && !$site->user->is_in_group("visu_cotisants"))
      $elements[] = "`publique_utl`>='2'";
174

Feu's avatar
Feu committed
175
176
177
178
    $req = new requete($site->db,"SELECT COUNT(`utilisateurs`.`id_utilisateur`) " .
        "FROM `utilisateurs` " .
        "LEFT JOIN `utl_etu` ON `utl_etu`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
        "LEFT JOIN `utl_etu_utbm` ON `utl_etu_utbm`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
slopez's avatar
slopez committed
179
        "WHERE "  .implode(" AND ",$elements));
180

Feu's avatar
Feu committed
181
    list($count) = $req->get_row();
182

Feu's avatar
fix    
Feu committed
183
184
    $cts->add_title(2,"Résultat : $count personne(s)");

Feu's avatar
Feu committed
185
    if ( $count == 0 )
Feu's avatar
fix    
Feu committed
186
      $cts->add_paragraph("Aucune personne ne correspond aux critères.");
187

Feu's avatar
Feu committed
188
    /*elseif ( $count > 350 )
Feu's avatar
fix    
Feu committed
189
      $cts->add_paragraph("Votre recherche est trop imprécise, il y a plus de 350 personnes correspondantes.");
190
    */
Feu's avatar
Feu committed
191
192
    else
    {
Feu's avatar
fix    
Feu committed
193
      $npp=24;
Feu's avatar
Feu committed
194
      $page = intval($_REQUEST["page"]);
195

Feu's avatar
Feu committed
196
197
198
199
      if ( $page)
        $st=$page*$npp;
      else
        $st=0;
200

Feu's avatar
Feu committed
201
      if ( $st > $count )
202
203
        $st = floor($count/$npp)*$npp;

mbriand's avatar
mbriand committed
204
205
206
207
      $req = new requete($site->db,"SELECT `utilisateurs`.*, `utl_etu`.citation,
        `utl_etu`.adresse_parents, `utl_etu`.ville_parents,
        `utl_etu`.cpostal_parents, `utl_etu`.pays_parents, `utl_etu`.tel_parents,
        `utl_etu`.nom_ecole_etudiant, `utl_etu`.visites, `utl_etu`.id_ville,
208
209
210
211
212
213
        `utl_etu`.id_pays, `utl_etu_utbm`.semestre_utbm,
        `utl_etu_utbm`.branche_utbm, `utl_etu_utbm`.filiere_utbm,
        `utl_etu_utbm`.surnom_utbm, `utl_etu_utbm`.email_utbm,
        `utl_etu_utbm`.promo_utbm, `utl_etu_utbm`.date_diplome_utbm,
        `utl_etu_utbm`.role_utbm, `utl_etu_utbm`.departement_utbm,
        `utilisateurs`.`id_ville` as `id_ville`,
mbriand's avatar
mbriand committed
214
215
216
217
218
        `utl_etu`.`id_ville` as `ville_parents`,
        `utilisateurs`.`id_pays` as `id_pays`, `utl_etu`.`id_pays` as `pays_parents`
        FROM `utilisateurs`
        LEFT JOIN `utl_etu` ON `utl_etu`.`id_utilisateur`=`utilisateurs`.`id_utilisateur`
        LEFT JOIN `utl_etu_utbm` ON `utl_etu_utbm`.`id_utilisateur`=`utilisateurs`.`id_utilisateur`
mbriand's avatar
mbriand committed
219
        WHERE "  .implode(" AND ",$elements)." $order LIMIT $st,$npp");
220

Feu's avatar
fix    
Feu committed
221
      $user = new utilisateur($site->db);
222

Feu's avatar
Feu committed
223
      $gal = new gallery();
224

Feu's avatar
Feu committed
225
226
227
      while ( $row = $req->get_row() )
      {
        $user->_load_all($row);
mbriand's avatar
mbriand committed
228
229
        $same_promo = ($user->promo_utbm == $site->user->promo_utbm);
        $gal->add_item(new userinfov2($user, "small", false, "user.php", $same_promo));
Feu's avatar
Feu committed
230
      }
231

Feu's avatar
fix    
Feu committed
232
      $cts->add($gal);
233

Feu's avatar
wip    
Feu committed
234
235
      //if ( $count > $npp )
      //{
Feu's avatar
fix    
Feu committed
236
237
238
        $tabs = array();
        $i=0;
        $n=0;
Feu's avatar
fix    
Feu committed
239
        while ( $i < $count )
Feu's avatar
fix    
Feu committed
240
        {
Feu's avatar
wip    
Feu committed
241
          $tabs[]=array($n,"matmatronch/index.php?action=search&page=".$n.$params,$n+1 );
Feu's avatar
fix    
Feu committed
242
          $i+=$npp;
243
          $n++;
Feu's avatar
fix    
Feu committed
244
        }
Feu's avatar
fix    
Feu committed
245
        $cts->add(new tabshead($tabs, $page, "_bottom"));
246
247
      //}

Feu's avatar
Feu committed
248
249
250
    }
  }
}
Feu's avatar
wip    
Feu committed
251
252
253
elseif ( $_REQUEST["action"] == "searchedt" )
{
  $uv->load_by_id($_REQUEST["id_uv"]);
254

Feu's avatar
Feu committed
255
  $params="&id_uv=".rawurlencode($uv->id)."&type=".rawurlencode($_REQUEST["type"]);
Feu's avatar
wip    
Feu committed
256
257
258
259

  if ( $_REQUEST["type"] == 2 )
  {
    $t = "TD";
Feu's avatar
Feu committed
260
    $params.="&td_jour=".rawurlencode($_REQUEST["td_jour"])."&td_heure=".rawurlencode($_REQUEST["td_heure"]);
261
    $cond =
Feu's avatar
Feu committed
262
263
      "AND jour_grp='".mysql_escape_string($_REQUEST["td_jour"])."' ".
      "AND TIME_FORMAT(heure_debut_grp,'%k')='".mysql_escape_string($_REQUEST["td_heure"])."' ";
Feu's avatar
wip    
Feu committed
264
  }
Feu's avatar
wip    
Feu committed
265
  elseif ( $_REQUEST["type"] == 3 )
Feu's avatar
wip    
Feu committed
266
267
  {
    $t = "TP";
268
269
    $params.="&tp_jour=".rawurlencode($_REQUEST["tp_jour"])."&tp_heure=".rawurlencode($_REQUEST["tp_heure"]);
    $cond =
Feu's avatar
Feu committed
270
271
      "AND jour_grp='".mysql_escape_string($_REQUEST["tp_jour"])."' ".
      "AND TIME_FORMAT(heure_debut_grp,'%k')='".mysql_escape_string($_REQUEST["tp_heure"])."' ";
Feu's avatar
wip    
Feu committed
272
273
274
275
276
  }
  else
  {
    $t = "C";
    $cond="";
277
278
  }

Feu's avatar
Feu committed
279
  $req = new requete($site->db,"SELECT id_uv_groupe FROM edu_uv_groupe WHERE semestre_grp='".$semestre."' AND id_uv='".mysql_escape_string($uv->id)."' AND type_grp='".$t."' $cond");
Feu's avatar
wip    
Feu committed
280

Feu's avatar
wip    
Feu committed
281
282
283
284
285
286
287
288
289
  if ( $req->lines < 1 )
  {
    $cts->add_title(2,"Résultat : Aucun groupe n'a été trouvé");
    $cts->add_paragraph("Aucun groupe n'a été trouvé ($semestre).");
  }
  else
  {
    $groupes=array();
    while(list($id)=$req->get_row()) $groupes[]=$id;
290

Feu's avatar
wip    
Feu committed
291
292
293
294
295
296
    $req = new requete($site->db,"SELECT COUNT(`utilisateurs`.`id_utilisateur`) " .
        "FROM `edu_uv_groupe_etudiant` " .
        "INNER JOIN `utilisateurs` USING(id_utilisateur) " .
        "LEFT JOIN `utl_etu` ON `utl_etu`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
        "LEFT JOIN `utl_etu_utbm` ON `utl_etu_utbm`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
        "WHERE id_uv_groupe IN (".implode(",",$groupes).")");
297

Feu's avatar
wip    
Feu committed
298
    list($count) = $req->get_row();
299

Feu's avatar
wip    
Feu committed
300
    $cts->add_title(2,"Résultat : $count personne(s)");
Feu's avatar
Feu committed
301

Feu's avatar
wip    
Feu committed
302
303
    if ( $count == 0 )
      $cts->add_paragraph("Aucune personne ne correspond aux critères.");
304

Feu's avatar
Feu committed
305
    /*elseif ( $count > 350 )
Feu's avatar
wip    
Feu committed
306
      $cts->add_paragraph("Votre recherche est trop imprécise, il y a plus de 350 personnes correspondantes.");
307
    */
Feu's avatar
wip    
Feu committed
308
309
310
311
    else
    {
      $npp=24;
      $page = intval($_REQUEST["page"]);
312

Feu's avatar
wip    
Feu committed
313
314
315
316
      if ( $page)
        $st=$page*$npp;
      else
        $st=0;
317

Feu's avatar
wip    
Feu committed
318
      if ( $st > $count )
319
320
        $st = floor($count/$npp)*$npp;

Feu's avatar
wip    
Feu committed
321
322
      $req = new requete($site->db,"SELECT `utilisateurs`.*, `utl_etu`.*, `utl_etu_utbm`.*, `utilisateurs`.`id_ville` as `id_ville`, `utl_etu`.`id_ville` as `ville_parents`, `utilisateurs`.`id_pays` as `id_pays`, `utl_etu`.`id_pays` as `pays_parents` " .
        "FROM `edu_uv_groupe_etudiant` " .
Feu's avatar
wip    
Feu committed
323
324
325
326
        "INNER JOIN `utilisateurs` USING(id_utilisateur) " .
        "LEFT JOIN `utl_etu` ON `utl_etu`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
        "LEFT JOIN `utl_etu_utbm` ON `utl_etu_utbm`.`id_utilisateur`=`utilisateurs`.`id_utilisateur` " .
        "WHERE id_uv_groupe IN (".implode(",",$groupes).") ORDER BY `nom_utl`,`prenom_utl` LIMIT $st,$npp");
327

Feu's avatar
wip    
Feu committed
328
      $user = new utilisateur($site->db);
329

Feu's avatar
wip    
Feu committed
330
      $gal = new gallery();
331

Feu's avatar
wip    
Feu committed
332
333
334
      while ( $row = $req->get_row() )
      {
        $user->_load_all($row);
mbriand's avatar
mbriand committed
335
336
        $same_promo = ($user->promo_utbm == $site->user->promo_utbm);
        $gal->add_item(new userinfov2($user, "small", false, "user.php", $same_promo));
Feu's avatar
wip    
Feu committed
337
      }
338

Feu's avatar
wip    
Feu committed
339
      $cts->add($gal);
340

Feu's avatar
wip    
Feu committed
341
342
      //if ( $count > $npp )
      //{
Feu's avatar
wip    
Feu committed
343
344
345
346
347
        $tabs = array();
        $i=0;
        $n=0;
        while ( $i < $count )
        {
Feu's avatar
wip    
Feu committed
348
          $tabs[]=array($n,"matmatronch/index.php?action=searchedt&page=".$n.$params,$n+1 );
Feu's avatar
wip    
Feu committed
349
          $i+=$npp;
350
          $n++;
Feu's avatar
wip    
Feu committed
351
352
        }
        $cts->add(new tabshead($tabs, $page, "_bottom"));
353
      //}
Feu's avatar
wip    
Feu committed
354
355
356
    }
  }
}
Feu's avatar
Feu committed
357

Feu's avatar
wip    
Feu committed
358
$frm = new form("mmtprofil","index.php",true,"POST","Recherche par profil");
Feu's avatar
Feu committed
359
$frm->add_hidden("action","search");
360
$frm->add_text_field("nom","Nom");
Feu's avatar
Feu committed
361
$frm->add_text_field("prenom","Prenom");
362
$frm->add_text_field("surnom","Surnom");
Feu's avatar
fix    
Feu committed
363
$frm->add_radiobox_field("sexe","Sexe",array(1=>"Homme",2=>"Femme",0=>"Indifférent"),0, -1);
364
$frm->add_select_field("role","Role",$GLOBALS["utbm_roles"],"etu");
Feu's avatar
Feu committed
365
366
$frm->add_select_field("departement","Departement",$GLOBALS["utbm_departements"],"");
$frm->add_text_field("semestre","Semestre","");
mbriand's avatar
mbriand committed
367
$frm->add_select_field("promo", "Promo", $site->user->liste_promos("Toutes"), 0);
Feu's avatar
Feu committed
368
369
370
371
$frm->add_date_field("date_naissance","Date de naissance");
$frm->add_checkbox("inclus_ancien","Inclure les anciens",false);
$frm->add_checkbox("inclus_nutbm","Inclure les non-utbm",false);
//TODO:améliorer la présentation
Feu's avatar
wip    
Feu committed
372

Feu's avatar
Feu committed
373
$frm->add_submit("go","Rechercher");
Feu's avatar
wip    
Feu committed
374
if ( isset($_REQUEST["action"]) && (isset($_REQUEST["numtel"]) || isset($_REQUEST["pattern"])||$_REQUEST["action"]=="searchedt") )
Feu's avatar
wip    
Feu committed
375
376
$cts->add($frm, true, true, "bxnor", false, true, false);
else
Feu's avatar
Feu committed
377
378
$cts->add($frm,true);

mbriand's avatar
bleh    
mbriand committed
379
/* TODO : mettre à jour...
pedrov's avatar
pedrov committed
380
381
$semestre = ((date("m") > 6 || date("m") < 2) ? "A" : "P");

mbriand's avatar
bleh    
mbriand committed
382
/* on est encore en semestre d'automne année précédente *
383
if (date("m") < 2)
pedrov's avatar
pedrov committed
384
385
386
{
  $semestre .= sprintf("%02d", (date("y") -1));
}
mbriand's avatar
bleh    
mbriand committed
387
/* sinon, semestre suivant *
pedrov's avatar
pedrov committed
388
389
390
391
else
{
  $semestre .= date("y");
}
Feu's avatar
wip    
Feu committed
392

pedrov's avatar
pedrov committed
393

394
395
396
397
398
$req = new requete($site->db, "SELECT `semestre_grp`, `edu_uv_groupe_etudiant`.`id_utilisateur`
                            FROM `edu_uv_groupe`
                            INNER JOIN `edu_uv_groupe_etudiant`
                            USING(`id_uv_groupe`)
                            WHERE `id_utilisateur` = '".$site->user->id."'
Feu's avatar
Feu committed
399
400
401
402
403
                            AND `semestre_grp`= '".$semestre."'
                            GROUP BY `semestre_grp`, `id_utilisateur`");
if ( $req->lines < 1 )
{
  $cts->add_title(2,"Recherche par emploi du temps");
404

Feu's avatar
Feu committed
405
  $cts->add_paragraph("Pour pouvoir utiliser la recherche par emploi du temps, vous devez avoir renseigné votre emploi du temps sur le site.","error");
Feu's avatar
Feu committed
406
407
408
409
410
  $cts->add_paragraph("Créez votre emploi du temps, pour en obtenir une version graphique, pour permettre à vos binomes de vous retrouver plus facilement, et pour trouver en tout simplicité des horraires pour vos réunions.");
  $cts->add_paragraph("<a href=\"../uvs/create.php\">Ajouter votre emploi du temps</a>");
}
else
{
Feu's avatar
fix    
Feu committed
411
  $type = 1;
Feu's avatar
Feu committed
412
413
  if ( $_REQUEST["action"] == "searchedt" && $_REQUEST["type"] > 0 )
    $type = intval($_REQUEST["type"]);
414

Feu's avatar
wip    
Feu committed
415
  $frm = new form("mmtedt","index.php",true,"POST","Recherche par emploi du temps");
Feu's avatar
Feu committed
416
417
  $frm->add_hidden("action","searchedt");
  $frm->add_info("Remarque: Cet outil ne fonctionne que pour les personnes ayant renseigné leur emploi du temps sur le site.");
Feu's avatar
Feu committed
418
  $frm->add_entity_smartselect ( "id_uv", "UV", $uv );
Feu's avatar
Feu committed
419
420
  $sfrm = new form("type",null,true,null,"Tous / Cours");
  $frm->add($sfrm,false,true, $type==1 , 1,false,true);
421

Feu's avatar
Feu committed
422
423
424
425
  $sfrm = new form("type",null,true,null,"TD");
  $sfrm->add_select_field("td_jour","Jour",$jours,$_REQUEST["td_jour"]);
  $sfrm->add_select_field("td_heure","Heure (début)",$heures,$_REQUEST["td_heure"]);
  $frm->add($sfrm,false,true, $type==2 , 2,false,true);
426

Feu's avatar
Feu committed
427
428
429
430
  $sfrm = new form("type",null,true,null,"TP");
  $sfrm->add_select_field("tp_jour","Jour",$jours,$_REQUEST["tp_jour"]);
  $sfrm->add_select_field("tp_heure","Heure (début)",$heures,$_REQUEST["tp_heure"]);
  $frm->add($sfrm,false,true, $type==3 , 3,false,true);
431

Feu's avatar
Feu committed
432
  $frm->add_submit("go","Rechercher");
433

Feu's avatar
wip    
Feu committed
434
435
436
  if ( isset($_REQUEST["action"]) && $_REQUEST["action"]!="searchedt" )
  $cts->add($frm, true, true, "bxedt", false, true, false);
  else
Feu's avatar
Feu committed
437
438
  $cts->add($frm,true);
}
mbriand's avatar
bleh    
mbriand committed
439
*/
Feu's avatar
Feu committed
440

Feu's avatar
wip    
Feu committed
441
$frm = new form("mmtinv","index.php",true,"POST","Recherche inversée");
Feu's avatar
Feu committed
442
443
444
$frm->add_hidden("action","search");
$frm->add_text_field("numtel","Numéro de téléphone");
$frm->add_submit("go","Rechercher");
Feu's avatar
wip    
Feu committed
445
446
447
if ( isset($_REQUEST["action"]) && !isset($_REQUEST["numtel"]) )
$cts->add($frm, true, true, "bxtel", false, true, false);
else
Feu's avatar
Feu committed
448
449
$cts->add($frm,true);

Feu's avatar
wip    
Feu committed
450
$frm = new form("mmtpat","index.php",true,"POST","Recherche simple");
Feu's avatar
wip    
Feu committed
451
452
453
$frm->add_hidden("action","search");
$frm->add_text_field("pattern","Nom/Prenom ou Surnom",$_REQUEST["pattern"]);
$frm->add_submit("go","Rechercher");
Feu's avatar
wip    
Feu committed
454
455
456
457

if ( isset($_REQUEST["action"]) && !isset($_REQUEST["pattern"]) )
$cts->add($frm, true, true, "bxpat", false, true, false);
else
Feu's avatar
wip    
Feu committed
458
$cts->add($frm,true);
Feu's avatar
Feu committed
459

Feu's avatar
wip    
Feu committed
460

slopez's avatar
slopez committed
461
462
$ville = new ville($site->db);
$pays = new pays($site->db);
463
$pays->load_by_id(1);
slopez's avatar
slopez committed
464
465
$frm = new form("mmtville","index.php",true,"POST","Recherche par ville");
$frm->add_hidden("action","search");
slopez's avatar
slopez committed
466
$frm->add_entity_smartselect ("id_pays","Pays", $pays,true);
slopez's avatar
slopez committed
467
$frm->add_entity_smartselect ("id_ville","Ville", $ville,true,false,array('id_pays'=>'id_pays_id'),true);
468
$frm->add_checkbox ("ville_parents","Chercher aussi parmis les adresses des parents");
slopez's avatar
slopez committed
469
470
471
472
473
$frm->add_submit("go","Rechercher");
if ( isset($_REQUEST["action"]) && !isset($_REQUEST["ville"]) )
  $cts->add($frm, true, true, "bxville", false, true, false);
else
  $cts->add($frm,true);
Feu's avatar
wip    
Feu committed
474
475


Feu's avatar
Feu committed
476
477
478
$site->add_contents($cts);
$site->end_page();

Ayolo's avatar
Ayolo committed
479
?>