-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchpart.php
206 lines (184 loc) · 9.23 KB
/
searchpart.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
<html>
<head>
<title>CMS Tracker Flat Sheets Database</title>
<link rel="StyleSheet" type="text/css" href="theme.css"/>
</head>
<body>
<script src="showHideElements.js"></script>
<h1 align="center"> CMS Tracker Flat Sheets Database </h1>
<?php
session_start();
if ($_SESSION["username"] != "")
{
echo "Current User: ".$_SESSION["firstname"]." ".$_SESSION["lastname"]."<br/> \n";
echo "Affiliation: ".$_SESSION["affiliation"]."<br/> \n";
echo "Privilege: ".$_SESSION["privilege"]."<br/> \n";
echo "<br/> \n";
echo "<p> \n";
echo "<form action='searchpart.php' method='post' enctype='multipart/form-data'> \n";
echo " Search by <b>Sheet String</b>: <input type='text' name='searchstring' value='%'/> <br/> \n";
echo "Wildcards allowed: \n";
echo "<ul> \n";
echo " <li> <b>%</b> Represents zero or more characters. For example, 'bl%' finds bl, black, blue, and blob. </li> \n";
echo " <li> <b>_</b> Represents a single character. For example, h_t finds hot, hat, and hit. </li> \n";
echo " <li> <b>[]</b> Represents any single character within the brackets. For example, h[oa]t finds hot and hat, but not hit. </li> \n";
echo " <li> <b>^</b> Represents any character not in the brackets. For example, h[^oa]t finds hit, but not hot and hat. </li> \n";
echo " <li> <b>-</b> Represents a range of characters. For example, c[a-b]t finds cat and cbt. </li> \n";
echo "</ul> \n";
echo " AND <b>Current Location</b>: \n";
echo " <select name='location'> \n";
echo " <option value='Any'>Any</option> \n";
include("dbconnect.php");
$connection = openConnection();
$sqlQuery = "SELECT affiliation FROM affiliations";
$queryResult = mysqli_query($connection, $sqlQuery);
while ($map_output = mysqli_fetch_assoc($queryResult))
echo " <option value='".$map_output["affiliation"]."'>".$map_output["affiliation"]."</option> \n";
mysqli_close($connection);
echo " </select> <br/><br/> \n";
echo " AND <b>Thickness Mean Range</b>: <input type='text' name='thicknessMean_lo' value='0'/> to <input type='text' name='thicknessMean_hi' value='1000'/> μm <br/><br/> \n";
echo " AND <b>Thickness Standard Deviation Range</b>: <input type='text' name='thicknessStdDev_lo' value='0'/> to <input type='text' name='thicknessStdDev_hi' value='1000'/> μm <br/><br/> \n";
echo " <input type='submit' value='Search'> \n";
echo "</form> \n";
echo "</p> \n";
}
?>
<?php
$goodArguments = false;
if (isset($_SESSION["searchstring"]))
{
if ($_SESSION["searchstring"] != "")
{
$searchstring = $_SESSION["searchstring"]; unset($_SESSION["searchstring"]);
$searchLocation = $_SESSION["location"]; unset($_SESSION["location"]);
$thicknessMean_lo = $_SESSION["thicknessMean_lo"]; unset($_SESSION["thicknessMean_lo"]);
$thicknessMean_hi = $_SESSION["thicknessMean_hi"]; unset($_SESSION["thicknessMean_hi"]);
$thicknessStdDev_lo = $_SESSION["thicknessStdDev_lo"]; unset($_SESSION["thicknessStdDev_lo"]);
$thicknessStdDev_hi = $_SESSION["thicknessStdDev_hi"]; unset($_SESSION["thicknessStdDev_hi"]);
$goodArguments = true;
}
}
else if (isset($_POST["searchstring"]))
{
if ($_POST["searchstring"] != "")
{
$searchstring = $_POST["searchstring"];
$searchLocation = $_POST["location"];
$thicknessMean_lo = $_POST["thicknessMean_lo"];
$thicknessMean_hi = $_POST["thicknessMean_hi"];
$thicknessStdDev_lo = $_POST["thicknessStdDev_lo"];
$thicknessStdDev_hi = $_POST["thicknessStdDev_hi"];
$goodArguments = true;
}
else echo "You must enter a search string. <br/> \n";
}
if ($goodArguments)
{
if ($searchLocation == "Any") $searchLocation = "%";
echo "<br/> \n";
echo "<p> \n";
echo "<h2> Matching Sheets </h2> \n";
echo "<table> \n";
echo " <tr> \n";
echo " <th> # </th> \n";
echo " <th> Sheet String </th> \n";
echo " <th> Datasheets Entered by </th> \n";
echo " <th> PDF Datasheet </th> \n";
echo " <th> CSV Datasheet </th> \n";
echo " <th> Thickness Mean <br/> (μm) </th> \n";
echo " <th> Thickness Std Dev <br/> (μm) </th> \n";
echo " <th> Location </th> \n";
echo " <th> Location Modified by </th> \n";
echo " <th> Location Modified on </th> \n";
echo " </tr> \n";
$connection = openConnection();
$sqlQuery = "SELECT * FROM sheets WHERE sheetstring LIKE '".$searchstring."' AND
location LIKE '".$searchLocation."' AND
thickness_mean >= '".$thicknessMean_lo."' AND
thickness_mean <= '".$thicknessMean_hi."' AND
thickness_stddev >= '".$thicknessStdDev_lo."' AND
thickness_stddev <= '".$thicknessStdDev_hi."'";
$queryResult = mysqli_query($connection, $sqlQuery);
$itemNumber = 0;
while ($map_output = mysqli_fetch_assoc($queryResult))
{
++$itemNumber;
$sheetstring = $map_output["sheetstring"];
$file = $map_output["folder"].$sheetstring;
$thickness_mean = $map_output["thickness_mean"];
$thickness_stddev = $map_output["thickness_stddev"];
$location = $map_output["location"];
$movingTime = $map_output["movingTime"];
$created_at = $map_output["created_at"];
$userId = $map_output["userId"];
$sqlQuery_user = "SELECT firstname, lastname, affiliation FROM users WHERE id=".$userId;
$map_output_user = mysqli_fetch_assoc(mysqli_query($connection, $sqlQuery_user));
$userInformation = $map_output_user["firstname"]." ".$map_output_user["lastname"].", ".$map_output_user["affiliation"].", at ".$created_at;
$moverId = $map_output["moverId"];
$sqlQuery_mover = "SELECT firstname, lastname, affiliation FROM users WHERE id=".$moverId;
$result_mover = mysqli_query($connection, $sqlQuery_mover);
$moverInformation = "";
if ($result_mover)
{
$map_output_mover = mysqli_fetch_assoc($result_mover);
$moverInformation = $map_output_mover["firstname"]." ".$map_output_mover["lastname"].", ".$map_output_mover["affiliation"];
}
echo "<tr> \n";
echo " <td> ".$itemNumber." </td> \n";
echo " <td> \n";
echo $sheetstring." \n";
// The sheet can be deleted if the privilege is Administrator
if ($_SESSION["privilege"] == "Administrator")
{
echo "<button type='button' id='delete_".$sheetstring."' onclick=showMovingElements('".$sheetstring."')>Delete</button> \n";
}
echo " </td> \n";
echo " <td> ".$userInformation." </td> \n";
echo " <td> <a href='".$file.".pdf' target='_blank'>".$sheetstring.".PDF</a> </td> \n";
echo " <td> <a href='".$file.".csv' target='_blank'>".$sheetstring.".CSV</a> </td> \n";
echo " <td> ".$thickness_mean." </td> \n";
echo " <td> ".$thickness_stddev." </td> \n";
echo " <td > \n";
echo $location." \n";
// The location can be changed if the privilege is Editor or Administrator
if ($_SESSION["privilege"] == "Editor" || $_SESSION["privilege"] == "Administrator")
{
echo "<button type='button' id='edit_".$sheetstring."' onclick=showMovingElements('".$sheetstring."')>Change Location</button> \n";
echo "<form action='move.php' method='post' enctype='multipart/form-data'> \n";
echo " <select id='dropDown_".$sheetstring."' style='display:none' name='newLocation'> \n";
echo " <option value = 'Purdue'>Purdue</option";
$sqlQuery_affiliations = "SELECT affiliation FROM affiliations";
$queryResult_affiliations = mysqli_query($connection, $sqlQuery_affiliations);
while ($map_affiliations = mysqli_fetch_assoc($queryResult_affiliations))
echo " <option value='".$map_affiliations["affiliation"]."'>".$map_affiliations["affiliation"]."</option> \n";
echo " </select> \n";
echo " <input type='hidden' name='searchstring' value='".$searchstring."'/>";
echo " <input type='hidden' name='searchLocation' value='".$searchLocation."'/>";
echo " <input type='hidden' name='thicknessMean_lo' value='".$thicknessMean_lo."'/>";
echo " <input type='hidden' name='thicknessMean_hi' value='".$thicknessMean_hi."'/>";
echo " <input type='hidden' name='thicknessStdDev_lo' value='".$thicknessStdDev_lo."'/>";
echo " <input type='hidden' name='thicknessStdDev_hi' value='".$thicknessStdDev_hi."'/>";
echo " <input type='hidden' name='sheetstring' value='".$sheetstring."'/>";
echo " <input id='submit_".$sheetstring."' style='display:none' type='submit' value='Submit'/> \n";
echo "</form> \n";
echo "<button type='button' id='cancel_".$sheetstring."' style='display:none' onclick=hideMovingElements('".$sheetstring."')>Cancel</button> \n";
}
echo " </td> \n";
echo " <td> ".$moverInformation." </td> \n";
echo " <td> ".$movingTime." </td> \n";
echo "</tr> \n";
}
mysqli_close($connection);
echo "</table> \n";
}
?>
<br/><br/>
<a href="main.php">Back</a>
<br/>
<p align="right">
Author: Souvik Das <br/>
Purdue University, 2021 <br/>
</p>
</body>
</html>