質問編集履歴
1
HTMLの内容をPHPに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
|
25
25
|
![イメージ説明](9f22143fcce7dc686ff78fea8afb6e19.png)
|
26
26
|
|
27
|
-
出力されたH
|
27
|
+
出力されたPHPのソース
|
28
|
-
|
28
|
+
|
29
|
-
```h
|
29
|
+
```php
|
30
30
|
|
31
31
|
<!DOCTYPE html>
|
32
32
|
|
@@ -70,116 +70,306 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
<!DOCTYPE html>
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
<h
|
73
|
+
<?php
|
78
|
-
|
74
|
+
|
79
|
-
|
75
|
+
session_start();
|
76
|
+
|
80
|
-
|
77
|
+
require("nav_user.php");
|
78
|
+
|
79
|
+
require('dbconnect.php');
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
$year = date('Y');
|
84
|
+
|
85
|
+
$month = date('m');
|
86
|
+
|
87
|
+
if(isset($_GET["month"])){
|
88
|
+
|
81
|
-
|
89
|
+
$month = $_GET["month"];
|
82
|
-
|
83
|
-
|
84
|
-
|
90
|
+
|
85
|
-
|
91
|
+
if(isset($_GET["year"])){
|
86
|
-
|
92
|
+
|
87
|
-
|
93
|
+
$year = $_GET["year"];
|
94
|
+
|
88
|
-
|
95
|
+
if(isset($_GET["btn"])){
|
96
|
+
|
89
|
-
|
97
|
+
if($_GET["btn"] == 'next'){
|
90
|
-
|
91
|
-
|
98
|
+
|
92
|
-
|
93
|
-
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
|
94
|
-
|
95
|
-
<script type="text/javascript" src="js/bootstrap.js"></script>
|
96
|
-
|
97
|
-
<link href="css/bootstrap.min.css" rel="stylesheet">
|
98
|
-
|
99
|
-
|
99
|
+
$month = $month+1;
|
100
|
-
|
101
|
-
|
100
|
+
|
102
|
-
|
103
|
-
|
101
|
+
if($month == 13){
|
102
|
+
|
104
|
-
|
103
|
+
$month = 1;
|
104
|
+
|
105
|
+
$year = $year+1;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
105
|
-
|
109
|
+
}elseif($_GET["btn"] == 'prev'){
|
110
|
+
|
111
|
+
$month = $month-1;
|
112
|
+
|
113
|
+
if($month == 0){
|
114
|
+
|
115
|
+
$month = 12;
|
116
|
+
|
117
|
+
$year = $year-1;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
//linkでやる12月の次の処理、linkにyearを追加
|
134
|
+
|
135
|
+
// else{
|
136
|
+
|
137
|
+
// $month = date('m');
|
138
|
+
|
139
|
+
// }
|
140
|
+
|
141
|
+
// echo $month+1;
|
142
|
+
|
143
|
+
// exit;
|
106
144
|
|
107
145
|
|
108
146
|
|
147
|
+
|
148
|
+
|
149
|
+
$reservations = $db->prepare('select * from reservation where year=? and month=?');
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
$reservations->execute(array(
|
154
|
+
|
155
|
+
$year,$month
|
156
|
+
|
157
|
+
));
|
158
|
+
|
159
|
+
$monthly=[];//予定が空のときに処理
|
160
|
+
|
161
|
+
while($reservation = $reservations->fetch()){
|
162
|
+
|
163
|
+
$monthly[$reservation['day']][] = array($reservation['time1'],$reservation['time2'],$reservation['g_name']);
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
// var_dump($reservation);
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
// ksort($monthly);
|
172
|
+
|
173
|
+
// print_r($monthly);
|
174
|
+
|
175
|
+
// print $reservation['time2'];
|
176
|
+
|
177
|
+
// exit;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
// 一か月分の日付を曜日付きで出力する
|
182
|
+
|
183
|
+
$lastd = 31;//$yearと$monthから計算して求める
|
184
|
+
|
185
|
+
$time = mktime(0, 0, 0, $month + 1, 0, $year);
|
186
|
+
|
109
|
-
|
187
|
+
$lastd = date('d',$time);
|
110
|
-
|
188
|
+
|
111
|
-
|
189
|
+
//時区間分割を実現する
|
112
|
-
|
190
|
+
|
113
|
-
|
191
|
+
$divided=[];
|
192
|
+
|
114
|
-
|
193
|
+
for ($d=1; $d<= $lastd; $d++){
|
194
|
+
|
195
|
+
if (array_key_exists($d, $monthly)){
|
196
|
+
|
197
|
+
//配列のキーが存在するか調べる(キー、対象の配列)
|
198
|
+
|
199
|
+
//この日に予定があれば、分割していく
|
200
|
+
|
201
|
+
$intv = [[9,21,'']];
|
202
|
+
|
203
|
+
foreach ($monthly[$d] as $yotei){//(対象配列 as その中身)、$yoteiは[x,y,z]
|
204
|
+
|
205
|
+
$intv= div($intv, $yotei);
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
$divided[$d] = $intv;//=[x,y,z]
|
210
|
+
|
211
|
+
}else{
|
212
|
+
|
213
|
+
$divided[$d] = [[9,21,'']];
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
//print_r($divided);
|
222
|
+
|
223
|
+
//exit;
|
224
|
+
|
225
|
+
echo '<div id="content">';
|
226
|
+
|
227
|
+
echo '<table border=1>';
|
228
|
+
|
229
|
+
echo '<h2>スケジュール編集</h2> ';
|
230
|
+
|
231
|
+
// echo '<ul class="nav nav-tabs" role="tablist">
|
232
|
+
|
233
|
+
// <li class="nav-item">
|
234
|
+
|
235
|
+
// <a class="nav-link active" id="item1-tab" data-toggle="tab" href="#item1" role="tab" aria-controls="item1" aria-selected="true">野球場</a>
|
236
|
+
|
237
|
+
// </li>
|
238
|
+
|
239
|
+
// <li class="nav-item">
|
240
|
+
|
241
|
+
// <a class="nav-link" id="item2-tab" data-toggle="tab" href="#item2" role="tab" aria-controls="item2" aria-selected="false">テニスコート</a>
|
242
|
+
|
243
|
+
// </li>
|
244
|
+
|
245
|
+
// </ul>';
|
246
|
+
|
247
|
+
echo "<h3>{$year}年{$month}月</h3>";
|
248
|
+
|
249
|
+
echo "<a class='btn btn-info' href='?year=$year&month=$month&btn=prev'>前月</a>";
|
250
|
+
|
251
|
+
echo "<a class='btn btn-info' href='#'>引き継ぐ</a>";
|
252
|
+
|
253
|
+
echo "<a class='btn btn-info' href='?year=$year&month=$month&btn=next'>次月</a>";
|
254
|
+
|
255
|
+
echo '<tr><td></td>';
|
256
|
+
|
115
|
-
|
257
|
+
for ($h=9; $h<22; $h++){
|
258
|
+
|
259
|
+
echo '<td >', $h, '</td>';
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
echo '</tr>';
|
264
|
+
|
265
|
+
for ($d=1; $d<=$lastd; $d++){
|
266
|
+
|
267
|
+
$time = mktime(0, 0, 0, $month, $d, $year);
|
268
|
+
|
269
|
+
$w = date('w',$time);
|
270
|
+
|
271
|
+
$wdays = array('日','月','火','水','木','金','土',);
|
272
|
+
|
273
|
+
$class = '';
|
274
|
+
|
275
|
+
if ($w==0) $class='sun';
|
276
|
+
|
277
|
+
if ($w==6) $class='sat';
|
278
|
+
|
279
|
+
echo '<tr>';
|
280
|
+
|
281
|
+
echo '<td><span class="'.$class.'">', $d,'('. $wdays[$w].')</span>'. '</td>';
|
282
|
+
|
283
|
+
$yotei = $divided[$d];
|
284
|
+
|
285
|
+
foreach ($yotei as $y){//$yotei=$divided[$d]=[x,y,z]
|
286
|
+
|
287
|
+
$y1 = $y[0];//[x,y,z]のx
|
288
|
+
|
289
|
+
$y2 = $y[1];//[x,y,z]のy
|
290
|
+
|
291
|
+
$y3 = $y[2];//[x,y,z]のz
|
292
|
+
|
293
|
+
$colspan=$y2-$y1+1;
|
294
|
+
|
295
|
+
if(!empty($y3)){
|
296
|
+
|
297
|
+
echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'&facility='.$f.'&gm='.$y3.'">'.$y3.'</a></td>';
|
298
|
+
|
299
|
+
}else{
|
300
|
+
|
301
|
+
echo '<td colspan="'. $colspan . '"><a href="schedule_add_delete.php?y='.$year.'&m='.$month.'&d='.$d.'&w='.$wdays[$w].'&t1='.$y1.'&t2='.$y2.'">○</a></td>';
|
116
302
|
|
117
303
|
}
|
118
304
|
|
119
305
|
|
120
306
|
|
121
|
-
|
122
|
-
|
123
|
-
</
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<b
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
<div class="navbar-header">
|
136
|
-
|
137
|
-
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
138
|
-
|
139
|
-
<span class="sr-only">Toggle navigation</span>
|
140
|
-
|
141
|
-
<span class="icon-bar"></span>
|
142
|
-
|
143
|
-
<span class="icon-bar"></span>
|
144
|
-
|
145
|
-
<span class="icon-bar"></span>
|
146
|
-
|
147
|
-
</button>
|
148
|
-
|
149
|
-
<a class="navbar-brand" href="#">○○市施設予約システム</a>
|
150
|
-
|
151
|
-
</div>
|
152
|
-
|
153
|
-
<ul class="nav navbar-nav navbar-right">
|
154
|
-
|
155
|
-
<li><a href="#">橋本 五郎</a></li><li><a href="user_home.php">ホーム</a> </li><li><a href="register.php">会員登録</a> </li><li><a href="facility_search.php">空き照会・申込</a> </li><li><a href="reservation-confirm_cancel.php">予約確認・本申請・取消</a> </li><li><a href="logout.php">ログアウト</a> </li>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
<!-- <li class="dropdown">
|
160
|
-
|
161
|
-
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">予約・セット予約 <span class="caret"></span></a>
|
162
|
-
|
163
|
-
<ul class="dropdown-menu">
|
164
|
-
|
165
|
-
<li><a href="#">申請</li>
|
166
|
-
|
167
|
-
<li><a href="#">確認・キャンセル</a></li>
|
168
|
-
|
169
|
-
</ul>
|
170
|
-
|
171
|
-
</li> -->
|
172
|
-
|
173
|
-
</ul>
|
174
|
-
|
175
|
-
</div>
|
176
|
-
|
177
|
-
</nav>
|
178
|
-
|
179
|
-
</body><div id="content"><table border=1><h2>スケジュール編集</h2> <h3>2020年12月</h3><a class='btn btn-info' href='?year=2020&month=12&btn=prev'>前月</a><a class='btn btn-info' href='#'>引き継ぐ</a><a class='btn btn-info' href='?year=2020&month=12&btn=next'>次月</a><tr><td></td><td >9</td><td >10</td><td >11</td><td >12</td><td >13</td><td >14</td><td >15</td><td >16</td><td >17</td><td >18</td><td >19</td><td >20</td><td >21</td></tr><tr><td><span class="">1(火)</span></td><td colspan="4"><a href="schedule_add_delete.php?y=2020&m=12&d=1&w=火&t1=9&t2=12">○</a></td><td colspan="5"><a href="schedule_add_delete.php?id=y=2020&m=12&d=1&w=火&t1=13&t2=17&facility=&gm=xxxx">xxxx</a></td><td colspan="4"><a href="schedule_add_delete.php?y=2020&m=12&d=1&w=火&t1=18&t2=21">○</a></td></tr><tr><td><span class="">2(水)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=2&w=水&t1=9&t2=21">○</a></td></tr><tr><td><span class="">3(木)</span></td><td colspan="13"><a href="schedule_add_delete.php?id=y=2020&m=12&d=3&w=木&t1=9&t2=21&facility=&gm=西武">西武</a></td></tr><tr><td><span class="">4(金)</span></td><td colspan="13"><a href="schedule_add_delete.php?id=y=2020&m=12&d=4&w=金&t1=9&t2=21&facility=&gm=楽天">楽天</a></td></tr><tr><td><span class="sat">5(土)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=5&w=土&t1=9&t2=21">○</a></td></tr><tr><td><span class="sun">6(日)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=6&w=日&t1=9&t2=21">○</a></td></tr><tr><td><span class="">7(月)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=7&w=月&t1=9&t2=21">○</a></td></tr><tr><td><span class="">8(火)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=8&w=火&t1=9&t2=21">○</a></td></tr><tr><td><span class="">9(水)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=9&w=水&t1=9&t2=21">○</a></td></tr><tr><td><span class="">10(木)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=10&w=木&t1=9&t2=21">○</a></td></tr><tr><td><span class="">11(金)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=11&w=金&t1=9&t2=21">○</a></td></tr><tr><td><span class="sat">12(土)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=12&w=土&t1=9&t2=21">○</a></td></tr><tr><td><span class="sun">13(日)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=13&w=日&t1=9&t2=21">○</a></td></tr><tr><td><span class="">14(月)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=14&w=月&t1=9&t2=21">○</a></td></tr><tr><td><span class="">15(火)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=15&w=火&t1=9&t2=21">○</a></td></tr><tr><td><span class="">16(水)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=16&w=水&t1=9&t2=21">○</a></td></tr><tr><td><span class="">17(木)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=17&w=木&t1=9&t2=21">○</a></td></tr><tr><td><span class="">18(金)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=18&w=金&t1=9&t2=21">○</a></td></tr><tr><td><span class="sat">19(土)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=19&w=土&t1=9&t2=21">○</a></td></tr><tr><td><span class="sun">20(日)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=20&w=日&t1=9&t2=21">○</a></td></tr><tr><td><span class="">21(月)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=21&w=月&t1=9&t2=21">○</a></td></tr><tr><td><span class="">22(火)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=22&w=火&t1=9&t2=21">○</a></td></tr><tr><td><span class="">23(水)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=23&w=水&t1=9&t2=21">○</a></td></tr><tr><td><span class="">24(木)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=24&w=木&t1=9&t2=21">○</a></td></tr><tr><td><span class="">25(金)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=25&w=金&t1=9&t2=21">○</a></td></tr><tr><td><span class="sat">26(土)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=26&w=土&t1=9&t2=21">○</a></td></tr><tr><td><span class="sun">27(日)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=27&w=日&t1=9&t2=21">○</a></td></tr><tr><td><span class="">28(月)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=28&w=月&t1=9&t2=21">○</a></td></tr><tr><td><span class="">29(火)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=29&w=火&t1=9&t2=21">○</a></td></tr><tr><td><span class="">30(水)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=30&w=水&t1=9&t2=21">○</a></td></tr><tr><td><span class="">31(木)</span></td><td colspan="13"><a href="schedule_add_delete.php?y=2020&m=12&d=31&w=木&t1=9&t2=21">○</a></td></tr></table></div></body>
|
307
|
+
}
|
308
|
+
|
309
|
+
echo '</tr>';
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
echo '</table>';
|
314
|
+
|
315
|
+
echo '</div>';
|
316
|
+
|
317
|
+
?>
|
318
|
+
|
319
|
+
</body>
|
180
320
|
|
181
321
|
</html>
|
182
322
|
|
183
|
-
|
323
|
+
<?php
|
324
|
+
|
325
|
+
//div.phpからコピーしたもの
|
326
|
+
|
327
|
+
function div($intv, $a){
|
328
|
+
|
329
|
+
// $a=[11,12,''] =(div)=> $intv=[[9,10,''],[11,12,'試合'],[13,21,'']]
|
330
|
+
|
331
|
+
$a1 = $a[0];
|
332
|
+
|
333
|
+
$a2 = $a[1];
|
334
|
+
|
335
|
+
$a3 = $a[2];//追加
|
336
|
+
|
337
|
+
$out = [];
|
338
|
+
|
339
|
+
for ($i=0; $i<count($intv); $i++){
|
340
|
+
|
341
|
+
$b1 = $intv[$i][0];
|
342
|
+
|
343
|
+
$b2 = $intv[$i][1];
|
344
|
+
|
345
|
+
$b3 = $intv[$i][2];//追加
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
if ($a1 >= $b1 and $a2 <= $b2){
|
350
|
+
|
351
|
+
if ($b1<=$a1-1)
|
352
|
+
|
353
|
+
$out[]=[$b1, $a1-1, $b3]; //$b3を追加
|
354
|
+
|
355
|
+
$out[]=[$a1, $a2, $a3]; //$a3を追加
|
356
|
+
|
357
|
+
if ($a2+1<=$b2)
|
358
|
+
|
359
|
+
$out[]=[$a2+1,$b2, $b3]; //$b3を追加
|
360
|
+
|
361
|
+
}else{
|
362
|
+
|
363
|
+
$out[] = $intv[$i];
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
return $out;
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
?>
|
184
374
|
|
185
375
|
```
|