/
map-i.php
executable file
·260 lines (229 loc) · 7.08 KB
/
map-i.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
<?php
require_once 'init.php';
$db = connectDb();
if(!isSignin()) {
$signin_url = 'signin.php';
header("Location: {$signin_url}");
exit;
}
function getevent($pdo){
$sql = "SELECT * FROM event";
$statement = $pdo->prepare($sql);
$statement->execute();
if($rows = $statement->fetchAll(PDO::FETCH_ASSOC)) {
return $rows;
}else{
return false;
}
}
function getEventId($pdo, $fac_id, $event_name){
$sql = "SELECT id FROM event WHERE 'fac_id' = :fac_id, 'event_name' = :event_name";
$statement->bindValue(':fac_id', $fac_id, PDO::PARAM_INT);
$statement->bindValue(':event_name', $event_name, PDO::PARAM_STR);
$statement = $pdo->prepare($sql);
$statement->execute();
if($rows = $statement->fetch(PDO::FETCH_ASSOC)) {
return $rows['id'];
}else{
return false;
}
}
function getEventName($pdo, $id){
$sql = "SELECT event_name FROM event WHERE `id` = :id";
$statement = $pdo->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
if($rows = $statement->fetch(PDO::FETCH_ASSOC)) {
return $rows['event_name'];
}else{
return false;
}
}
function getFacility($pdo){
$sql = "SELECT * FROM facility";
$statement = $pdo->prepare($sql);
$statement->execute();
if($rows = $statement->fetchAll(PDO::FETCH_ASSOC)) {
return $rows;
}else{
return false;
}
}
function getFacName($pdo, $id){
$sql = "SELECT fac_name FROM facility WHERE `id` = :id";
$statement = $pdo->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
if($rows = $statement->fetch(PDO::FETCH_ASSOC)) {
return $rows['fac_name'];
}else{
return false;
}
}
function OnIcon($db,$fac_id){
$fac_name = getFacName($db, $fac_id);
switch ($fac_id){
case 5://寒梅館
echo '<form method="POST" action="map-i.php">
<DIV style="position:absolute; top : 35px ; left : 610px ; ">
<button type="button" onclick="clickIcon(5)" data-toggle="modal" data-target="#myModal" name="TC1"><img src="doushisha_icon.png" width="30px" height="30px" border="0"></button>
</DIV>
</form>';
break;
case 6://チャペル
echo '<form method="POST" action="map-i.php">
<DIV style="position:absolute; top : 350px ; left : 290px ; ">
<button type="button" onclick="clickIcon(6)" data-toggle="modal" data-target="#myModal" name="TC2"><img src="doushisha_icon.png" width="30px" height="30px" border="0"></button>
</DIV>
</form>';
break;
case 7://未定
echo '<form method="POST" action="map-i.php">
<DIV style="position:absolute; top : 225px ; left : 415px ; ">
<button type="button" onclick="clickIcon(7)" data-toggle="modal" data-target="#myModal" name="TC3"><img src="doushisha_icon.png" width="30px" height="30px" border="0"></button>
</DIV>
</form>';
break;
case 8://未定
echo '<form method="POST" action="map-i.php">
<DIV style="position:absolute; top : 480px ; left : 950px ; ">
<button type="button" onclick="clickIcon(8)" data-toggle="modal" data-target="#myModal" name="TC3"><img src="doushisha_icon.png" width="30px" height="30px" border="0"></button>
</DIV>
</form>';
break;
case 5:
break;
case 6:
break;
default:
break;
}
}
$event = getevent($db);
$facility = getFacility($db);
function getEventFromFacility($pdo, $fac_id){
$sql = "SELECT * FROM event WHERE `fac_id` = :fac_id";
$statement = $pdo->prepare($sql);
$statement->bindValue(':fac_id', $fac_id, PDO::PARAM_INT);
$statement->execute();
if($rows = $statement->fetch(PDO::FETCH_ASSOC)) {
return $rows;
}else{
return false;
}
}
function getEventNum($pdo){
$sql = "SELECT id FROM event ORDER BY `id` DESC LIMIT 1";
$statement = $pdo->prepare($sql);
$statement->execute();
if($rows = $statement->fetch(PDO::FETCH_ASSOC)) {
return $rows['id'];
}else{
return false;
}
}
$all_event_array = array();
foreach ($facility as $key => $value) {
//var_dump($value);
$fac_event = getEventFromFacility($db, $value["id"]);
$fac_name = $value["fac_name"];
$fac_info = array(
'event_id' => $fac_event['id'],
'event_name' => $fac_event["event_name"],
'fac_name' => $fac_name
);
$all_event_array[$value["id"]] = $fac_info;
}
$eventNum = getEventNum($db);
/*
$box = 0;
while(1){
$bid = $box + 1;
//print $box;
var_dump($box);
print "--------------------------------------";
var_dump($facility);
//var_dump($facility[2]["fac_name"]);
$fac_event = getEventFromFacility($db, $facility[$box][$bid]["id"]);
$fac_name = $facility[$box][$bid]["fac_name"];
$fac_info = array(
'event_id' => $fac_event['id'],
'event_name' => $fac_event["event_name"],
'fac_name' => $fac_name
);
$all_event_array[$facility[$box][$bid]["id"]] = $fac_info;
$box++;
if ($box == $eventNum) {
break;
}
}
*/
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
function clickIcon(fac_id){
var place = document.getElementById("eventPlace");
var name = document.getElementById("eventName");
<?php $all_event_json = json_encode($all_event_array); ?>
var all_event = JSON.parse('<?php echo $all_event_json ?>');
place.innerHTML = all_event[fac_id]['fac_name'];
name.innerHTML = '<form name="place" method="POST" action="./event.php"><input type="hidden" name="place" value="'
+ all_event[fac_id]['event_id'] + '"></form><a href="javascript:document.place.submit()">'
+ all_event[fac_id]['event_name'] + '</a>';
}
</script>
<style>
button {
width: auto;
padding:0;
margin:0;
background:none;
border:0;
font-size:0;
line-height:0;
overflow:visible;
cursor:pointer;
}
</style>
</head>
<body>
<DIV style="position: relative; left : 0px">
<!-- 地図 //-->
<IMG src="imadegawa.png" width="90%" height="auto" border="0">
<!--同志社アイコン-->
<?php
foreach ($event as $key => $value) {
if (isset($value)) {
OnIcon($db,$value['fac_id']);
}
}
?>
</DIV>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title" id="eventPlace">eventPlace</h4>
</div>
<div class="modal-body">
<p id="eventName">eventName</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>