-
Notifications
You must be signed in to change notification settings - Fork 9
/
staff_right.php
233 lines (215 loc) · 6.35 KB
/
staff_right.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php
############################################
# ThaiRIS (Thai Radiology Information System)
# Version: 1.0
# File last modified: 8 Nov 2016
# File name:
# Description :
# http://www.thairis.net
# Email : [email protected]
############################################
include "connectdb.php";
include "session.php";
$sql =
"SELECT
xray_user.ID AS ID,
xray_user.CODE AS CODE,
xray_user.NAME AS NAME,
xray_user.LOGIN,
xray_user.LASTNAME AS LASTNAME,
xray_user.CENTER_CODE,
xray_user_right.USER_ID AS USER_ID,
xray_user_right.SUPER_ADMIN AS SUPER_ADMIN,
xray_user_right.ADMIN AS ADMIN,
xray_user_right.DELETE_ORDER AS DELETE_ORDER,
xray_user_right.CHANGE_STATUS AS CHANGE_STATUS,
xray_user_right.EDIT_PATIENT AS EDIT_PATIENT
FROM xray_user
RIGHT JOIN xray_user_right ON xray_user.ID = xray_user_right.USER_ID
WHERE xray_user.CENTER_CODE ='$usercenter'";
$result = mysql_query($sql);
?>
<html>
<head>
<title>User Right</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
</head>
<body bgcolor="#d4d4d4" topmargin=0 leftmargin=0>
<div id="header-wrap">
<div id="header-container">
<table border=0 cellspacing=0 cellpedding=0 width=100%>
<tr>
<td BACKGROUND="cornner/hl.gif" border=0 width=20 height=36></td>
<td background="cornner/bg.gif" height=36 width=70%></td>
<td background="cornner/hm1.gif" width=33 align=right></td>
<td background="cornner/hm2.gif">User right</td>
<td background="cornner/hm4.gif" width=1></td>
<td background="cornner/hm2.gif"></td>
<td background="cornner/hm3.gif" width=30></td>
</tr>
</table>
</div>
</div>
<br/>
<center>
<u>User Right</u>
</center><br>
<?php
echo "<center><table border='1' bordercolor=black bgcolor='#79acf3' width=95%>
<tr>
<th>ID</th>
<th>CODE</th>
<th>NAME</th>
<th>LASTNAME</th>
<th>User Login</th>
<th>Super Admin</th>
<th>Admin</th>
<th>Delete</th>
<th>Change Status</th>
<th>Edit Patient</th>
<th>Upload</th>
<th>Delete Upload</th>
</tr>\n";
//$row1 = mysql_fetch_array($result);
//if ($row1 < 0) {
//exit;
//}
$bg ="#FFCCCC";
//while($row = mysql_fetch_array($result))
while($row = mysql_fetch_assoc($result))
{
if($bg == "#FFFFFF")
{ //ส่วนของการ สลับสี
$bg = "#C8C8C8";
}
else
{
$bg = "#FFFFFF";
}
echo "<tr bgcolor=$bg>";
//$id[]=$row['ID2'];
echo "<td>" .$row['ID'] ." </td>";
echo "<td>" . $row['CODE'] . "</td>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['LASTNAME'] . "</td>";
echo "<td>".$row['LOGIN']."</td>";
echo "<form name=\"form1\" method=\"post\" action=\"\">\n";
echo "<input type=hidden name=id[]".$row['ID']." value=".$row['ID'].">";
//echo "<input type=hidden name=userid".$row['ID']." value=".$row['ID'].">";
if ($row['SUPER_ADMIN'] == 1)
{
echo "<td align=center><input type=\"checkbox\" name=\"SUPER_ADMIN[".$row['ID']."]\" id=\"SUPER_ADMIN\" value=\"1\" checked></td>\n";
}
else
{
echo "<td align=center><input type=\"checkbox\" name=\"SUPER_ADMIN[".$row['ID']."]\" id=\"SUPER_ADMIN\" value=\"1\" ></td>\n";
}
if ($row['ADMIN'] == 1)
{
echo "<td align=center><input type=\"checkbox\" name=\"ADMIN[".$row['ID']."]\" id=\"ADMIN\" value=\"1\" checked></td>\n";
}
else
{
echo "<td align=center><input type=\"checkbox\" name=\"ADMIN[".$row['ID']."]\" id=\"ADMIN\" value=\"1\"></td>\n";
}
if ($row['DELETE_ORDER'] == 1)
{
echo "<td align=center><input type=\"checkbox\" name=\"DELETE_ORDER[".$row['ID']."]\" value=\"1\" checked></td>\n";
}
else
{
echo "<td align=center><input type=\"checkbox\" name=\"DELETE_ORDER[".$row['ID']."]\" value=\"1\"></td>\n";
}
if ($row['CHANGE_STATUS'] ==1)
{
echo "<td align=center><input type=\"checkbox\" name=\"CHANGE_STATUS[".$row['ID']."]\" value=\"1\" checked></td>\n";
}
else
{
echo "<td align=center><input type=\"checkbox\" name=\"CHANGE_STATUS[".$row['ID']."]\" value=\"1\"></td>\n";
}
if ($row['EDIT_PATIENT'] ==1)
{
echo "<td align=center><input type=\"checkbox\" name=\"EDIT_PATIENT[".$row['ID']."]\" value=\"1\" checked></td>\n";
}
else
{
echo "<td align=center><input type=\"checkbox\" name=\"EDIT_PATIENT[".$row['ID']."]\" value=\"1\"></td>\n";
}
echo "<td></td><td></td></tr>\n";
}
echo "
<tr>
<th>ID</th>
<th>CODE</th>
<th>NAME</th>
<th>LASTNAME</th>
<th>User Login</th>
<th>Super Admin</th>
<th>Admin</th>
<th>Delete</th>
<th>Change Status</th>
<th>Edit Patient</th>
<th>Upload</th>
<th>Delete Upload</th>
</tr>\n";
echo "</table></center>\n";
echo "<center><input type=submit name=submit value=Submit></center>"; //<input type="submit" name="Submit" value="Submit">
echo "</form>";
echo "<br /></br />";
?>
</body>
</html>
<?php
if ( isset( $_POST["submit"] ) )
{
//echo '<pre>';
//print_r( $_POST );
//echo '</pre>';
foreach( $_POST["id"] AS $id )
{
if ($_POST["SUPER_ADMIN"][$id] == '')
{
$_POST["SUPER_ADMIN"][$id] = '0';
}
if ($_POST["ADMIN"][$id] == '')
{
$_POST["ADMIN"][$id] = '0';
}
if ($_POST["DELETE_ORDER"][$id] == '')
{
$_POST["DELETE_ORDER"][$id] = '0';
}
if ($_POST["CHANGE_STATUS"][$id] == '')
{
$_POST["CHANGE_STATUS"][$id] = '0';
}
if ($_POST["EDIT_PATIENT"][$id] == '')
{
$_POST["EDIT_PATIENT"][$id] = '0';
}
//echo 'ID is ' . $id . '<br />';
//echo 'Super is ' . $_POST["SUPER_ADMIN"][$id]."<br />";
//echo 'Field2 is ' . $_POST["ADMIN"][$id]."<br />";
//echo 'Field3 is ' . $_POST["DELETE"][$id]."<br />";
//echo 'Field4 is ' . $_POST["CHANGE_STATUS"][$id]."<br />";
//echo 'Field5 is ' . $_POST["EDIT_PATIENT"][$id]."<br />";
$SUPER_ADMIN = mysql_real_escape_string($_POST["SUPER_ADMIN"][$id]);
$ADMIN = mysql_real_escape_string($_POST["ADMIN"][$id]);
$DELETE_ORDER= mysql_real_escape_string($_POST["DELETE_ORDER"][$id]);
$CHANGE_STATUS = mysql_real_escape_string($_POST["CHANGE_STATUS"][$id]);
$EDIT_PATIENT = mysql_real_escape_string($_POST["EDIT_PATIENT"][$id]);
$update ="UPDATE xray_user_right
SET SUPER_ADMIN='$SUPER_ADMIN',
ADMIN='$ADMIN',
DELETE_ORDER='$DELETE_ORDER',
CHANGE_STATUS='$CHANGE_STATUS',
EDIT_PATIENT='$EDIT_PATIENT'
WHERE
USER_ID='$id' ";
mysql_query($update);// or die( mysql_error() );
//echo $update."<br />";
}
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=staff_right.php\">";
}
?>