-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_other.php
232 lines (193 loc) · 6.31 KB
/
table_other.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
<?php
session_start();
// If the session vars aren't set, try to set them with a cookie
if (!isset($_SESSION['user_id'])) {
if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) {
$_SESSION['user_id'] = $_COOKIE['user_id'];
$_SESSION['username'] = $_COOKIE['username'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FTK Production Database Interface - View General Devices Data</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h3>FTK Production Database Interface - View Board Data</h3>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
require_once('appvars.php');
require_once('connectvars.php');
// Make sure the user is logged in before going any further.
if (!isset($_SESSION['user_id'])) {
echo '<p class="login">Please <a href="login.php">log in</a> to access this page.</p>';
exit();
}
else {
echo('<p class="login">You are logged in as ' . $_SESSION['username'] . '. <a href="logout.php">Log out</a>.<br /> Go back to the <a href="index.php">Index</a>.</p>');
}
//<?php
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die(mysql_error());
//mysql_connect('localhost','root','root')
// or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());
$field='com_type';
$sort='ASC';
if(isset($_GET['sorting']))
{
if($_GET['sorting']=='ASC')
{
$sort='DESC';
}
else
{
$sort='ASC';
}
}
if($_GET['field']=='com_type')
{
$field = "com_type";
}
elseif($_GET['field']=='com_id')
{
$field = "com_id";
}
elseif($_GET['field']=='location')
{
$field="location";
}
elseif($_GET['field']=='rack')
{
$field="rack";
}
elseif($_GET['field']=='crate')
{
$field="crate";
}
elseif($_GET['field']=='slot')
{
$field="slot";
}
elseif($_GET['field']=='inst_status')
{
$field="inst_status";
}
elseif($_GET['field']=='cern_receival_date')
{
$field="cern_receival_date";
}
elseif($_GET['field']=='prod_date')
{
$field="prod_date";
}
elseif($_GET['field']=='firmware_version')
{
$field="firmware_version";
}
elseif($_GET['field']=='serial_number')
{
$field="serial_number";
}
elseif($_GET['field']=='owner')
{
$field="owner";
}
elseif($_GET['field']=='last_user')
{
$field="last_user";
}
elseif($_GET['field']=='Status')
{
$field="Status";
}
elseif($_GET['field']=='id')
{
$field="Id";
}
//$sql = "SELECT com_type, com_id, inst_status FROM FTK_parts ORDER BY $field $sort";
$sql = "SELECT * FROM ftk_other ORDER BY $field $sort";
//$sql = "SELECT com_type, com_id, inst_status FROM FTK_parts ORDER BY id $sort";
$result = mysql_query($sql) or die(mysql_error());
if (isset($_POST['submit'])) {
foreach ($_POST['todelete'] as $delete_id) {
$query = "DELETE FROM ftk_other WHERE id = $delete_id";
//echo $query;
//echo '<br />';
//mysqli_query($dbc, $query)
mysql_query($query)
or die('Error querying database.');
}
echo 'Module(s) removed.<br />';
}
echo'<table border="1">';
if($_SESSION['username']==ADMIN || $_SESSION['username']==ADMIN2)
{
//echo 'strange mode';
//echo '<tr><td> Remove</td>';
echo'<th>Remove</th><th><a href="table_other.php?sorting='.$sort.'&field=id">ID</a></th>';
}
else
{
echo'<th><a href="table_other.php?sorting='.$sort.'&field=id">ID</a></th>';
}
echo'<th><a href="table_other.php?sorting='.$sort.'&field=com_type">Device Type</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=com_id">Device ID</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=location">Location</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=rack">Rack</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=crate">Crate</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=slot">Slot</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=inst_status">Inst Status</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=cern_receival_date">CERN Receival</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=test_date">Test</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=prod_date">Production</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=firmware_version">Firmware Version</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=serial_number">Serial Number</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=owner">Owner</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=last_user">Last User</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=Status">Status</a></th>
<th><a href="table_other.php?sorting='.$sort.'&field=notes">Notes</a></th>';
while($row = mysql_fetch_array($result))
{
if($_SESSION['username']==ADMIN || $_SESSION['username']==ADMIN2)
{
echo'<tr><td><input type="checkbox" value="' . $row['id'] . '" name="todelete[]" /></td>';
echo '<td><A HREF="FTK_other_reception2_def.php?id='. $row['id']. '">'. $row['id']."</A></td>";
}
else
{
echo '<tr><td><A HREF="FTK_other_reception2_def.php?id='. $row['id']. '">'. $row['id']."</A></td>";
}
echo'<td>'.$row['com_type'].'</td>
<td>'.$row['com_id'].'</td>
<td>'.$row['location'].'</td>
<td>'.$row['rack'].'</td>
<td>'.$row['crate'].'</td>
<td>'.$row['slot'].'</td>
<td>'.$row['inst_status'].'</td>
<td>'.$row['cern_receival_date'].'</td>
<td>'.$row['test_date'].'</td>
<td>'.$row['prod_date'].'</td>
<td>'.$row['firmware_version'].'</td>
<td>'.$row['serial_number'].'</td>
<td>'.$row['owner'].'</td>
<td>'.$row['last_user'].'</td>
<td>'.$row['status'].'</td>
<td>'.$row['notes'].'</td>
</tr>';
}
echo'</table>';
mysqli_close($dbc);
?>
<?php
if($_SESSION['username']==ADMIN || $_SESSION['username']==ADMIN2){
echo '<input type="submit" name="submit" value="Remove" />';
}
else{
echo '<input type="hidden" name="submit" value="Remove" />';
}
?>