-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientListingsPageBackend.php
224 lines (208 loc) · 7.65 KB
/
clientListingsPageBackend.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
<?php
session_start();
require_once("db.php");
if(isset($_SESSION['clientName'])) $clientName=$_SESSION['clientName'];
if(isset($_SESSION['clientID'])) $clientID=$_SESSION['clientID'];
if (isset($_POST["submit"])) {
if(isset($_POST["listingID"])) $_SESSION['listingID']=$_POST["listingID"];
Header("Location: clientListingDetailView.php");
}
echo
"<div style='margin-left: auto; display: block; margin-right: auto;width: 1200px;'>
<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>";
$conditions = "where clientID='$clientID' and clientName='$clientName'";
if(isset($_GET['originDropdown']) && !($_GET['originDropdown']=="") && !($_GET['originDropdown']=="[object Object]")) {
$conditions=$conditions." and origin='".$_GET['originDropdown']."'";}
if((isset($_GET['minRPM']) && !($_GET['minRPM']=="") && !($_GET['minRPM']=="[object Object]")) &&
(isset($_GET['maxRPM']) && !($_GET['maxRPM']=="") && !($_GET['maxRPM']=="[object Object]"))){
$conditions=$conditions." and ratePerMile between '".$_GET['minRPM']."' and '".$_GET['maxRPM']."'";
echo "rpmworks";}
elseif(isset($_GET['minRPM']) && !($_GET['minRPM']=="") && !($_GET['minRPM']=="[object Object]")) {
$conditions=$conditions." and ratePerMile>='".$_GET['minRPM']."'";}
elseif(isset($_GET['maxRPM']) && !($_GET['maxRPM']=="") && !($_GET['maxRPM']=="[object Object]")) {
$conditions= $conditions."and ratePerMile<='".$_GET['maxRPM']."'";}
if((isset($_GET['maxWeight']) && !($_GET['maxWeight']=="") && !($_GET['maxWeight']=="[object Object]")) &&
(isset($_GET['minWeight']) && !($_GET['minWeight']=="") && !($_GET['minWeight']=="[object Object]"))){
$conditions=$conditions." and weight between '".$_GET['minWeight']."' and '".$_GET['maxWeight']."'";
echo "weightworks";}
elseif(isset($_GET['maxWeight']) && !($_GET['maxWeight']=="") && !($_GET['maxWeight']=="[object Object]")) {
$conditions=$conditions." and weight<='".$_GET['maxWeight']."'";}
elseif(isset($_GET['minWeight']) && !($_GET['minWeight']=="") && !($_GET['minWeight']=="[object Object]")) {
$conditions=$conditions." and weight>='".$_GET['minWeight']."'";}
if(isset($_GET['destinationDropdown']) && !($_GET['destinationDropdown']=="") && !($_GET['destinationDropdown']=="[object Object]")) {
$conditions=$conditions." and destination='".$_GET['destinationDropdown']."'";}
if((isset($_GET['minMiles']) && !($_GET['minMiles']=="") && !($_GET['minMiles']=="[object Object]")) &&
(isset($_GET['maxMiles']) && !($_GET['maxMiles']=="") && !($_GET['maxMiles']=="[object Object]"))){
$conditions=$conditions." and miles between '".$_GET['minMiles']."' and '".$_GET['maxMiles']."'";
echo "milesworks";}
elseif(isset($_GET['minMiles']) && !($_GET['minMiles']=="") && !($_GET['minMiles']=="[object Object]")) {
$conditions=$conditions." and miles>='".$_GET['minMiles']."'";}
elseif(isset($_GET['maxMiles']) && !($_GET['maxMiles']=="") && !($_GET['maxMiles']=="[object Object]")) {
$conditions=$conditions." and miles<='".$_GET['maxMiles']."'";}
if(isset($_GET['state']) && !($_GET['state']=="") && !($_GET['state']=="[object Object]")) {
$conditions=$conditions." and state='".$_GET['state']."'";}
$sql="select * from listing ".$conditions;
?>
<html>
<head>
</head>
<body style="background-color:skyblue;">
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/4.7.2/d3.min.js"></script>
<script src="d3pie.min.js"></script>
<script>
d3pie.destroy("pieChart");
</script>
<div id="pieChart" style="margin: auto;
background-color:white;
width: 625px;
border: 3px solid black;
padding: 10px;"></div>
<script>
var pie = new d3pie("pieChart", {
"header": {
"title": {
"text": "Current Query Composition",
"fontSize": 20,
"font": "open sans"
},
"subtitle": {
"text": "by fulfillment status",
"color": "#999999",
"font": "open sans"
},
"titleSubtitlePadding": 9
},
"footer": {
"color": "#999999",
"fontSize": 10,
"font": "open sans",
"location": "bottom-left"
},
"size": {
"canvasWidth": 590,
"pieInnerRadius": "40%",
"pieOuterRadius": "63%"
},
"data": {
"sortOrder": "value-desc",
"content": [
{
"label": "Needs Approval",
"value": <?php $sql2=("select count(state) as total from listing ".$conditions." and state='NA'");
$result = $mydb->query($sql2);
while($row=mysqli_fetch_array($result)){echo $row['total'];}?>,
"color": "#1c6898"
},
{
"label": "Listed",
"value": <?php $sql2=("select count(state) as total from listing ".$conditions." and state='L'");
$result = $mydb->query($sql2);
while($row=mysqli_fetch_array($result)){echo $row['total'];}?>,
"color": "#a39216"
},
{
"label": "In-Transit",
"value": <?php $sql2=("select count(state) as total from listing ".$conditions." and state='IT'");
$result = $mydb->query($sql2);
while($row=mysqli_fetch_array($result)){echo $row['total'];}?>,
"color": "#1628a4"
},
{
"label": "Fulfilled",
"value": <?php $sql2=("select count(state) as total from listing ".$conditions." and state='F'");
$result = $mydb->query($sql2);
while($row=mysqli_fetch_array($result)){echo $row['total'];}?>,
"color": "#12bd09"
},
{
"label": "Cancelled",
"value": <?php $sql2=("select count(state) as total from listing ".$conditions." and state='C'");
$result = $mydb->query($sql2);
while($row=mysqli_fetch_array($result)){echo $row['total'];}?>,
"color": "#a11818"
}
]
},
"labels": {
"outer": {
"pieDistance": 32
},
"inner": {
"hideWhenLessThanPercentage": 3
},
"mainLabel": {
"fontSize": 11
},
"percentage": {
"color": "#ffffff",
"decimalPlaces": 0
},
"value": {
"color": "#adadad",
"fontSize": 11
},
"lines": {
"enabled": true
},
"truncation": {
"enabled": true
}
},
"effects": {
"pullOutSegmentOnClick": {
"effect": "linear",
"speed": 400,
"size": 8
}
},
"misc": {
"gradient": {
"enabled": true,
"percentage": 100
}
}
});</script>
</body>
</html>
<?php
$result = $mydb->query($sql);
while($row = mysqli_fetch_array($result)) {
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>Canceled </td>";}
echo"<td><form method='post'
action='".$_SERVER['PHP_SELF']."'>
<input type='hidden' name='listingID' value=".$row['listingID']." />
<input type='submit' name='submit' value='View More' />
</form></td>
</tr>
";
}
echo "</table></div>";
?>