-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadmin_type_modify.php
More file actions
247 lines (233 loc) · 9.24 KB
/
admin_type_modify.php
File metadata and controls
247 lines (233 loc) · 9.24 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/**
* admin_type_modify.php
* interface de création/modification des types de réservations
* Ce script fait partie de l'application GRR
* Dernière modification : $Date: 2010-03-03 14:41:34 $
* @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_modify.php,v 1.8 2010-03-03 14:41:34 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_modify.php,v $
* Revision 1.8 2010-03-03 14:41:34 grr
* *** empty log message ***
*
* 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-03-24 13:30:07 grr
* *** empty log message ***
*
* Revision 1.4 2008-11-16 22:00:58 grr
* *** empty log message ***
*
*
*/
include "include/admin.inc.php";
$grr_script_name = "admin_type_modify.php";
$ok = NULL;
$back = '';
if (isset($_SERVER['HTTP_REFERER'])) $back = my_htmlspecialcharacters($_SERVER['HTTP_REFERER']);
if(authGetUserLevel(getUserName(),-1) < 6)
{
$day = date("d");
$month = date("m");
$year = date("Y");
showAccessDenied($day, $month, $year, '',$back);
exit();
}
// Initialisation
$id_type = isset($_GET["id_type"]) ? $_GET["id_type"] : 0;
$type_name = isset($_GET["type_name"]) ? $_GET["type_name"] : NULL;
$order_display = isset($_GET["order_display"]) ? $_GET["order_display"] : NULL;
$type_letter = isset($_GET["type_letter"]) ? $_GET["type_letter"] : NULL;
$couleur = isset($_GET["couleur"]) ? $_GET["couleur"] : NULL;
$disponible = isset($_GET["disponible"]) ? $_GET["disponible"] : NULL;
$msg ='';
if (isset($_GET["change_room_and_back"])) {
$_GET['change_type'] = "yes";
$_GET['change_done'] = "yes";
}
// Enregistrement
if (isset($_GET['change_type'])) {
$_SESSION['displ_msg'] = "yes";
if ($type_name == '') $type_name = "A définir";
if ($type_letter == '') $type_letter = "A";
if ($couleur == '') $couleur = "1";
if ($disponible == '') $disponible = "2";
if ($id_type>0)
{
// Test sur $type_letter
$test = grr_sql_query1("select count(id) from ".TABLE_PREFIX."_type_area where type_letter='".$type_letter."' and id!='".$id_type."'");
if ($test > 0) {
$msg = "Enregistrement impossible : Un type portant la même lettre existe déjà.";
} else {
$sql = "UPDATE ".TABLE_PREFIX."_type_area SET
type_name='".protect_data_sql($type_name)."',
order_display =";
if (is_numeric($order_display))
$sql= $sql .intval($order_display).",";
else
$sql= $sql ."0,";
$sql = $sql . 'type_letter="'.$type_letter.'",';
$sql = $sql . 'couleur="'.$couleur.'",';
$sql = $sql . 'disponible="'.$disponible.'"';
$sql = $sql . " WHERE id=$id_type";
if (grr_sql_command($sql) < 0)
{
fatal_error(0, get_vocab('update_type_failed') . grr_sql_error());
$ok = 'no';
} else
$msg = get_vocab("message_records");
}
}
else
{
// Test sur $type_letter
$test = grr_sql_query1("select count(id) from ".TABLE_PREFIX."_type_area where type_letter='".$type_letter."'");
if ($test > 0) {
$msg = "Enregistrement impossible : Un type portant la même lettre existe déjà.";
} else {
$sql = "INSERT INTO ".TABLE_PREFIX."_type_area SET
type_name='".protect_data_sql($type_name)."',
order_display =";
if (is_numeric($order_display))
$sql= $sql .intval($order_display).",";
else
$sql= $sql ."0,";
$sql = $sql . 'type_letter="'.$type_letter.'",';
$sql = $sql . 'couleur="'.$couleur.'"';
if (grr_sql_command($sql) < 0)
{
fatal_error(1, "<p>" . grr_sql_error());
$ok = 'no';
} else {
$msg = get_vocab("message_records");
}
}
}
}
// Si pas de problème, retour à la page d'accueil après enregistrement
if ((isset($_GET['change_done'])) and (!isset($ok))) {
$_SESSION['displ_msg'] = 'yes';
Header("Location: "."admin_type.php?msg=".$msg);
exit();
}
# print the page header
print_header("","","","",$type="with_session", $page="admin");
echo "<div class=\"page_sans_col_gauche\">";
affiche_pop_up($msg,"admin");
if ((isset($id_type)) and ($id_type>0)) {
$res = grr_sql_query("SELECT * FROM ".TABLE_PREFIX."_type_area WHERE id=$id_type");
if (! $res) fatal_error(0, get_vocab('message_records_error'));
$row = grr_sql_row_keyed($res, 0);
grr_sql_free($res);
$change_type='modif';
echo "<h2>".get_vocab("admin_type_modify_modify.php")."</h2>";
} else {
$row["id"] = '0';
$row["type_name"] = '';
$row["type_letter"] = '';
$row["order_display"] = 0;
$row["disponible"] = 2;
$row["couleur"] = '';
echo "<h2>".get_vocab('admin_type_modify_create.php')."</h2>";
}
echo get_vocab('admin_type_explications')."<br /><br />";
?>
<form action="admin_type_modify.php" method='get'>
<?php
echo "<div><input type=\"hidden\" name=\"id_type\" value=\"".$id_type."\" /></div>\n";
echo "<table border=\"1\">\n";
echo "<tr>";
echo "<td>".get_vocab("type_name").get_vocab("deux_points")."</td>\n";
echo "<td><input type=\"text\" name=\"type_name\" value=\"".my_htmlspecialcharacters($row["type_name"])."\" size=\"20\" /></td>\n";
echo "</tr><tr>\n";
echo "<td>".get_vocab("type_num").get_vocab("deux_points")."</td>\n";
echo "<td>";
echo "<select name=\"type_letter\" size=\"1\">\n";
echo "<option value=''>".get_vocab("choose")."</option>\n";
$letter = "A";
for ($i=1;$i<=100;$i++) {
echo "<option value='".$letter."' ";
if ($row['type_letter'] == $letter) echo " selected=\"selected\"";
echo ">".$letter."</option>\n";
$letter++;
}
echo "</select>";
echo "</td>\n";
echo "</tr><tr>\n";
echo "<td>".get_vocab("type_order").get_vocab("deux_points")."</td>\n";
echo "<td><input type=\"text\" name=\"order_display\" value=\"".my_htmlspecialcharacters($row["order_display"])."\" size=\"20\" /></td>\n";
echo "</tr>";
echo "<tr><td>".get_vocab("disponible_pour").get_vocab("deux_points")."</td>\n";
echo "<td>"."<select name=\"disponible\" size=\"1\">\n";
echo "<option value = '2' ";
if ($row['disponible']=='2') {echo " selected=\"selected\"";}
echo ">".get_vocab("all")."</option>\n";
echo "<option value = '3' ";
if ($row['disponible']=='3') {echo " selected=\"selected\"";}
echo ">".get_vocab("gestionnaires_et_administrateurs")."</option>\n";
echo "<option value = '5' ";
if ($row['disponible']=='5') {echo " selected=\"selected\"";}
echo ">".get_vocab("only_administrators")."</option>\n";
echo "</select>";
echo "</td></tr>";
if ($row["couleur"] != '') {
echo "<tr>\n";
echo "<td>".get_vocab("type_color").get_vocab("deux_points")."</td>\n";
echo "<td bgcolor=\"".$tab_couleur[$row["couleur"]]."\"> </td>";
echo "</tr>";
}
echo "</table>\n";
echo "<p>".get_vocab("type_color").get_vocab("deux_points")."</p>";
echo "<table border=\"2\"><tr>\n";
$nct = 0;
foreach($tab_couleur as $key=>$value)
{
$checked = " ";
if ($key == $row["couleur"])
$checked = "checked=\"checked\"";
if (++$nct > 4)
{
$nct = 1;
echo "</tr><tr>";
}
echo "<td style=\"background-color:".$tab_couleur[$key].";\"><input type=\"radio\" name=\"couleur\" value=\"".$key."\" ".$checked." />______________</td>";
}
echo "</tr></table>\n";
echo "<table><tr><td>\n";
echo "<input type=\"submit\" name=\"change_type\" value=\"".get_vocab("save")."\" />\n";
echo "</td><td>\n";
echo "<input type=\"submit\" name=\"change_done\" value=\"".get_vocab("back")."\" />";
echo "</td><td>\n";
echo "<input type=\"submit\" name=\"change_room_and_back\" value=\"".get_vocab("save_and_back")."\" />";
echo "</td></tr></table>";
?>
</form>
</div>
</body>
</html>