-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbranch.php
118 lines (107 loc) · 4.19 KB
/
branch.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
<?php
session_start();
require_once './db.php';
$id = isset($_SESSION['id']) ? $_SESSION['id'] : 'unknown';
$db = new db();
if (!isset($_SESSION['token']) || !isset($_SESSION['id']) || $_GET['token'] != $_SESSION['token']) {
$db->writeLog('Branch', 'Token and session check failed for branch.php page user ID: '.$id);
header('Location: http://' . $_SERVER['HTTP_HOST'] . '?err=auth');
}
$token = $_SESSION['token'];
$customer_name = $db->getUserNameSurname($id);
$branches_array = $db->getBranches();
?>
<!DOCTYPE html>
<html>
<head>
<?php
require_once './modules/header.php';
?>
<link rel="stylesheet" href="css/branch.css">
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var mapCanvas = document.getElementById('map');
var mapOptions = {
center: new google.maps.LatLng(22.317802, 114.176795),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions);
var infoWindow = new google.maps.InfoWindow();
var marker;
<?php
foreach ($branches_array as $branch) {
echo 'marker =new google.maps.Marker({
position: new google.maps.LatLng('.$branch['latitude'].','.$branch['longitude'].'),
map: map,
title: "'.$branch['city'].'"
});
google.maps.event.addListener(marker, "click", (function (marker) {
return function () {
infoWindow.setContent(
"<div>" +
"<h4>'.$branch['city'].'</h4>" +
"<p><span><strong>Address: </strong></span>'.$branch['address'].'</p>" +
"<p><span><strong>Phone: </strong></span>'.$branch['phone'].'</p>" +
"<p><span><strong>Opening Time: </strong></span>'.$branch['open_time'].'</p>" +
"</div>"
);
infoWindow.open(map, marker);
}
})(marker));';
}
echo '}';
?>
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<?php
require_once './modules/logo.php';
echo '<p id="user_message">Logged As: ' . $customer_name . ' <a href="/index.php?logout=true">Log Out</a></p>';
require_once './modules/menubar.php';
?>
<div id="background" style="padding: 30px;">
<h4>Bank Branches Table and Map Location</h4>
<h5><strong><a href="atm.php?token=<?php echo $token; ?>">Check ATM Table and Location</a></strong></h5>
<div id="map"></div>
<h4 class="error"><?php echo $error; ?></h4>
<table class="table table-bordered">
<thead>
<tr>
<td>
Address
</td>
<td>
City
</td>
<td>
Phone Number
</td>
<td>
Opening Time
</td>
</tr>
</thead>
<tbody>
<?php
foreach ($branches_array as $row) {
echo '<tr>';
echo '<td>' . $row['address'] . '</td>';
echo '<td>' . $row['city'] . '</td>';
echo '<td>' . $row['phone'] . '</td>';
echo '<td>' . $row['open_time'] . '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<?php
require_once './modules/footer.php';
?>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>