| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | 4 | exit; // Exit if accessed directly. |
| @@ -123,17 +123,23 @@ | ||
| 123 | 123 | // Content for Partially booked item - "time slot" or "change over days". |
| 124 | 124 | if ( 1 ) { |
| 125 | 125 | $my_partially = ''; |
| 126 | 126 | |
| 127 | - $booking_timeslot_day_bg_as_available = ( 'On' === get_bk_option( 'booking_timeslot_day_bg_as_available' ) ) ? ' wpbc_timeslot_day_bg_as_available' : ''; | |
| 128 | - $booking_timeslot_day_bg_as_available .= ( 'Off' !== get_bk_option( 'booking_change_over_days_triangles' ) ) ? ' wpbc_change_over_triangle' : ''; | |
| 127 | + $booking_change_over_triangle = ( 'Off' !== get_bk_option( 'booking_change_over_days_triangles' ) ) ? ' wpbc_change_over_triangle' : ''; | |
| 129 | 128 | |
| 130 | 129 | |
| 131 | - $my_partially .= '<span class="' . $booking_timeslot_day_bg_as_available . '">'; | |
| 130 | + $my_partially .= '<span class="' . $booking_change_over_triangle . '">'; | |
| 132 | 131 | $my_partially .= '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; // FixIn: 9.3.1.4. |
| 133 | 132 | $my_partially .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>'; |
| 134 | - if ( ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) ) && ( wpbc_is_booking_used_check_in_out_time( false, $params['resource_id'] ) ) ) { // FixIn: 8.9.4.10. | |
| 135 | - $my_partially .= '<td class="datepick-days-cell date_available date_approved timespartly check_in_time check_in_time_date_approved wpbc_calendar_legend_day_cell_height">'; | |
| 133 | + $is_change_over_legend = null; | |
| 134 | + if ( function_exists( 'wpbc_settings_calendar__preview_is_changeover_enabled' ) ) { | |
| 135 | + $is_change_over_legend = wpbc_settings_calendar__preview_is_changeover_enabled( $params['resource_id'], false ); | |
| 136 | + } | |
| 137 | + if ( null === $is_change_over_legend ) { | |
| 138 | + $is_change_over_legend = ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) ) && ( wpbc_is_booking_used_check_in_out_time( false, $params['resource_id'] ) ); // FixIn: 8.9.4.10. | |
| 139 | + } | |
| 140 | + if ( $is_change_over_legend ) { | |
| 141 | + $my_partially .= '<td class="datepick-days-cell date_available date_approved timespartly check_in_time check_out_time check_in_time_date_approved check_out_time_date2approve wpbc_calendar_legend_day_cell_height">'; | |
| 136 | 142 | } else { |
| 137 | 143 | $my_partially .= '<td class="datepick-days-cell date_available date2approve timespartly times_clock wpbc_calendar_legend_day_cell_height">'; |
| 138 | 144 | } |
| 139 | 145 | $my_partially .= '<div class="wpbc-cell-box">'; |
| @@ -167,10 +173,10 @@ | ||
| 167 | 173 | $my_unavailable .= '</td></tr></tbody></table>'; |
| 168 | 174 | $my_unavailable .= '</div>'; |
| 169 | 175 | } |
| 170 | 176 | |
| 171 | - // Resource Unavailable. | |
| 172 | - if ( 1 ) { | |
| 177 | + // Resource Unavailable. | |
| 178 | + if ( 1 ) { | |
| 173 | 179 | $my_resource_unavailable = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; // FixIn: 9.3.1.4. |
| 174 | 180 | $my_resource_unavailable .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>'; |
| 175 | 181 | $my_resource_unavailable .= '<td class="datepick-days-cell resource_unavailable date_user_unavailable wpbc_calendar_legend_day_cell_height">'; |
| 176 | 182 | $my_resource_unavailable .= '<div class="wpbc-cell-box">'; |
| @@ -180,10 +186,42 @@ | ||
| 180 | 186 | $my_resource_unavailable .= ' <div class="date-content-bottom"></div>'; |
| 181 | 187 | $my_resource_unavailable .= ' </div>'; |
| 182 | 188 | $my_resource_unavailable .= '</div>'; |
| 183 | 189 | $my_resource_unavailable .= '</td></tr></tbody></table>'; |
| 184 | - $my_resource_unavailable .= '</div>'; | |
| 185 | - } | |
| 190 | + $my_resource_unavailable .= '</div>'; | |
| 191 | + } | |
| 192 | + | |
| 193 | + // Some Resources unavailable in an aggregate calendar. | |
| 194 | + if ( 1 ) { | |
| 195 | + $my_resources_partially_unavailable = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; | |
| 196 | + $my_resources_partially_unavailable .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>'; | |
| 197 | + $my_resources_partially_unavailable .= '<td class="datepick-days-cell date_available wpbc_resources_partially_unavailable wpbc_calendar_legend_day_cell_height">'; | |
| 198 | + $my_resources_partially_unavailable .= '<div class="wpbc-cell-box">'; | |
| 199 | + $my_resources_partially_unavailable .= ' <div class="date-cell-content">'; | |
| 200 | + $my_resources_partially_unavailable .= ' <div class="date-content-top"></div>'; | |
| 201 | + $my_resources_partially_unavailable .= ' <span>' . esc_html( $params['text_for_day_cell'] ) . '</span>'; | |
| 202 | + $my_resources_partially_unavailable .= ' <div class="date-content-bottom"></div>'; | |
| 203 | + $my_resources_partially_unavailable .= ' </div>'; | |
| 204 | + $my_resources_partially_unavailable .= '</div>'; | |
| 205 | + $my_resources_partially_unavailable .= '</td></tr></tbody></table>'; | |
| 206 | + $my_resources_partially_unavailable .= '</div>'; | |
| 207 | + } | |
| 208 | + | |
| 209 | + // One or more Resources have bookings in an aggregate calendar. | |
| 210 | + if ( 1 ) { | |
| 211 | + $my_resources_have_bookings = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; | |
| 212 | + $my_resources_have_bookings .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>'; | |
| 213 | + $my_resources_have_bookings .= '<td class="datepick-days-cell date_available wpbc_resources_have_bookings wpbc_calendar_legend_day_cell_height">'; | |
| 214 | + $my_resources_have_bookings .= '<div class="wpbc-cell-box">'; | |
| 215 | + $my_resources_have_bookings .= ' <div class="date-cell-content">'; | |
| 216 | + $my_resources_have_bookings .= ' <div class="date-content-top"></div>'; | |
| 217 | + $my_resources_have_bookings .= ' <span>' . esc_html( $params['text_for_day_cell'] ) . '</span>'; | |
| 218 | + $my_resources_have_bookings .= ' <div class="date-content-bottom"></div>'; | |
| 219 | + $my_resources_have_bookings .= ' </div>'; | |
| 220 | + $my_resources_have_bookings .= '</div>'; | |
| 221 | + $my_resources_have_bookings .= '</td></tr></tbody></table>'; | |
| 222 | + $my_resources_have_bookings .= '</div>'; | |
| 223 | + } | |
| 186 | 224 | |
| 187 | 225 | |
| 188 | 226 | |
| 189 | 227 | $items_arr = array( 'available' => array( |
| @@ -222,14 +260,24 @@ | ||
| 222 | 260 | ) |
| 223 | 261 | , 'text_for_day_cell' => $my_unavailable |
| 224 | 262 | , 'css_class' => '' //'datepick-days-cell datepick-unselectable date_user_unavailable' |
| 225 | 263 | ) |
| 226 | - , 'resource_unavailable' => array( | |
| 227 | - 'title' => ( ! empty( $params['titles']['resource_unavailable'] ) ) ? $params['titles']['resource_unavailable'] : __( 'Resource unavailable days', 'booking' ) | |
| 228 | - , 'text_for_day_cell' => $my_resource_unavailable | |
| 229 | - , 'css_class' => '' //'datepick-days-cell resource_unavailable date_user_unavailable' | |
| 230 | - ) | |
| 231 | - ); | |
| 264 | + , 'resource_unavailable' => array( | |
| 265 | + 'title' => ( ! empty( $params['titles']['resource_unavailable'] ) ) ? $params['titles']['resource_unavailable'] : __( 'Resource unavailable days', 'booking' ) | |
| 266 | + , 'text_for_day_cell' => $my_resource_unavailable | |
| 267 | + , 'css_class' => '' //'datepick-days-cell resource_unavailable date_user_unavailable' | |
| 268 | + ) | |
| 269 | + , 'resources_partially_unavailable' => array( | |
| 270 | + 'title' => ( ! empty( $params['titles']['resources_partially_unavailable'] ) ) ? $params['titles']['resources_partially_unavailable'] : __( 'Some booking items unavailable', 'booking' ) | |
| 271 | + , 'text_for_day_cell' => $my_resources_partially_unavailable | |
| 272 | + , 'css_class' => '' | |
| 273 | + ) | |
| 274 | + , 'resources_have_bookings' => array( | |
| 275 | + 'title' => ( ! empty( $params['titles']['resources_have_bookings'] ) ) ? $params['titles']['resources_have_bookings'] : __( 'Bookings exist for one or more booking items', 'booking' ) | |
| 276 | + , 'text_for_day_cell' => $my_resources_have_bookings | |
| 277 | + , 'css_class' => '' | |
| 278 | + ) | |
| 279 | + ); | |
| 232 | 280 | |
| 233 | 281 | $calendar_legend_html = '<div class="block_hints datepick ' . ( ( $params['is_vertical'] ) ? ' block_hints_vertical ' : '' ) . '">'; |
| 234 | 282 | |
| 235 | 283 | foreach ( $params['items'] as $item_name ) { |
| @@ -260,9 +308,9 @@ | ||
| 260 | 308 | * Example of shortcode parameters: |
| 261 | 309 | * [legend_items items="available,unavailable,pending,approved,partially" text_for_day_cell="31"] |
| 262 | 310 | * [legend_items is_vertical="1"] |
| 263 | 311 | * [legend_items] |
| 264 | - * [legend_items items="resource_unavailable,available,unavailable,pending,approved,partially" text_for_day_cell="31" titles="resource_unavailable={Resource unavailable days} unavailable={Season unavailable}"] | |
| 312 | + * [legend_items items="resource_unavailable,resources_partially_unavailable,resources_have_bookings,available,unavailable,pending,approved,partially" text_for_day_cell="31" titles="resource_unavailable={Resource unavailable days} unavailable={Season unavailable}"] | |
| 265 | 313 | * |
| 266 | 314 | * PHP code example with escaping single and double quotes: |
| 267 | 315 | * echo wpbc_replace_shortcodes_in_booking_form__legend_items( '[legend_items' |
| 268 | 316 | . ' items="unavailable,available,pending,approved,partially"' |