-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin_type_area.php
216 lines (198 loc) · 8.32 KB
/
admin_type_area.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
/**
* admin_type_area.php
* interface de gestion des types de réservations pour un domaine
* Ce script fait partie de l'application GRR
* Dernière modification : $Date: 2009-04-14 12:59:17 $
* @author Laurent Delineau <laurent.delineau@ac-poitiers.fr>
* @copyright Copyright 2003-2008 Laurent Delineau
* @link http://www.gnu.org/licenses/licenses.html
* @package root
* @version $Id: admin_type_area.php,v 1.7 2009-04-14 12:59:17 grr Exp $
* @filesource
*
* This file is part of GRR.
*
* GRR is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GRR 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 GRR; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* $Log: admin_type_area.php,v $
* Revision 1.7 2009-04-14 12:59:17 grr
* *** empty log message ***
*
* Revision 1.6 2009-04-09 14:52:31 grr
* *** empty log message ***
*
* Revision 1.5 2009-02-27 13:28:19 grr
* *** empty log message ***
*
* Revision 1.4 2008-11-16 22:00:58 grr
* *** empty log message ***
*
* Revision 1.3 2008-11-11 22:01:14 grr
* *** empty log message ***
*
*
*/
include "include/admin.inc.php";
$grr_script_name = "admin_type_area.php";
// Initialisation
$id_area = isset($_GET["id_area"]) ? $_GET["id_area"] : NULL;
if(authGetUserLevel(getUserName(),$id_area,'area') < 4)
{
$back = '';
if (isset($_SERVER['HTTP_REFERER'])) $back = my_htmlspecialcharacters($_SERVER['HTTP_REFERER']);
$day = date("d");
$month = date("m");
$year = date("Y");
showAccessDenied($day, $month, $year, '',$back);
exit();
}
$back = "";
if (isset($_SERVER['HTTP_REFERER'])) $back = my_htmlspecialcharacters($_SERVER['HTTP_REFERER']);
// Gestion du retour à la page précédente sans enregistrement
if (isset($_GET['change_done']))
{
Header("Location: "."admin_room.php?id_area=".$_GET['id_area']);
exit();
}
if ((isset($_GET['msg'])) and isset($_SESSION['displ_msg']) and ($_SESSION['displ_msg']=='yes') ) {
$msg = $_GET['msg'];
}
else
$msg = '';
# print the page header
print_header("","","","",$type="with_session", $page="admin");
$sql = "SELECT id, type_name, order_display, couleur, type_letter FROM ".TABLE_PREFIX."_type_area
ORDER BY order_display, type_letter";
//
// Enregistrement
//
if (isset($_GET['valider'])) {
$res = grr_sql_query($sql);
$nb_types_valides = 0;
if ($res) {
for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
{
if (isset($_GET[$row[0]])) {
$nb_types_valides ++;
$del = grr_sql_query("delete from ".TABLE_PREFIX."_j_type_area where id_area='".$id_area."' and id_type = '".$row[0]."'");
} else {
$type_si_aucun = $row[0];
$test = grr_sql_query1("select count(id_type) from ".TABLE_PREFIX."_j_type_area where id_area = '".$id_area."' and id_type = '".$row[0]."'");
if ($test == 0) {
// faire le test si il existe une réservation en cours avec ce type de réservation
// $type_id = grr_sql_query1("select type_letter from ".TABLE_PREFIX."_type_area where id = '".$row[0]."'");
// $test1 = grr_sql_query1("select count(id) from ".TABLE_PREFIX."_entry where type= '".$type_id."'");
// $test2 = grr_sql_query1("select count(id) from ".TABLE_PREFIX."_repeat where type= '".$type_id."'");
// if (($test1 != 0) or ($test2 != 0)) {
// $msg = "Suppression impossible : des réservations ont été enregistrées avec ce type.";
// } else {
$sql1 = "insert into ".TABLE_PREFIX."_j_type_area set id_area='".$id_area."', id_type = '".$row[0]."'";
if (grr_sql_command($sql1) < 0) {fatal_error(1, "<p>" . grr_sql_error());}
// }
}
}
}
}
if ($nb_types_valides == 0) {
// Aucun type n'a été sélectionné. Dans ce cas, on impose au moins un type :
$del = grr_sql_query("delete from ".TABLE_PREFIX."_j_type_area where id_area='".$id_area."' and id_type = '".$type_si_aucun."'");
$msg = "Vous devez au définir au moins un type valide !";
}
// Type par défaut :
// On enregistre le nouveau type par défaut :
$reg_type_par_defaut = grr_sql_query("update ".TABLE_PREFIX."_area set id_type_par_defaut='".$_GET['id_type_par_defaut']."' where id='".$id_area."'");
}
affiche_pop_up($msg,"admin");
$area_name = grr_sql_query1("select area_name from ".TABLE_PREFIX."_area where id='".$id_area."'");
echo "<div class=\"page_sans_col_gauche\">";
echo "<h2>".get_vocab('admin_type.php')."</h2>";
echo "<h2>".get_vocab("match_area").get_vocab('deux_points')." ".$area_name."</h2>";
$res = grr_sql_query($sql);
$nb_lignes = grr_sql_count($res);
if ($nb_lignes == 0) {
echo "</body></html>";
die();
}
echo "<form action=\"admin_type_area.php\" id=\"type\" method=\"get\">\n";
echo "<table>";
if(authGetUserLevel(getUserName(),-1) >= 6)
echo "<tr><td><a href=\"admin_type_modify.php?id=0\">".get_vocab("display_add_type")."</a></td></tr>";
echo "<tr><td>".get_vocab("explications_active_type")."</td></tr>";
echo "<tr><td>\n";
// Affichage du tableau
echo "<table border=\"1\" cellpadding=\"3\"><tr>\n";
// echo "<tr><td><b>".get_vocab("type_num")."</a></b></td>\n";
echo "<td><b>".get_vocab("type_num")."</b></td>\n";
echo "<td><b>".get_vocab("type_name")."</b></td>\n";
echo "<td><b>".get_vocab("type_color")."</b></td>\n";
echo "<td><b>".get_vocab("type_order")."</b></td>\n";
echo "<td><b>".get_vocab("type_valide_domaine")."</b></td>";
echo "<td><b>".get_vocab("type_par_defaut")."</b></td>";
echo "</tr>";
if ($res) {
for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
{
$id_type = $row[0];
$type_name = $row[1];
$order_display = $row[2];
$couleur = $row[3];
$type_letter = $row[4];
// Affichage des numéros et descriptions
$col[$i][1] = $type_letter;
$col[$i][2] = $id_type;
$col[$i][3] = $type_name;
// Affichage de l'ordre
$col[$i][4]= $order_display;
$col[$i][5]= $couleur;
echo "<tr>\n";
echo "<td>{$col[$i][1]}</td>\n";
echo "<td>{$col[$i][3]}</td>\n";
echo "<td style=\"background-color:".$tab_couleur[$col[$i][5]]."\"></td>\n";
echo "<td>{$col[$i][4]}</td>\n";
echo "<td><input type=\"checkbox\" name=\"".$col[$i][2]."\" value=\"y\" ";
$test = grr_sql_query1("select count(id_type) from ".TABLE_PREFIX."_j_type_area where id_area = '".$id_area."' and id_type = '".$row[0]."'");
if ($test < 1) echo " checked=\"checked\"";
echo " /></td>";
echo "<td><input type=\"radio\" name=\"id_type_par_defaut\" value=\"".$col[$i][2]."\" ";
$test = grr_sql_query1("select id_type_par_defaut from ".TABLE_PREFIX."_area where id = '".$id_area."'");
if ($test == $col[$i][2]) echo " checked=\"checked\"";
echo " /></td>";
// Fin de la ligne courante
echo "</tr>";
}
echo "<tr><td> </td>\n";
echo "<td> </td>\n";
echo "<td> </td>\n";
echo "<td> </td>\n";
echo "<td> </td>\n";
echo "<td><input type=\"radio\" name=\"id_type_par_defaut\" value=\"-1\" ";
$test = grr_sql_query1("select id_type_par_defaut from ".TABLE_PREFIX."_area where id = '".$id_area."'");
if ($test <= 0) echo " checked=\"checked\"";
echo " />".$vocab["nobody"]." </td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr></table>";
echo "<div style=\"text-align:center;\"><input type=\"hidden\" name=\"id_area\" value=\"".$id_area."\" />";
echo "<input type=\"submit\" name=\"valider\" value=\"".get_vocab("save")."\" />\n";
echo " <input type=\"submit\" name=\"change_done\" value=\"".get_vocab("back")."\" />";
echo "</div>";
echo "</form>\n";
echo "</div>";
?>
</body>
</html>