-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescription.php
383 lines (290 loc) · 8.38 KB
/
description.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
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?php
$conn = new PDO("mysql:host=edward2.solent.ac.uk;dbname=dspokes;","dspokes","shaetuvo");
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Description</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bluebootstrap.css">
<!-- <script type='text/javascript'>jQuery(document).on("mobileinit", function() {
jQuery.mobile.autoInitializePage = false;
});
</script>-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript">
var hotel_coords = new Array();
var destination_coords =new Array();
<?php
$hotelID = $_GET['hotelID'];
$flightID = $_GET['flightID'];
$sql ="SELECT * FROM Hotels h where h.ID='$hotelID'";
$results = $conn->query($sql);
while ($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo "var pos = new Array();";
echo "pos[0]=$row[lat];";
echo "pos[1]=$row[long];";
echo " hotel_coords.push(pos);";
}
$sql ="SELECT DISTINCT h.city ,h.lat , h.long FROM Flights f ,Hotels h where f.F_Id='$flightID' AND f.Dest_city=h.city";
$results = $conn->query($sql);
while ($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo "var pos = new Array();";
echo "pos[0]=$row[lat];";
echo "pos[1]=$row[long];";
echo " destination_coords.push(pos);";
}
?>
var geocoder;
var markers = [];
var maps = [];
function initialize(canvasname ,mapIndex) {
//createa and initilise geo coder
geocoder = new google.maps.Geocoder();
//set map options
var mapOptions = {
zoom: 6
};
//create the map
maps[mapIndex] = new google.maps.Map(document.getElementById(canvasname),
mapOptions);
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
maps[mapIndex].setCenter(pos);
var coords =destination_coords;
if(mapIndex==1)
coords = hotel_coords;
if(mapIndex==0)
{
var flightPlanCoordinates = [
new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(maps[0]);
}
for(var i = 0; i< coords.length;i++)
{
var pos = coords[i];
var lat = pos[0];
var lon = pos[1];
// alert(lat+" and "+lon);
if (lat === undefined || lon === undefined) {
}
else
{
placeMarker( new google.maps.LatLng(lat, lon) , "France Hotel" ,"<div>Best place to go to</div>",maps[mapIndex]);
if(i==coords.length-1)
maps[mapIndex].setCenter(new google.maps.LatLng(lat, lon));
}
}
}, function() {
handleNoGeolocation(true);
});
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(false);
}
// add more listners
}
//
//
function placeMarker(location , title ,description, map) {
// info window to show when a marker is selected
var infowindow = new google.maps.InfoWindow({
content: description
});
//create the marker
var marker = new google.maps.Marker({
position: location,
map: map,
title:title
});
//listen to mark clikced event , so we show the info
google.maps.event.addListener(marker, 'click', function() {
//open the marker details using the info window
infowindow.open(map,marker);
});
//map.setCenter(location);
markers.push(marker);
}
var pages =Array();
var page = 0;
pages.push("#pagecontent");
pages.push("#pagecontent2");
pages.push("#pagecontent3");
function onSlide()
{
page++;
if(page > 2)
{
page =0;
}
var width = $( "#content" ).width();
for(var p = 0; p<3 ; p++)
$( pages[p] ).animate({ "left": "+="+width+"px" }, "slow", function(){
for(var j = 0; j<3;j++)
if($(pages[j]).position().left>width)
{
$( pages[j] ).css("left" , "-"+width+"px");
//initialize(canvases[page]);
}
});
}
function onSlideLeft()
{
page--;
if(page < 0 )
{
page =2;
}
var width = $( "#content" ).width();
for(var p = 0; p<3 ; p++)
$( pages[p] ).animate({ "left": "-="+width+"px" }, "slow", function(){
for(var j = 0; j<3;j++)
if($(pages[j]).position().left<-width)
{
$( pages[j] ).css("left" , ""+width+"px");
}
});
}
$(function(){
// Bind the swipeleftHandler callback function to the swipe event on div.box
$( "#content" ).on( "swipeleft", function(e){
onSlideLeft();
});
});
$(function(){
// Bind the swipeleftHandler callback function to the swipe event on div.box
$( "#content" ).on( "swiperight", function(e){
onSlide();
});
});
function init()
{
initialize('map-canvas',0);
initialize('map-canvas2',1);
initialize('map-canvas3',2);
}
</script>
<link href="css/main.css" rel="stylesheet" type="text/css">
</head>
<body onLoad="init()">
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand">StudentTravels</a>
</div>
<div>
<ul class="nav navbar-nav">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="results.php?destination=Australia">Info</a></li>
</ul>
</div>
</div>
</nav>
<div name="container">
<div id="content">
<div id="pagecontent">
<h2>Description</h2>
<!-- Total Price for holiday -->
<div id="map-canvas"></div>
<div id="descript-content">
<!--content changed-->
<h3>General Area Information</h3>
<p>Drinking Age Limit = 18</p>
<p>Smoking Age Limit = 16</p>
<p>Legal consent age = 21</p>
<p>Clubbing / Bar age = 14</p>
<p>No public drinking or smoking</p>
</div>
</div>
<!-- content 2 -->
<div id="pagecontent2">
<h2>Hotel Prices</h2>
<div id="map-canvas2"></div>
<div id="descript-content2">
<!--content changed-->
<?php
$hotelID = $_GET['hotelID'];
$flightID = $_GET['flightID'];
echo '<table class="table table-striped">
<tr>
<th></th>
<th>Hotel</th>
<th>City</th>
<th>Price(£) pppn</th>
<th></th>
</tr>';
$sql ="SELECT * FROM Hotels h where h.ID='$hotelID'";
$results = $conn->query($sql);
while ($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo ' <tr>';
echo "<td><img src=$row[flag] width='32' height='32'/></td>";
echo "<td>$row[name]</td>";
echo "<td>$row[city]</td>";
echo "<td>£ $row[price]</td>";
echo "<td><a href=''>Book</a></td>";
echo "</tr>";
}
echo " </table>";
?>
</div>
</div>
<!-- content 2 -->
<div id="pagecontent3">
<h2>Flight Prices</h2>
<div id="map-canvas3"></div>
<div id="descript-content3">
<!--content changed-->
<?php
$hotelID = $_GET['hotelID'];
$flightID = $_GET['flightID'];
echo '<table class="table table-striped">
<tr>
<th></th>
<th>From</th>
<th>Destination</th>
<th>Price</th>
<th></th>
</tr>';
$sql ="SELECT f.From , f.Dest_city , ROUND(f.Price,2) as Price ,f.flag FROM Flights f where f.F_Id='$flightID' ";
$results = $conn->query($sql);
while ($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo ' <tr>';
echo "<td><img src=$row[flag] width='32' height='32'/></td>";
echo "<td>$row[From]</td>";
echo "<td>$row[Dest_city]</td>";
echo "<td>£ $row[Price]</td>";
echo "<td><input type='submit' class='btn btn-info'value='Book' />
</td></tr>";
}
echo "</table>";
?>
</div>
</div>
</div>
</div>
<!--<input type="button" value="next page" onClick="onSlide()" style="top:700px; position:absolute"/>
<input type="button" value="prev page" onClick="onSlideLeft()" style="top:700px; left:60px; position:absolute"/>-->
</body>
</html>