-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtabVehicles.html
More file actions
299 lines (269 loc) · 13.9 KB
/
tabVehicles.html
File metadata and controls
299 lines (269 loc) · 13.9 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Browse Vehicles">
<title>All Vehicles</title>
<link rel="icon" type="image/png" href="images/caricon.png">
<link rel="stylesheet" type=text/css href="styles/main.css">
<link rel="stylesheet" type="text/css" href="styles/bootstrap4/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="styles/util.css">
<link rel="stylesheet" type="text/css" href="styles/style.css">
<link rel="stylesheet" type="text/css" href="styles/table.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>
<body>
<?php session_start(); ?>
<header>
<div id="logo"><a><img src="images/logo.png"></a></div>
<nav>
<ul>
<?php
if(isset($_SESSION['customer']))
{
echo '<li><a href="logout.php">Logout</a></li>';
echo '<li><a href="custAccount.html" style=text-decoration:none;>Welcome ' . $_SESSION['fname'] . '</a></li>';
} else if(isset($_SESSION['wsmanager']) || isset($_SESSION['ldmanager1']) || isset($_SESSION['ldmanager2']) || isset($_SESSION['salesrep1']) || isset($_SESSION['salesrep2']))
{
echo '<li><a href="logout.php">Logout</a></li>';
echo '<li><a href="empAccount.html" style=text-decoration:none;>Welcome ' . $_SESSION['fname'] . '</a></li>';
} else
{
echo '<li>';
echo '<a style=color:red;>Sign In</a>';
echo '<ul class="dropdown">';
echo '<li><a href="signIn.html">Customers</a></li>';
echo '<li><a href="empSignin.html">Employees</a></li>';
echo '</ul>';
echo '</li>';
echo '<li><a href="registerPage.html">Register</a></li>';
}
?>
<li><a>|</a></li>
<li><a href="contactUs.html">Contact Us</a></li>
<li><a href="tabVehicles.html">Vehicles</a></li>
<li><a href="tabPackages.html">Packages</a></li>
<li><a href="tabRebates.html">Rebates</a></li>
<li><a href="index.html">Home</a></li>
</ul>
</nav>
<div class="services">
<div class="container">
<div class="row">
<div class="col text-center">
<div class="section_title">View All Vehicles</div>
<div class="section_subtitle">Search for the perfect one</div>
</div>
</div>
</div>
</div>
</header>
<!-- Cars in the database for dealer -->
<?php
$dbconnect = mysqli_connect("127.0.0.1", "root", "", "globalviews");
$query = "SELECT serial_no, color, warehouse, rebate, dealer, model.model, model.price, model.type, model.gas_mileage,
model.seat, model.engine FROM available_auto
INNER JOIN model ON globalviews.available_auto.model = globalviews.model.model";
$output = $dbconnect->query($query);
if($_SERVER["REQUEST_METHOD"] == "POST")
{
//collect value of search input fields
$color = $_POST['color'];
$model = $_POST['model'];
$mileage = $_POST['gas_mileage'];
$seat = $_POST['seat'];
$engine = $_POST['engine'];
$min = $_POST['min_price'];
$max = $_POST['max_price'];
if(isset($_POST['column']))
{
//collect value of sort input fields
$column = $_POST['column'];
}
if(isset($_POST['order']))
{
$order = $_POST['order'];
}
$query = "SELECT serial_no, color, warehouse, rebate, dealer, model.model, model.price, model.type, model.gas_mileage,
model.seat, model.engine FROM available_auto
INNER JOIN model ON globalviews.available_auto.model = globalviews.model.model";
$conditions = array();
$sort = array();
if(!empty($color))
{
$conditions[] = "color LIKE '%$color%'";
}
if(!empty($model))
{
$conditions[] = "model.model LIKE '%$model%'";
}
if(!empty($mileage))
{
$conditions[] = "gas_mileage LIKE '%$mileage%'";
}
if(!empty($seat))
{
$conditions[] = "seat LIKE '%$seat%'";
}
if(!empty($engine))
{
$conditions[] = "engine LIKE '%$engine%'";
}
if(!empty($min) && !empty($max))
{
$conditions[] = "model.price BETWEEN '$min' AND '$max'";
}
if(!empty($column) && !empty($order))
{
$sort[] = " ORDER BY $column $order";
} else if(!empty($column))
{
$sort[] = " ORDER BY $column";
}
$sql = $query;
if(count($conditions) > 0 && count($sort) > 0)
{
$sql .= " WHERE " . implode(' AND ', $conditions);
$sql .= implode(' ', $sort);
} else if(count($conditions) == 0 && count($sort) > 0)
{
$sql .= implode(' ', $sort);
} else
{
$sql .= " WHERE " . implode(' AND ', $conditions);
}
$output = $dbconnect->query($sql);
}
?>
<div class="limiter">
<div class="container-table100">
<div class="wrap-table100">
<form method="POST" action= "<?php echo $_SERVER['PHP_SELF'];?>">
<div style="text-align:right">
<span class="login100-form-title" style="display:inline-block;float:left;">Search:</span>
<div style="width:17%;display:inline-block;" class="wrap-input100">
<input class="input100" type="text" name="color" placeholder="Search Color">
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</div>
<div style="width:17%;display:inline-block" class="wrap-input100">
<input class="input100" type="text" name="model" placeholder="Search Model">
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</div>
<div style="width:17%;display:inline-block" class="wrap-input100">
<input class="input100" type="text" name="gas_mileage" placeholder="Search Gas Mileage">
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</div>
<div style="width:17%;display:inline-block" class="wrap-input100">
<input class="input100" type="text" name="seat" placeholder="Search Seats">
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</div>
<div style="width:17%;display:inline-block" class="wrap-input100">
<input class="input100" type="text" name="engine" placeholder="Search Engine">
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</div>
</div>
<div style="text-align:right;margin-top:10px;">
<span class="login100-form-title" style="display:inline-block;float:left;">Filter:</span>
<div style="width:17%;display:inline-block" class="wrap-input100">
<input class="input100" type="" id="min" name="min_price" placeholder="Minimum Range">
</div>
<div style="width:17%;display:inline-block" class="wrap-input100">
<input class="input100" type="" id="max" name="max_price" placeholder="Maximum Range">
</div>
</div>
<div style="text-align:right;margin-top:10px;">
<span class="login100-form-title" style="display:inline-block;float:left;">Sort:</span>
<select style="width:17%;display:inline-block" class="wrap-input100" name="column">
<option value="" selected>Sort By</option>
<option value="price">Price</option>
<option value="gas_mileage">Gas Mileage</option>
<option value="engine">Engine</option>
<option value="color">Color</option>
<option value="model">Model</option>
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</select>
<select style="width:17%;display:inline-block" class="wrap-input100" name="order">
<option value="" selected>Order By</option>
<option value="DESC">High to Low</option>
<option value="ASC">Low to High</option>
<option value="DESC">Z-A</option>
<option value="ASC">A-Z</option>
<span class="focus-input100-1"></span>
<span class="focus-input100-2"></span>
</select>
</div>
<input style="padding:10px;float:right;margin:10px 0px" type="submit" name="submit" value="Submit">
</form>
<br>
<?php if($output){ ?>
<div class="table100 ver2 m-b-110" style="margin-top:50px;">
<div class="table100-head">
<table>
<thead>
<tr class="row100 head">
<th class="cell100 column1">Serial No.</th>
<th class="cell100 column2">Model</th>
<th class="cell100 column3">Color</th>
<th class="cell100 column4">Warehouse</th>
<th class="cell100 column5">Dealership</th>
<th class="cell100 column6">Rebate<input style="margin-left:10px" type="checkbox" id="myCheck"></th>
<th class="cell100 column7">Price</th>
<th class="cell100 column8">Type</th>
<th class="cell100 column9">Gas Mileage</th>
<th class="cell100 column10">Seat</th>
<th class="cell100 column11">Engine</th>
</tr>
</thead>
</table>
</div>
<div class="table100-body js-pscroll ps ps--active-y">
<table>
<tbody>
<?php if(($output)){
while($result = mysqli_fetch_assoc($output)){ ?>
<tr class="row100 body">
<td class="cell100 column1"><?php echo $result['serial_no']?></td>
<td class="cell100 column2"><?php echo $result['model']?></td>
<td class="cell100 column3"><?php echo $result['color']?></td>
<td class="cell100 column4"><?php echo $result['warehouse']?></td>
<td class="cell100 column5"><?php echo $result['dealer']?></td>
<td class="cell100 column6"><?php echo $result['rebate']?></td>
<td class="cell100 column7"><?php echo $result['price']?></td>
<td class="cell100 column8"><?php echo $result['type']?></td>
<td class="cell100 column9"><?php echo $result['gas_mileage']?></td>
<td class="cell100 column10"><?php echo $result['seat']?></td>
<td class="cell100 column11"><?php echo $result['engine']?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php } } else { ?>
<section>
<h1 style="margin-top:50px;" id="page_title">No Vehicles Available <?php echo $dbconnect->error?></h1>
</section>
<?php } ?>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#myCheck').change( function() {
$('td:contains("No")').parent().toggle();
});
});
</script>
<footer>
<h3>All Rights Reserved, Copyright © 2020</h3>
</footer>
</body>
</html>