| @@ -93,8 +93,14 @@ | ||
| 93 | 93 | */ |
| 94 | 94 | private function __construct( $schedule_data ) { |
| 95 | 95 | $this->database = new Booktics_Database(); |
| 96 | 96 | $this->schedule_data = $schedule_data; |
| 97 | + if ( ! isset( $this->schedule_data['enable_custom_holiday'] ) || ! $this->schedule_data['enable_custom_holiday'] ) { | |
| 98 | + $this->schedule_data['holiday'] = array(); | |
| 99 | + } | |
| 100 | + if ( ! isset( $this->schedule_data['enable_custom_schedule'] ) || ! $this->schedule_data['enable_custom_schedule'] ) { | |
| 101 | + $this->schedule_data['custom'] = array(); | |
| 102 | + } | |
| 97 | 103 | $this->init( |
| 98 | 104 | $this->schedule_data['schedule'] ?? array(), |
| 99 | 105 | $this->schedule_data['custom'] ?? array(), |
| 100 | 106 | $this->schedule_data['holiday'] ?? array() |
| @@ -260,9 +266,9 @@ | ||
| 260 | 266 | * @return void |
| 261 | 267 | */ |
| 262 | 268 | private function clear_existing_schedules(): void { |
| 263 | 269 | $this->database->delete( |
| 264 | - 'booktics_schedules', array( | |
| 270 | + booktics_get_table_name( 'booktics_schedules' ), array( | |
| 265 | 271 | 'service_id' => $this->service_id, |
| 266 | 272 | 'team_member_id' => $this->team_member_id, |
| 267 | 273 | ) |
| 268 | 274 | ); |
| @@ -280,9 +286,9 @@ | ||
| 280 | 286 | if ( empty( $records ) ) { |
| 281 | 287 | return; |
| 282 | 288 | } |
| 283 | 289 | |
| 284 | - $this->database->insert_batch( 'booktics_schedules', $records ); | |
| 290 | + $this->database->insert_batch( booktics_get_table_name( 'booktics_schedules' ), $records ); | |
| 285 | 291 | } |
| 286 | 292 | |
| 287 | 293 | /** |
| 288 | 294 | * build map for schedule records |
| @@ -354,13 +360,16 @@ | ||
| 354 | 360 | string $end_time, |
| 355 | 361 | string $week_day, |
| 356 | 362 | string $custom_date |
| 357 | 363 | ): array { |
| 364 | + $utc_start_time = booktics_time_to_gmt( $start_time, $custom_date ); | |
| 365 | + $utc_end_time = booktics_time_to_gmt( $end_time, $custom_date ); | |
| 366 | + | |
| 358 | 367 | return array( |
| 359 | 368 | 'team_member_id' => $this->team_member_id, |
| 360 | 369 | 'service_id' => $this->service_id, |
| 361 | - 'start_time' => $start_time, | |
| 362 | - 'end_time' => $end_time, | |
| 370 | + 'start_time' => $utc_start_time, | |
| 371 | + 'end_time' => $utc_end_time, | |
| 363 | 372 | 'week_day' => $week_day, |
| 364 | 373 | 'custom_date' => $custom_date, |
| 365 | 374 | ); |
| 366 | 375 | } |