| @@ -29,20 +29,20 @@ | ||
| 29 | 29 | * @return array |
| 30 | 30 | */ |
| 31 | 31 | public function get_schedules( $id, $type = 'team_member' ) { |
| 32 | 32 | $database = new Booktics_Database(); |
| 33 | - if ( $type === 'default' ) { | |
| 33 | + if ( 'default' === $type ) { | |
| 34 | 34 | $where = array( |
| 35 | 35 | 'team_member_id' => 0, |
| 36 | 36 | 'service_id' => 0, |
| 37 | 37 | ); |
| 38 | - } elseif ( $type === 'team_member' ) { | |
| 38 | + } elseif ( 'team_member' === $type ) { | |
| 39 | 39 | $where = array( 'team_member_id' => $id ); |
| 40 | 40 | } else { |
| 41 | 41 | $where = array( 'service_id' => $id ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $schedules = $database->select( 'booktics_schedules', $where ); | |
| 44 | + $schedules = $database->select( booktics_get_table_name( 'booktics_schedules' ), $where ); | |
| 45 | 45 | |
| 46 | 46 | $formatted = array( |
| 47 | 47 | 'schedule' => array(), |
| 48 | 48 | 'custom' => array(), |
| @@ -53,11 +53,11 @@ | ||
| 53 | 53 | return $formatted; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | foreach ( $schedules as $schedule ) { |
| 57 | - if ( $schedule->custom_date == '0' ) { | |
| 57 | + if ( '0' == $schedule->custom_date ) { | |
| 58 | 58 | $day = strtolower( array_search( $schedule->week_day, Schedule_Manager::$day_map ) ); |
| 59 | - if ( $schedule->start_time == '0' && $schedule->end_time == '0' ) { | |
| 59 | + if ( '0' == $schedule->start_time && '0' == $schedule->end_time ) { | |
| 60 | 60 | continue; |
| 61 | 61 | } |
| 62 | 62 | $formatted['schedule'][ $day ][] = array( |
| 63 | 63 | 'start_time' => $this->format_time( $schedule->start_time ), |
| @@ -62,9 +62,9 @@ | ||
| 62 | 62 | $formatted['schedule'][ $day ][] = array( |
| 63 | 63 | 'start_time' => $this->format_time( $schedule->start_time ), |
| 64 | 64 | 'end_time' => $this->format_time( $schedule->end_time ), |
| 65 | 65 | ); |
| 66 | - } elseif ( $schedule->start_time == '0' && $schedule->end_time == '0' ) { | |
| 66 | + } elseif ( '0' == $schedule->start_time && '0' == $schedule->end_time ) { | |
| 67 | 67 | $formatted['holiday'][] = $schedule->custom_date; |
| 68 | 68 | } else { |
| 69 | 69 | $formatted['custom'][] = array( |
| 70 | 70 | $schedule->custom_date, |
| @@ -100,22 +100,23 @@ | ||
| 100 | 100 | |
| 101 | 101 | $ranges = array(); |
| 102 | 102 | $start = $dates[0]; |
| 103 | 103 | $prev = $dates[0]; |
| 104 | + $dates_count = count( $dates ); | |
| 104 | 105 | |
| 105 | - for ( $i = 1; $i <= count( $dates ); $i++ ) { | |
| 106 | + for ( $i = 1; $i <= $dates_count; $i++ ) { | |
| 106 | 107 | $current = $dates[ $i ] ?? null; |
| 107 | 108 | |
| 108 | 109 | // If we've reached the end or found a gap in dates |
| 109 | - if ( $current === null || strtotime( $current ) > strtotime( '+1 day', strtotime( $prev ) ) ) { | |
| 110 | + if ( null === $current || strtotime( $current ) > strtotime( '+1 day', strtotime( $prev ) ) ) { | |
| 110 | 111 | // Add the range only if start and end are different or it's the last single date |
| 111 | 112 | $ranges[] = array( $start, $prev ); |
| 112 | - if ( $current !== null ) { | |
| 113 | + if ( null !== $current ) { | |
| 113 | 114 | $start = $current; |
| 114 | 115 | } |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | - if ( $current !== null ) { | |
| 118 | + if ( null !== $current ) { | |
| 118 | 119 | $prev = $current; |
| 119 | 120 | } |
| 120 | 121 | } |
| 121 | 122 | |