-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayTrackingHistory.php
62 lines (52 loc) · 2.17 KB
/
displayTrackingHistory.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
<!-- AJAX handling php file to receive the response from the request in the helper.js
file which is triggered by the the onclick function in the orders.php file when
the user clicks on the show Tracking Order Buttons without reloading the webpage -->
<?php
require_once ("../../mysqli_Coffee_config.php"); // Connect to the database
$value = $_GET['value'];
$query = "SELECT trackingNum AS trackingNum, transactionNum AS entryNumber, dateShipped, timeShipped,
get_location(transactionNum) AS Location
FROM ShipmentEntry
WHERE trackingNum = '$value'
ORDER BY dateShipped, timeShipped";
$result = mysqli_query($dbc, $query);
if (mysqli_num_rows($result) > 0){
$all_rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
else{
echo("<div class=\"success\"><h2>$value doesn't seem to be a tracking number.
Please check the number and try again</h2></div>");
exit;
}
if (mysqli_num_rows($result) > 0){
echo("<table class=\"trackingHistoryTable\">");
echo ("<h2 class=\"tableHeader\">Tracking History</h2>");
echo ("<tr>");
echo ("<th>Tracking Number</th>");
echo ("<th>Shipment Entry Number</th>");
echo ("<th>Date Shipped</th>");
echo ("<th>Time Shipped</th>");
echo ("<th>Location</th>");
echo ("</tr>");
}
foreach ($all_rows as $entry){
echo("<tr class=\"orderRow\">");
echo "<td>".$entry['trackingNum']."</td>" ;
echo "<td>".$entry['entryNumber']."</td>";
echo "<td>".$entry['dateShipped']."</td>";
echo "<td>".$entry['timeShipped']."</td>";
if (substr($entry['entryNumber'], 0, 2) == "TR"){
echo "<td> On Truck, VIN#".$entry['Location']."</td>";
}
if (substr($entry['entryNumber'], 0, 2) == "WA"){
echo "<td> In Warehouse, ID#".$entry['Location']."</td>";
}
if (substr($entry['entryNumber'], 0, 2) == "SU"){
echo "<td> At Supplier, ID#".$entry['Location']."</td>";
}
echo("</tr>");
}
mysqli_free_result($result);
echo("</table>");
mysqli_close($dbc);
?>