@@ -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 | } |