| @@ 157-174 (lines=18) @@ | ||
| 154 | ||
| 155 | if ($granularity == Event::BAT_HOURLY) { |
|
| 156 | // Write Hours |
|
| 157 | foreach ($itemized[Event::BAT_HOUR] as $year => $months) { |
|
| 158 | foreach ($months as $month => $days) { |
|
| 159 | foreach ($days as $day => $hours) { |
|
| 160 | // Count required as we may receive empty hours for granular events that start and end on midnight |
|
| 161 | if (count($hours) > 0) { |
|
| 162 | db_merge($this->hour_table) |
|
| 163 | ->key(array( |
|
| 164 | 'unit_id' => $event->unit_id, |
|
| 165 | 'year' => $year, |
|
| 166 | 'month' => $month, |
|
| 167 | 'day' => substr($day, 1) |
|
| 168 | )) |
|
| 169 | ->fields($hours) |
|
| 170 | ->execute(); |
|
| 171 | } |
|
| 172 | } |
|
| 173 | } |
|
| 174 | } |
|
| 175 | ||
| 176 | //If we have minutes write minutes |
|
| 177 | foreach ($itemized[Event::BAT_MINUTE] as $year => $months) { |
|
| @@ 178-193 (lines=16) @@ | ||
| 175 | ||
| 176 | //If we have minutes write minutes |
|
| 177 | foreach ($itemized[Event::BAT_MINUTE] as $year => $months) { |
|
| 178 | foreach ($months as $month => $days) { |
|
| 179 | foreach ($days as $day => $hours) { |
|
| 180 | foreach ($hours as $hour => $minutes) { |
|
| 181 | db_merge($this->minute_table) |
|
| 182 | ->key(array( |
|
| 183 | 'unit_id' => $event->unit_id, |
|
| 184 | 'year' => $year, |
|
| 185 | 'month' => $month, |
|
| 186 | 'day' => substr($day, 1), |
|
| 187 | 'hour' => substr($hour, 1) |
|
| 188 | )) |
|
| 189 | ->fields($minutes) |
|
| 190 | ->execute(); |
|
| 191 | } |
|
| 192 | } |
|
| 193 | } |
|
| 194 | } |
|
| 195 | } |
|
| 196 | } |
|