@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $current_states = array_keys($unit_states); |
130 | 130 | // Compare the current states with the set of valid states |
131 | 131 | $remaining_states = array_diff($current_states, $valid_states); |
132 | - if (count($remaining_states) == 0 ) { |
|
132 | + if (count($remaining_states) == 0) { |
|
133 | 133 | // Unit is in a state that is within the set of valid states so add to result set |
134 | 134 | $units[$unit] = $unit; |
135 | 135 | $response->addMatch($keyed_units[$unit], CalendarResponse::VALID_STATE); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | foreach ($months as $month => $days) { |
219 | 219 | foreach ($days as $day => $hours) { |
220 | 220 | foreach ($hours as $hour => $value) { |
221 | - $events[$unit][BAT_HOUR][$year][$month]['d'.$day][$hour] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
221 | + $events[$unit][BAT_HOUR][$year][$month]['d' . $day][$hour] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | foreach ($hours as $hour => $minutes) { |
233 | 233 | foreach ($minutes as $minute => $value) { |
234 | 234 | if (isset($db_events[$unit][BAT_MINUTE][$year][$month][$day][$hour][$minute])) { |
235 | - $events[$unit][BAT_MINUTE][$year][$month]['d' .$day]['h'.$hour][$minute] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute]); |
|
235 | + $events[$unit][BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour][$minute] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute]); |
|
236 | 236 | } |
237 | 237 | else { |
238 | 238 | // If nothing from db - then revert to the defaults |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | foreach ($days as $day => $hours) { |
251 | 251 | foreach ($hours as $hour => $minutes) { |
252 | 252 | foreach ($minutes as $minute => $value) { |
253 | - $events[$unit][BAT_MINUTE][$year][$month]['d'.$day]['h'.$hour][$minute] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
253 | + $events[$unit][BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour][$minute] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
@@ -325,12 +325,12 @@ discard block |
||
325 | 325 | // Value just switched - let us wrap up with current event and start a new one |
326 | 326 | $normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
327 | 327 | $start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
328 | - $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
328 | + $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute, 1)); |
|
329 | 329 | $current_value = $minute_value; |
330 | 330 | } |
331 | 331 | if ($current_value === NULL) { |
332 | 332 | // We are down to minutes and haven't created and event yet - do one now |
333 | - $start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
333 | + $start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute, 1)); |
|
334 | 334 | $end_event = clone($start_event); |
335 | 335 | } |
336 | 336 | $current_value = $minute_value; |
@@ -134,7 +134,7 @@ |
||
134 | 134 | $text = t('The stay') . ' '; |
135 | 135 | } |
136 | 136 | else { |
137 | - $text .= ' ' . t('the stay') . ' '; |
|
137 | + $text .= ' ' . t('the stay') . ' '; |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | if ($minimum_stay && $maximum_stay) { |
@@ -444,14 +444,14 @@ discard block |
||
444 | 444 | |
445 | 445 | $counter = (int)$period_start->format('i'); |
446 | 446 | $start_minute = $counter; |
447 | - foreach($period as $minute) { |
|
447 | + foreach ($period as $minute) { |
|
448 | 448 | // Doing minutes so set the values in the minute array |
449 | - $itemized[AbstractEvent::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d'. $minute->format('j')]['h'. $minute->format('G')]['m' .$minute->format('i')] = $this->getValue(); |
|
449 | + $itemized[AbstractEvent::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')]['m' . $minute->format('i')] = $this->getValue(); |
|
450 | 450 | // Let the hours know that it cannot determine availability |
451 | - $itemized[AbstractEvent::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d'. $minute->format('j')]['h'. $minute->format('G')] = -1; |
|
451 | + $itemized[AbstractEvent::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = -1; |
|
452 | 452 | $counter++; |
453 | 453 | |
454 | - if ($counter == 60 && $start_minute!==0) { |
|
454 | + if ($counter == 60 && $start_minute !== 0) { |
|
455 | 455 | // Not a real hour - leave as is and move on |
456 | 456 | $counter = 0; |
457 | 457 | $start_minute = 0; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | // Did a real whole hour so initialize the hour |
461 | 461 | $itemized[AbstractEvent::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = $this->getValue(); |
462 | 462 | // We have a whole hour so get rid of the minute info |
463 | - unset($itemized[AbstractEvent::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d'. $minute->format('j')]['h'. $minute->format('G')]); |
|
463 | + unset($itemized[AbstractEvent::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')]); |
|
464 | 464 | $counter = 0; |
465 | 465 | $start_minute = 0; |
466 | 466 | } |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | // Set the end date to the last day of the month so that we are sure to get that last month |
482 | 482 | $adjusted_end_day = new \DateTime($this->end_date->format('Y-n-t')); |
483 | 483 | |
484 | - $daterange = new \DatePeriod($this->start_date, $interval ,$adjusted_end_day); |
|
484 | + $daterange = new \DatePeriod($this->start_date, $interval, $adjusted_end_day); |
|
485 | 485 | |
486 | 486 | $itemized = array(); |
487 | 487 | |
488 | 488 | // Cycle through each month |
489 | - foreach($daterange as $date) { |
|
489 | + foreach ($daterange as $date) { |
|
490 | 490 | |
491 | 491 | $year = $date->format("Y"); |
492 | 492 | $dayinterval = new \DateInterval('P1D'); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getEventData(\DateTime $start_date, \DateTime $end_date, $unit_ids) { |
83 | 83 | |
84 | - $queries = $this->buildQueries($start_date, $end_date, $unit_ids); |
|
84 | + $queries = $this->buildQueries($start_date, $end_date, $unit_ids); |
|
85 | 85 | |
86 | 86 | $results = array(); |
87 | 87 | // Run each query and store results |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | $db_events = array(); |
93 | 93 | |
94 | 94 | // Cycle through day results and setup an event array |
95 | - while( $data = $results[Event::BAT_DAY]->fetchAssoc()) { |
|
95 | + while ($data = $results[Event::BAT_DAY]->fetchAssoc()) { |
|
96 | 96 | // Figure out how many days the current month has |
97 | 97 | $temp_date = new \DateTime($data['year'] . "-" . $data['month']); |
98 | 98 | $days_in_month = (int)$temp_date->format('t'); |
99 | - for ($i = 1; $i<=$days_in_month; $i++) { |
|
100 | - $db_events[$data['unit_id']][Event::BAT_DAY][$data['year']][$data['month']]['d' . $i] = $data['d'.$i]; |
|
99 | + for ($i = 1; $i <= $days_in_month; $i++) { |
|
100 | + $db_events[$data['unit_id']][Event::BAT_DAY][$data['year']][$data['month']]['d' . $i] = $data['d' . $i]; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | // With the day events taken care off let's cycle through hours |
105 | - while( $data = $results[Event::BAT_HOUR]->fetchAssoc()) { |
|
106 | - for ($i = 0; $i<=23; $i++) { |
|
107 | - $db_events[$data['unit_id']][Event::BAT_HOUR][$data['year']][$data['month']][$data['day']]['h'. $i] = $data['h'.$i]; |
|
105 | + while ($data = $results[Event::BAT_HOUR]->fetchAssoc()) { |
|
106 | + for ($i = 0; $i <= 23; $i++) { |
|
107 | + $db_events[$data['unit_id']][Event::BAT_HOUR][$data['year']][$data['month']][$data['day']]['h' . $i] = $data['h' . $i]; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | 111 | // With the hour events taken care off let's cycle through minutes |
112 | - while( $data = $results[Event::BAT_MINUTE]->fetchAssoc()) { |
|
113 | - for ($i = 0; $i<=59; $i++) { |
|
112 | + while ($data = $results[Event::BAT_MINUTE]->fetchAssoc()) { |
|
113 | + for ($i = 0; $i <= 59; $i++) { |
|
114 | 114 | if ($i <= 9) { |
115 | - $index = 'm0'.$i; |
|
115 | + $index = 'm0' . $i; |
|
116 | 116 | } |
117 | 117 | else { |
118 | - $index = 'm'.$i; |
|
118 | + $index = 'm' . $i; |
|
119 | 119 | } |
120 | 120 | $db_events[$data['unit_id']][Event::BAT_MINUTE][$data['year']][$data['month']][$data['day']][$data['hour']][$index] = $data[$index]; |
121 | 121 | } |
@@ -233,16 +233,16 @@ discard block |
||
233 | 233 | |
234 | 234 | $query_parameters = ''; |
235 | 235 | |
236 | - foreach($itemized[Event::BAT_DAY] as $year => $months) { |
|
236 | + foreach ($itemized[Event::BAT_DAY] as $year => $months) { |
|
237 | 237 | if ($year_count > 0) { |
238 | 238 | // We are dealing with multiple years so add an OR |
239 | 239 | $query_parameters .= ' OR '; |
240 | 240 | } |
241 | 241 | $query_parameters .= 'year IN (' . $year . ') '; |
242 | - $query_parameters .= 'AND month IN (' . implode("," ,array_keys($months)) .') '; |
|
242 | + $query_parameters .= 'AND month IN (' . implode(",", array_keys($months)) . ') '; |
|
243 | 243 | if (count($unit_ids) > 0) { |
244 | 244 | // Unit ids are defined so add this as a filter |
245 | - $query_parameters .= 'AND unit_id in (' . implode("," , $unit_ids) .') '; |
|
245 | + $query_parameters .= 'AND unit_id in (' . implode(",", $unit_ids) . ') '; |
|
246 | 246 | } |
247 | 247 | $year_count++; |
248 | 248 | } |