first reimport from platal
[platal.git] / htdocs / fiche_referent.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
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
23 require_once("xorg.inc.php");
24 new_simple_page('fiche_referent.tpl',AUTH_COOKIE);
25
26 if (!Env::has('user')) {
27 exit;
28 }
29
30 $res = $globals->xdb->query(
31 "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias
32 FROM auth_user_md5 AS u
33 INNER JOIN aliases AS a ON (u.user_id=a.id AND FIND_IN_SET('bestalias',a.flags))
34 INNER JOIN aliases AS a1 ON (u.user_id=a1.id AND a1.alias = {?} AND a1.type!='homonyme')",
35 Env::get('user'));
36 if ($res->numRows() != 1) {
37 exit;
38 }
39
40 list($prenom, $nom, $user_id, $promo, $cv, $bestalias) = $res->fetchOneRow();
41
42 $page->assign('prenom', $prenom);
43 $page->assign('nom', $nom);
44 $page->assign('promo', $promo);
45 $page->assign('cv', $cv);
46 $page->assign('bestalias', $bestalias);
47
48
49 //recuperation des infos professionnelles
50 $res = $globals->xdb->query(
51 "SELECT e.entreprise, s.label as secteur , ss.label as ss_secteur , f.fonction_fr as fonction,
52 e.poste, e.adr1, e.adr2, e.adr3, e.postcode, e.city,
53 gp.pays, gr.name, e.tel, e.fax, e.mobile
54 FROM entreprises AS e
55 LEFT JOIN emploi_secteur AS s ON(e.secteur = s.id)
56 LEFT JOIN emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur)
57 LEFT JOIN fonctions_def AS f ON(e.fonction = f.id)
58 LEFT JOIN geoloc_pays AS gp ON (gp.a2 = e.country)
59 LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.country and gr.region = e.region)
60 WHERE e.uid = {?}
61 ORDER BY e.entrid", $user_id);
62 $page->assign('adr_pro', $res->fetchAllAssoc());
63
64 ///// recuperations infos referent
65
66 //expertise
67 $res = $globals->xdb->query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id);
68 $page->assign('expertise', $res->fetchOneCell());
69
70 //secteurs
71 $secteurs = $ss_secteurs = Array();
72 $res = $globals->xdb->iterRow(
73 "SELECT s.label, ss.label
74 FROM mentor_secteurs AS m
75 LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id)
76 LEFT JOIN emploi_ss_secteur AS ss ON(m.secteur = ss.secteur AND m.ss_secteur = ss.id)
77 WHERE uid = {?}", $user_id);
78 while (list($sec, $ssec) = $res->next()) {
79 $secteurs[] = $sec;
80 $ss_secteurs[] = $ssec;
81 }
82 $page->assign_by_ref('secteurs', $secteurs);
83 $page->assign_by_ref('ss_secteurs', $ss_secteurs);
84
85 //pays
86 $res = $globals->xdb->query(
87 "SELECT gp.pays
88 FROM mentor_pays AS m
89 LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2)
90 WHERE uid = {?}", $user_id);
91 $page->assign('pays', $res->fetchColumn());
92
93 $page->addJsLink('javascript/close_on_esc.js');
94 $page->run();
95 ?>