-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfindTour.php
187 lines (153 loc) · 5.88 KB
/
findTour.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
<?php
include('layout/header.php');
$d = new DateTime($_POST['date']);
$date = $d->format('Y-m-d');
?>
<style>
.table-vcenter td {
vertical-align: middle!important;
}
</style>
<div class="panel panel-white">
<div class="panel-body">
<form class="form-group-lg" method="post">
<?php
?>
<div class="row">
<div class="col-sm-3">
<div class="form-group ">
<label for="exampleInputName2"><h3>Departure</h3></label>
<select name="dep" class="form-control input-lg" >
<?php
$stmt = $db->prepare('SELECT Name,CityID FROM city'); //TODO ADD STATION
$stmt->execute();
$res = $stmt->fetchAll();
foreach ($res as $city)
{
if ($_POST['dep'] == $city['CityID'])
echo"<option value=".$city['CityID']." selected='true'>".$city['Name']."</option>";
else
echo"<option value=".$city['CityID'].">".$city['Name']."</option>";
}
?>
</select>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label for="exampleInputName2"><h3>Destination</h3></label>
<select name="des" class="form-control input-lg ">
<?php
foreach ($res as $city)
{
if ($_POST['des'] == $city['CityID'])
echo"<option value=".$city['CityID']." selected='true'>".$city['Name']."</option>";
else
echo"<option value=".$city['CityID'].">".$city['Name']."</option>";
}
?>
</select>
</div>
</div>
<div class="col-sm-3" >
<div class="form-group">
<label for="exampleInputName2"><h3>Date</h3></label>
<input type="text" class="form-control input-lg " name="date" value="<?php echo $_POST['date']; ?>" id="calendar">
</div>
</div>
<div class="col-sm-3" >
<div class="form-group" align="left">
<br><br><br>
<button type="submit" class="form-control btn btn-primary btn-block">Search!</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="panel panel-white">
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-body">
<?php
$stmt = $db->prepare("SELECT *, model.Name as modelName, bustype.Name as busName
FROM tour t
INNER JOIN bus ON (bus.BusID = t.BusID)
INNER JOIN bustype ON bus.BusType = bustype.TypeID
INNER JOIN model ON bus.Model = model.TypeID
WHERE t.DepartureStationID = " . $_POST['dep'] ." AND t.ArrivalStationID = ".$_POST['des']."
AND t.TourDate = '".$date."' ORDER BY t.DepartureTime ASC"
); //todo add view for busses
$stmt->execute();
$tours = $stmt->fetchAll();
$count = count($tours);
if($count == 0)
echo"<h2><center> No Busses Found. </center></h2> ";
else
{
?>
<table class="table table-striped table-vcenter" >
<thead>
<tr><b>
<td><b>Time</b></td>
<td>Bus Type</td>
<td>Seat Count</td>
<td>Price</td>
<td> </td>
</b>
</tr>
</thead>
<tbody>
<?php
foreach ($tours as $tour)
{
$count++;
echo"
<tr>
<td><h4><b>".$tour['DepartureTime']."</b></h4></td>
<td>".$tour['modelName']." - ".$tour['busName']."</td>
<td>".$tour['Capacity']."</td>
<td>85</td>
<td> <a href='selectSeat.php?tourID=".$tour['TourID']."' class='btn btn-success btn-block'>Buy</a></td>
</tr>";
}
?>
</tbody>
</table>
<?php } ?>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="style/js/bootstrap-datepicker.js"></script>
<script>
function checkDate()
{
if(!$('#date').val())
{
// TODO ADD ALERT ADD PLACES CHECK
return false;
}
return true;
}
$('#calendar').datepicker({
});
!function ($) {
$(document).on("click","ul.nav li.parent > a > span.icon", function(){
$(this).find('em:first').toggleClass("glyphicon-minus");
});
$(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
}(window.jQuery);
$(window).on('resize', function () {
if ($(window).width() > 768) $('#sidebar-collapse').collapse('show')
})
$(window).on('resize', function () {
if ($(window).width() <= 767) $('#sidebar-collapse').collapse('hide')
})
$('#calendar').datepicker().on('click', function () {
$('#date').val($('#calendar').datepicker('getDate'));
});
</script>
</div> <!-- container -->