@@ -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 | } |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | if (!($this->event->getStartDate()->format('H:i') == '00:00' && $this->event->getEndDate()->format('H:i') == '23:59')) { |
| 219 | 219 | $period = new \DatePeriod($start_date, $interval, $end_date->add(new \DateInterval('PT1M'))); |
| 220 | 220 | $itemized_same_day = $this->createHourlyGranular($period, $start_date); |
| 221 | - $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
|
| 222 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
|
| 223 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
|
| 221 | + $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d'.$sd] = -1; |
|
| 222 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd]; |
|
| 223 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd]; |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | else { |
@@ -228,27 +228,27 @@ discard block |
||
| 228 | 228 | if (!($this->event->getStartDate()->format('H:i') == '00:00')) { |
| 229 | 229 | $start_period = new \DatePeriod($start_date, $interval, new \DateTime($start_date->format("Y-n-j 23:59:59"))); |
| 230 | 230 | $itemized_start = $this->createHourlyGranular($start_period, $start_date); |
| 231 | - $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
|
| 232 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
|
| 233 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
|
| 231 | + $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d'.$sd] = -1; |
|
| 232 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd]; |
|
| 233 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd]; |
|
| 234 | 234 | } |
| 235 | 235 | else { |
| 236 | 236 | // Just set an empty hour and minute |
| 237 | - $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
|
| 238 | - $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
|
| 237 | + $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d'.$sd] = array(); |
|
| 238 | + $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d'.$sd] = array(); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | // Deal with the end date unless it ends just before midnight at which point we don't need to go further |
| 242 | 242 | if ($this->event->getEndDate()->format('H:i') == '23:59') { |
| 243 | - $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = array(); |
|
| 244 | - $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = array(); |
|
| 243 | + $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed] = array(); |
|
| 244 | + $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed] = array(); |
|
| 245 | 245 | } |
| 246 | 246 | else { |
| 247 | 247 | $end_period = new \DatePeriod(new \DateTime($end_date->format("Y-n-j 00:00:00")), $interval, $end_date->add(new \DateInterval('PT1M'))); |
| 248 | 248 | $itemized_end = $this->createHourlyGranular($end_period, new \DateTime($end_date->format("Y-n-j 00:00:00"))); |
| 249 | - $itemized[EventItemizer::BAT_DAY][$ey][$em]['d' . $ed] = -1; |
|
| 250 | - $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed]; |
|
| 251 | - $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = $itemized_end[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed]; |
|
| 249 | + $itemized[EventItemizer::BAT_DAY][$ey][$em]['d'.$ed] = -1; |
|
| 250 | + $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed] = $itemized_end[EventItemizer::BAT_HOUR][$ey][$em]['d'.$ed]; |
|
| 251 | + $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed] = $itemized_end[EventItemizer::BAT_MINUTE][$ey][$em]['d'.$ed]; |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | $start_minute = $counter; |
| 271 | 271 | foreach ($period as $minute) { |
| 272 | 272 | // Doing minutes so set the values in the minute array |
| 273 | - $itemized[EventItemizer::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')]['m' . $minute->format('i')] = $this->event->getValue(); |
|
| 273 | + $itemized[EventItemizer::BAT_MINUTE][$minute->format('Y')][$minute->format('n')]['d'.$minute->format('j')]['h'.$minute->format('G')]['m'.$minute->format('i')] = $this->event->getValue(); |
|
| 274 | 274 | // Let the hours know that it cannot determine availability |
| 275 | - $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = -1; |
|
| 275 | + $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d'.$minute->format('j')]['h'.$minute->format('G')] = -1; |
|
| 276 | 276 | $counter++; |
| 277 | 277 | |
| 278 | 278 | if ($counter == 60 && $start_minute !== 0) { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | elseif ($counter == 60 && $start_minute == 0) { |
| 284 | 284 | // Did a real whole hour so initialize the hour |
| 285 | - $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = $this->event->getValue(); |
|
| 285 | + $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d'.$minute->format('j')]['h'.$minute->format('G')] = $this->event->getValue(); |
|
| 286 | 286 | |
| 287 | 287 | $counter = 0; |
| 288 | 288 | $start_minute = 0; |
@@ -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 | |
@@ -222,8 +221,7 @@ discard block |
||
| 222 | 221 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
| 223 | 222 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_same_day[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
| 224 | 223 | } |
| 225 | - } |
|
| 226 | - else { |
|
| 224 | + } else { |
|
| 227 | 225 | // Deal with the start day unless it starts on midnight precisely at which point the whole day is booked |
| 228 | 226 | if (!($this->event->getStartDate()->format('H:i') == '00:00')) { |
| 229 | 227 | $start_period = new \DatePeriod($start_date, $interval, new \DateTime($start_date->format("Y-n-j 23:59:59"))); |
@@ -231,8 +229,7 @@ discard block |
||
| 231 | 229 | $itemized[EventItemizer::BAT_DAY][$sy][$sm]['d' . $sd] = -1; |
| 232 | 230 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd]; |
| 233 | 231 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = $itemized_start[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd]; |
| 234 | - } |
|
| 235 | - else { |
|
| 232 | + } else { |
|
| 236 | 233 | // Just set an empty hour and minute |
| 237 | 234 | $itemized[EventItemizer::BAT_HOUR][$sy][$sm]['d' . $sd] = array(); |
| 238 | 235 | $itemized[EventItemizer::BAT_MINUTE][$sy][$sm]['d' . $sd] = array(); |
@@ -242,8 +239,7 @@ discard block |
||
| 242 | 239 | if ($this->event->getEndDate()->format('H:i') == '23:59') { |
| 243 | 240 | $itemized[EventItemizer::BAT_HOUR][$ey][$em]['d' . $ed] = array(); |
| 244 | 241 | $itemized[EventItemizer::BAT_MINUTE][$ey][$em]['d' . $ed] = array(); |
| 245 | - } |
|
| 246 | - else { |
|
| 242 | + } else { |
|
| 247 | 243 | $end_period = new \DatePeriod(new \DateTime($end_date->format("Y-n-j 00:00:00")), $interval, $end_date->add(new \DateInterval('PT1M'))); |
| 248 | 244 | $itemized_end = $this->createHourlyGranular($end_period, new \DateTime($end_date->format("Y-n-j 00:00:00"))); |
| 249 | 245 | $itemized[EventItemizer::BAT_DAY][$ey][$em]['d' . $ed] = -1; |
@@ -279,8 +275,7 @@ discard block |
||
| 279 | 275 | // Not a real hour - leave as is and move on |
| 280 | 276 | $counter = 0; |
| 281 | 277 | $start_minute = 0; |
| 282 | - } |
|
| 283 | - elseif ($counter == 60 && $start_minute == 0) { |
|
| 278 | + } elseif ($counter == 60 && $start_minute == 0) { |
|
| 284 | 279 | // Did a real whole hour so initialize the hour |
| 285 | 280 | $itemized[EventItemizer::BAT_HOUR][$minute->format('Y')][$minute->format('n')]['d' . $minute->format('j')]['h' . $minute->format('G')] = $this->event->getValue(); |
| 286 | 281 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | protected function normalizeMinMaxDaysConstraints() { |
| 97 | 97 | $new_constraints = array(); |
| 98 | 98 | |
| 99 | - $constraints = array_map(function ($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\MinMaxDaysConstraint']); |
|
| 99 | + $constraints = array_map(function($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\MinMaxDaysConstraint']); |
|
| 100 | 100 | |
| 101 | 101 | foreach (array_reverse($constraints) as $constraint) { |
| 102 | 102 | $start_date = $constraint->getStartDate(); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | protected function normalizeCheckInDayConstraints() { |
| 173 | 173 | $new_constraints = array(); |
| 174 | 174 | |
| 175 | - $constraints = array_map(function ($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\CheckInDayConstraint']); |
|
| 175 | + $constraints = array_map(function($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\CheckInDayConstraint']); |
|
| 176 | 176 | |
| 177 | 177 | foreach (array_reverse($constraints) as $constraint) { |
| 178 | 178 | $start_date = $constraint->getStartDate(); |
@@ -115,12 +115,10 @@ discard block |
||
| 115 | 115 | if ($start_date >= $new_start_date && $start_date <= $new_end_date) { |
| 116 | 116 | $new_end_date_clone = clone($new_end_date); |
| 117 | 117 | $constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); |
| 118 | - } |
|
| 119 | - elseif ($end_date >= $new_start_date && $end_date <= $new_end_date) { |
|
| 118 | + } elseif ($end_date >= $new_start_date && $end_date <= $new_end_date) { |
|
| 120 | 119 | $new_start_date_clone = clone($new_start_date); |
| 121 | 120 | $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
| 122 | - } |
|
| 123 | - elseif ($start_date < $new_start_date && $end_date > $new_end_date) { |
|
| 121 | + } elseif ($start_date < $new_start_date && $end_date > $new_end_date) { |
|
| 124 | 122 | if ($constraint->getEndDate() > $new_start_date) { |
| 125 | 123 | $new_start_date_clone = clone($new_start_date); |
| 126 | 124 | $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); |
@@ -132,8 +130,7 @@ discard block |
||
| 132 | 130 | $split_end_date = $end_date; |
| 133 | 131 | |
| 134 | 132 | $split_constraint = new MinMaxDaysConstraint($constraint->getUnits(), $constraint->getMinDays(), $constraint->getMaxDays(), $split_start_date, $split_end_date, $constraint->getCheckinDay()); |
| 135 | - } |
|
| 136 | - else { |
|
| 133 | + } else { |
|
| 137 | 134 | $split_start_date = $split_constraint->getStartDate(); |
| 138 | 135 | $split_end_date = $split_constraint->getEndDate(); |
| 139 | 136 | |
@@ -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, NULL), -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 | } |