/
dropdowns.inc
162 lines (152 loc) · 6.25 KB
/
dropdowns.inc
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
<?
// Copyright 2002 Brian Ronald. All rights reserved.
// Portable PHP/MySQL Corporate Intranet System
//
// This program 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.
//
// 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.
//////////////////////////////////////////////////////////////////////////////
// This file uses multiple forms to allow admins to alter the rows
// in the locations and the teams tables.
if(isset($mod_name))
{
if(isset($mod_locationid))
{
$sql = "UPDATE locations SET name='".safe_escape($mod_name)."' WHERE locationid='$mod_locationid'";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
if(isset($mod_teamid))
{
$sql = "UPDATE teams SET name='".safe_escape($mod_name)."' WHERE teamid='$mod_teamid'";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
if(isset($del_locationid))
{
$sql = "DELETE FROM locations WHERE locationid='$del_locationid' LIMIT 1";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
if(isset($del_teamid))
{
$sql = "DELETE FROM teams WHERE teamid='$del_teamid' LIMIT 1";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
if(isset($ins_locationid))
if($mod_name!="")
{
$sql = "INSERT INTO locations (name) VALUES ('".safe_escape($mod_name)."')";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
if(isset($ins_teamid))
if($mod_name!="")
{
$sql = "INSERT INTO teams (name) VALUES ('".safe_escape($mod_name)."')";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
}
print("<table>\n");
print("<tr><td colspan=\"2\"><i>".$lang['take_care_no_confirm']."</i></td></tr>\n");
print("<tr><td class=\"page_div\">\n");
print("<table>\n");
print("<tr><td class=\"centered\" colspan=\"3\"><b>".$lang['teams']."</b></td></tr>\n");
$sql = "SELECT * FROM teams ORDER BY name";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
print("<tr>\n");
print("<form id=\"loc".$row["teamid"]."\" method=\"post\" action=\"$PHP_SELF?callmodule=".rawurlencode($callmodule)."\">\n");
print("<td class=\"right\">\n");
print("<input type=\"hidden\" name=\"ins_teamid\" value=\"yes\">\n");
print("<input type=\"text\" size=\"25\" name=\"mod_name\" value=\"\">");
print("</td>\n");
print("<td colspan=\"2\">\n");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['add_new']."\">");
print("</td>\n");
print("</tr>\n");
print("</form>");
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
print("<tr>\n");
print("<form id=\"loc".$row["teamid"]."\" method=\"post\" action=\"$PHP_SELF?callmodule=".rawurlencode($callmodule)."\">\n");
print("<td class=\"right\">\n");
print("<input type=\"hidden\" name=\"mod_teamid\" value=\"".$row["teamid"]."\">\n");
print("<input type=\"text\" size=\"25\" name=\"mod_name\" value=\"".$row["name"]."\">");
print("</td>\n");
print("<td>\n");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['rename']."\">");
print("</td>\n");
print("</form>");
print("<form id=\"dloc".$row["teamid"]."\" method=\"post\" action=\"$PHP_SELF?callmodule=".rawurlencode($callmodule)."\">\n");
print("<td>\n");
print("<input type=\"hidden\" name=\"del_teamid\" value=\"".$row["teamid"]."\">\n");
print("<input type=\"hidden\" name=\"mod_name\" value=\"".$row["name"]."\">\n");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['delete']."\">");
print("</td>\n");
print("</form>");
print("</tr>\n");
}
}
print("</table>\n");
print("</td>\n");
print("<td class=\"page_div\">\n");
print("<table>\n");
print("<tr><td class=\"centered\" colspan=\"3\"><b>".$lang['locations']."</b></td></tr>\n");
$sql = "SELECT * FROM locations ORDER BY name";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
print("<tr>\n");
print("<form id=\"loc".$row["locationid"]."\" method=\"post\" action=\"$PHP_SELF?callmodule=".rawurlencode($callmodule)."\">\n");
print("<td class=\"right\">\n");
print("<input type=\"hidden\" name=\"ins_locationid\" value=\"yes\">\n");
print("<input type=\"text\" size=\"25\" name=\"mod_name\" value=\"\">");
print("</td>\n");
print("<td colspan=\"2\">\n");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['add_new']."\">");
print("</td>\n");
print("</tr>\n");
print("</form>");
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
print("<tr>\n");
print("<form id=\"loc".$row["locationid"]."\" method=\"post\" action=\"$PHP_SELF?callmodule=".rawurlencode($callmodule)."\">\n");
print("<td class=\"right\">\n");
print("<input type=\"hidden\" name=\"mod_locationid\" value=\"".$row["locationid"]."\">\n");
print("<input type=\"text\" size=\"25\" name=\"mod_name\" value=\"".$row["name"]."\">");
print("</td>\n");
print("<td>\n");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['rename']."\">");
print("</td>\n");
print("</form>\n");
print("<form id=\"delloc".$row["locationid"]."\" method=\"post\" action=\"$PHP_SELF?callmodule=".rawurlencode($callmodule)."\">\n");
print("<td>\n");
print("<input type=\"hidden\" name=\"del_locationid\" value=\"".$row["locationid"]."\">\n");
print("<input type=\"hidden\" name=\"mod_name\" value=\"".$row["name"]."\">\n");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['delete']."\">");
print("</td>\n");
print("</form>\n");
print("</tr>\n");
}
}
print("</table>\n");
print("</td></tr>\n");
print("<table>\n");
$help_keyword="dropdowns";
?>