-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminViewListingsBackend.php
127 lines (114 loc) · 5.11 KB
/
adminViewListingsBackend.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
<?php
session_start();
require_once("db.php");
if (isset($_POST["submit"])) {
if(isset($_POST["listingID"])) $_SESSION['listingID']=$_POST["listingID"];
Header("Location: adminDetail.php");
}
echo
"<table>
<tr>
<th> ListingID </th>
<th> Client Name </th>
<th> Package Origin </th>
<th> Package Destination </th>
<th> date listed </th>
<th> Weight (in tons) </th>
<th> rate </th>
<th> Miles </th>
<th> Rate per Mile </th>
<th> Status </th>
<th>Detail View </th>
</tr>";
$andExists = false;
$sql = "select * from listing";
if(isset($_GET['originDropdown']) && !($_GET['originDropdown']=="") && !($_GET['originDropdown']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."origin='".$_GET['originDropdown']."'";}
if((isset($_GET['minRPM']) && !($_GET['minRPM']=="") && !($_GET['minRPM']=="[object Object]")) &&
(isset($_GET['maxRPM']) && !($_GET['maxRPM']=="") && !($_GET['maxRPM']=="[object Object]"))){
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
"ratePerMile between '".$_GET['maxRPM']."' and '".$_GET['maxRPM']."'";}
elseif(isset($_GET['minRPM']) && !($_GET['minRPM']=="") && !($_GET['minRPM']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."ratePerMile>='".$_GET['minRPM']."'";}
elseif(isset($_GET['maxRPM']) && !($_GET['maxRPM']=="") && !($_GET['maxRPM']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql= $sql."ratePerMile<='".$_GET['maxRPM']."'";}
if((isset($_GET['maxWeight']) && !($_GET['maxWeight']=="") && !($_GET['maxWeight']=="[object Object]")) &&
(isset($_GET['minWeight']) && !($_GET['minWeight']=="") && !($_GET['minWeight']=="[object Object]"))){
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
"weight between '".$_GET['maxWeight']."' and '".$_GET['minWeight']."'";}
elseif(isset($_GET['maxWeight']) && !($_GET['maxWeight']=="") && !($_GET['maxWeight']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."weight<='".$_GET['maxWeight']."'";}
elseif(isset($_GET['minWeight']) && !($_GET['minWeight']=="") && !($_GET['minWeight']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."weight>='".$_GET['minWeight']."'";}
if(isset($_GET['destinationDropdown']) && !($_GET['destinationDropdown']=="") && !($_GET['destinationDropdown']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."destination='".$_GET['destinationDropdown']."'";}
if((isset($_GET['minMiles']) && !($_GET['minMiles']=="") && !($_GET['minMiles']=="[object Object]")) &&
(isset($_GET['maxMiles']) && !($_GET['maxMiles']=="") && !($_GET['maxMiles']=="[object Object]"))){
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
"miles between '".$_GET['maxMiles']."' and '".$_GET['minMiles']."'";}
elseif(isset($_GET['minMiles']) && !($_GET['minMiles']=="") && !($_GET['minMiles']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."miles>='".$_GET['minMiles']."'";}
elseif(isset($_GET['maxMiles']) && !($_GET['maxMiles']=="") && !($_GET['maxMiles']=="[object Object]")) {
if($andExists==true){$sql=$sql." and ";}else{$sql=$sql." where ";}
$andExists = true;
$sql=$sql."miles<='".$_GET['maxMiles']."'";}
echo $sql;
$result = $mydb->query($sql);
echo
"</br><div><table>
<tr>
<th> ListingID </th>
<th> Client Name </th>
<th> Origin </th>
<th> Destination </th>
<th> date listed </th>
<th> Weight </th>
<th> rate </th>
<th> Miles </th>
<th> Rate per Mile </th>
<th> Status </th>
</tr>";
while($row = mysqli_fetch_array($result)) {
$lid=$row['listingID'];
echo
"<tr>
<td>".$row['listingID']."</td>
<td>".$row['clientName']."</td>
<td>".$row['origin']."</td>
<td>".$row['destination']."</td>
<td>".$row['dateListed']."</td>
<td>".$row['weight']."</td>
<td>$".$row['rate']."</td>
<td>$".$row['miles']."</td>
<td>$".$row['ratePerMile']."</td>";
if ($row['state']=="NA"){echo "<td>Needs Approval</td>";}
elseif($row['state']=="L"){echo "<td>Listed</td>";}
elseif($row['state']=="IT"){echo "<td>In Transit</td>";}
elseif($row['state']=="F"){echo "<td>Fulfilled</td>";}
elseif($row['state']=="C"){echo "<td>Cancelled</td>";}
echo"<td><form method='post'
action='".$_SERVER['PHP_SELF']."'>
<input type='hidden' name='listingID' value=".$lid." />
<input type='submit' name='submit' value='View Detail' />
</form></td>
</tr>";
}
echo "</table></div>";
?>