@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $dayrange = new \DatePeriod($this->event->getStartDate(), $dayinterval, $this->event->endMonthDate($this->event->getStartDate())); |
161 | 161 | } |
162 | 162 | foreach ($dayrange as $day) { |
163 | - $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d' . $day->format('j')] = $this->event->getValue(); |
|
163 | + $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d'.$day->format('j')] = $this->event->getValue(); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | elseif ($this->event->isLastMonth($date)) { |
169 | 169 | $dayrange = new \DatePeriod(new \DateTime($date->format("Y-n-1")), $dayinterval, $this->event->getEndDate()); |
170 | 170 | foreach ($dayrange as $day) { |
171 | - $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d' . $day->format('j')] = $this->event->getValue(); |
|
171 | + $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d'.$day->format('j')] = $this->event->getValue(); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | else { |
177 | 177 | $dayrange = new \DatePeriod(new \DateTime($date->format("Y-n-1")), $dayinterval, new \DateTime($date->format("Y-n-t 23:59:59"))); |
178 | 178 | foreach ($dayrange as $day) { |
179 | - $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d' . $day->format('j')] = $this->event->getValue(); |
|
179 | + $itemized[EventItemizer::BAT_DAY][$year][$day->format('n')]['d'.$day->format('j')] = $this->event->getValue(); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -217,35 +217,35 @@ discard block |
||
217 | 217 | if ($this->event->isSameDay()) { |
218 | 218 | if (!($this->event->getStartDate()->format('H:i') == '00:00' && $this->event->getEndDate()->format('H:i') == '23:59')) { |
219 | 219 | $itemized_same_day = $this->createHourlyGranular($start_date, $end_date->add(new \DateInterval('PT1M')), $interval); |
220 | - $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
|
221 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
|
222 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
|
220 | + $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d'.$sd] = -1; |
|
221 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd]; |
|
222 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd]; |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | else { |
226 | 226 | // Deal with the start day unless it starts on midnight precisely at which point the whole day is booked |
227 | 227 | if (!($this->event->getStartDate()->format('H:i') == '00:00')) { |
228 | 228 | $itemized_start = $this->createHourlyGranular($start_date, new \DateTime($start_date->format("Y-n-j 23:59:59")), $interval); |
229 | - $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
|
230 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
|
231 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
|
229 | + $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d'.$sd] = -1; |
|
230 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd]; |
|
231 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd]; |
|
232 | 232 | } |
233 | 233 | else { |
234 | 234 | // Just set an empty hour and minute |
235 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
|
236 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
|
235 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = array(); |
|
236 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = array(); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | // Deal with the end date unless it ends just before midnight at which point we don't need to go further |
240 | 240 | if ($this->event->getEndDate()->format('H:i') == '23:59') { |
241 | - $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = array(); |
|
242 | - $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = array(); |
|
241 | + $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed] = array(); |
|
242 | + $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed] = array(); |
|
243 | 243 | } |
244 | 244 | else { |
245 | 245 | $itemized_end = $this->createHourlyGranular(new \DateTime($end_date->format("Y-n-j 00:00:00")), $end_date->add(new \DateInterval('PT1M')), $interval); |
246 | - $itemized[EventItemizer::BAT_DAY][$ey][$em]['d' . $ed] = -1; |
|
247 | - $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed]; |
|
248 | - $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed]; |
|
246 | + $itemized[EventItemizer::BAT_DAY][$ey][$em]['d'.$ed] = -1; |
|
247 | + $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed]; |
|
248 | + $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed] = $itemized_end[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed]; |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // Doing minutes so set the values in the minute array |
290 | - $itemized[EventItemizer::BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour]['m' . $min] = $event_value; |
|
290 | + $itemized[EventItemizer::BAT_MINUTE][$year][$month]['d'.$day]['h'.$hour]['m'.$min] = $event_value; |
|
291 | 291 | // Let the hours know that it cannot determine availability |
292 | - $itemized[EventItemizer::BAT_HOUR][$year][$month]['d' . $day]['h' . $hour] = -1; |
|
292 | + $itemized[EventItemizer::BAT_HOUR][$year][$month]['d'.$day]['h'.$hour] = -1; |
|
293 | 293 | $min++; |
294 | 294 | |
295 | 295 | if ($min == 60 && $start_minute !== 0) { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | elseif ($min == 60 && $start_minute == 0) { |
302 | 302 | // Did a real whole hour so initialize the hour |
303 | - $itemized[EventItemizer::BAT_HOUR][$year][$month]['d' . $day]['h' . $hour] = $event_value; |
|
303 | + $itemized[EventItemizer::BAT_HOUR][$year][$month]['d'.$day]['h'.$hour] = $event_value; |
|
304 | 304 | |
305 | 305 | $min = 0; |
306 | 306 | $hour++; |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | |
323 | 323 | $hour = $date->format('G'); |
324 | 324 | for ($i = 0; $i < 60; $i++) { |
325 | - $minute = ($i < 10) ? '0' . $i : $i; |
|
325 | + $minute = ($i < 10) ? '0'.$i : $i; |
|
326 | 326 | |
327 | - $itemized[EventItemizer::BAT_MINUTE][$date->format('Y')][$date->format('n')]['d' . $date->format('j')]['h' . $hour]['m' . $minute] = $this->event->getValue(); |
|
327 | + $itemized[EventItemizer::BAT_MINUTE][$date->format('Y')][$date->format('n')]['d'.$date->format('j')]['h'.$hour]['m'.$minute] = $this->event->getValue(); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } |
@@ -129,8 +129,7 @@ discard block |
||
129 | 129 | // We add a minute to compensate |
130 | 130 | elseif (($this->event->getStartDate()->format('Y-m-d H:i') == $this->event->getEndDate()->format('Y-m-d H:i')) && $this->granularity == EventItemizer::BAT_DAILY) { |
131 | 131 | $adjusted_end_day = new \DateTime($this->event->getEndDate()->add(new \DateInterval('PT1M'))->format('Y-m-d H:i')); |
132 | - } |
|
133 | - else { |
|
132 | + } else { |
|
134 | 133 | $adjusted_end_day = new \DateTime($this->event->getEndDate()->format('Y-m-d H:i')); |
135 | 134 | } |
136 | 135 | |
@@ -221,16 +220,14 @@ discard block |
||
221 | 220 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
222 | 221 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
223 | 222 | } |
224 | - } |
|
225 | - else { |
|
223 | + } else { |
|
226 | 224 | // Deal with the start day unless it starts on midnight precisely at which point the whole day is booked |
227 | 225 | if (!($this->event->getStartDate()->format('H:i') == '00:00')) { |
228 | 226 | $itemized_start = $this->createHourlyGranular($start_date, new \DateTime($start_date->format("Y-n-j 23:59:59")), $interval); |
229 | 227 | $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
230 | 228 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
231 | 229 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
232 | - } |
|
233 | - else { |
|
230 | + } else { |
|
234 | 231 | // Just set an empty hour and minute |
235 | 232 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
236 | 233 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
@@ -240,8 +237,7 @@ discard block |
||
240 | 237 | if ($this->event->getEndDate()->format('H:i') == '23:59') { |
241 | 238 | $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = array(); |
242 | 239 | $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = array(); |
243 | - } |
|
244 | - else { |
|
240 | + } else { |
|
245 | 241 | $itemized_end = $this->createHourlyGranular(new \DateTime($end_date->format("Y-n-j 00:00:00")), $end_date->add(new \DateInterval('PT1M')), $interval); |
246 | 242 | $itemized[EventItemizer::BAT_DAY][$ey][$em]['d' . $ed] = -1; |
247 | 243 | $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed]; |
@@ -297,8 +293,7 @@ discard block |
||
297 | 293 | $min = 0; |
298 | 294 | $hour++; |
299 | 295 | $start_minute = 0; |
300 | - } |
|
301 | - elseif ($min == 60 && $start_minute == 0) { |
|
296 | + } elseif ($min == 60 && $start_minute == 0) { |
|
302 | 297 | // Did a real whole hour so initialize the hour |
303 | 298 | $itemized[EventItemizer::BAT_HOUR][$year][$month]['d' . $day]['h' . $hour] = $event_value; |
304 | 299 |
@@ -77,23 +77,23 @@ discard block |
||
77 | 77 | $this->event_type = $event_type; |
78 | 78 | |
79 | 79 | if ($event_data == SqlDBStore::BAT_STATE) { |
80 | - $this->day_table = $prefix . 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_STATE; |
|
81 | - $this->hour_table = $prefix . 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_STATE; |
|
82 | - $this->minute_table = $prefix . 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_STATE; |
|
80 | + $this->day_table = $prefix.'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_STATE; |
|
81 | + $this->hour_table = $prefix.'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_STATE; |
|
82 | + $this->minute_table = $prefix.'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_STATE; |
|
83 | 83 | |
84 | - $this->day_table_no_prefix = 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_STATE; |
|
85 | - $this->hour_table_no_prefix = 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_STATE; |
|
86 | - $this->minute_table_no_prefix = 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_STATE; |
|
84 | + $this->day_table_no_prefix = 'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_STATE; |
|
85 | + $this->hour_table_no_prefix = 'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_STATE; |
|
86 | + $this->minute_table_no_prefix = 'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_STATE; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | if ($event_data == SqlDBStore::BAT_EVENT) { |
90 | - $this->day_table = $prefix . 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_EVENT; |
|
91 | - $this->hour_table = $prefix . 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_EVENT; |
|
92 | - $this->minute_table = $prefix . 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_EVENT; |
|
90 | + $this->day_table = $prefix.'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_EVENT; |
|
91 | + $this->hour_table = $prefix.'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_EVENT; |
|
92 | + $this->minute_table = $prefix.'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_EVENT; |
|
93 | 93 | |
94 | - $this->day_table_no_prefix = 'bat_event_' . $event_type . '_day_' . SqlDBStore::BAT_EVENT; |
|
95 | - $this->hour_table_no_prefix = 'bat_event_' . $event_type . '_hour_' . SqlDBStore::BAT_EVENT; |
|
96 | - $this->minute_table_no_prefix = 'bat_event_' . $event_type . '_minute_' . SqlDBStore::BAT_EVENT; |
|
94 | + $this->day_table_no_prefix = 'bat_event_'.$event_type.'_day_'.SqlDBStore::BAT_EVENT; |
|
95 | + $this->hour_table_no_prefix = 'bat_event_'.$event_type.'_hour_'.SqlDBStore::BAT_EVENT; |
|
96 | + $this->minute_table_no_prefix = 'bat_event_'.$event_type.'_minute_'.SqlDBStore::BAT_EVENT; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | public function buildQueries(\DateTime $start_date, \DateTime $end_date, $unit_ids) { |
109 | 109 | $queries = array(); |
110 | 110 | |
111 | - $queries[Event::BAT_DAY] = 'SELECT * FROM ' . $this->day_table . ' WHERE '; |
|
112 | - $queries[Event::BAT_HOUR] = 'SELECT * FROM ' . $this->hour_table . ' WHERE '; |
|
113 | - $queries[Event::BAT_MINUTE] = 'SELECT * FROM ' . $this->minute_table . ' WHERE '; |
|
111 | + $queries[Event::BAT_DAY] = 'SELECT * FROM '.$this->day_table.' WHERE '; |
|
112 | + $queries[Event::BAT_HOUR] = 'SELECT * FROM '.$this->hour_table.' WHERE '; |
|
113 | + $queries[Event::BAT_MINUTE] = 'SELECT * FROM '.$this->minute_table.' WHERE '; |
|
114 | 114 | |
115 | 115 | // Create a mock event which we will use to determine how to query the database |
116 | 116 | $mock_event = new Event($start_date, $end_date, new Unit(0, 0, array()), -10); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | // We are dealing with multiple years so add an OR |
129 | 129 | $query_parameters .= ' OR '; |
130 | 130 | } |
131 | - $query_parameters .= 'year IN (' . $year . ') '; |
|
132 | - $query_parameters .= 'AND month IN (' . implode(",", array_keys($months)) . ') '; |
|
131 | + $query_parameters .= 'year IN ('.$year.') '; |
|
132 | + $query_parameters .= 'AND month IN ('.implode(",", array_keys($months)).') '; |
|
133 | 133 | if (count($unit_ids) > 0) { |
134 | 134 | // Unit ids are defined so add this as a filter |
135 | - $query_parameters .= 'AND unit_id in (' . implode("," , $unit_ids) . ') '; |
|
135 | + $query_parameters .= 'AND unit_id in ('.implode(",", $unit_ids).') '; |
|
136 | 136 | } |
137 | 137 | $year_count++; |
138 | 138 | } |