-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_cables.php
240 lines (206 loc) · 6.7 KB
/
table_cables.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
234
235
236
237
238
239
<?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 Boad 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
echo "DATA CONTENT TO BE FINISHED";
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='cable_type';
$sort='ASC';
if(isset($_GET['sorting']))
{
if($_GET['sorting']=='ASC')
{
$sort='DESC';
}
else
{
$sort='ASC';
}
}
if($_GET['field']=='cable_type')
{
$field = "cable_type";
}
elseif($_GET['field']=='cable_id')
{
$field = "cable_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']=='owner')
{
$field="owner";
}
elseif($_GET['field']=='last_user')
{
$field="last_user";
}
elseif($_GET['field']=='MB_SN')
{
$field="MB_SN";
}
elseif($_GET['field']=='MB_Pos')
{
$field="MB_Pos";
}
elseif($_GET['field']=='FPGA')
{
$field="FPGA";
}
elseif($_GET['field']=='firmware_version')
{
$field="firmware_version";
}
elseif($_GET['field']=='Status')
{
$field="Status";
}
elseif($_GET['field']=='id')
{
$field="Id";
}
//$sql = "SELECT cable_type, cable_id, inst_status FROM FTK_parts ORDER BY $field $sort";
$sql = "SELECT * FROM ftk_cables ORDER BY $field $sort";
//$sql = "SELECT cable_type, cable_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_cables 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_cables.php?sorting='.$sort.'&field=cable_type">Board Type</a></th>';
}
else
{
echo'<th><a href="table_cables.php?sorting='.$sort.'&field=cable_type">Board Type</a></th>';
}
echo'<th><a href="table_cables.php?sorting='.$sort.'&field=id">ID</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=cable_id">Board ID</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=location">location</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=rack">rack</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=crate">crate</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=slot">slot</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=inst_status">Inst Status</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=CERN_receival_date">CERN_receival_date</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=TEST_date">TEST_date</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=Prod_date">Prod_date</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=owner">owner</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=last_user">last_user</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=MB_SN">MB_SN</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=MB_Pos">MB_Pos</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=FPGA">FPGA</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=firmware_version">firmware_version</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=Status">Status</a></th>
<th><a href="table_cables.php?sorting='.$sort.'&field=cable_type_ID">Board type ID</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_Board_reception2_def.php?id='. $row['id']. '">'. $row['id']."</A></td>";
}
else
{
echo '<tr><td><A HREF="FTK_Board_reception2_def.php?id='. $row['id']. '">'. $row['id']."</A></td>";
}
echo'<td>'.$row['cable_type'].'</td>
<td>'.$row['cable_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['owner'].'</td>
<td>'.$row['last_user'].'</td>
<td>'.$row['MB_SN'].'</td>
<td>'.$row['MB_Pos'].'</td>
<td>'.$row['FPGA'].'</td>
<td>'.$row['firmware_version'].'</td>
<td>'.$row['Status'].'</td>
<td>'.$row['cable_type_ID'].'</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" />';
}
?>