質問編集履歴
3
phpソースの編集をしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,6 +68,144 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
+
// カレンダー表示
|
72
|
+
|
73
|
+
// 前月表示
|
74
|
+
|
75
|
+
$tr = '<div class="cal_tr">';
|
76
|
+
|
77
|
+
$tail = null;
|
78
|
+
|
79
|
+
//前月の最終日を習得
|
80
|
+
|
81
|
+
$lastDayOfPrevMonth = new DateTime('last day of ' . $yearMonth . ' -1 month');
|
82
|
+
|
83
|
+
while ($lastDayOfPrevMonth->format('N') < 7) {
|
84
|
+
|
85
|
+
$tail = sprintf('<div></div>', $lastDayOfPrevMonth->format('d')) . $tail;
|
86
|
+
|
87
|
+
$tail = sprintf('<div class="cal cal_td empty"><div class="cal_body"></div></div>', $lastDayOfPrevMonth->format('d')) . $tail;
|
88
|
+
|
89
|
+
$lastDayOfPrevMonth->sub(new DateInterval('P1D'));
|
90
|
+
|
91
|
+
$prevmanth = $lastDayOfPrevMonth->format('Y-m');
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
// 当月表示
|
98
|
+
|
99
|
+
$body = null;
|
100
|
+
|
101
|
+
$period = new DatePeriod (
|
102
|
+
|
103
|
+
new DateTime('first day of' . $yearMonth),
|
104
|
+
|
105
|
+
new DateInterval('P1D'),
|
106
|
+
|
107
|
+
new DateTime('first day of' . $yearMonth . '+1 month')
|
108
|
+
|
109
|
+
);
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
$today = new DateTime('today');
|
114
|
+
|
115
|
+
foreach ($period as $day) {
|
116
|
+
|
117
|
+
if ($day->format('N') === '1'){
|
118
|
+
|
119
|
+
$body .= '</div></div>';
|
120
|
+
|
121
|
+
$body .= '<div class="cal_tr">';
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
$days = $day->format('Y-m-d');
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
$sch = '';
|
130
|
+
|
131
|
+
foreach($holiday as $key) {
|
132
|
+
|
133
|
+
$id = $key['id'];
|
134
|
+
|
135
|
+
$user = $key['account_id'];
|
136
|
+
|
137
|
+
$from = $key['datetime_from'];
|
138
|
+
|
139
|
+
$to = $key['datetime_to'];
|
140
|
+
|
141
|
+
$type = $key['holiday_type'];
|
142
|
+
|
143
|
+
$comment = $key['comment'];
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
if($from == $days){
|
148
|
+
|
149
|
+
$todayClass = ($day->format('Y-m-d') === $today->format('Y-m-d')) ? 'today' : '';
|
150
|
+
|
151
|
+
$sch .= '<div class="area_btn" data-user="' . $user . '" data-from="' . $from . '" data-to="' . $to . '" data-type="' . $type . '" draggable="true">' . $type . '/' . ' ' .$user .'</div>';
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
if($sch !== '') {
|
160
|
+
|
161
|
+
$todayClass = ($day->format('Y-m-d') === $today->format('Y-m-d')) ? 'today' : '';
|
162
|
+
|
163
|
+
$body .= sprintf('<div class="cal cal_td" data-date="' . $days . '"><div class="cal_date day_%d %s">%d</div><div class="cal_plan"></div><div class="cal_body day">' . $sch . '</div></div>', $day->format('w'), $todayClass, $day->format('d'));
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
} else {
|
168
|
+
|
169
|
+
$todayClass = ($day->format('Y-m-d') === $today->format('Y-m-d')) ? 'today' : '';
|
170
|
+
|
171
|
+
$body .= sprintf('<div class="cal cal_td" data-date="' . $days . '"><div class="cal_date day_%d %s">%d</div><div class="cal_plan"></div><div class="cal_body day"></div></div>', $day->format('w'), $todayClass, $day->format('d'));
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
// 次月表示
|
180
|
+
|
181
|
+
$head = null;
|
182
|
+
|
183
|
+
$firstDayOfNextMonth = new DateTime('first day of' . $yearMonth . '+1 month');
|
184
|
+
|
185
|
+
// var_dump($firstDayOfNextMonth->format('N'));
|
186
|
+
|
187
|
+
while($firstDayOfNextMonth->format('N') > 1) {
|
188
|
+
|
189
|
+
$head .= '<div class="cal cal_td empty">' . $firstDayOfNextMonth->format('d');
|
190
|
+
|
191
|
+
$head .= '<div class="cal_body"></div>';
|
192
|
+
|
193
|
+
$head .= '</div>';
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
$firstDayOfNextMonth->add(new DateInterval('P1D'));
|
198
|
+
|
199
|
+
$nextMonth = $firstDayOfNextMonth->format('Y-m');
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
echo $tr . $tail . $body . $head;
|
206
|
+
|
207
|
+
|
208
|
+
|
71
209
|
```
|
72
210
|
|
73
211
|
|
2
Ajax処理を追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,6 +72,62 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
+
```jquery
|
76
|
+
|
77
|
+
$(window).on('load', function(){
|
78
|
+
|
79
|
+
$.ajaxSetup({
|
80
|
+
|
81
|
+
type:'POST',
|
82
|
+
|
83
|
+
ifModified:false,
|
84
|
+
|
85
|
+
cache:false,
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
var ajax_url = './calendar.php';
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
var today = $('.thismonth').attr('data-month');
|
96
|
+
|
97
|
+
var date = today;
|
98
|
+
|
99
|
+
console.log(date);
|
100
|
+
|
101
|
+
var data = {
|
102
|
+
|
103
|
+
today : date,
|
104
|
+
|
105
|
+
};
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
return $.ajax({
|
110
|
+
|
111
|
+
url:ajax_url,
|
112
|
+
|
113
|
+
data:data,
|
114
|
+
|
115
|
+
}).done(function(data, textStatus, jqXHR){
|
116
|
+
|
117
|
+
$('.inner').html(data);
|
118
|
+
|
119
|
+
}).fail(function(jqXHR, textStatus, errorThrown ){
|
120
|
+
|
121
|
+
$('.inner').children('.cal_tr').html(textStatus);
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
```
|
128
|
+
|
129
|
+
|
130
|
+
|
75
131
|
どの様に対処すればよいか困っています。
|
76
132
|
|
77
133
|
|
1
ソースの可読性を改善しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,11 +22,9 @@
|
|
22
22
|
|
23
23
|
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
|
24
24
|
|
25
|
-
|
25
|
+
return true;
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
return false;
|
27
|
+
return false;
|
30
28
|
|
31
29
|
}
|
32
30
|
|
@@ -34,7 +32,11 @@
|
|
34
32
|
|
35
33
|
if(funcIsAjax()) header("Content-type: text/plain; charset=UTF-8");
|
36
34
|
|
35
|
+
else{
|
36
|
+
|
37
|
-
|
37
|
+
header("Location: {$base_url}"); exit;
|
38
|
+
|
39
|
+
}
|
38
40
|
|
39
41
|
|
40
42
|
|