This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitebat.php
124 lines (112 loc) · 4.11 KB
/
sitebat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/* Copyright 2006
* - Julien Etelain < julien at pmad dot net >
*
* Ce fichier fait partie du site de l'Association des Étudiants de
* l'UTBM, http://ae.utbm.fr.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License a
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
$topdir = "./";
include($topdir. "include/site.inc.php");
require_once($topdir. "include/cts/sqltable.inc.php");
require_once($topdir. "include/entities/sitebat.inc.php");
require_once($topdir. "include/entities/batiment.inc.php");
$site = new site ();
$sitebat = new sitebat($site->db,$site->dbrw);
if ( isset($_REQUEST["id_site"]) )
{
$sitebat->load_by_id($_REQUEST["id_site"]);
if ( $sitebat->id < 1 )
{
$site->error_not_found("services");
exit();
}
if ( $_REQUEST["action"] == "addbat" && $site->user->is_in_group("gestion_ae") )
{
$batiment = new batiment($site->db,$site->dbrw);
if ( $_REQUEST["nom"] != "" )
$batiment->add($sitebat->id,$_REQUEST["nom"], $_REQUEST["fumeur"], $_REQUEST["convention"], $_REQUEST["notes"] );
}
}
else if ( $_REQUEST["action"] == "addsite" && $site->user->is_in_group("gestion_ae") )
{
if ( $_REQUEST["nom"] != "" )
$sitebat->add($_REQUEST["nom"], $_REQUEST["fumeur"], $_REQUEST["convention"], $_REQUEST["notes"] );
}
if ( $sitebat->id > 0 )
{
$site->start_page("services",$sitebat->nom);
$cts = new contents($sitebat->get_html_link());
$cts->add_paragraph("Voir aussi : <a href=\"sitebat.php\">Autre sites</a>");
$req = new requete($site->db,"SELECT * FROM `sl_batiment` WHERE `id_site`='".$sitebat->id."'");
$tbl = new sqltable(
"listsites",
"Batiments", $req, "sitebat.php?id_site=".$sitebat->id,
"id_batiment",
array("nom_bat"=>"Batiment"),
array(), array(),array()
);
$cts->add($tbl,true);
$req = new requete($site->db,"SELECT `id_salle`,`nom_salle`,`etage`,`sl_batiment`.`id_batiment`,`nom_bat` FROM `sl_salle` " .
"INNER JOIN `sl_batiment` ON `sl_batiment`.`id_batiment`=`sl_salle`.`id_batiment` " .
"WHERE `id_site`='".$sitebat->id."'");
$tbl = new sqltable(
"listsalles",
"Salles", $req, "salle.php",
"id_salle",
array("nom_salle"=>"Salle","etage"=>"Etage","nom_bat"=>"Batiment"),
array(), array(),array()
);
$cts->add($tbl,true);
if ( $site->user->is_in_group("gestion_ae") )
{
$frm = new form("newbat","sitebat.php?id_site=".$sitebat->id,true,"POST","Nouveau batiment");
$frm->add_hidden("action","addbat");
$frm->add_text_field("nom","Nom du batiment","",true);
$frm->add_checkbox("fumeur","Fumeur",$sitebat->fumeur);
$frm->add_checkbox("convention","Convention de locaux",$sitebat->convention);
$frm->add_text_area("notes","Notes");
$frm->add_submit("valid","Ajouter");
$cts->add($frm,true);
}
$site->add_contents($cts);
$site->end_page();
exit();
}
$site->start_page("services","Sites");
$req = new requete($site->db,"SELECT * FROM `sl_site`");
$tbl = new sqltable(
"listsites",
"Sites", $req, "sitebat.php",
"id_site",
array("nom_site"=>"Site"),
array(), array(),array()
);
$site->add_contents($tbl);
if ( $site->user->is_in_group("gestion_ae") )
{
$frm = new form("newsitebat","sitebat.php",true,"POST","Nouveau site");
$frm->add_hidden("action","addsite");
$frm->add_text_field("nom","Nom du site","",true);
$frm->add_checkbox("fumeur","Fumeur");
$frm->add_checkbox("convention","Convention de locaux");
$frm->add_text_area("notes","Notes");
$frm->add_submit("valid","Ajouter");
$site->add_contents($frm);
}
$site->end_page();
?>