| 1 |
<?php /** |
| 2 |
* @version 1.1 |
| 3 |
* @package Booking Calendar |
| 4 |
* @category Timeline for Admin Panel |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site https://wpbookingcalendar.com/ |
| 8 |
* @email info@wpbookingcalendar.com |
| 9 |
* |
| 10 |
* @modified 2016-01-18 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
class WPBC_TimelineFlex { |
| 17 |
|
| 18 |
|
| 19 |
public $bookings; // Booking objects from external function |
| 20 |
public $booking_types; // Resources objects from external function |
| 21 |
|
| 22 |
public $dates_array; // Dates for Timeline format |
| 23 |
public $time_array_new; // Times for Timeline format |
| 24 |
|
| 25 |
public $request_args; // Parsed paramaters |
| 26 |
|
| 27 |
private $is_frontend; // Client ot Admin sides. |
| 28 |
|
| 29 |
public $timeline_titles; |
| 30 |
|
| 31 |
private $week_days_titles; |
| 32 |
private $current_user_id; |
| 33 |
|
| 34 |
private $html_client_id; // ID of border element at client side. |
| 35 |
public $options; // FixIn: 7.0.1.50. |
| 36 |
|
| 37 |
private $data_in_previous_cell; // FixIn: 8.5.2.6. |
| 38 |
|
| 39 |
public function __construct(){// $bookings, $booking_types ) { |
| 40 |
|
| 41 |
$this->reset_data_in_previous_cell(); |
| 42 |
|
| 43 |
$this->options = array(); // FixIn: 7.0.1.50. |
| 44 |
|
| 45 |
$this->html_client_id = false; |
| 46 |
|
| 47 |
$this->current_user_id = 0; |
| 48 |
|
| 49 |
$this->is_frontend = false; |
| 50 |
|
| 51 |
// FixIn: 8.1.3.31. |
| 52 |
$calendar_overview_start_time = get_bk_option( 'booking_calendar_overview_start_time' ); |
| 53 |
$calendar_overview_end_time = get_bk_option( 'booking_calendar_overview_end_time' ); |
| 54 |
$hours_limit = ( empty( $calendar_overview_start_time ) ? '0' : $calendar_overview_start_time ) |
| 55 |
. ',' |
| 56 |
. ( empty( $calendar_overview_end_time ) ? '24' : $calendar_overview_end_time ); |
| 57 |
$this->request_args = array( |
| 58 |
'wh_booking_type' => '1' |
| 59 |
, 'is_matrix' => false |
| 60 |
, 'view_days_num' => '90' |
| 61 |
, 'scroll_start_date' => '' |
| 62 |
, 'scroll_day' => 0 |
| 63 |
, 'scroll_month' => 0 |
| 64 |
, 'wh_trash' => '' |
| 65 |
, 'limit_hours' => $hours_limit // '0,24' //FixIn: 7.0.1.14 if ( ! ( ( $tt >= $start_hour_for_1day_view ) && ( $tt <= $end_hour_for_1day_view ) ) ) continue; |
| 66 |
, 'only_booked_resources' => ( isset( $_REQUEST['only_booked_resources'] ) ) ? 1 : 0 /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ |
| 67 |
, 'booking_hash' => ( isset( $_REQUEST['booking_hash'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['booking_hash'] ) ) : '', /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ |
| 68 |
|
| 69 |
); |
| 70 |
|
| 71 |
$this->timeline_titles = array( |
| 72 |
'header_column1' => __('Resources', 'booking') |
| 73 |
, 'header_column2' => __('Dates', 'booking') |
| 74 |
, 'header_title' => __('Bookings', 'booking') |
| 75 |
); |
| 76 |
|
| 77 |
|
| 78 |
$this->week_days_titles = array( |
| 79 |
'full' => array( |
| 80 |
1 => __( 'Monday', 'booking' ) |
| 81 |
, 2 => __( 'Tuesday', 'booking' ) |
| 82 |
, 3 => __( 'Wednesday', 'booking' ) |
| 83 |
, 4 => __( 'Thursday', 'booking' ) |
| 84 |
, 5 => __( 'Friday', 'booking' ) |
| 85 |
, 6 => __( 'Saturday', 'booking' ) |
| 86 |
, 7 => __( 'Sunday', 'booking' ) |
| 87 |
) |
| 88 |
, '3' => array( // FixIn: 7.0.1.11. |
| 89 |
1 => __( 'Mon', 'booking' ) |
| 90 |
, 2 => __( 'Tue', 'booking' ) |
| 91 |
, 3 => __( 'Wed', 'booking' ) |
| 92 |
, 4 => __( 'Thu', 'booking' ) |
| 93 |
, 5 => __( 'Fri', 'booking' ) |
| 94 |
, 6 => __( 'Sat', 'booking' ) |
| 95 |
, 7 => __( 'Sun', 'booking' ) |
| 96 |
) |
| 97 |
, '1' => array( //FixIn: 7.0.1.11 // FixIn: 8.7.7.14. |
| 98 |
1 => mb_substr( __( 'Mon', 'booking' ), 0, -1 ) |
| 99 |
, 2 => mb_substr( __( 'Tue', 'booking' ), 0, -1 ) |
| 100 |
, 3 => mb_substr( __( 'Wed', 'booking' ), 0, -1 ) |
| 101 |
, 4 => mb_substr( __( 'Thu', 'booking' ), 0, -1 ) |
| 102 |
, 5 => mb_substr( __( 'Fri', 'booking' ), 0, -1 ) |
| 103 |
, 6 => mb_substr( __( 'Sat', 'booking' ), 0, -1 ) |
| 104 |
, 7 => mb_substr( __( 'Sun', 'booking' ), 0, -1 ) |
| 105 |
) |
| 106 |
, 'short' => array( |
| 107 |
1 => mb_substr( __( 'Mon', 'booking' ), 0, 1 ) |
| 108 |
, 2 => mb_substr( __( 'Tue', 'booking' ), 0, 1 ) |
| 109 |
, 3 => mb_substr( __( 'Wed', 'booking' ), 0, 1 ) |
| 110 |
, 4 => mb_substr( __( 'Thu', 'booking' ), 0, 1 ) |
| 111 |
, 5 => mb_substr( __( 'Fri', 'booking' ), 0, 1 ) |
| 112 |
, 6 => mb_substr( __( 'Sat', 'booking' ), 0, 1 ) |
| 113 |
, 7 => mb_substr( __( 'Sun', 'booking' ), 0, 1 ) |
| 114 |
) |
| 115 |
); |
| 116 |
|
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
/** |
| 122 |
* Rezet data in previos cell |
| 123 |
*/ |
| 124 |
private function reset_data_in_previous_cell(){ |
| 125 |
|
| 126 |
$this->data_in_previous_cell = array( |
| 127 |
'bookings_in_cell' => array(), |
| 128 |
'previous_month' => '' |
| 129 |
); |
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
// ----------------------------------------------------------------------------------------------------------------- |
| 134 |
/** |
| 135 |
* Init Timeline From page shortcode |
| 136 |
* |
| 137 |
* @param array $attr = array( |
| 138 |
'wh_booking_type' => '' |
| 139 |
, 'is_matrix' => false |
| 140 |
, 'view_days_num' => '30' |
| 141 |
, 'scroll_start_date' => '' |
| 142 |
, 'scroll_day' => 0 |
| 143 |
, 'scroll_month' => 0 |
| 144 |
); |
| 145 |
*/ |
| 146 |
public function client_init( $attr ) { |
| 147 |
|
| 148 |
$this->is_frontend = true; |
| 149 |
|
| 150 |
// FixIn: 7.0.1.50. |
| 151 |
if ( isset( $attr['options'] ) ) { |
| 152 |
|
| 153 |
$shortcode_param__options = $attr['options']; |
| 154 |
$shortcode_param__options = html_entity_decode( $shortcode_param__options ); // FixIn: 9.8.15.6. |
| 155 |
$custom_params = array(); |
| 156 |
if (! empty($shortcode_param__options)) { |
| 157 |
$param ='\s*([^\s]+)=[\'"]{1}([^\'"]+)[\'"]{1}\s*'; // Find all possible options |
| 158 |
$pattern_to_search='%\s*{([^\s]+)' . $param .'}\s*[,]?\s*%'; |
| 159 |
preg_match_all($pattern_to_search, $shortcode_param__options, $matches, PREG_SET_ORDER); |
| 160 |
//debuge($matches); |
| 161 |
/** |
| 162 |
* [bookingtimeline ... options='{resource_link 3="http://beta/resource-apartment3-id3/"},{resource_link 4="http://beta/resource-3-id4/"}' ... ] |
| 163 |
[0] => {resource_link 3="http://beta/resource-apartment3-id3/"}, |
| 164 |
[1] => resource_link // Name |
| 165 |
[2] => 3 // ID |
| 166 |
[3] => http://beta/resource-apartment3-id3/ // Value |
| 167 |
*/ |
| 168 |
foreach ( $matches as $matche_value ) { |
| 169 |
|
| 170 |
if ( ! isset( $this->options[ $matche_value[1] ] ) ) { |
| 171 |
$this->options[ $matche_value[1] ] = array(); |
| 172 |
} |
| 173 |
$this->options[ $matche_value[1] ][ $matche_value[2] ] = $matche_value[3]; |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
//debuge($this->options); |
| 178 |
} |
| 179 |
// FixIn: 7.0.1.50. |
| 180 |
|
| 181 |
|
| 182 |
//Ovverride some parameters |
| 183 |
//if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| 184 |
if ( isset( $attr['type'] ) ) { |
| 185 |
$attr['wh_booking_type'] = $attr['type']; //Instead of 'wh_booking_type' paramter in shortcode is used 'type' parameter |
| 186 |
} |
| 187 |
|
| 188 |
// Get paramaters from shortcode paramaters |
| 189 |
$this->define_request_view_params_from_params( $attr ); |
| 190 |
|
| 191 |
if ( ! $this->request_args['is_matrix'] ) |
| 192 |
$this->timeline_titles['header_column1'] = ''; |
| 193 |
|
| 194 |
//Override any possible titles from shortcode paramaters |
| 195 |
$this->timeline_titles = wp_parse_args( $attr, $this->timeline_titles ); |
| 196 |
|
| 197 |
// Get clean parameters to request booking data |
| 198 |
$args = $this->wpbc_get_clean_paramas_from_request_for_timeline(); |
| 199 |
|
| 200 |
|
| 201 |
// FixIn: 8.1.3.5. |
| 202 |
/** Client - Page first load |
| 203 |
* |
| 204 |
* If provided valid request_args['booking_hash'] |
| 205 |
* - Firstly defined in constructor in $_REQUEST['booking_hash'] |
| 206 |
* - or overwrited in define_request_view_params_from_params from parameters in shortcode 'booking_hash' |
| 207 |
* then check, if exist booking for this hash. |
| 208 |
* If exist, get Email of this booking, and |
| 209 |
* filter getting all other bookings by email keyword. |
| 210 |
* Addtionly set param ['only_booked_resources'] for showing only booking resources with exist bookings. |
| 211 |
*/ |
| 212 |
if ( isset( $this->request_args['booking_hash'] ) ) { |
| 213 |
|
| 214 |
// Get booking details by HASH, and then return Email (or other data of booking, or false if error |
| 215 |
$booking_details_email = wpbc_get__booking_data_field__by_booking_hash( $this->request_args['booking_hash'] , 'email' ); |
| 216 |
|
| 217 |
if ( ! empty( $booking_details_email ) ) { |
| 218 |
|
| 219 |
// Do not show booking resources with no bookings |
| 220 |
$this->request_args['only_booked_resources'] = 1; |
| 221 |
|
| 222 |
//Set keyword for showing bookings ony relative to this email |
| 223 |
$args['wh_keyword'] = $booking_details_email; // 'jo@wpbookingcalendar.com'; |
| 224 |
} |
| 225 |
} |
| 226 |
//FixIn: 8.1.3.5 - End |
| 227 |
|
| 228 |
|
| 229 |
// Get booking data |
| 230 |
$bk_listing = wpbc_get_bookings_objects( $args ); |
| 231 |
$this->bookings = $bk_listing['bookings']; |
| 232 |
$this->booking_types = $bk_listing['resources']; |
| 233 |
|
| 234 |
//Get Dates and Times for Timeline format |
| 235 |
//debuge($this->bookings[84]); |
| 236 |
$bookings_date_time = $this->wpbc_get_dates_and_times_for_timeline( $this->bookings ); |
| 237 |
$this->dates_array = $bookings_date_time[0]; |
| 238 |
$this->time_array_new = $bookings_date_time[1]; |
| 239 |
//debuge($this->time_array_new['2017-01-13']); |
| 240 |
|
| 241 |
|
| 242 |
//$milliseconds = round(microtime(true) * 1000); //FixIn: 7.0.Beta.18 |
| 243 |
$milliseconds = wp_rand( 10000, 99999 ); |
| 244 |
|
| 245 |
$this->html_client_id = 'wpbc_timeline_' . $milliseconds; |
| 246 |
|
| 247 |
return $this->html_client_id; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
/** |
| 252 |
* Init parameters after Ajax Navigation actions |
| 253 |
* |
| 254 |
* @param array $attr |
| 255 |
* @return string html_client_id - exist from input parameters |
| 256 |
*/ |
| 257 |
public function ajax_init( $attr ) { |
| 258 |
|
| 259 |
if ( ! defined( 'WPBC_TIMELINE_AJAX' ) ) { define( 'WPBC_TIMELINE_AJAX', true ); } // FixIn: 8.4.7.13. |
| 260 |
|
| 261 |
// FixIn: 10.14.14.2. |
| 262 |
$is_frontend = (bool) $attr['is_frontend']; |
| 263 |
|
| 264 |
// Not front-end (or possibly changed parameter by attacker to see the bookings). |
| 265 |
if ( ! $is_frontend ) { |
| 266 |
|
| 267 |
// If this is not front-end -- admin side, then allow do this only for logged in users, with minimum user role, defined in the settings. |
| 268 |
// Get minimum user role to access the Timeline in admin panel (Booking Listing and Timeline Overview (Calendar Overview). |
| 269 |
$curr_user_role = get_bk_option( 'booking_user_role_booking' ); |
| 270 |
|
| 271 |
// Get current user. |
| 272 |
$current_user = wpbc_get_current_user(); |
| 273 |
$user_role_map = array( |
| 274 |
'administrator' => 10, |
| 275 |
'editor' => 7, |
| 276 |
'author' => 2, |
| 277 |
'contributor' => 1, |
| 278 |
'subscriber' => 0, |
| 279 |
); |
| 280 |
|
| 281 |
$level = 0; |
| 282 |
if ( isset( $user_role_map[ $curr_user_role ] ) ) { |
| 283 |
$level = $user_role_map[ $curr_user_role ]; |
| 284 |
} |
| 285 |
|
| 286 |
if ( empty( $current_user ) || empty( $current_user->user_level ) || ( $current_user->user_level < $level ) ) { |
| 287 |
// Security Fix: Enforce frontend mode for non-admins. |
| 288 |
$attr['is_frontend'] = 1; |
| 289 |
} |
| 290 |
} |
| 291 |
|
| 292 |
$this->is_frontend = (bool) $attr['is_frontend']; |
| 293 |
|
| 294 |
//Ovverride some parameters |
| 295 |
//if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| 296 |
if ( isset( $attr['type'] ) ) { |
| 297 |
$attr['wh_booking_type'] = $attr['type']; //Instead of 'wh_booking_type' paramter in shortcode is used 'type' parameter |
| 298 |
} |
| 299 |
//debuge($this->request_args, $attr); |
| 300 |
// Get paramaters from shortcode paramaters |
| 301 |
$this->define_request_view_params_from_params( $attr ); |
| 302 |
|
| 303 |
//debuge($this->request_args); |
| 304 |
if ( ! $this->request_args['is_matrix'] ) { |
| 305 |
|
| 306 |
switch ( $this->request_args['view_days_num'] ) { |
| 307 |
case '90': |
| 308 |
case '30': |
| 309 |
if ( isset( $this->request_args['scroll_day'] ) ) $scroll_day = intval( $this->request_args['scroll_day'] ); |
| 310 |
else $scroll_day = 0; |
| 311 |
|
| 312 |
// FixIn: 8.9.4.3. |
| 313 |
// Here we need to define number of days to scroll depends from selected number of days to show. |
| 314 |
$days_num_to_scroll = intval( get_bk_option( 'booking_timeline__month_mode__days_number_show' ) ); |
| 315 |
if ( empty( $days_num_to_scroll ) ) { |
| 316 |
$days_num_to_scroll = 7; |
| 317 |
} |
| 318 |
|
| 319 |
if ( $attr['nav_step'] == '-1' ) { |
| 320 |
$this->request_args['scroll_day'] = intval( $scroll_day - $days_num_to_scroll ); |
| 321 |
} |
| 322 |
if ( $attr['nav_step'] == '1' ) { |
| 323 |
$this->request_args['scroll_day'] = intval( $scroll_day + $days_num_to_scroll ); |
| 324 |
} |
| 325 |
|
| 326 |
/* |
| 327 |
* From Admin panel: |
| 328 |
* |
| 329 |
// Here we need to define number of days to scroll depends from selected number of days to show. |
| 330 |
$days_num_to_scroll = intval( get_bk_option( 'booking_calendar_overview__day_mode__days_number_show' ) ); |
| 331 |
if ( empty( $days_num_to_scroll ) ) { |
| 332 |
$days_num_to_scroll = 7; |
| 333 |
} |
| 334 |
|
| 335 |
$scroll_params = array( '&scroll_day='.intval( $scroll_day - $days_num_to_scroll * 2 ), |
| 336 |
'&scroll_day='.intval( $scroll_day - $days_num_to_scroll ), |
| 337 |
'&scroll_day=0', |
| 338 |
'&scroll_day='.intval( $scroll_day + $days_num_to_scroll ), |
| 339 |
'&scroll_day='.intval( $scroll_day + $days_num_to_scroll *2 ) ); |
| 340 |
$scroll_titles = array( __( 'Previous', 'booking' ) . ' ' . ( 2 * $days_num_to_scroll ) . ' ' . __( 'days', 'booking' ), |
| 341 |
__( 'Previous', 'booking' ) . ' ' . $days_num_to_scroll . ' ' . __( 'days', 'booking' ), |
| 342 |
__('Current week' ,'booking'), |
| 343 |
__( 'Next', 'booking' ) . ' ' . $days_num_to_scroll . ' ' . __( 'days', 'booking' ), |
| 344 |
__( 'Next', 'booking' ) . ' ' . ( 2 * $days_num_to_scroll ) . ' ' . __( 'days', 'booking' ) ); |
| 345 |
*/ |
| 346 |
break; |
| 347 |
default: // 365 |
| 348 |
if ( !isset( $this->request_args['scroll_month'] ) ) $this->request_args['scroll_month'] = 0; |
| 349 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 350 |
|
| 351 |
if ( $attr['nav_step'] == '-1' ) $this->request_args['scroll_month'] = intval( $scroll_month - 1 ); |
| 352 |
if ( $attr['nav_step'] == '1' ) $this->request_args['scroll_month'] = intval( $scroll_month + 1 ); |
| 353 |
/* |
| 354 |
$scroll_params = array( '&scroll_month='.intval($scroll_month-3), |
| 355 |
'&scroll_month='.intval($scroll_month-1), |
| 356 |
'&scroll_month=0', |
| 357 |
'&scroll_month='.intval($scroll_month+1 ), |
| 358 |
'&scroll_month='.intval($scroll_month+3) ); |
| 359 |
$scroll_titles = array( __('Previous 3 months' ,'booking'), |
| 360 |
__('Previous month' ,'booking'), |
| 361 |
__('Current month' ,'booking'), |
| 362 |
__('Next month' ,'booking'), |
| 363 |
__('Next 3 months' ,'booking') );*/ |
| 364 |
break; |
| 365 |
} |
| 366 |
} else { // Matrix |
| 367 |
|
| 368 |
switch ( $this->request_args['view_days_num'] ) { |
| 369 |
case '1': //Day |
| 370 |
if ( isset( $this->request_args['scroll_day'] ) ) $scroll_day = intval( $this->request_args['scroll_day'] ); |
| 371 |
else $scroll_day = 0; |
| 372 |
|
| 373 |
if ( $attr['nav_step'] == '-1' ) $this->request_args['scroll_day'] = intval( $scroll_day - 1 ); |
| 374 |
if ( $attr['nav_step'] == '1' ) $this->request_args['scroll_day'] = intval( $scroll_day + 1 ); |
| 375 |
/* |
| 376 |
$scroll_params = array( '&scroll_day='.intval($scroll_day-7), |
| 377 |
'&scroll_day='.intval($scroll_day-1), |
| 378 |
'&scroll_day=0', |
| 379 |
'&scroll_day='.intval($scroll_day+1 ), |
| 380 |
'&scroll_day='.intval($scroll_day+7) ); |
| 381 |
$scroll_titles = array( __('Previous 7 days' ,'booking'), |
| 382 |
__('Previous day' ,'booking'), |
| 383 |
__('Current day' ,'booking'), |
| 384 |
__('Next day' ,'booking'), |
| 385 |
__('Next 7 days' ,'booking') );*/ |
| 386 |
break; |
| 387 |
|
| 388 |
case '7': //Week |
| 389 |
|
| 390 |
if ( isset( $this->request_args['scroll_day'] ) ) $scroll_day = intval( $this->request_args['scroll_day'] ); |
| 391 |
else $scroll_day = 0; |
| 392 |
|
| 393 |
if ( $attr['nav_step'] == '-1' ) $this->request_args['scroll_day'] = intval( $scroll_day - 7 ); |
| 394 |
if ( $attr['nav_step'] == '1' ) $this->request_args['scroll_day'] = intval( $scroll_day + 7 ); |
| 395 |
/* |
| 396 |
$scroll_params = array( '&scroll_day='.intval($scroll_day-4*7), |
| 397 |
'&scroll_day='.intval($scroll_day-7), |
| 398 |
'&scroll_day=0', |
| 399 |
'&scroll_day='.intval($scroll_day+7 ), |
| 400 |
'&scroll_day='.intval($scroll_day+4*7) ); |
| 401 |
$scroll_titles = array( __('Previous 4 weeks' ,'booking'), |
| 402 |
__('Previous week' ,'booking'), |
| 403 |
__('Current week' ,'booking'), |
| 404 |
__('Next week' ,'booking'), |
| 405 |
__('Next 4 weeks' ,'booking') );*/ |
| 406 |
break; |
| 407 |
|
| 408 |
case '30': |
| 409 |
case '60': |
| 410 |
case '90': //3 months |
| 411 |
|
| 412 |
if ( !isset( $this->request_args['scroll_month'] ) ) $this->request_args['scroll_month'] = 0; |
| 413 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 414 |
|
| 415 |
if ( $attr['nav_step'] == '-1' ) $this->request_args['scroll_month'] = intval( $scroll_month - 1 ); |
| 416 |
if ( $attr['nav_step'] == '1' ) $this->request_args['scroll_month'] = intval( $scroll_month + 1 ); |
| 417 |
/* |
| 418 |
$scroll_params = array( '&scroll_month='.intval($scroll_month-3), |
| 419 |
'&scroll_month='.intval($scroll_month-1), |
| 420 |
'&scroll_month=0', |
| 421 |
'&scroll_month='.intval($scroll_month+1 ), |
| 422 |
'&scroll_month='.intval($scroll_month+3) ); |
| 423 |
$scroll_titles = array( __('Previous 3 months' ,'booking'), |
| 424 |
__('Previous month' ,'booking'), |
| 425 |
__('Current month' ,'booking'), |
| 426 |
__('Next month' ,'booking'), |
| 427 |
__('Next 3 months' ,'booking') );*/ |
| 428 |
break; |
| 429 |
|
| 430 |
default: // 30, 60, 90... |
| 431 |
if ( !isset( $this->request_args['scroll_month'] ) ) $this->request_args['scroll_month'] = 0; |
| 432 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 433 |
|
| 434 |
if ( $attr['nav_step'] == '-1' ) $this->request_args['scroll_month'] = intval( $scroll_month - 1 ); |
| 435 |
if ( $attr['nav_step'] == '1' ) $this->request_args['scroll_month'] = intval( $scroll_month + 1 ); |
| 436 |
/* |
| 437 |
$scroll_params = array( '&scroll_month='.intval($scroll_month-3), |
| 438 |
'&scroll_month='.intval($scroll_month-1), |
| 439 |
'&scroll_month=0', |
| 440 |
'&scroll_month='.intval($scroll_month+1 ), |
| 441 |
'&scroll_month='.intval($scroll_month+3) ); |
| 442 |
$scroll_titles = array( __('Previous 3 months' ,'booking'), |
| 443 |
__('Previous month' ,'booking'), |
| 444 |
__('Current month' ,'booking'), |
| 445 |
__('Next month' ,'booking'), |
| 446 |
__('Next 3 months' ,'booking') ); |
| 447 |
*/ |
| 448 |
break; |
| 449 |
} |
| 450 |
} |
| 451 |
|
| 452 |
// Titles |
| 453 |
if ( ! $this->request_args['is_matrix'] ) |
| 454 |
$this->timeline_titles['header_column1'] = ''; |
| 455 |
|
| 456 |
//Override any possible titles from shortcode paramaters |
| 457 |
$this->timeline_titles = wp_parse_args( $attr, $this->timeline_titles ); |
| 458 |
|
| 459 |
|
| 460 |
// Get clean parameters to request booking data |
| 461 |
$args = $this->wpbc_get_clean_paramas_from_request_for_timeline(); |
| 462 |
|
| 463 |
|
| 464 |
// FixIn: 8.1.3.5. |
| 465 |
/** |
| 466 |
* If provided valid ['booking_hash'] in timeline_obj in JavaScript param during Ajax request, |
| 467 |
* then check, if exist booking for this hash. If exist, get Email of this booking, and |
| 468 |
* filter getting all other bookings by email keyword. |
| 469 |
* Addtionly set param ['only_booked_resources'] for showing only booking resources with exist bookings |
| 470 |
*/ |
| 471 |
if ( isset( $attr['booking_hash'] ) ) { |
| 472 |
|
| 473 |
// Get booking details by HASH, and then return Email (or other data of booking, or false if error |
| 474 |
$booking_details_email = wpbc_get__booking_data_field__by_booking_hash( $attr['booking_hash'] , 'email' ); |
| 475 |
//debuge($attr, $booking_details_email); |
| 476 |
if ( ! empty( $booking_details_email ) ) { |
| 477 |
|
| 478 |
// Do not show booking resources with no bookings |
| 479 |
$this->request_args['only_booked_resources'] = 1; |
| 480 |
|
| 481 |
//Set keyword for showing bookings ony relative to this email |
| 482 |
$args['wh_keyword'] = $booking_details_email; // 'jo@wpbookingcalendar.com'; |
| 483 |
} |
| 484 |
if ( ( empty( $booking_details_email ) ) && ( ! empty( $attr['booking_hash'] ) ) ) { // FixIn: 8.4.6.1. |
| 485 |
// FixIn: 8.4.5.13. |
| 486 |
$this->request_args['only_booked_resources'] = 1; |
| 487 |
$args['wh_keyword'] = '``^`````^^````^`````````'; |
| 488 |
} |
| 489 |
} |
| 490 |
//FixIn: 8.1.3.5 - End |
| 491 |
|
| 492 |
|
| 493 |
// Get booking data |
| 494 |
$bk_listing = wpbc_get_bookings_objects( $args ); |
| 495 |
|
| 496 |
$this->bookings = $bk_listing['bookings']; |
| 497 |
$this->booking_types = $bk_listing['resources']; |
| 498 |
|
| 499 |
//Get Dates and Times for Timeline format |
| 500 |
$bookings_date_time = $this->wpbc_get_dates_and_times_for_timeline( $this->bookings ); |
| 501 |
$this->dates_array = $bookings_date_time[0]; |
| 502 |
$this->time_array_new = $bookings_date_time[1]; |
| 503 |
|
| 504 |
|
| 505 |
$this->html_client_id = $attr['html_client_id']; |
| 506 |
|
| 507 |
return $this->html_client_id; |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
/** |
| 512 |
* Define initial REQUEST parameters for Admin Panel and Get bookings and resources |
| 513 |
*/ |
| 514 |
public function admin_init() { |
| 515 |
|
| 516 |
// User //////////////////////////////////////////////////////////////// |
| 517 |
$user = wpbc_get_current_user(); |
| 518 |
$this->current_user_id = $user->ID; |
| 519 |
|
| 520 |
$this->is_frontend = false; |
| 521 |
|
| 522 |
// Get paramaters from REQUEST |
| 523 |
$this->define_request_view_params(); |
| 524 |
|
| 525 |
if ( ! $this->request_args['is_matrix'] ) |
| 526 |
$this->timeline_titles['header_column1'] = ''; |
| 527 |
|
| 528 |
// debuge($this->request_args); |
| 529 |
|
| 530 |
// Get clean parameters to request booking data |
| 531 |
$args = $this->wpbc_get_clean_paramas_from_request_for_timeline(); |
| 532 |
|
| 533 |
// Get booking data |
| 534 |
$bk_listing = wpbc_get_bookings_objects( $args ); |
| 535 |
$this->bookings = $bk_listing['bookings']; |
| 536 |
$this->booking_types = $bk_listing['resources']; |
| 537 |
|
| 538 |
//Get Dates and Times for Timeline format |
| 539 |
$bookings_date_time = $this->wpbc_get_dates_and_times_for_timeline( $this->bookings ); |
| 540 |
$this->dates_array = $bookings_date_time[0]; |
| 541 |
$this->time_array_new = $bookings_date_time[1]; |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
public function client_navigation( $param ) { |
| 546 |
?> |
| 547 |
<script type="text/javascript"> |
| 548 |
wpbc_timeline_obj["<?php echo esc_js( $this->html_client_id ); ?>"] = { |
| 549 |
is_frontend : "<?php echo esc_js( $this->is_frontend ? '1' : '0' ); ?>", |
| 550 |
html_client_id : "<?php echo esc_js( $this->html_client_id ); ?>", |
| 551 |
wh_booking_type : "<?php echo esc_js( $this->request_args['wh_booking_type'] ); ?>", |
| 552 |
is_matrix : "<?php echo esc_js( $this->request_args['is_matrix'] ? '1' : '0' ); ?>", |
| 553 |
view_days_num : "<?php echo esc_js( $this->request_args['view_days_num'] ); ?>", |
| 554 |
scroll_start_date : "<?php echo esc_js( $this->request_args['scroll_start_date'] ); ?>", |
| 555 |
scroll_day : "<?php echo esc_js( $this->request_args['scroll_day'] ); ?>", |
| 556 |
scroll_month : "<?php echo esc_js( $this->request_args['scroll_month'] ); ?>", |
| 557 |
'header_column1' : "<?php echo esc_js( $this->timeline_titles['header_column1'] ); ?>", |
| 558 |
'header_column2' : "<?php echo esc_js( $this->timeline_titles['header_column2'] ); ?>", |
| 559 |
'header_title' : "<?php echo esc_js( $this->timeline_titles['header_title'] ); ?>", |
| 560 |
'wh_trash' : "<?php echo esc_js( $this->request_args['wh_trash'] ); ?>", |
| 561 |
'limit_hours' : "<?php echo esc_js( $this->request_args['limit_hours'] ); ?>", |
| 562 |
'only_booked_resources': "<?php echo esc_js( $this->request_args['only_booked_resources'] ); ?>", |
| 563 |
'options' : '<?php echo wp_json_encode( $this->options ); ?>', |
| 564 |
'booking_hash' : "<?php echo esc_js( $this->request_args['booking_hash'] ); ?>" |
| 565 |
}; |
| 566 |
</script> |
| 567 |
<div class="flex_tl_nav"> |
| 568 |
<div class="flex_tl_prev" href="javascript:void(0)" |
| 569 |
onclick="javascript:wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo esc_js( $this->html_client_id ); ?>'], -1 );"> |
| 570 |
<a>«</a></div> |
| 571 |
<div class="flex_tl_title"><?php echo esc_html( $param['title'] ); ?></div> |
| 572 |
<div class="flex_tl_next" href="javascript:void(0)" |
| 573 |
onclick="javascript:wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo esc_js( $this->html_client_id ); ?>'], 1 );"> |
| 574 |
<a>»</a></div> |
| 575 |
</div> |
| 576 |
<?php |
| 577 |
} |
| 578 |
|
| 579 |
// ----------------------------------------------------------------------------------------------------------------- |
| 580 |
// S u p p o r t |
| 581 |
// ----------------------------------------------------------------------------------------------------------------- |
| 582 |
/** |
| 583 |
* Get array of cleaned (limited number) paramas from request for getting bookings by "wpbc_get_bookings_objects" |
| 584 |
* |
| 585 |
* @return array |
| 586 |
*/ |
| 587 |
public function wpbc_get_clean_paramas_from_request_for_timeline() { |
| 588 |
|
| 589 |
//Replacing in this file from gmdate( to date_i18n( to wpbc_datetime__no_wp_timezone( // FixIn: 9.9.0.18. |
| 590 |
$start_year = intval( wpbc_datetime__no_wp_timezone( "Y" ) ); |
| 591 |
$start_month = intval( wpbc_datetime__no_wp_timezone( "m" ) ); |
| 592 |
$start_day = 1; |
| 593 |
//debuge( '1.( $start_year, $start_month, $start_day , $this->request_args ', $start_year, $start_month, $start_day , $this->request_args ); |
| 594 |
if ( ! empty( $this->request_args['scroll_start_date'] ) ) { // scroll_start_date=2013-07-01 |
| 595 |
|
| 596 |
list( $start_year, $start_month, $start_day ) = explode( '-', $this->request_args['scroll_start_date'] ); |
| 597 |
$start_year = intval( $start_year ); |
| 598 |
$start_month = intval( $start_month ); |
| 599 |
$start_day = intval( $start_day ); |
| 600 |
} |
| 601 |
//debuge( '2.( $start_year, $start_month, $start_day )', $start_year, $start_month, $start_day ); |
| 602 |
$scroll_day = 0; |
| 603 |
$scroll_month = 0; |
| 604 |
|
| 605 |
if ( ( isset( $this->request_args['view_days_num'] ) ) |
| 606 |
//&& ($this->request_args['view_days_num'] != '30') |
| 607 |
) |
| 608 |
$view_days_num = $this->request_args['view_days_num']; |
| 609 |
else |
| 610 |
$view_days_num = get_bk_option( 'booking_view_days_num' ); |
| 611 |
|
| 612 |
$view_days_num = intval( $view_days_num ); |
| 613 |
//debuge( '2.1( $view_days_num )', $view_days_num ); |
| 614 |
$is_matrix = (bool) $this->request_args['is_matrix']; |
| 615 |
|
| 616 |
if ( $is_matrix ) { |
| 617 |
|
| 618 |
switch ( $view_days_num ) { |
| 619 |
|
| 620 |
case '1': |
| 621 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 622 |
$start_day = intval( wpbc_datetime__no_wp_timezone( "d" ) ); // Today date |
| 623 |
|
| 624 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 625 |
$scroll_day = intval( $this->request_args['scroll_day'] ); |
| 626 |
|
| 627 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); |
| 628 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 629 |
|
| 630 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); |
| 631 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 632 |
break; |
| 633 |
|
| 634 |
case '7': |
| 635 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 636 |
$start_day = intval( wpbc_datetime__no_wp_timezone( "d" ) ); //Today date |
| 637 |
$start_week_day_num = intval( wpbc_datetime__no_wp_timezone( "w" ) ); |
| 638 |
$start_day_weeek = intval( get_bk_option( 'booking_start_day_weeek' ) ); //[0]:Sun .. [6]:Sut |
| 639 |
if ( $start_week_day_num != $start_day_weeek ) { |
| 640 |
for ( $d_inc = 1; $d_inc < 8; $d_inc++ ) { // Just get week back |
| 641 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) - intval( $d_inc ) ), intval( $start_year ) ); |
| 642 |
$start_week_day_num = intval( wpbc_datetime__no_wp_timezone( "w", $real_date ) ); |
| 643 |
if ( $start_week_day_num == $start_day_weeek ) { |
| 644 |
$start_day = intval( wpbc_datetime__no_wp_timezone( "d", $real_date ) ); |
| 645 |
$start_year = intval( wpbc_datetime__no_wp_timezone( "Y", $real_date ) ); |
| 646 |
$start_month = intval( wpbc_datetime__no_wp_timezone( "m", $real_date ) ); |
| 647 |
$d_inc = 9; |
| 648 |
} |
| 649 |
} |
| 650 |
} |
| 651 |
|
| 652 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 653 |
$scroll_day = intval( $this->request_args['scroll_day'] ); |
| 654 |
|
| 655 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); |
| 656 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 657 |
|
| 658 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + 7 + intval( $scroll_day ) ), intval( $start_year ) ); |
| 659 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 660 |
break; |
| 661 |
|
| 662 |
case '30': |
| 663 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 664 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 665 |
|
| 666 |
//debuge('3.$scroll_month, $start_month, $start_day, $start_year', $scroll_month, $start_month, $start_day, $start_year ); |
| 667 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); |
| 668 |
//debuge('4.$real_date',$real_date); |
| 669 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 670 |
//debuge('5.$wh_booking_date',$wh_booking_date); |
| 671 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + 1 + intval( $scroll_month ) ), ( intval( $start_day ) - 1 ), intval( $start_year ) ); |
| 672 |
//debuge('6.$real_date',$real_date); |
| 673 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 674 |
//debuge('7.$wh_booking_date2', $wh_booking_date2); |
| 675 |
break; |
| 676 |
|
| 677 |
case '60': |
| 678 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 679 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 680 |
|
| 681 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); |
| 682 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2012-12-01'; |
| 683 |
|
| 684 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + 2 + intval( $scroll_month ) ), ( intval( $start_day ) - 1 ), intval( $start_year ) ); |
| 685 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2013-02-31'; |
| 686 |
break; |
| 687 |
|
| 688 |
//////////////////////////////////////////////////////////////////////////////// |
| 689 |
default: // 30 - default |
| 690 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 691 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 692 |
|
| 693 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); |
| 694 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2012-12-01'; |
| 695 |
|
| 696 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + 1 + intval( $scroll_month ) ), ( intval( $start_day ) - 1 ), intval( $start_year ) ); |
| 697 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2012-12-31'; |
| 698 |
break; |
| 699 |
} |
| 700 |
|
| 701 |
} else { // Single resource |
| 702 |
|
| 703 |
switch ( $view_days_num ) { |
| 704 |
|
| 705 |
case '90': |
| 706 |
|
| 707 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 708 |
$start_day = intval( wpbc_datetime__no_wp_timezone( "d" ) ); //Today Date |
| 709 |
$start_week_day_num = intval( wpbc_datetime__no_wp_timezone( "w" ) ); |
| 710 |
$start_day_weeek = intval( get_bk_option( 'booking_start_day_weeek' ) ); //[0]:Sun .. [6]:Sut |
| 711 |
|
| 712 |
if ( $start_week_day_num != $start_day_weeek ) { |
| 713 |
for ( $d_inc = 1; $d_inc < 8; $d_inc++ ) { // Just get week back |
| 714 |
$real_date = mktime( 0, 0, 0, intval($start_month), (intval($start_day) - intval($d_inc) ), intval($start_year) ); |
| 715 |
$start_week_day_num = intval( wpbc_datetime__no_wp_timezone( "w", $real_date ) ); |
| 716 |
if ( $start_week_day_num == $start_day_weeek ) { |
| 717 |
$start_day = intval( wpbc_datetime__no_wp_timezone( "d", $real_date ) ); |
| 718 |
$start_year = intval( wpbc_datetime__no_wp_timezone( "Y", $real_date ) ); |
| 719 |
$start_month = intval( wpbc_datetime__no_wp_timezone( "m", $real_date ) ); |
| 720 |
$d_inc = 9; |
| 721 |
} |
| 722 |
} |
| 723 |
} |
| 724 |
|
| 725 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 726 |
$scroll_day = intval( $this->request_args['scroll_day'] ); |
| 727 |
|
| 728 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); |
| 729 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2012-12-01'; |
| 730 |
|
| 731 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + 7 * 12 + 7 + intval( $scroll_day ) ), intval( $start_year ) ); |
| 732 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2013-12-31'; |
| 733 |
break; |
| 734 |
|
| 735 |
case '30': |
| 736 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 737 |
$start_day = intval( wpbc_datetime__no_wp_timezone( "d" ) ); //Today Date |
| 738 |
|
| 739 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 740 |
$scroll_day = intval( $this->request_args['scroll_day'] ); |
| 741 |
|
| 742 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); |
| 743 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2012-12-01'; |
| 744 |
|
| 745 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + 31 + intval( $scroll_day ) ), intval( $start_year ) ); |
| 746 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2013-12-31'; |
| 747 |
break; |
| 748 |
|
| 749 |
default: // 365 |
| 750 |
|
| 751 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 752 |
$scroll_month = intval( $this->request_args['scroll_month'] ); |
| 753 |
else |
| 754 |
$scroll_month = 0; |
| 755 |
|
| 756 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); |
| 757 |
$wh_booking_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2012-12-01'; |
| 758 |
|
| 759 |
$real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) + 13 ), ( intval( $start_day ) - 1 ), intval( $start_year ) ); |
| 760 |
$wh_booking_date2 = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); // '2013-12-31'; |
| 761 |
|
| 762 |
break; |
| 763 |
} |
| 764 |
} |
| 765 |
|
| 766 |
$or_sort = ''; |
| 767 |
|
| 768 |
$args = array( |
| 769 |
'wh_booking_type' => $this->request_args['wh_booking_type'], |
| 770 |
'wh_approved' => '', |
| 771 |
'wh_booking_id' => '', |
| 772 |
'wh_is_new' => '', |
| 773 |
'wh_pay_status' => 'all', |
| 774 |
'wh_keyword' => '', |
| 775 |
'wh_booking_date' => $wh_booking_date, |
| 776 |
'wh_booking_date2' => $wh_booking_date2, |
| 777 |
'wh_modification_date' => '3', |
| 778 |
'wh_modification_date2' => '', |
| 779 |
'wh_cost' => '', |
| 780 |
'wh_cost2' => '', |
| 781 |
'or_sort' => $or_sort, |
| 782 |
'page_num' => '1', |
| 783 |
'wh_trash' => $this->request_args['wh_trash'], |
| 784 |
'limit_hours' => $this->request_args['limit_hours'], |
| 785 |
'only_booked_resources' => $this->request_args['only_booked_resources'], // FixIn: 7.0.1.51. |
| 786 |
'page_items_count' => '100000' |
| 787 |
); |
| 788 |
//debuge('8.',$args); |
| 789 |
return $args; |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
/** |
| 794 |
* Define View Params from $_REQUEST |
| 795 |
*/ |
| 796 |
public function define_request_view_params() { |
| 797 |
|
| 798 |
// All other sanitizing and escaping are inside of this function wpbc_check_request_paramters(), which executing before. // FixIn: 8.9.2.1. |
| 799 |
|
| 800 |
// Used once for comma seperated resources only. |
| 801 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 802 |
if ( isset( $_REQUEST['wh_booking_type'] ) ) { |
| 803 |
$this->request_args['wh_booking_type'] = wpbc_clean_digit_or_csd( $_REQUEST['wh_booking_type'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized // FixIn: 8.9.2.1. |
| 804 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 805 |
} elseif ( isset( $_GET['booking_type'] ) ) { |
| 806 |
$this->request_args['wh_booking_type'] = wpbc_clean_digit_or_csd( $_GET['booking_type'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized // FixIn: 8.9.2.1. |
| 807 |
} |
| 808 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash |
| 809 |
if ( ( isset( $_REQUEST['wh_booking_type'] ) ) && ( strpos( $_REQUEST['wh_booking_type'], ',' ) !== false ) ) { |
| 810 |
$this->request_args['is_matrix'] = true; |
| 811 |
} |
| 812 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 813 |
if ( isset( $_REQUEST['view_days_num'] ) ) { |
| 814 |
$this->request_args['view_days_num'] = sanitize_text_field( wp_unslash( $_REQUEST['view_days_num'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 815 |
} |
| 816 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 817 |
if ( isset( $_REQUEST['scroll_start_date'] ) ) { |
| 818 |
$this->request_args['scroll_start_date'] = sanitize_text_field( wp_unslash( $_REQUEST['scroll_start_date'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 819 |
} |
| 820 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 821 |
if ( isset( $_REQUEST['scroll_day'] ) ) { |
| 822 |
$this->request_args['scroll_day'] = sanitize_text_field( wp_unslash( $_REQUEST['scroll_day'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 823 |
} |
| 824 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 825 |
if ( isset( $_REQUEST['scroll_month'] ) ) { |
| 826 |
$this->request_args['scroll_month'] = sanitize_text_field( wp_unslash( $_REQUEST['scroll_month'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 827 |
} |
| 828 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 829 |
if ( isset( $_REQUEST['wh_trash'] ) ) { |
| 830 |
$this->request_args['wh_trash'] = sanitize_text_field( wp_unslash( $_REQUEST['wh_trash'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 831 |
} |
| 832 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 833 |
if ( isset( $_REQUEST['limit_hours'] ) ) { |
| 834 |
$this->request_args['limit_hours'] = sanitize_text_field( wp_unslash( $_REQUEST['limit_hours'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ |
| 835 |
} // FixIn: 7.0.1.14. |
| 836 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 837 |
if ( isset( $_REQUEST['only_booked_resources'] ) ) { |
| 838 |
$this->request_args['only_booked_resources'] = 1; |
| 839 |
} //$_REQUEST['only_booked_resources']; // FixIn: 7.0.1.51. |
| 840 |
} |
| 841 |
|
| 842 |
|
| 843 |
/** |
| 844 |
* Define Request View Params |
| 845 |
* |
| 846 |
* @param array $param = = array( |
| 847 |
* 'wh_booking_type' => '' |
| 848 |
* , 'is_matrix' => false |
| 849 |
* , 'view_days_num' => '30' |
| 850 |
* , 'scroll_start_date' => '' |
| 851 |
* , 'scroll_day' => 0 |
| 852 |
* , 'scroll_month' => 0 |
| 853 |
* ); |
| 854 |
*/ |
| 855 |
public function define_request_view_params_from_params( $param ) { |
| 856 |
//debuge( $param , $this->options , maybe_unserialize( wp_unslash( $param['options'] ) ) );die; |
| 857 |
if ( isset( $param['wh_booking_type'] ) ) { |
| 858 |
$this->request_args['wh_booking_type'] = $param['wh_booking_type']; |
| 859 |
} // Used once for comma seperated resources only. |
| 860 |
|
| 861 |
if ( ( isset( $param['wh_booking_type'] ) ) && ( strpos( $param['wh_booking_type'], ',' ) !== false ) ) { |
| 862 |
$this->request_args['is_matrix'] = true; |
| 863 |
} |
| 864 |
if ( isset( $param['view_days_num'] ) ) { |
| 865 |
$this->request_args['view_days_num'] = $param['view_days_num']; |
| 866 |
} |
| 867 |
if ( isset( $param['scroll_start_date'] ) ) { |
| 868 |
$this->request_args['scroll_start_date'] = $param['scroll_start_date']; |
| 869 |
} |
| 870 |
if ( isset( $param['scroll_day'] ) ) { |
| 871 |
$this->request_args['scroll_day'] = $param['scroll_day']; |
| 872 |
} |
| 873 |
if ( isset( $param['scroll_month'] ) ) { |
| 874 |
$this->request_args['scroll_month'] = $param['scroll_month']; |
| 875 |
} |
| 876 |
if ( isset( $param['wh_trash'] ) ) { |
| 877 |
$this->request_args['wh_trash'] = $param['wh_trash']; |
| 878 |
} |
| 879 |
if ( isset( $param['limit_hours'] ) ) { |
| 880 |
$this->request_args['limit_hours'] = $param['limit_hours']; |
| 881 |
} // FixIn: 7.0.1.14. |
| 882 |
if ( isset( $param['only_booked_resources'] ) ) { |
| 883 |
$this->request_args['only_booked_resources'] = $param['only_booked_resources']; |
| 884 |
} // FixIn: 7.0.1.14. |
| 885 |
if ( isset( $param['booking_hash'] ) ) { |
| 886 |
$this->request_args['booking_hash'] = $param['booking_hash']; |
| 887 |
} // FixIn: 8.1.3.5. |
| 888 |
if ( ( empty( $this->options ) ) && ( isset( $param['options'] ) ) ) { |
| 889 |
$this->options = json_decode( wp_unslash( $param['options'] ), true ); // FixIn: 9.2.1.8. |
| 890 |
} |
| 891 |
|
| 892 |
} |
| 893 |
|
| 894 |
|
| 895 |
/** |
| 896 |
* Get D A T E S and T I M E S from B o o k i n g s |
| 897 |
* |
| 898 |
* @param array $bookings - Booking input array |
| 899 |
* @return array - array( $dates_array, $time_array_new ) |
| 900 |
*/ |
| 901 |
public function wpbc_get_dates_and_times_for_timeline( $bookings ) { |
| 902 |
|
| 903 |
// Generate: Array ( [0] => array(), [3600] => array(), [7200] => array(), ..... [43200] => array(),.... [82800] => array() ) |
| 904 |
$fixed_time_hours_array = array(); |
| 905 |
for ( $tt = 0; $tt < 24; $tt++ ) { |
| 906 |
$fixed_time_hours_array[$tt * 60 * 60] = array(); |
| 907 |
} |
| 908 |
//debuge($bookings); |
| 909 |
// Dates array: { '2012-12-24' => array( Booking ID 1, Booking ID 2, ....), ... } |
| 910 |
$dates_array = $time_array = array(); |
| 911 |
foreach ( $bookings as $bk ) { |
| 912 |
|
| 913 |
|
| 914 |
/** |
| 915 |
* Check situation , while we are having end time but do not have start time, like here: |
| 916 |
* $bk->dates = Array( |
| 917 |
[0] => stdClass Object ( |
| 918 |
[booking_id] => 911 |
| 919 |
[booking_date] => 2019-07-22 00:00:00 |
| 920 |
[approved] => 1 |
| 921 |
[type_id] => ) |
| 922 |
|
| 923 |
[1] => stdClass Object ( |
| 924 |
[booking_id] => 911 |
| 925 |
[booking_date] => 2019-07-23 00:00:00 |
| 926 |
[approved] => 1 |
| 927 |
[type_id] => ) |
| 928 |
|
| 929 |
[2] => stdClass Object ( |
| 930 |
[booking_id] => 911 |
| 931 |
[booking_date] => 2019-07-24 15:00:02 |
| 932 |
[approved] => 1 |
| 933 |
[type_id] => ) |
| 934 |
) |
| 935 |
* |
| 936 |
* So we need to add the new Start time before End time, like this: |
| 937 |
* |
| 938 |
[0] => stdClass Object ( |
| 939 |
[booking_id] => 911 |
| 940 |
[booking_date] => 2019-07-22 00:00:00 |
| 941 |
[approved] => 1 |
| 942 |
[type_id] => ) |
| 943 |
|
| 944 |
[1] => stdClass Object ( |
| 945 |
[booking_id] => 911 |
| 946 |
[booking_date] => 2019-07-23 00:00:00 |
| 947 |
[approved] => 1 |
| 948 |
[type_id] => ) |
| 949 |
[2] => stdClass Object ( |
| 950 |
[booking_id] => 911 |
| 951 |
[booking_date] => 2019-07-24 00:00:01 |
| 952 |
[approved] => 1 |
| 953 |
[type_id] => ) |
| 954 |
[2] => stdClass Object ( |
| 955 |
[booking_id] => 911 |
| 956 |
[booking_date] => 2019-07-24 15:00:02 |
| 957 |
[approved] => 1 |
| 958 |
[type_id] => ) |
| 959 |
* |
| 960 |
*/ |
| 961 |
$dates_to_check = array(); |
| 962 |
$is_started = 0; |
| 963 |
foreach ( $bk->dates as $dt ) { |
| 964 |
|
| 965 |
$last_second = substr( $dt->booking_date, -1); |
| 966 |
|
| 967 |
// Count start end end times started. |
| 968 |
switch ( $last_second ) { |
| 969 |
case '1': // Start |
| 970 |
$is_started++; |
| 971 |
break; |
| 972 |
case '2': // End |
| 973 |
case '8': // FixIn: 9.0.1.2. |
| 974 |
$is_started--; |
| 975 |
break; |
| 976 |
case '0': // Full |
| 977 |
default: |
| 978 |
} |
| 979 |
|
| 980 |
// Its means that we have now end time, but was not having start time |
| 981 |
if ( $is_started < 0 ) { |
| 982 |
$is_started++; |
| 983 |
$my_temp_start_time = clone $dt; |
| 984 |
|
| 985 |
$temp_time = explode( ' ' ,$my_temp_start_time->booking_date ); |
| 986 |
$temp_time = $temp_time[0] . ' 00:00:01'; |
| 987 |
|
| 988 |
$my_temp_start_time->booking_date = $temp_time; |
| 989 |
// Add start time day |
| 990 |
$dates_to_check[] = $my_temp_start_time; |
| 991 |
} |
| 992 |
$dates_to_check[] = $dt; |
| 993 |
} |
| 994 |
|
| 995 |
if ( 0 != $is_started ) { |
| 996 |
?><div class="warning_check_in_out_not_equal"><?php |
| 997 |
// FixIn: 9.2.4.5. |
| 998 |
?><div style="margin:0 10px 10px;font-weight:600;font-size:1.1em;"><?php |
| 999 |
echo( 'Warning! Structure of your booking dates has an issue.'); |
| 1000 |
?></div><?php |
| 1001 |
?><div style="margin:0 10px 30px;font-weight:400;font-size:1.1em;"><?php |
| 1002 |
printf( 'Number of check in times != check out times in a booking, or check-in time is older than the check-out time on the same date in the same booking.' ); |
| 1003 |
?></div><?php |
| 1004 |
?><div style="margin:10px;font-weight:600;font-size:1.05em;color:#752;"><?php |
| 1005 |
printf( 'To resolve this issue, you need to delete the following bookings and create new bookings with the same booking details.' ); |
| 1006 |
?></div><?php |
| 1007 |
$bookings_to_del = array(); |
| 1008 |
for( $day_i = 0; $day_i <= ( count( $dates_to_check ) - 1 ); $day_i++) { |
| 1009 |
$bookings_to_del[] = $dates_to_check[$day_i]->booking_id; |
| 1010 |
} |
| 1011 |
$bookings_to_del = array_unique( $bookings_to_del ); |
| 1012 |
for ( $bk_i = 0; $bk_i <= ( count( $bookings_to_del ) - 1 ); $bk_i ++ ) { |
| 1013 |
$booking_id__to_del = $bookings_to_del [ $bk_i ]; |
| 1014 |
|
| 1015 |
?><div style="margin:10px;font-weight:600;font-size:1.05em;"><?php |
| 1016 |
|
| 1017 |
echo wp_kses_post( sprintf( 'Delete booking with %s', htmlspecialchars_decode( '<strong></strong><a href="' . esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing&wh_booking_id=' . $booking_id__to_del ) . '">' . 'ID = ' . $booking_id__to_del . '</a></strong>' ) ) ); |
| 1018 |
|
| 1019 |
?></div><?php |
| 1020 |
} |
| 1021 |
|
| 1022 |
?><div style="margin:50px;font-weight:600;font-size:1.05em;"></div><?php |
| 1023 |
|
| 1024 |
debuge( $dates_to_check, $is_started) ; |
| 1025 |
|
| 1026 |
?></div><script type="text/javascript"> jQuery( '.warning_check_in_out_not_equal' ).animate( {opacity: 1}, 15000 ).toggle(1000); </script><?php |
| 1027 |
} |
| 1028 |
|
| 1029 |
|
| 1030 |
foreach ( $dates_to_check as $dt ) { |
| 1031 |
//foreach ( $bk->dates as $dt ) { |
| 1032 |
|
| 1033 |
// Transform from MySQL date to PHP date |
| 1034 |
$dt->booking_date = trim( $dt->booking_date ); |
| 1035 |
$dta = explode( ' ', $dt->booking_date ); |
| 1036 |
$tms = $dta[1]; |
| 1037 |
// FixIn: 8.2.1.21. |
| 1038 |
//if ( substr( $dta[1], - 1 ) == '2' ) { continue; } |
| 1039 |
$tms = explode( ':', $tms ); // array('13','30','40') |
| 1040 |
$dta = $dta[0]; |
| 1041 |
$dta = explode( '-', $dta ); // array('2012','12','30') |
| 1042 |
$php_dt = mktime( intval( $tms[0] ), intval( $tms[1] ), intval( $tms[2] ), intval( $dta[1] ), intval( $dta[2] ), intval( $dta[0] ) ); |
| 1043 |
|
| 1044 |
if ( ( isset( $dt->type_id ) ) && (!empty( $dt->type_id )) ) |
| 1045 |
$date_bk_res_id = $dt->type_id; |
| 1046 |
else |
| 1047 |
$date_bk_res_id = $bk->booking_type; |
| 1048 |
|
| 1049 |
//FixIn: 9.9.0.18 - booking |
| 1050 |
$my_date = wpbc_datetime__no_wp_timezone( "Y-m-d", $php_dt ); // '2012-12-01'; |
| 1051 |
|
| 1052 |
if ( !isset( $dates_array[$my_date] ) ) { |
| 1053 |
$dates_array[$my_date] = array( array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ) ); |
| 1054 |
} else { |
| 1055 |
$dates_array[$my_date][] = array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ); |
| 1056 |
} |
| 1057 |
|
| 1058 |
//FixIn: 9.9.0.18 - booking |
| 1059 |
$my_time = wpbc_datetime__no_wp_timezone( "H:i:s", $php_dt ); // '21:55:01'; |
| 1060 |
|
| 1061 |
$my_time_index = explode( ':', $my_time ); |
| 1062 |
$my_time_index = (int) ($my_time_index[0] * 60 * 60 + $my_time_index[1] * 60 + $my_time_index[2]); |
| 1063 |
|
| 1064 |
$my_time = strtotime( $my_time ); // FixIn: 8.1.1.6. |
| 1065 |
|
| 1066 |
if ( !isset( $time_array[$my_date] ) ) { |
| 1067 |
$time_array[$my_date] = array( $my_time_index => array( $my_time => array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ) ) ); |
| 1068 |
} else { |
| 1069 |
|
| 1070 |
if ( !isset( $time_array[$my_date][$my_time_index] ) ) |
| 1071 |
$time_array[$my_date][$my_time_index] = array( $my_time => array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ) ); |
| 1072 |
else { |
| 1073 |
if ( !isset( $time_array[$my_date][$my_time_index][$my_time] ) ) |
| 1074 |
$time_array[$my_date][$my_time_index][$my_time] = array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ); |
| 1075 |
else { |
| 1076 |
$my_time_inc = 3; |
| 1077 |
while ( isset( $time_array[$my_date][$my_time_index][$my_time + $my_time_inc] ) ) { |
| 1078 |
$my_time_inc++; |
| 1079 |
} |
| 1080 |
//Just in case if we are have the booking in the same time, so we are |
| 1081 |
$time_array[$my_date][$my_time_index][($my_time + $my_time_inc)] = array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ); |
| 1082 |
} |
| 1083 |
} |
| 1084 |
} |
| 1085 |
} |
| 1086 |
} |
| 1087 |
|
| 1088 |
|
| 1089 |
//debuge($time_array); |
| 1090 |
// Sorting .......... |
| 1091 |
foreach ( $time_array as $key => $value_t ) { // Sort the times from lower to higher |
| 1092 |
ksort( $value_t ); |
| 1093 |
$time_array[$key] = $value_t; |
| 1094 |
} |
| 1095 |
ksort( $time_array ); // Sort array by dates from lower to higher. |
| 1096 |
/* $time_array: |
| 1097 |
$key_date $value_t |
| 1098 |
[2012-12-13] => Array ( $tt_index $times_bk_id_array |
| 1099 |
[44401] => Array ( [12:20:01] => 19) |
| 1100 |
), |
| 1101 |
[2012-12-14] => Array ( |
| 1102 |
[10802] => Array([03:00:02] => 19), |
| 1103 |
[43801] => Array([12:10:01] => 2) |
| 1104 |
), |
| 1105 |
.... */ |
| 1106 |
|
| 1107 |
//debuge($time_array); |
| 1108 |
|
| 1109 |
$time_array_new = array(); |
| 1110 |
foreach ( $time_array as $key_date => $value_t ) { // fill the $time_array_new - by bookings of full dates.... |
| 1111 |
$new_times_array = $fixed_time_hours_array; // Array ( [0] => Array, [3600] => Array, [7200] => Array ..... |
| 1112 |
|
| 1113 |
foreach ( $value_t as $tt_index => $times_bk_id_array ) { // [44401] => Array ( [12:20:01] => 19 ), ..... |
| 1114 |
$tt_index_round = floor( ($tt_index / 60) / 60 ) * 60 * 60; // 14400, 18000, |
| 1115 |
$is_bk_for_full_date = $tt_index % 10; // 0, 1, 2 |
| 1116 |
|
| 1117 |
switch ( $is_bk_for_full_date ) { |
| 1118 |
case 0: // Full date - fill every time slot |
| 1119 |
foreach ( $new_times_array as $round_time_slot => $bk_id_array ) { |
| 1120 |
$new_times_array[$round_time_slot] = array_merge( $bk_id_array, array_values( $times_bk_id_array ) ); |
| 1121 |
} |
| 1122 |
//debuge('$time_array[$key_date][$tt_index]',$time_array[$key_date][$tt_index], $round_time_slot); |
| 1123 |
unset( $time_array[$key_date][$tt_index] ); |
| 1124 |
break; |
| 1125 |
|
| 1126 |
case 1: break; |
| 1127 |
case 2: break; |
| 1128 |
default: break; |
| 1129 |
} |
| 1130 |
} |
| 1131 |
if ( count( $time_array[$key_date] ) == 0 ) |
| 1132 |
unset( $time_array[$key_date] ); |
| 1133 |
|
| 1134 |
$time_array_new[$key_date] = $new_times_array; |
| 1135 |
} |
| 1136 |
//$time_array_new - Array filled by bookings FOR FULL DAY booking only |
| 1137 |
|
| 1138 |
//debuge($time_array_new); |
| 1139 |
|
| 1140 |
|
| 1141 |
foreach ( $time_array as $key_date => $value_t ) { |
| 1142 |
$new_times_array_for_day_start = $new_times_array_for_day_end = array(); |
| 1143 |
foreach ( $value_t as $tt_index => $times_bk_id_array ) { // [44401] => Array ( [12:20:01] => 19 ), ..... |
| 1144 |
$tt_index_round = floor( ($tt_index / 60) / 60 ) * 60 * 60; // 14400, 18000, |
| 1145 |
//debuge($tt_index, $tt_index_round); |
| 1146 |
$is_bk_for_full_date = $tt_index % 10; // 0, 1, 2 |
| 1147 |
|
| 1148 |
if ( $is_bk_for_full_date == 1 ) { |
| 1149 |
if ( !isset( $new_times_array_for_day_start[$tt_index_round] ) ) |
| 1150 |
$new_times_array_for_day_start[$tt_index_round] = array(); |
| 1151 |
$new_times_array_for_day_start[$tt_index_round] = array_merge( $new_times_array_for_day_start[$tt_index_round], array_values( $times_bk_id_array ) ); |
| 1152 |
} |
| 1153 |
if ( $is_bk_for_full_date == 2 ) { |
| 1154 |
|
| 1155 |
// Its mean that the booking is finished exactly at the beginig of this hour, |
| 1156 |
// so we will not fill the end of booking in this hour, but in previous |
| 1157 |
if ( ($tt_index_round - $tt_index) == -2 ) { |
| 1158 |
$tt_index_round = $tt_index_round - 60 * 60; |
| 1159 |
} |
| 1160 |
|
| 1161 |
if ( !isset( $new_times_array_for_day_end[$tt_index_round] ) ) |
| 1162 |
$new_times_array_for_day_end[$tt_index_round] = array(); |
| 1163 |
$new_times_array_for_day_end[$tt_index_round] = array_merge( $new_times_array_for_day_end[$tt_index_round], array_values( $times_bk_id_array ) ); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
$time_array[$key_date] = array( 'start' => $new_times_array_for_day_start, 'end' => $new_times_array_for_day_end ); |
| 1167 |
} |
| 1168 |
|
| 1169 |
//debuge($time_array); |
| 1170 |
//$time_array['2019-07-24']['start'][0] = $time_array['2019-07-24']['end'][82800]; |
| 1171 |
|
| 1172 |
/* $time_array |
| 1173 |
[2012-12-24] => Array |
| 1174 |
( |
| 1175 |
[start] => Array ( |
| 1176 |
[68400] => Array ( [0] => 15 ) ) |
| 1177 |
[end] => Array ( |
| 1178 |
[64800] => Array ( [0] => 6 ) ) |
| 1179 |
|
| 1180 |
) */ |
| 1181 |
$fill_this_date = array(); |
| 1182 |
//debuge($time_array_new['2017-01-13']); |
| 1183 |
|
| 1184 |
//debuge($time_array_new); |
| 1185 |
// Fil specific times based on start and end times |
| 1186 |
foreach ( $time_array_new as $ddate => $ttime_round_array ) { |
| 1187 |
foreach ( $ttime_round_array as $ttime_round => $bk_id_array ) { // [3600] => Array( [0] => Array ( [id] => 214 [resource] => 9 ), [1] => Array ( [id] => 154 [resource] => 7 |
| 1188 |
|
| 1189 |
//if ('2019-11-27' == $ddate ) { |
| 1190 |
//debuge( ' $fill_this_date', $dates_array[ $ddate ], $fill_this_date ); |
| 1191 |
//} |
| 1192 |
|
| 1193 |
//////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1194 |
/** |
| 1195 |
* Search for situation, when at some previous date was started some booking at specific start time, like: |
| 1196 |
* Booking #77: "October 30 18:00; December 4; December 25 20:00" |
| 1197 |
* This booking exist in $fill_this_date - array ( [0] => array( [id] => 77, [resource] => 1 ) ) |
| 1198 |
* |
| 1199 |
* but at current date "November 6" (where start other Booking #76: November 6 18:00; November 13; November 27 20:00" |
| 1200 |
* this booking #77 does not exist at all !!! |
| 1201 |
* so we nee to remove this booking(s) from array $fill_this_date |
| 1202 |
*/ |
| 1203 |
// FixIn: 8.7.1.1. |
| 1204 |
if(1){ |
| 1205 |
//////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1206 |
// Search to remove |
| 1207 |
$remove_arr_keys = array(); |
| 1208 |
foreach ( $fill_this_date as $is_remove_key => $is_remove_value ) { |
| 1209 |
/** |
| 1210 |
* Remove elements from $fill_this_date |
| 1211 |
* if such elements does not exist in $dates_array[$ddate] |
| 1212 |
*/ |
| 1213 |
if ( ! in_array( $is_remove_value, $dates_array[ $ddate ] ) ) { |
| 1214 |
$remove_arr_keys[] = $is_remove_key; |
| 1215 |
//if ($is_remove_value['id']==76) { |
| 1216 |
//debuge('$ddate,$ttime_round_array',$ddate); |
| 1217 |
//} |
| 1218 |
} |
| 1219 |
} |
| 1220 |
// Removing |
| 1221 |
foreach ( $remove_arr_keys as $is_remove_key ) { |
| 1222 |
unset($fill_this_date[$is_remove_key]); // Remove item at index 1 which is 'for' |
| 1223 |
} |
| 1224 |
$fill_this_date = array_values($fill_this_date); // Re-index the array elements |
| 1225 |
} |
| 1226 |
//////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1227 |
|
| 1228 |
//if ('2019-11-27' == $ddate ) { |
| 1229 |
//debuge( 'updated $fill_this_date', $fill_this_date ); |
| 1230 |
//} |
| 1231 |
|
| 1232 |
|
| 1233 |
if ( isset( $time_array[$ddate] ) ) { |
| 1234 |
|
| 1235 |
if ( isset( $time_array[$ddate]['start'][$ttime_round] ) ) // array |
| 1236 |
$fill_this_date = array_merge( $fill_this_date, array_values( $time_array[$ddate]['start'][$ttime_round] ) ); |
| 1237 |
|
| 1238 |
//debuge($fill_this_date); |
| 1239 |
|
| 1240 |
$time_array_new[$ddate][$ttime_round] = array_merge( $time_array_new[$ddate][$ttime_round], $fill_this_date ); |
| 1241 |
//debuge('$ttime_round',$ttime_round); |
| 1242 |
//debuge($ddate, $ttime_round, $time_array_new[$ddate][$ttime_round]); |
| 1243 |
|
| 1244 |
//FixIn: 7.0.1.16 - advanced checking about delettion of times in $time_array[$ddate]['end'] |
| 1245 |
|
| 1246 |
// End array checking for deleting. |
| 1247 |
if ( isset( $time_array[$ddate]['end'][$ttime_round] ) ) // array |
| 1248 |
foreach ( $time_array[$ddate]['end'][$ttime_round] as $toDelete ) { |
| 1249 |
//debuge($ddate, $ttime_round, $fill_this_date); |
| 1250 |
//if ( $ddate == '2019-07-24' ) { |
| 1251 |
// debuge('$toDelete, $fill_this_date',$toDelete, $fill_this_date); |
| 1252 |
//} |
| 1253 |
//debuge($toDelete); |
| 1254 |
$fill_this_date_keys_to_delete = array(); |
| 1255 |
foreach ( $fill_this_date as $fill_this_date_key => $check_element_array ) { // [0] => Array ( [id] => 54 [resource] => 5 ) |
| 1256 |
//debuge($ddate,'$toDelete, $check_element_array', $toDelete, $check_element_array); |
| 1257 |
if ( // Check if arrays equals - identical |
| 1258 |
( is_array( $toDelete ) && is_array( $check_element_array ) ) |
| 1259 |
&& ( count( $toDelete ) == count( $check_element_array ) ) |
| 1260 |
&& ( array_diff( $toDelete, $check_element_array ) === array_diff( $check_element_array, $toDelete ) ) |
| 1261 |
) { |
| 1262 |
$fill_this_date_keys_to_delete[] = $fill_this_date_key; // $toDelete element exist so save key in original array |
| 1263 |
} |
| 1264 |
} |
| 1265 |
|
| 1266 |
|
| 1267 |
//FixIn: on 2019-07-24 14:22 |
| 1268 |
/** |
| 1269 |
// Fix, when we are having END time but was not having START time (usually when first booking |
| 1270 |
// was booked for entire day, and last day booking, have the end time. |
| 1271 |
// So in this case at day with end time we need to fill all "round times" with End time data |
| 1272 |
*/ |
| 1273 |
// FixIn: 8.7.1.1. |
| 1274 |
if(1) |
| 1275 |
if ( empty( $fill_this_date_keys_to_delete ) ) { |
| 1276 |
// Fill the date by data $toDelete |
| 1277 |
foreach ( $time_array_new[ $ddate ] as $time_round_refill => $time_array_new_value_refill ) { |
| 1278 |
|
| 1279 |
if ( $time_round_refill <= $ttime_round ) { |
| 1280 |
// Refill |
| 1281 |
$time_array_new[ $ddate ][ $time_round_refill ][] = $toDelete; |
| 1282 |
} |
| 1283 |
} |
| 1284 |
} |
| 1285 |
|
| 1286 |
|
| 1287 |
//debuge(' $fill_this_date_keys_to_delete ',$fill_this_date_keys_to_delete ); |
| 1288 |
$fill_this_date_new = array(); |
| 1289 |
foreach ( $fill_this_date as $fill_this_date_key => $fill_this_date_value ) { |
| 1290 |
if ( ! in_array( $fill_this_date_key, $fill_this_date_keys_to_delete ) ) { |
| 1291 |
$fill_this_date_new[] = $fill_this_date_value; |
| 1292 |
} |
| 1293 |
} |
| 1294 |
$fill_this_date = $fill_this_date_new; // Reassign cleared array (with deleted values) |
| 1295 |
|
| 1296 |
//debuge($toDelete); |
| 1297 |
if ( !empty( $fill_this_date ) ) { |
| 1298 |
// $fill_this_date = array_diff( $fill_this_date, array( $toDelete ) ); |
| 1299 |
|
| 1300 |
//if ( $ddate == '2017-01-13' ) { |
| 1301 |
// debuge('AFTER:: $toDelete, $fill_this_date',$toDelete, $fill_this_date); |
| 1302 |
//} |
| 1303 |
} |
| 1304 |
} |
| 1305 |
} |
| 1306 |
} |
| 1307 |
} |
| 1308 |
//debuge( '$dates_array, $time_array_new',$dates_array, $time_array_new ); |
| 1309 |
return array( $dates_array, $time_array_new ); |
| 1310 |
} |
| 1311 |
|
| 1312 |
|
| 1313 |
// ----------------------------------------------------------------------------------------------------------------- |
| 1314 |
// C a l e n d a r T i m e l i n e /////////////////////////////// |
| 1315 |
// ----------------------------------------------------------------------------------------------------------------- |
| 1316 |
private function wpbc_dates_only_of_specific_resource( $booked_dates_array, $resource_id, $bookings ) { |
| 1317 |
|
| 1318 |
foreach ( $booked_dates_array as $key => $value ) { |
| 1319 |
|
| 1320 |
$new_array = array(); |
| 1321 |
foreach ( $value as $bk_id ) { |
| 1322 |
if ( $bk_id['resource'] == $resource_id ) { |
| 1323 |
$new_array[] = $bk_id['id']; |
| 1324 |
} |
| 1325 |
} |
| 1326 |
if ( !empty( $new_array ) ) |
| 1327 |
$booked_dates_array[$key] = $new_array; |
| 1328 |
else |
| 1329 |
unset( $booked_dates_array[$key] ); |
| 1330 |
} |
| 1331 |
return $booked_dates_array; |
| 1332 |
} |
| 1333 |
|
| 1334 |
|
| 1335 |
private function wpbc_times_only_of_specific_resource( $time_array_new, $resource_id, $bookings ) { |
| 1336 |
|
| 1337 |
foreach ( $time_array_new as $date_key => $times_array ) { |
| 1338 |
|
| 1339 |
foreach ( $times_array as $time_key => $value ) { |
| 1340 |
|
| 1341 |
$new_array = array(); |
| 1342 |
foreach ( $value as $bk_id ) { |
| 1343 |
|
| 1344 |
if ( $bk_id['resource'] == $resource_id ) { |
| 1345 |
$new_array[] = $bk_id['id']; |
| 1346 |
} |
| 1347 |
} |
| 1348 |
$time_array_new[$date_key][$time_key] = $new_array; |
| 1349 |
} |
| 1350 |
} |
| 1351 |
return $time_array_new; |
| 1352 |
} |
| 1353 |
|
| 1354 |
|
| 1355 |
private function wpbc_write_bk_id_css_classes( $prefix, $previous_booking_id ) { |
| 1356 |
|
| 1357 |
if ( (!isset( $previous_booking_id )) || (empty( $previous_booking_id )) ) |
| 1358 |
return ''; |
| 1359 |
|
| 1360 |
if ( is_string( $previous_booking_id ) ) |
| 1361 |
$bk_id_array = explode( ',', $previous_booking_id ); |
| 1362 |
else if ( is_array( $previous_booking_id ) ) |
| 1363 |
$bk_id_array = $previous_booking_id; |
| 1364 |
else // Some Unknown situation |
| 1365 |
return ''; |
| 1366 |
|
| 1367 |
$bk_id_array = array_unique( $bk_id_array ); |
| 1368 |
|
| 1369 |
// If we are have several bookings, so add this special class |
| 1370 |
if ( count( $bk_id_array ) > 1 ) |
| 1371 |
$css_class = 'here_several_bk_id '; |
| 1372 |
else |
| 1373 |
$css_class = ''; |
| 1374 |
|
| 1375 |
foreach ( $bk_id_array as $bk_id ) { |
| 1376 |
$css_class .= $prefix . $bk_id . ' '; |
| 1377 |
} |
| 1378 |
|
| 1379 |
return $css_class; |
| 1380 |
} |
| 1381 |
|
| 1382 |
|
| 1383 |
// ----------------------------------------------------------------------------------------------------------------- |
| 1384 |
// Header |
| 1385 |
// ----------------------------------------------------------------------------------------------------------------- |
| 1386 |
/** Header */ |
| 1387 |
public function wpbc_show_timeline_header_row( $start_date = false ) { |
| 1388 |
|
| 1389 |
$current_resource_id = ''; |
| 1390 |
$is_matrix = $this->request_args['is_matrix']; |
| 1391 |
$view_days_num = $this->request_args['view_days_num']; |
| 1392 |
$start_hour_for_1day_view = 0; // FixIn: 7.0.1.14. |
| 1393 |
$end_hour_for_1day_view = 24; |
| 1394 |
$limit_hours = 24; |
| 1395 |
|
| 1396 |
if ( $is_matrix ) { |
| 1397 |
|
| 1398 |
// MATRIX VIEW |
| 1399 |
switch ( $view_days_num ) { |
| 1400 |
case '1': |
| 1401 |
$days_num = 1; |
| 1402 |
$dwa = $this->week_days_titles['full']; |
| 1403 |
$time_selles_num = 24; |
| 1404 |
if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. |
| 1405 |
$limit_hours = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1406 |
$start_hour_for_1day_view = intval( $limit_hours[0] ); |
| 1407 |
$end_hour_for_1day_view = intval( $limit_hours[1] ); |
| 1408 |
$limit_hours = $limit_hours[1] - $limit_hours[0]; |
| 1409 |
} |
| 1410 |
break; |
| 1411 |
case '7': |
| 1412 |
$days_num = 7; |
| 1413 |
//$dwa = $this->week_days_titles['3']; |
| 1414 |
$dwa = $this->week_days_titles['1']; |
| 1415 |
$time_selles_num = 1; |
| 1416 |
break; |
| 1417 |
case '30': |
| 1418 |
$days_num = 31; |
| 1419 |
$days_num = intval( wpbc_datetime__no_wp_timezone('t',$start_date) ); // num of days in the specific month, wchih relative to $real_date from header // FixIn: 7.0.1.47. |
| 1420 |
$dwa = $this->week_days_titles['1']; |
| 1421 |
$time_selles_num = 1; |
| 1422 |
break; |
| 1423 |
case '60': |
| 1424 |
$days_num = 62; |
| 1425 |
//$dwa = $this->week_days_titles['short']; |
| 1426 |
$dwa = $this->week_days_titles['1']; |
| 1427 |
$time_selles_num = 1; |
| 1428 |
break; |
| 1429 |
default: // 30 |
| 1430 |
$days_num = 31; |
| 1431 |
$dwa = $this->week_days_titles['3']; |
| 1432 |
$time_selles_num = 1; |
| 1433 |
break; |
| 1434 |
} |
| 1435 |
|
| 1436 |
} else { |
| 1437 |
|
| 1438 |
switch ( $view_days_num ) { |
| 1439 |
case '90': |
| 1440 |
$days_num = 7; |
| 1441 |
$dwa = $this->week_days_titles['3']; |
| 1442 |
$time_selles_num = 1; |
| 1443 |
break; |
| 1444 |
case '365': |
| 1445 |
$days_num = 31; // FixIn: 8.7.6.5. |
| 1446 |
//$days_num = intval( wpbc_datetime__no_wp_timezone('t',$start_date) ); // num of days in the specific month, wchih relative to $real_date from header // FixIn: 7.0.1.47. |
| 1447 |
$dwa = $this->week_days_titles['3']; |
| 1448 |
$time_selles_num = 1; |
| 1449 |
break; |
| 1450 |
default: // 30 |
| 1451 |
$days_num = 1; |
| 1452 |
$dwa = $this->week_days_titles['full']; |
| 1453 |
$time_selles_num = 24; |
| 1454 |
if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. |
| 1455 |
$limit_hours = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1456 |
$start_hour_for_1day_view = intval( $limit_hours[0] ); |
| 1457 |
$end_hour_for_1day_view = intval( $limit_hours[1] ); |
| 1458 |
$limit_hours = $limit_hours[1] - $limit_hours[0]; |
| 1459 |
} |
| 1460 |
break; |
| 1461 |
} |
| 1462 |
} |
| 1463 |
|
| 1464 |
if ( $start_date === false ) { |
| 1465 |
|
| 1466 |
if ( ! empty( $this->request_args['scroll_start_date'] ) ) |
| 1467 |
list( $start_year, $start_month, $start_day ) = explode( '-', $this->request_args['scroll_start_date'] ); // scroll_start_date=2013-07-01 |
| 1468 |
else |
| 1469 |
list( $start_year, $start_month, $start_day ) = explode( '-', wpbc_datetime__no_wp_timezone( 'Y-n-j' ) ); |
| 1470 |
|
| 1471 |
} else { |
| 1472 |
list( $start_year, $start_month, $start_day ) = explode( '-', wpbc_datetime__no_wp_timezone( 'Y-m-d', $start_date ) ); |
| 1473 |
} |
| 1474 |
|
| 1475 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1476 |
// Month Line |
| 1477 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1478 |
?><div class="flex_tl_dates_bar flex_tl_dates_bar_month"><?php |
| 1479 |
$previous_month = ''; |
| 1480 |
//Scroll months Firstly |
| 1481 |
for ( $d_inc = 0; $d_inc < $days_num; $d_inc++ ) { |
| 1482 |
|
| 1483 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) ), intval( $start_year ) ); |
| 1484 |
$yy = wpbc_datetime__no_wp_timezone( "Y", $real_date ); //2012 |
| 1485 |
$mm = wpbc_datetime__no_wp_timezone( "m", $real_date ); //09 |
| 1486 |
$dd = wpbc_datetime__no_wp_timezone( "d", $real_date ); //31 |
| 1487 |
$ww = wpbc_datetime__no_wp_timezone( "N", $real_date ); //7 |
| 1488 |
$day_week = $dwa[$ww]; //Su |
| 1489 |
|
| 1490 |
$month_title = ''; |
| 1491 |
$month_class = ''; |
| 1492 |
|
| 1493 |
|
| 1494 |
if ( ($view_days_num == 30) || ($view_days_num == 60) ) { |
| 1495 |
if (( (intval($ww)-1) === intval(get_bk_option( 'booking_start_day_weeek' )) )){ |
| 1496 |
$month_class = ' new_month '; |
| 1497 |
} |
| 1498 |
} else { |
| 1499 |
if(( $previous_month != $mm ) || ( 1 == $dd )){ |
| 1500 |
$month_class = ' new_month '; |
| 1501 |
} |
| 1502 |
} |
| 1503 |
if ($month_class == ' new_month '){ |
| 1504 |
$previous_month = $mm; |
| 1505 |
$month_title = wpbc_datetime__no_wp_timezone( "F", $real_date ); //09 |
| 1506 |
} |
| 1507 |
|
| 1508 |
?> |
| 1509 |
<div class="<?php echo implode(' ', array( |
| 1510 |
'flex_tl_day_cell', |
| 1511 |
'flex_tl_day_cell_header', |
| 1512 |
'flex_time_in_days_num_' . esc_attr( $view_days_num ), |
| 1513 |
esc_attr( $month_class ) |
| 1514 |
)); ?>" |
| 1515 |
><?php |
| 1516 |
// New Month ! |
| 1517 |
if ( $month_title != '' ) { |
| 1518 |
?> |
| 1519 |
<div class="in_cell_month_year"><?php |
| 1520 |
|
| 1521 |
if ( $is_matrix ) { |
| 1522 |
|
| 1523 |
echo esc_attr( $dd . ' ' . $month_title . ', ' . $yy ); |
| 1524 |
|
| 1525 |
if ( '1' == $view_days_num ) { |
| 1526 |
echo ' (' . esc_attr( $day_week ) . ')'; |
| 1527 |
} |
| 1528 |
|
| 1529 |
} else { |
| 1530 |
if ( '30' == $view_days_num ) { |
| 1531 |
//echo '(' . esc_attr($day_week) . ') ' . esc_attr($dd) . ' '; |
| 1532 |
} |
| 1533 |
} |
| 1534 |
?></div><?php |
| 1535 |
} |
| 1536 |
?> </div> <?php |
| 1537 |
} |
| 1538 |
?> |
| 1539 |
</div><?php |
| 1540 |
|
| 1541 |
|
| 1542 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1543 |
// Dates / Times Line |
| 1544 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1545 |
?><div class="flex_tl_dates_bar <?php echo esc_attr( $is_matrix ? ' flex_tl_matrix_resources ' : ' flex_tl_single_resource ' ); ?>" |
| 1546 |
id="timeline_scroller<?php echo esc_attr( $current_resource_id ); ?>" |
| 1547 |
><?php |
| 1548 |
$previous_month = ''; |
| 1549 |
|
| 1550 |
$bk_admin_url_today = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), array( 'scroll_month', 'scroll_day', 'scroll_start_date' ) ); |
| 1551 |
|
| 1552 |
for ( $d_inc = 0; $d_inc < $days_num; $d_inc++ ) { |
| 1553 |
|
| 1554 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) ), intval( $start_year ) ); |
| 1555 |
|
| 1556 |
if ( wpbc_datetime__no_wp_timezone( 'm.d.Y' ) == wpbc_datetime__no_wp_timezone( "m.d.Y", $real_date ) ) |
| 1557 |
$is_today = ' today_date '; |
| 1558 |
else |
| 1559 |
$is_today = ''; |
| 1560 |
|
| 1561 |
$yy = wpbc_datetime__no_wp_timezone( "Y", $real_date ); //2012 |
| 1562 |
$mm = wpbc_datetime__no_wp_timezone( "m", $real_date ); //09 |
| 1563 |
$dd = wpbc_datetime__no_wp_timezone( "d", $real_date ); //31 |
| 1564 |
$ww = wpbc_datetime__no_wp_timezone( "N", $real_date ); //7 |
| 1565 |
$day_week = $dwa[$ww]; //Su |
| 1566 |
|
| 1567 |
$day_title = $dd . ' ' . $day_week; |
| 1568 |
if ( $is_matrix ) { |
| 1569 |
if ( $view_days_num == 1 ) { |
| 1570 |
$day_title = '<div class="in_cell_day_num">' . esc_html__( 'Times', 'booking' ) . '</div>'; |
| 1571 |
} |
| 1572 |
if ( $view_days_num == 7 ) { |
| 1573 |
$day_title = '<div class="in_cell_day_num">' . $dd . '</div><div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1574 |
} |
| 1575 |
if ( $view_days_num == 30 ) { |
| 1576 |
$day_title = '<div class="in_cell_day_num">' . $dd . '</div><div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1577 |
} |
| 1578 |
if ( $view_days_num == 60 ) { |
| 1579 |
$day_title = '<div class="in_cell_day_num">' . $dd . '</div><div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1580 |
} |
| 1581 |
} else { |
| 1582 |
if ( $view_days_num == 30 ) { |
| 1583 |
$day_title = '<div class="in_cell_day_num">' . esc_html__( 'Times', 'booking' ) . '</div>'; |
| 1584 |
} |
| 1585 |
if ( $view_days_num == 90 ) { |
| 1586 |
$day_title = '<div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1587 |
} |
| 1588 |
if ( $view_days_num == 365 ) { |
| 1589 |
$day_title = '<div class="in_cell_day_num">' . $dd . '</div>'; |
| 1590 |
} |
| 1591 |
} |
| 1592 |
$day_filter_id = $yy . '-' . $mm . '-' . $dd; |
| 1593 |
|
| 1594 |
if ( ( $previous_month != $mm ) || ( 1 == $dd ) ) { |
| 1595 |
$previous_month = $mm; |
| 1596 |
$month_class = ' new_month '; |
| 1597 |
} else { |
| 1598 |
$month_class = ''; |
| 1599 |
} |
| 1600 |
|
| 1601 |
?> |
| 1602 |
<div id="cell_<?php echo esc_attr( $current_resource_id . '_' . $day_filter_id ); ?>" |
| 1603 |
class="<?php echo esc_attr( implode(' ', array( |
| 1604 |
'flex_tl_day_cell', |
| 1605 |
'flex_tl_day_cell_header', |
| 1606 |
'flex_time_in_days_num_' . $view_days_num, |
| 1607 |
'flex_tl_weekday' . $ww, |
| 1608 |
$day_filter_id, |
| 1609 |
$month_class |
| 1610 |
))); ?>" |
| 1611 |
><?php |
| 1612 |
|
| 1613 |
if ( ( $is_matrix ) && ( ( $view_days_num == 30 ) || ( $view_days_num == 60 ) ) ) { |
| 1614 |
|
| 1615 |
?><div class="in_cell_date_container day_num<?php echo esc_attr( $d_inc ); ?>"><?php |
| 1616 |
|
| 1617 |
if ( ! $this->is_frontend ) { |
| 1618 |
?><a href='<?php echo esc_url( $bk_admin_url_today . '&scroll_start_date=' . $yy . '-' . $mm . '-' . $dd ); ?>'><?php |
| 1619 |
} |
| 1620 |
echo wp_kses_post( $day_title ); |
| 1621 |
|
| 1622 |
if ( ! $this->is_frontend ) { |
| 1623 |
?></a><?php |
| 1624 |
} |
| 1625 |
|
| 1626 |
?></div><?php |
| 1627 |
|
| 1628 |
} else { |
| 1629 |
?> |
| 1630 |
<div class="in_cell_date_container day_num<?php echo esc_attr( $d_inc ); ?>"><?php echo wp_kses_post( $day_title ); ?></div><?php |
| 1631 |
} |
| 1632 |
|
| 1633 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 1634 |
// T i m e c e l l s |
| 1635 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 1636 |
$tm = floor( 24 / $time_selles_num ); |
| 1637 |
if ( $time_selles_num > 1 ) { |
| 1638 |
?><div class="<?php echo esc_attr( implode(' ', array( |
| 1639 |
'in_cell_time_section_in_day', |
| 1640 |
'flex_time_section_in_day_header', |
| 1641 |
'flex_time_in_days_num_' . $view_days_num |
| 1642 |
) ) ); ?>"><?php |
| 1643 |
|
| 1644 |
for ( $tt = 0; $tt < $time_selles_num; $tt++ ) { ?> |
| 1645 |
|
| 1646 |
<?php if ( ( $tt < $start_hour_for_1day_view ) || ( $tt > $end_hour_for_1day_view ) ) { continue; } //FixIn: 7.0.1.14 ?> |
| 1647 |
|
| 1648 |
<div class="<?php echo esc_attr( 'in_cell_time_hour time_hour' . ( $tt * $tm ) ); ?>" ><?php |
| 1649 |
|
| 1650 |
$this->show_time_number_in_correct_format( $tt * $tm , $view_days_num ); |
| 1651 |
|
| 1652 |
?></div><?php |
| 1653 |
} |
| 1654 |
?></div><?php |
| 1655 |
} |
| 1656 |
?></div><?php |
| 1657 |
|
| 1658 |
} |
| 1659 |
?></div><?php |
| 1660 |
|
| 1661 |
return $real_date ; |
| 1662 |
} |
| 1663 |
|
| 1664 |
|
| 1665 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1666 |
// Booking Row Support functions |
| 1667 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1668 |
|
| 1669 |
/** |
| 1670 |
* Define Init Row settings parameters |
| 1671 |
* |
| 1672 |
* @param $row_settings array |
| 1673 |
* |
| 1674 |
* @return array |
| 1675 |
*/ |
| 1676 |
private function get_init_row_settings( $row_settings ){ |
| 1677 |
|
| 1678 |
// Initial params |
| 1679 |
$row_settings['is_matrix'] = $this->request_args['is_matrix']; |
| 1680 |
$row_settings['start_hour_for_1day_view'] = 0; |
| 1681 |
$row_settings['end_hour_for_1day_view'] = 24; |
| 1682 |
$row_settings['limit_hours'] = 24; |
| 1683 |
$row_settings['view_days_num'] = $this->request_args['view_days_num']; |
| 1684 |
|
| 1685 |
// Single booking resource |
| 1686 |
if ( ! $row_settings['is_matrix'] ) { |
| 1687 |
|
| 1688 |
switch ($row_settings['view_days_num']) { |
| 1689 |
case '90': |
| 1690 |
$row_settings['days_num'] = 7; |
| 1691 |
$row_settings['dwa'] = $this->week_days_titles['full']; |
| 1692 |
$row_settings['time_selles_num'] = 1; |
| 1693 |
break; |
| 1694 |
case '365': |
| 1695 |
$row_settings['days_num'] = 31; |
| 1696 |
//$row_settings['days_num'] = intval( wpbc_datetime__no_wp_timezone('t',$row_settings['start_date']) ); // num of days in the specific month, wchih relative to $row_settings['real_date'] from header // FixIn: 7.0.1.47. |
| 1697 |
$row_settings['dwa'] = $this->week_days_titles['1']; |
| 1698 |
$row_settings['time_selles_num'] = 1; |
| 1699 |
break; |
| 1700 |
default: // 30 |
| 1701 |
$row_settings['days_num'] = 1; |
| 1702 |
$row_settings['dwa'] = $this->week_days_titles['3']; |
| 1703 |
$row_settings['time_selles_num'] = 24;//25; |
| 1704 |
|
| 1705 |
if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. |
| 1706 |
$row_settings['limit_hours'] = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1707 |
$row_settings['start_hour_for_1day_view'] = intval( $row_settings['limit_hours'][0] ); |
| 1708 |
$row_settings['end_hour_for_1day_view'] = intval( $row_settings['limit_hours'][1] ); |
| 1709 |
$row_settings['limit_hours'] = $row_settings['limit_hours'][1] - $row_settings['limit_hours'][0]; |
| 1710 |
} |
| 1711 |
|
| 1712 |
//$row_settings['view_days_num'] = 1; |
| 1713 |
break; |
| 1714 |
} |
| 1715 |
|
| 1716 |
} else { // Multiple booking resources |
| 1717 |
|
| 1718 |
//$row_settings['view_days_num'] = 365; |
| 1719 |
switch ($row_settings['view_days_num']) { |
| 1720 |
case '1': |
| 1721 |
$row_settings['days_num'] = 1; |
| 1722 |
$row_settings['dwa'] = $this->week_days_titles['full']; |
| 1723 |
$row_settings['time_selles_num'] = 24; |
| 1724 |
|
| 1725 |
if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. |
| 1726 |
$row_settings['limit_hours'] = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1727 |
$row_settings['start_hour_for_1day_view'] = intval( $row_settings['limit_hours'][0] ); |
| 1728 |
$row_settings['end_hour_for_1day_view'] = intval( $row_settings['limit_hours'][1] ); |
| 1729 |
$row_settings['limit_hours'] = $row_settings['limit_hours'][1] - $row_settings['limit_hours'][0]; |
| 1730 |
} |
| 1731 |
|
| 1732 |
break; |
| 1733 |
case '7': |
| 1734 |
$row_settings['days_num'] = 7; |
| 1735 |
$row_settings['dwa'] = $this->week_days_titles['full']; |
| 1736 |
$row_settings['time_selles_num'] = 1; |
| 1737 |
break; |
| 1738 |
case '60': |
| 1739 |
$row_settings['days_num'] = 62; |
| 1740 |
$row_settings['dwa'] = $this->week_days_titles['1']; |
| 1741 |
$row_settings['time_selles_num'] = 1; |
| 1742 |
break; |
| 1743 |
case 'old_365': |
| 1744 |
$row_settings['days_num'] = 365; |
| 1745 |
$row_settings['time_selles_num'] = 1; |
| 1746 |
$row_settings['dwa'] = $this->week_days_titles['1']; |
| 1747 |
break; |
| 1748 |
|
| 1749 |
default: // 30 |
| 1750 |
$row_settings['days_num'] = 32; |
| 1751 |
$row_settings['days_num'] = intval( wpbc_datetime__no_wp_timezone('t',$row_settings['start_date']) ); // num of days in the specific month, wchih relative to $row_settings['real_date'] from header // FixIn: 7.0.1.47. |
| 1752 |
$row_settings['dwa'] = $this->week_days_titles['3']; |
| 1753 |
$row_settings['time_selles_num'] = 1;//25; |
| 1754 |
break; |
| 1755 |
} |
| 1756 |
} |
| 1757 |
|
| 1758 |
return $row_settings; |
| 1759 |
} |
| 1760 |
|
| 1761 |
|
| 1762 |
/** |
| 1763 |
* Show time in correct format - showing in Header, and in time CELLs |
| 1764 |
* |
| 1765 |
* @param $time_milliseconds |
| 1766 |
* @param $view_days_num |
| 1767 |
*/ |
| 1768 |
private function show_time_number_in_correct_format( $time_milliseconds, $view_days_num ) { |
| 1769 |
|
| 1770 |
// FixIn: 8.1.3.34. |
| 1771 |
$bc_time_format = get_bk_option( 'booking_time_format' ); |
| 1772 |
if ( ! empty( $bc_time_format ) ) { // FixIn: 8.2.1.2. |
| 1773 |
$time_show = wpbc_datetime__no_wp_timezone( str_replace( ':i', '', get_bk_option( 'booking_time_format' ) ), mktime( intval( $time_milliseconds ), 0, 0 ) ); |
| 1774 |
echo wp_kses_post( ( $view_days_num < 31 ) ? $time_show : '' ); |
| 1775 |
} else { |
| 1776 |
echo wp_kses_post( ( $view_days_num < 31 ) ? ( ( ( $time_milliseconds ) < 10 ? '0' : '' ) . ( $time_milliseconds ) . '<sup>:00</sup>' ) : '' ); |
| 1777 |
} |
| 1778 |
} |
| 1779 |
|
| 1780 |
|
| 1781 |
/** |
| 1782 |
* Is show Day View ( showing days || times ) |
| 1783 |
* |
| 1784 |
* @param $row_settings |
| 1785 |
* |
| 1786 |
* @return bool |
| 1787 |
*/ |
| 1788 |
private function is_show_day_view( $row_settings ) { |
| 1789 |
if ( |
| 1790 |
( ( 30 == $row_settings['view_days_num'] ) && ( ! $row_settings['is_matrix'] ) ) // Day View for Single |
| 1791 |
|| ( ( 1 == $row_settings['view_days_num'] ) && ( $row_settings['is_matrix'] ) ) // Day View for Matrix |
| 1792 |
) { |
| 1793 |
return true; |
| 1794 |
} else { |
| 1795 |
return false; |
| 1796 |
} |
| 1797 |
} |
| 1798 |
|
| 1799 |
|
| 1800 |
/** |
| 1801 |
* Check, if starting new booking (something changed) relative to previous CELL |
| 1802 |
* |
| 1803 |
* @param array $bookings_in_cell |
| 1804 |
* @param array $previous_bookings_in_cell |
| 1805 |
* |
| 1806 |
* @return bool |
| 1807 |
*/ |
| 1808 |
private function is_start_new_booking_cell( $bookings_in_cell, $previous_bookings_in_cell ) { |
| 1809 |
|
| 1810 |
$bookings_in_cell = implode( '|', $bookings_in_cell ); |
| 1811 |
$previous_bookings_in_cell = implode( '|', $previous_bookings_in_cell ); |
| 1812 |
|
| 1813 |
if ( $bookings_in_cell !== $previous_bookings_in_cell ) { |
| 1814 |
return true; |
| 1815 |
} else { |
| 1816 |
return false; |
| 1817 |
} |
| 1818 |
} |
| 1819 |
|
| 1820 |
|
| 1821 |
/** |
| 1822 |
* Check method 2, if starting new booking (something changed) relative to previous CELL |
| 1823 |
* |
| 1824 |
* @param array $bookings_in_cell |
| 1825 |
* @param array $previous_bookings_in_cell |
| 1826 |
* |
| 1827 |
* @return bool |
| 1828 |
*/ |
| 1829 |
private function is_start_new_booking_cell2( $bookings_in_cell, $previous_bookings_in_cell ) { |
| 1830 |
|
| 1831 |
$bookings_in_cell = implode( '|', $bookings_in_cell ); |
| 1832 |
$previous_bookings_in_cell = implode( '|', $previous_bookings_in_cell ); |
| 1833 |
|
| 1834 |
$bookings_in_cell_arr = explode( '|', $bookings_in_cell ); |
| 1835 |
$previous_bookings_in_cell_arr = explode( '|', $previous_bookings_in_cell ); |
| 1836 |
|
| 1837 |
$is_check1 = empty( array_diff( $bookings_in_cell_arr, $previous_bookings_in_cell_arr ) ); |
| 1838 |
$is_check2 = empty( array_diff( $previous_bookings_in_cell_arr, $bookings_in_cell_arr ) ); |
| 1839 |
|
| 1840 |
return ( ( ! $is_check1 ) && ( ! $is_check2 ) ); |
| 1841 |
} |
| 1842 |
|
| 1843 |
/** |
| 1844 |
* Get Text for booking Title in PIPELINE |
| 1845 |
* |
| 1846 |
* @param $bk_id |
| 1847 |
* @param $bookings |
| 1848 |
* |
| 1849 |
* @return string |
| 1850 |
*/ |
| 1851 |
private function get_booking_title_for_timeline( $bk_id, $bookings ){ |
| 1852 |
|
| 1853 |
$text_in_day_cell = ''; |
| 1854 |
|
| 1855 |
if ( $this->is_frontend ) $what_show_in_day_template = get_bk_option( 'booking_default_title_in_day_for_timeline_front_end' ); |
| 1856 |
else $what_show_in_day_template = get_bk_option( 'booking_default_title_in_day_for_calendar_view_mode' ); |
| 1857 |
|
| 1858 |
if ( function_exists( 'get_title_for_showing_in_day' ) ) { |
| 1859 |
$text_in_day_cell .= esc_textarea( get_title_for_showing_in_day( $bk_id, $bookings, $what_show_in_day_template ) ); // FixIn: 7.1.1.2. |
| 1860 |
} else { |
| 1861 |
if ( ! $this->is_frontend ) { |
| 1862 |
// Default Free // FixIn: 7.1.1.2. |
| 1863 |
$text_in_day_cell .= $bk_id . ':' ; |
| 1864 |
if ( isset( $bookings[ $bk_id ]->form_data['_all_fields_']['name'] ) ) { |
| 1865 |
$text_in_day_cell .= ' ' . esc_textarea( $bookings[ $bk_id ]->form_data['_all_fields_']['name'] ); |
| 1866 |
} |
| 1867 |
// FixIn: 10.0.0.24. |
| 1868 |
if ( isset( $bookings[ $bk_id ]->form_data['_all_fields_']['secondname'] ) ) { |
| 1869 |
$text_in_day_cell .= ' ' . esc_textarea( $bookings[ $bk_id ]->form_data['_all_fields_']['secondname'] ); |
| 1870 |
} |
| 1871 |
if ( isset( $bookings[ $bk_id ]->form_data['_all_fields_']['lastname'] ) ) { |
| 1872 |
$text_in_day_cell .= ' ' . esc_textarea( $bookings[ $bk_id ]->form_data['_all_fields_']['lastname'] ); |
| 1873 |
} |
| 1874 |
} |
| 1875 |
} |
| 1876 |
|
| 1877 |
return $text_in_day_cell; |
| 1878 |
} |
| 1879 |
|
| 1880 |
|
| 1881 |
/** |
| 1882 |
* Title, when mouse-over booking Pipeline (bar with background) |
| 1883 |
* |
| 1884 |
* @param $booking_id |
| 1885 |
* @param $row_settings |
| 1886 |
*/ |
| 1887 |
private function show_booking_title_for_pipeline_bar( $booking_id, $row_settings ){ |
| 1888 |
|
| 1889 |
// FixIn: 8.7.1.4. |
| 1890 |
$bk_title = ''; |
| 1891 |
|
| 1892 |
$is_date = wpbc_get_date_in_correct_format( wpbc_datetime__no_wp_timezone( "Y-m-d", $row_settings['real_date'] ) ); |
| 1893 |
if ( ( is_array( $is_date ) ) && ( ! empty( $is_date ) ) ) { |
| 1894 |
$bk_title = $is_date[0]; |
| 1895 |
} |
| 1896 |
|
| 1897 |
$bk_title .= " \n" . $this->get_booking_title_for_timeline( $booking_id, $row_settings['bookings'] ); |
| 1898 |
|
| 1899 |
$bk_title .= " \n" . wp_strip_all_tags( wpbc_get_short_dates_formated_to_show( $row_settings['bookings'][ $booking_id ]->dates_short ) ) ; |
| 1900 |
|
| 1901 |
?><a href="javascript:void(0)" |
| 1902 |
class="in_cell_date_booking_pipeline_a" |
| 1903 |
title="<?php echo esc_attr( $bk_title ); ?>" |
| 1904 |
><?php |
| 1905 |
?><div class="in_cell_date_booking_pipeline_a_sizer"></div><?php |
| 1906 |
?></a><?php |
| 1907 |
} |
| 1908 |
|
| 1909 |
|
| 1910 |
/** |
| 1911 |
* Show booking TITLE in PIPELINE |
| 1912 |
* |
| 1913 |
* @param $bookings_in_cell |
| 1914 |
* @param $row_settings |
| 1915 |
*/ |
| 1916 |
private function show_booking_title_for_timeline( $bookings_in_cell, $row_settings ){ |
| 1917 |
|
| 1918 |
$bk_a_title_arr = array(); |
| 1919 |
$popup_content_arr = array(); |
| 1920 |
$popup_title_arr = array(); |
| 1921 |
|
| 1922 |
$is_show_popover_in_timeline = wpbc_is_show_popover_in_flex_timeline( $this->is_frontend, $this->request_args['booking_hash'] ); // FixIn: 8.1.3.5. |
| 1923 |
|
| 1924 |
foreach ( $bookings_in_cell as $booking_id ) { |
| 1925 |
|
| 1926 |
$bk_a_title = $this->get_booking_title_for_timeline( $booking_id, $row_settings['bookings'] ); |
| 1927 |
$bk_a_title = htmlspecialchars_decode( $bk_a_title, ENT_NOQUOTES ); // FixIn: 8.7.11.5. |
| 1928 |
$bk_a_title_arr[] = $bk_a_title; |
| 1929 |
|
| 1930 |
$title_in_day = $title = $title_hint = ''; |
| 1931 |
|
| 1932 |
if ( $is_show_popover_in_timeline ) { |
| 1933 |
$popup_content = $this->wpbc_get_booking_info_4_popover( $booking_id, $row_settings['bookings'], $row_settings['booking_types'] ); |
| 1934 |
|
| 1935 |
|
| 1936 |
$popup_title_arr[] = $popup_content['title']; |
| 1937 |
//FixIn: 9.7.4.1 - escape coded html/xss |
| 1938 |
$popup_content_arr[] = '<div class="popover-title">' . esc_html($popup_content['title']) . '</div><div class="popover-content">' . esc_html( $popup_content['content'] ) . '</div>'; |
| 1939 |
} |
| 1940 |
//$popup_content_arr[] = $bk_a_title . ': ' . wp_strip_all_tags( wpbc_get_short_dates_formated_to_show( $row_settings['bookings'][ $booking_id ]->dates_short ) ) ; |
| 1941 |
} |
| 1942 |
|
| 1943 |
// Title A link |
| 1944 |
$bk_a_title__text = implode( ', ', $bk_a_title_arr ); |
| 1945 |
|
| 1946 |
if ( strlen( $bk_a_title__text ) > 20 ) { |
| 1947 |
$bk_a_title__text = substr( $bk_a_title__text, 0, 20 ) . '...'; |
| 1948 |
} |
| 1949 |
if ( count( $bookings_in_cell ) > 1 ) { |
| 1950 |
|
| 1951 |
if ( ! $this->is_bookings_use_check_in_out( $bookings_in_cell, $row_settings['bookings'] ) ) { |
| 1952 |
$bk_a_title__text = '<sup>[' . count( $bookings_in_cell ) . ']</sup> ' . $bk_a_title__text; |
| 1953 |
} else { |
| 1954 |
//return; // FixIn: 10.6.3.1. |
| 1955 |
} |
| 1956 |
|
| 1957 |
} |
| 1958 |
|
| 1959 |
|
| 1960 |
if ( ! $this->is_frontend ) { $line_separator = '<div class=\'clear\'></div>'; } |
| 1961 |
else { $line_separator = ''; } |
| 1962 |
$popup_title_arr = implode( $line_separator, $popup_title_arr ); |
| 1963 |
|
| 1964 |
$line_separator = ''; // '<hr class="wpbc_tl_popover_booking_separator" />'; |
| 1965 |
$popup_content_arr = implode( $line_separator, $popup_content_arr ); |
| 1966 |
|
| 1967 |
// Booking CELL Title |
| 1968 |
?><a href="javascript:void(0)" |
| 1969 |
class="<?php echo esc_attr( implode(' ', array( |
| 1970 |
'in_cell_date_booking_title', |
| 1971 |
( $is_show_popover_in_timeline ) ? 'popover_bottom' : '', |
| 1972 |
( $is_show_popover_in_timeline ) ? 'popover_click' : '', |
| 1973 |
( count( $bookings_in_cell ) > 1 ) ? 'several_bookings_in_cell' : '' |
| 1974 |
))); ?>" |
| 1975 |
<?php |
| 1976 |
// FixIn: 8.9.3.3. |
| 1977 |
if ( $is_show_popover_in_timeline ) { ?> |
| 1978 |
data-content="<?php echo esc_html( str_replace( '"', "", $popup_content_arr ) ); ?>" |
| 1979 |
data-original-title="<?php echo esc_html( str_replace( '"', "", $popup_title_arr ) ); ?>" |
| 1980 |
<?php } ?> |
| 1981 |
><?php |
| 1982 |
echo wp_kses_post( $bk_a_title__text ); |
| 1983 |
?></a><?php |
| 1984 |
} |
| 1985 |
|
| 1986 |
/** |
| 1987 |
* Check if some bookings used check in / out functionality |
| 1988 |
* |
| 1989 |
* @param $bookings_id_arr |
| 1990 |
* @param $bookings_obj_arr |
| 1991 |
* |
| 1992 |
* @return false |
| 1993 |
*/ |
| 1994 |
function is_bookings_use_check_in_out( $bookings_id_arr, $bookings_obj_arr ) { |
| 1995 |
|
| 1996 |
// ----------------------------------------------------------------------------------------------------- |
| 1997 |
// Is Check In/out ? |
| 1998 |
// ----------------------------------------------------------------------------------------------------- |
| 1999 |
$is_use_check_in_out_time = ( get_bk_option( 'booking_range_selection_time_is_active' ) == 'On' ); |
| 2000 |
|
| 2001 |
if ( $is_use_check_in_out_time ) { |
| 2002 |
foreach ( $bookings_id_arr as $booking_id ) { |
| 2003 |
|
| 2004 |
if ( isset( $bookings_obj_arr[ $booking_id ] ) ) { |
| 2005 |
foreach ( $bookings_obj_arr[ $booking_id ]->dates as $booking_date_obj ) { |
| 2006 |
$booking_date_ymdhis = $booking_date_obj->booking_date; |
| 2007 |
|
| 2008 |
$is_check_in_out__or_full = substr( $booking_date_ymdhis, - 1 ); // '1', '2' (not '0') |
| 2009 |
|
| 2010 |
if ( '1' === $is_check_in_out__or_full ) { |
| 2011 |
return true; |
| 2012 |
} |
| 2013 |
if ( '2' === $is_check_in_out__or_full ) { |
| 2014 |
return true; |
| 2015 |
} |
| 2016 |
} |
| 2017 |
} |
| 2018 |
} |
| 2019 |
} |
| 2020 |
return false; |
| 2021 |
} |
| 2022 |
|
| 2023 |
|
| 2024 |
/** |
| 2025 |
* Get array of CSS classes for booking bar |
| 2026 |
* @param int $booking_id |
| 2027 |
* @param array $bookings |
| 2028 |
* |
| 2029 |
* @return array |
| 2030 |
*/ |
| 2031 |
function get_booking_class_arr( $booking_id, $row_settings , $real_date, $time_hour ){ |
| 2032 |
|
| 2033 |
$bookings = $row_settings['bookings']; |
| 2034 |
|
| 2035 |
$class_arr = array(); |
| 2036 |
|
| 2037 |
if ( ( ! empty( $booking_id ) ) && isset( $bookings[ $booking_id ] ) ) { |
| 2038 |
|
| 2039 |
// Appoved | Pending |
| 2040 |
if ( count( $bookings[ $booking_id ]->dates ) > 0 ) { |
| 2041 |
$is_approved = $bookings[ $booking_id ]->dates[0]->approved; |
| 2042 |
} else { |
| 2043 |
$is_approved = 0; |
| 2044 |
} |
| 2045 |
$class_arr[] = $is_approved ? 'approved_booking' : 'pending_booking'; |
| 2046 |
|
| 2047 |
// ----------------------------------------------------------------------------------------------------- |
| 2048 |
// Is Check In/out ? |
| 2049 |
// ----------------------------------------------------------------------------------------------------- |
| 2050 |
$is_use_check_in_out_time = ( get_bk_option( 'booking_range_selection_time_is_active' ) == 'On' ); |
| 2051 |
$one_date__one_booking__check_in_out__arr = array(); |
| 2052 |
if ( |
| 2053 |
( $is_use_check_in_out_time ) |
| 2054 |
&& ( ( $row_settings['is_matrix'] ) || ( 30 != $row_settings['view_days_num'] ) ) |
| 2055 |
&& ( ( ! $row_settings['is_matrix'] ) || ( 1 != $row_settings['view_days_num'] ) ) |
| 2056 |
){ |
| 2057 |
$real_date_ymd = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); |
| 2058 |
foreach ( $bookings[ $booking_id ]->dates as $booking_date_obj ) { |
| 2059 |
$booking_date_ymdhis = $booking_date_obj->booking_date; |
| 2060 |
if ( substr( $booking_date_ymdhis, 0, 10 ) === $real_date_ymd ) { |
| 2061 |
$is_check_in_out__or_full = substr( $booking_date_ymdhis, -1 ); // '1', '2' (not '0') |
| 2062 |
|
| 2063 |
if ('1'=== $is_check_in_out__or_full ){ |
| 2064 |
$one_date__one_booking__check_in_out__arr[] = 'booking_check_in'; |
| 2065 |
} |
| 2066 |
if ('2'=== $is_check_in_out__or_full ){ |
| 2067 |
$one_date__one_booking__check_in_out__arr[] = 'booking_check_out'; |
| 2068 |
} |
| 2069 |
//break; |
| 2070 |
} |
| 2071 |
} |
| 2072 |
} |
| 2073 |
// If we have 2 or more like: [ 'booking_check_in', 'booking_check_out' ], in the same date for same booking, then it is time slots bookings |
| 2074 |
if ( count( $one_date__one_booking__check_in_out__arr ) == 1 ) { |
| 2075 |
$class_arr[] = $one_date__one_booking__check_in_out__arr[0]; |
| 2076 |
$class_arr[] = 'booking_change_over'; |
| 2077 |
} |
| 2078 |
if ( count( $one_date__one_booking__check_in_out__arr ) > 1 ) { |
| 2079 |
$class_arr[] = 'booking_time_slots'; |
| 2080 |
} |
| 2081 |
|
| 2082 |
// ----------------------------------------------------------------------------------------------------- |
| 2083 |
|
| 2084 |
if ( isset( $bookings[ $booking_id ]->trash ) ) { |
| 2085 |
$is_trash = $bookings[ $booking_id ]->trash; |
| 2086 |
} else { |
| 2087 |
$is_trash = false; |
| 2088 |
} |
| 2089 |
$class_arr[] = $is_trash ? 'booking_trash' : ''; |
| 2090 |
|
| 2091 |
///////////////////////////////////////////////////////////////// |
| 2092 |
|
| 2093 |
if ( ( isset( $bookings[ $booking_id ]->form_data['email'] ) ) |
| 2094 |
&& ( |
| 2095 |
( 'blank@wpbookingmanager.com' == $bookings[ $booking_id ]->form_data['email'] ) |
| 2096 |
|| ( 'admin@blank.com' == $bookings[ $booking_id ]->form_data['email'] ) |
| 2097 |
) |
| 2098 |
) { |
| 2099 |
$is_blank_bookings = true; |
| 2100 |
} else { |
| 2101 |
$is_blank_bookings = false; |
| 2102 |
} |
| 2103 |
$class_arr[] = $is_blank_bookings ? 'booking_blank' : ''; |
| 2104 |
|
| 2105 |
///////////////////////////////////////////////////////////////// |
| 2106 |
|
| 2107 |
if ( wpbc_datetime__no_wp_timezone( 'Y.m.d' ) > wpbc_datetime__no_wp_timezone( "Y.m.d", $real_date ) ) { |
| 2108 |
$class_arr[] = 'past_date'; |
| 2109 |
} |
| 2110 |
if ( wpbc_datetime__no_wp_timezone( 'Y.m.d' ) == wpbc_datetime__no_wp_timezone( "Y.m.d", $real_date ) ) { |
| 2111 |
$class_arr[] = 'today_date'; |
| 2112 |
} |
| 2113 |
|
| 2114 |
if ( $this->is_show_day_view( $row_settings ) ) { |
| 2115 |
if ( ( wpbc_datetime__no_wp_timezone( 'm.d.Y' ) == wpbc_datetime__no_wp_timezone( "m.d.Y", $real_date ) ) // Today Date |
| 2116 |
&& ( intval( wpbc_datetime__no_wp_timezone( 'H' ) ) > intval( $time_hour ) ) ) { |
| 2117 |
$class_arr[] = 'past_date'; |
| 2118 |
} |
| 2119 |
} |
| 2120 |
///////////////////////////////////////////////////////////////// |
| 2121 |
|
| 2122 |
$css_class_additional = apply_filters( 'wpbc_timeline_booking_header_css', '', $booking_id, $bookings ); // FixIn: 7.0.1.41. |
| 2123 |
$class_arr[] = $css_class_additional; |
| 2124 |
} |
| 2125 |
|
| 2126 |
// Remove empty values from array |
| 2127 |
$class_arr = array_filter( $class_arr ); |
| 2128 |
|
| 2129 |
return $class_arr; |
| 2130 |
} |
| 2131 |
|
| 2132 |
|
| 2133 |
/** |
| 2134 |
* Show Date cell :: 3 variants :: Date Number | Booking Pipeline | Booking Title |
| 2135 |
* @param $row_settings |
| 2136 |
*/ |
| 2137 |
private function show_day_cell( $row_settings ){ |
| 2138 |
|
| 2139 |
$data_in_previous_cell = $this->data_in_previous_cell; |
| 2140 |
|
| 2141 |
$yy = wpbc_datetime__no_wp_timezone( "Y", $row_settings[ 'real_date' ] ); // 2012 |
| 2142 |
$mm = wpbc_datetime__no_wp_timezone( "m", $row_settings[ 'real_date' ] ); // 09 |
| 2143 |
$dd = wpbc_datetime__no_wp_timezone( "d", $row_settings[ 'real_date' ] ); // 31 |
| 2144 |
$ww = wpbc_datetime__no_wp_timezone( "N", $row_settings[ 'real_date' ] ); // 7 |
| 2145 |
$day_week = $row_settings[ 'dwa' ][$ww]; // Su |
| 2146 |
|
| 2147 |
$row_settings['day_filter_id'] = $yy . '-' . $mm . '-' . $dd; |
| 2148 |
|
| 2149 |
|
| 2150 |
// <editor-fold defaultstate="collapsed" desc=" = $bookings_in_day_cell - Array of booking ID - Sorted by Time in this date cell = " > |
| 2151 |
|
| 2152 |
$bookings_in__times_arr = array(); |
| 2153 |
/** |
| 2154 |
* $bookings_in__times_arr = array( [0] => array( [0] => 918, [1] => 917 ), [3600] => array( [0] => 918 [1] => 917 ), ... |
| 2155 |
[82800] => Array ( |
| 2156 |
[0] => 918 |
| 2157 |
[1] => 917 |
| 2158 |
) |
| 2159 |
) |
| 2160 |
*/ |
| 2161 |
if ( ! empty ( $row_settings['time_array_new'][ $row_settings['day_filter_id'] ] ) ) { // $row_settings['time_array_new'][ '2019-07-19' ] |
| 2162 |
$bookings_in__times_arr = $row_settings['time_array_new'][ $row_settings['day_filter_id'] ]; |
| 2163 |
} |
| 2164 |
|
| 2165 |
$bookings_in_day_cell = array(); |
| 2166 |
if ( ! empty ( $bookings_in__times_arr ) ) { |
| 2167 |
foreach ( $bookings_in__times_arr as $times_milliseconds => $bookings_in_times_arr ) { |
| 2168 |
|
| 2169 |
foreach ( $bookings_in_times_arr as $booking_id_in_time_interval ) { |
| 2170 |
|
| 2171 |
if ( ! in_array( $booking_id_in_time_interval, $bookings_in_day_cell ) ) { |
| 2172 |
/** |
| 2173 |
* Array ( [0] => 15 [1] => 16 [2] => 13 [3] => 14 ) |
| 2174 |
*/ |
| 2175 |
$bookings_in_day_cell[] = $booking_id_in_time_interval; |
| 2176 |
} |
| 2177 |
} |
| 2178 |
} |
| 2179 |
} |
| 2180 |
// </editor-fold> |
| 2181 |
|
| 2182 |
//debuge($bookings_in__times_arr); |
| 2183 |
// <editor-fold defaultstate="collapsed" desc=" = $cell_css[] - Define CSS classes of day cell = " > |
| 2184 |
|
| 2185 |
$cell_css = array(); |
| 2186 |
$cell_css[] = 'flex_tl_day_cell'; |
| 2187 |
$cell_css[] = 'flex_tl_weekday' . $ww; |
| 2188 |
$cell_css[] = $row_settings['day_filter_id']; |
| 2189 |
|
| 2190 |
if ( wpbc_datetime__no_wp_timezone( 'm.d.Y' ) == wpbc_datetime__no_wp_timezone( "m.d.Y", $row_settings['real_date'] ) ) { |
| 2191 |
$cell_css[] = 'today_date'; |
| 2192 |
} else if ( wpbc_datetime__no_wp_timezone( 'Y.m.d' ) > wpbc_datetime__no_wp_timezone( "Y.m.d", $row_settings['real_date'] ) ) { |
| 2193 |
$cell_css[] = 'past_date'; |
| 2194 |
} |
| 2195 |
|
| 2196 |
if ( ( $data_in_previous_cell['previous_month'] != $mm ) || ( 1 == $dd ) ) { |
| 2197 |
|
| 2198 |
$data_in_previous_cell['previous_month'] = $mm; |
| 2199 |
$cell_css[] = 'new_month'; |
| 2200 |
} |
| 2201 |
|
| 2202 |
if ( ! empty( $bookings_in_day_cell ) ) { |
| 2203 |
$cell_css[] = 'exist_booking_in_cell'; |
| 2204 |
} else { |
| 2205 |
$cell_css[] = 'no_booking_in_cell'; |
| 2206 |
} |
| 2207 |
|
| 2208 |
// </editor-fold> |
| 2209 |
|
| 2210 |
|
| 2211 |
?><div id="cell_<?php echo esc_attr( $row_settings[ 'current_resource_id' ] . '_' . $row_settings['day_filter_id'] ); ?>" |
| 2212 |
class="<?php echo esc_attr( implode(' ', $cell_css ) ); ?>" |
| 2213 |
><?php |
| 2214 |
|
| 2215 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 2216 |
// T i m e c e l l s |
| 2217 |
//////////////////////////////////////////////////////////////////////////////////////// |
| 2218 |
$time_selles_num = $row_settings['time_selles_num']; |
| 2219 |
$tm = floor( 24 / $time_selles_num ); |
| 2220 |
|
| 2221 |
|
| 2222 |
?><div class="<?php echo esc_attr(implode(' ', array( |
| 2223 |
'in_cell_time_section_in_day', |
| 2224 |
'flex_time_section_in_day_booking', |
| 2225 |
'flex_time_in_days_num_' . $row_settings['view_days_num'] |
| 2226 |
)) ); ?>" |
| 2227 |
><?php |
| 2228 |
|
| 2229 |
for ( $tt = 0; $tt < $time_selles_num; $tt++ ) { |
| 2230 |
|
| 2231 |
// Get bookings for time-slot |
| 2232 |
if ( $this->is_show_day_view( $row_settings ) ) { |
| 2233 |
|
| 2234 |
$time_ms = $tt * 60 * 60; |
| 2235 |
$bookings_in_this_time_arr = empty( $bookings_in__times_arr[ $time_ms ] ) ? array() : $bookings_in__times_arr[ $time_ms ]; |
| 2236 |
$is_start_new_booking = $this->is_start_new_booking_cell( $bookings_in_this_time_arr, $data_in_previous_cell['bookings_in_cell'] ); |
| 2237 |
$is_start_new_booking2 = $this->is_start_new_booking_cell2( $bookings_in_this_time_arr, $data_in_previous_cell['bookings_in_cell'] ); |
| 2238 |
|
| 2239 |
$bookings_in_day_cell = $bookings_in_this_time_arr; |
| 2240 |
|
| 2241 |
} else { // Get bookings for a day |
| 2242 |
|
| 2243 |
$is_start_new_booking = $this->is_start_new_booking_cell( $bookings_in_day_cell, $data_in_previous_cell['bookings_in_cell'] ); |
| 2244 |
$is_start_new_booking2 = $this->is_start_new_booking_cell2( $bookings_in_day_cell, $data_in_previous_cell['bookings_in_cell'] ); |
| 2245 |
|
| 2246 |
} |
| 2247 |
|
| 2248 |
// Skip timeslots for day view |
| 2249 |
if ( $this->is_show_day_view( $row_settings ) ) { |
| 2250 |
if ( ( $tt < $row_settings['start_hour_for_1day_view'] ) || ( $tt > $row_settings['end_hour_for_1day_view'] ) ) { |
| 2251 |
continue; |
| 2252 |
} |
| 2253 |
} |
| 2254 |
|
| 2255 |
|
| 2256 |
$today_time_css_class=''; // FixIn: 10.0.0.40. |
| 2257 |
if ( wpbc_datetime__use_wp_timezone( 'Y.m.d' ) == wpbc_datetime__use_wp_timezone( "Y.m.d", $row_settings[ 'real_date' ] ) ) { |
| 2258 |
if ( $this->is_show_day_view( $row_settings ) ) { |
| 2259 |
if ( ( wpbc_datetime__use_wp_timezone( 'm.d.Y' ) == wpbc_datetime__use_wp_timezone( "m.d.Y", $row_settings[ 'real_date' ] ) ) // Today Date |
| 2260 |
&& ( intval( wpbc_datetime__use_wp_timezone( 'H' ) ) == intval( $tt ) ) ) { |
| 2261 |
$today_time_css_class = 'today_time'; |
| 2262 |
} |
| 2263 |
} |
| 2264 |
|
| 2265 |
} |
| 2266 |
|
| 2267 |
?><div class="<?php echo esc_attr( 'in_cell_time_hour time_hour' . ( $tt * $tm ) . ' ' . $today_time_css_class ); ?>" ><?php |
| 2268 |
|
| 2269 |
if ( 'show_dates' == $row_settings['what_to_show'] ) { |
| 2270 |
|
| 2271 |
?> |
| 2272 |
<div class="in_cell_date_container in_cell_date_container_<?php echo esc_attr( $row_settings['what_to_show'] ); ?>"><?php |
| 2273 |
//if ( empty( $bookings_in_day_cell ) ) { |
| 2274 |
if ( $this->is_show_day_view( $row_settings ) ) { |
| 2275 |
$this->show_time_number_in_correct_format( $tt * $tm , $row_settings['view_days_num'] ); |
| 2276 |
} else { |
| 2277 |
echo esc_html( $dd ); |
| 2278 |
} |
| 2279 |
//} |
| 2280 |
?></div><?php |
| 2281 |
} |
| 2282 |
|
| 2283 |
|
| 2284 |
if ( 'show_bookings' == $row_settings['what_to_show'] ) { |
| 2285 |
|
| 2286 |
if ( ! empty( $bookings_in_day_cell ) ) { |
| 2287 |
|
| 2288 |
$booking_id_title = array(); |
| 2289 |
|
| 2290 |
?> |
| 2291 |
<div class="in_cell_date_container in_cell_date_container_<?php echo esc_attr( $row_settings['what_to_show'] ); |
| 2292 |
|
| 2293 |
// FixIn: 10.5.0.1. |
| 2294 |
if (count($bookings_in_day_cell)>1){ |
| 2295 |
echo ' in_cell_date_container_has_several_bookings '; |
| 2296 |
} |
| 2297 |
|
| 2298 |
?>"><?php |
| 2299 |
|
| 2300 |
foreach ( $bookings_in_day_cell as $booking_id ) { |
| 2301 |
|
| 2302 |
$booking_css_class_arr = $this->get_booking_class_arr( $booking_id, $row_settings, $row_settings['real_date'], $tt ); |
| 2303 |
|
| 2304 |
if ( ! in_array( 'booking_change_over', $booking_css_class_arr ) ) { |
| 2305 |
if ( $is_start_new_booking2 ) { |
| 2306 |
$booking_css_class_arr[] = 'start_new_booking'; |
| 2307 |
} |
| 2308 |
} |
| 2309 |
|
| 2310 |
?> |
| 2311 |
<div class="<?php echo esc_attr( implode( ' ', array( |
| 2312 |
'booking_id', |
| 2313 |
'booking_id_' . $booking_id, |
| 2314 |
//$is_start_new_booking ? 'start_new_booking' : '', |
| 2315 |
) ) ); |
| 2316 |
echo ' ' . esc_attr( implode( ' ', $booking_css_class_arr ) ); |
| 2317 |
?>" |
| 2318 |
><?php |
| 2319 |
|
| 2320 |
// Booking CELL background |
| 2321 |
$this->show_booking_title_for_pipeline_bar( $booking_id, $row_settings ); // Title, when mouse-over booking Pipeline (bar with background) |
| 2322 |
|
| 2323 |
?></div><?php |
| 2324 |
} |
| 2325 |
?></div><?php |
| 2326 |
} |
| 2327 |
} |
| 2328 |
|
| 2329 |
|
| 2330 |
if ( 'show_booking_titles' == $row_settings['what_to_show'] ) { |
| 2331 |
|
| 2332 |
if ( ! empty( $bookings_in_day_cell ) ) { |
| 2333 |
|
| 2334 |
// Title of new booking(s) |
| 2335 |
if ( $is_start_new_booking ) { |
| 2336 |
|
| 2337 |
?><div class="<?php echo esc_attr( implode( ' ', array( |
| 2338 |
'in_cell_date_container', |
| 2339 |
'in_cell_date_container_booking_id_title', |
| 2340 |
'in_cell_date_container_' . $row_settings['what_to_show'] |
| 2341 |
) ) ); |
| 2342 |
echo esc_attr( ' booking_id_' . implode( '_', $bookings_in_day_cell ) ); |
| 2343 |
?>" |
| 2344 |
><?php |
| 2345 |
|
| 2346 |
$this->show_booking_title_for_timeline( $bookings_in_day_cell, $row_settings ); |
| 2347 |
|
| 2348 |
?></div><?php |
| 2349 |
} |
| 2350 |
} |
| 2351 |
} |
| 2352 |
|
| 2353 |
?></div><?php |
| 2354 |
|
| 2355 |
$data_in_previous_cell['bookings_in_cell'] = $bookings_in_day_cell; |
| 2356 |
} |
| 2357 |
|
| 2358 |
?></div><?php |
| 2359 |
|
| 2360 |
?></div><?php |
| 2361 |
|
| 2362 |
|
| 2363 |
$this->data_in_previous_cell = $data_in_previous_cell; |
| 2364 |
} |
| 2365 |
|
| 2366 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2367 |
// Booking R O W |
| 2368 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2369 |
|
| 2370 |
/** Row */ |
| 2371 |
public function wpbc_show_timeline_booking_row( $start_date, $booking_arr = array() ) { |
| 2372 |
|
| 2373 |
$row_settings = array( 'start_date' => $start_date ); |
| 2374 |
|
| 2375 |
$row_settings = $this->get_init_row_settings( $row_settings ); |
| 2376 |
|
| 2377 |
if ( $row_settings['start_date'] !== false ) { |
| 2378 |
list( $start_year, $start_month, $start_day ) = explode( '-', wpbc_datetime__no_wp_timezone( 'Y-m-d', $row_settings['start_date'] ) ); |
| 2379 |
} else { |
| 2380 |
if ( ! empty( $this->request_args['scroll_start_date'] ) ) |
| 2381 |
list( $start_year, $start_month, $start_day ) = explode( '-', $this->request_args['scroll_start_date'] ); // scroll_start_date=2013-07-01 |
| 2382 |
else |
| 2383 |
list( $start_year, $start_month, $start_day ) = explode( '-', wpbc_datetime__no_wp_timezone( 'Y-n-j' ) ); |
| 2384 |
} |
| 2385 |
|
| 2386 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2387 |
// Dates / Times Line |
| 2388 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2389 |
|
| 2390 |
$this->data_in_previous_cell['previous_booking_id'] = false; |
| 2391 |
|
| 2392 |
$saved_previos_data_cell = $this->data_in_previous_cell; |
| 2393 |
|
| 2394 |
foreach ( array( 'show_dates', 'show_bookings', 'show_booking_titles' ) as $what_to_show ) { |
| 2395 |
|
| 2396 |
$this->data_in_previous_cell = $saved_previos_data_cell; |
| 2397 |
|
| 2398 |
?><div id="flex_resource_row_<?php echo esc_attr( $what_to_show . '_' . $booking_arr['current_resource_id'] ); ?>" |
| 2399 |
class="<?php echo esc_attr( implode(' ', array( |
| 2400 |
'flex_tl_dates_bar', 'flex_tl_row_height', |
| 2401 |
'flex_tl_row_bar_' . $what_to_show , |
| 2402 |
$row_settings['is_matrix'] ? 'flex_tl_matrix_resources' : 'flex_tl_single_resource' |
| 2403 |
) ) ); ?>" |
| 2404 |
><?php |
| 2405 |
|
| 2406 |
for ( $d_inc = 0; $d_inc < $row_settings['days_num']; $d_inc ++ ) { |
| 2407 |
|
| 2408 |
$row_settings['real_date'] = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) ), intval( $start_year ) ); |
| 2409 |
|
| 2410 |
$day_cell_params = array_merge( $row_settings, $booking_arr ); |
| 2411 |
|
| 2412 |
$day_cell_params['what_to_show'] = $what_to_show; |
| 2413 |
|
| 2414 |
$this->show_day_cell( $day_cell_params ); |
| 2415 |
} |
| 2416 |
|
| 2417 |
?></div><?php |
| 2418 |
} |
| 2419 |
} |
| 2420 |
|
| 2421 |
|
| 2422 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2423 |
// Timeline |
| 2424 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2425 |
|
| 2426 |
/** Show Structure of the TimeLine */ |
| 2427 |
public function wpbc_show_timeline( $dates_array, $bookings, $booking_types, $time_array_new = array() ){ |
| 2428 |
|
| 2429 |
// Skip showing rows of booking resource(s) in TimeLine or Calendar Overview, if no any exist booking(s) for current view |
| 2430 |
$booked_booking_resources = array(); //FixIn: 7.0.1.51 |
| 2431 |
if ( ! empty( $this->request_args['only_booked_resources'] ) ) { |
| 2432 |
|
| 2433 |
foreach ( $bookings as $single_booking ) { |
| 2434 |
|
| 2435 |
if ( ! empty( $single_booking->booking_type ) ) |
| 2436 |
$booked_booking_resources[] = $single_booking->booking_type; |
| 2437 |
|
| 2438 |
foreach ( $single_booking->dates as $booking_date_obj ) { |
| 2439 |
if ( ( isset( $booking_date_obj->type_id ) ) && ( ! empty( $booking_date_obj->type_id ) ) ) |
| 2440 |
$booked_booking_resources[] = $booking_date_obj->type_id; |
| 2441 |
} |
| 2442 |
} |
| 2443 |
$booked_booking_resources = array_unique( $booked_booking_resources ); |
| 2444 |
} |
| 2445 |
|
| 2446 |
$view_days_num = $this->request_args['view_days_num']; // Get start date and number of rows, which is depend from the view days mode |
| 2447 |
$is_matrix = $this->request_args['is_matrix']; |
| 2448 |
$scroll_day = 0; |
| 2449 |
$scroll_month = 0; |
| 2450 |
$start_year = wpbc_datetime__no_wp_timezone( "Y" ); |
| 2451 |
$start_month = wpbc_datetime__no_wp_timezone( "m" ); // 09 |
| 2452 |
|
| 2453 |
if ( ! empty( $this->request_args['scroll_start_date'] ) ) { // scroll_start_date=2013-07-01 |
| 2454 |
// Set the correct start date, if was selected the stard date different from the today in the Filters Tab. |
| 2455 |
list( $start_year, $start_month, $start_day ) = explode( '-', $this->request_args['scroll_start_date'] ); |
| 2456 |
} |
| 2457 |
|
| 2458 |
//////////////////////////////////////////////////////////////////////// |
| 2459 |
// Get Start Date and Scroll Day/Month Variables |
| 2460 |
//////////////////////////////////////////////////////////////////////// |
| 2461 |
if ( $is_matrix ) { // MATRIX VIEW |
| 2462 |
|
| 2463 |
$bk_resources_id = explode( ',', $this->request_args['wh_booking_type'] ); |
| 2464 |
$max_rows_number = count( $bk_resources_id ); |
| 2465 |
|
| 2466 |
switch ( $view_days_num ) { |
| 2467 |
case '1': |
| 2468 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 2469 |
$scroll_day = $this->request_args['scroll_day']; |
| 2470 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2471 |
$start_day = wpbc_datetime__no_wp_timezone( "d" ); // FixIn: 7.0.1.13. |
| 2472 |
break; |
| 2473 |
|
| 2474 |
case '30': |
| 2475 |
case '60': |
| 2476 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 2477 |
$scroll_month = $this->request_args['scroll_month']; |
| 2478 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2479 |
$start_day = 1; |
| 2480 |
break; |
| 2481 |
|
| 2482 |
case '7': // 7 Week - start from Monday (or other start week day) |
| 2483 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 2484 |
$scroll_day = $this->request_args['scroll_day']; |
| 2485 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2486 |
$start_day = wpbc_datetime__no_wp_timezone( "d" ); |
| 2487 |
$start_week_day_num = wpbc_datetime__no_wp_timezone( "w" ); |
| 2488 |
$start_day_weeek = esc_js(get_bk_option( 'booking_start_day_weeek' )); //[0]:Sun .. [6]:Sut |
| 2489 |
|
| 2490 |
if ( $start_week_day_num != $start_day_weeek ) { |
| 2491 |
for ( $d_inc = 1; $d_inc < 8; $d_inc++ ) { // Just get week back |
| 2492 |
|
| 2493 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) - intval( $d_inc ) ), intval( $start_year ) ); |
| 2494 |
|
| 2495 |
$start_week_day_num = wpbc_datetime__no_wp_timezone( "w", $real_date ); |
| 2496 |
if ( $start_week_day_num == $start_day_weeek ) { |
| 2497 |
$start_day = wpbc_datetime__no_wp_timezone( "d", $real_date ); |
| 2498 |
$start_year = wpbc_datetime__no_wp_timezone( "Y", $real_date ); |
| 2499 |
$start_month = wpbc_datetime__no_wp_timezone( "m", $real_date ); |
| 2500 |
$d_inc = 9; |
| 2501 |
} |
| 2502 |
} |
| 2503 |
} |
| 2504 |
break; |
| 2505 |
|
| 2506 |
default: //30 |
| 2507 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 2508 |
$scroll_month = $this->request_args['scroll_month']; |
| 2509 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2510 |
$start_day = 1; |
| 2511 |
break; |
| 2512 |
} |
| 2513 |
|
| 2514 |
} else { // SINGLE Resource VIEW |
| 2515 |
|
| 2516 |
switch ( $view_days_num ) { |
| 2517 |
case '90': |
| 2518 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 2519 |
$scroll_day = $this->request_args['scroll_day']; |
| 2520 |
else |
| 2521 |
$scroll_day = 0; |
| 2522 |
|
| 2523 |
$max_rows_number = 12; |
| 2524 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2525 |
$start_day = wpbc_datetime__no_wp_timezone( "d" ); |
| 2526 |
$start_week_day_num = wpbc_datetime__no_wp_timezone( "w" ); |
| 2527 |
$start_day_weeek = esc_js(get_bk_option( 'booking_start_day_weeek' )); //[0]:Sun .. [6]:Sut |
| 2528 |
|
| 2529 |
if ( $start_week_day_num != $start_day_weeek ) { |
| 2530 |
for ( $d_inc = 1; $d_inc < 8; $d_inc++ ) { // Just get week back |
| 2531 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) - intval( $d_inc ) ), intval( $start_year ) ); |
| 2532 |
|
| 2533 |
$start_week_day_num = wpbc_datetime__no_wp_timezone( "w", $real_date ); |
| 2534 |
if ( $start_week_day_num == $start_day_weeek ) { |
| 2535 |
$start_day = wpbc_datetime__no_wp_timezone( "d", $real_date ); |
| 2536 |
$start_year = wpbc_datetime__no_wp_timezone( "Y", $real_date ); |
| 2537 |
$start_month = wpbc_datetime__no_wp_timezone( "m", $real_date ); |
| 2538 |
$d_inc = 9; |
| 2539 |
} |
| 2540 |
} |
| 2541 |
} |
| 2542 |
break; |
| 2543 |
|
| 2544 |
case '365': |
| 2545 |
if ( isset( $this->request_args['scroll_month'] ) ) |
| 2546 |
$scroll_month = $this->request_args['scroll_month']; |
| 2547 |
else |
| 2548 |
$scroll_month = 0; |
| 2549 |
$max_rows_number = 12; |
| 2550 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2551 |
$start_day = 1; |
| 2552 |
break; |
| 2553 |
|
| 2554 |
default: // 30 |
| 2555 |
if ( isset( $this->request_args['scroll_day'] ) ) |
| 2556 |
$scroll_day = $this->request_args['scroll_day']; |
| 2557 |
else |
| 2558 |
$scroll_day = 0; |
| 2559 |
|
| 2560 |
// FixIn: 8.9.4.3. |
| 2561 |
if ( $this->is_frontend ) { |
| 2562 |
$max_rows_number = intval( get_bk_option( 'booking_timeline__month_mode__days_number_show' ) ); |
| 2563 |
} else { |
| 2564 |
$max_rows_number = intval( get_bk_option( 'booking_calendar_overview__day_mode__days_number_show' ) );; |
| 2565 |
} |
| 2566 |
if (empty($max_rows_number)) { |
| 2567 |
$max_rows_number = 31; |
| 2568 |
} |
| 2569 |
|
| 2570 |
if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2571 |
$start_day = wpbc_datetime__no_wp_timezone( "d" ); // FixIn: 7.0.1.13. |
| 2572 |
break; |
| 2573 |
} |
| 2574 |
} |
| 2575 |
|
| 2576 |
//////////////////////////////////////////////////////////////////////////////////////////////// |
| 2577 |
|
| 2578 |
// FixIn: 10.0.0.25. |
| 2579 |
if ( ! $this->is_frontend ){ |
| 2580 |
$this->show_timeline_header_start__admin_panel(); |
| 2581 |
} |
| 2582 |
// New Spinner Loader // FixIn: 10.0.0.25. |
| 2583 |
?><div class="flex_tl_table_loading wpbc_spins_loading_container"> |
| 2584 |
<div class="wpbc_booking_form_spin_loader"><div class="wpbc_spins_loader_wrapper"><div class="wpbc_spin_loader_one_new"></div></div></div> |
| 2585 |
<?php // echo '<span class="0glyphicon 0glyphicon-refresh wpbc_icn_autorenew wpbc_spin"></span>' ?> |
| 2586 |
<span><?php esc_html_e('Loading','booking'); ?>...</span> |
| 2587 |
</div><?php |
| 2588 |
|
| 2589 |
|
| 2590 |
?><div class="flex_timeline_frame<?php |
| 2591 |
if ( $this->is_frontend ) echo ' wpbc_timeline_front_end' ?> flex_frame_view_days_num_<?php echo esc_attr( $view_days_num ); |
| 2592 |
if ($is_matrix) { echo ' flex_tl_matrix_resources '; } else { echo ' flex_tl_single_resource '; } |
| 2593 |
?>"> |
| 2594 |
<div class="flex_tl_table"> |
| 2595 |
<div class="flex_tl_table_header" style="<?php if ( ! $this->is_frontend ) { echo 'display:none;'; /* //FixIn: 10.0.0.25 */ } ?>"> |
| 2596 |
<?php |
| 2597 |
if ( $this->is_frontend ) { |
| 2598 |
?><div class="flex_tl_collumn_2"><?php |
| 2599 |
|
| 2600 |
$title = wpbc_lang( $this->timeline_titles['header_title'] ); |
| 2601 |
|
| 2602 |
$params_nav = array(); |
| 2603 |
$params_nav['title'] = $title; |
| 2604 |
$this->client_navigation( $params_nav ); |
| 2605 |
|
| 2606 |
?></div><?php |
| 2607 |
|
| 2608 |
} else { |
| 2609 |
?> |
| 2610 |
<div class="flex_tl_collumn_1"><?php |
| 2611 |
$title = wpbc_lang( $this->timeline_titles['header_column1'] ); |
| 2612 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2613 |
echo $title; // Resources . |
| 2614 |
?></div> |
| 2615 |
<div class="flex_tl_collumn_2"><?php |
| 2616 |
$title = wpbc_lang( $this->timeline_titles['header_column2'] ); |
| 2617 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2618 |
echo $title; // Dates. |
| 2619 |
?></div> |
| 2620 |
<?php } ?> |
| 2621 |
</div><?php |
| 2622 |
|
| 2623 |
?><div class="flex_tl__scrolling_sections"><?php |
| 2624 |
?><div class="flex_tl__scrolling_section1"> |
| 2625 |
<div class="flex_tl_table_titles"><div class="flex_tl_collumn_1"></div></div><?php |
| 2626 |
for ( $d_inc = 0; $d_inc < $max_rows_number; $d_inc++ ) { |
| 2627 |
|
| 2628 |
// Skip showing rows of booking resource(s) in TimeLine or Calendar Overview, if no any exist booking(s) for current view |
| 2629 |
if ( ! empty( $this->request_args['only_booked_resources'] ) ) { |
| 2630 |
|
| 2631 |
$resource_id = ( $is_matrix ) ? $bk_resources_id[ $d_inc ] : $this->request_args['wh_booking_type']; |
| 2632 |
|
| 2633 |
if ( ! in_array( $resource_id, $booked_booking_resources ) ) { continue; } |
| 2634 |
} |
| 2635 |
|
| 2636 |
// Ger Start Date to real_date variable |
| 2637 |
$real_date = $this->get_start_day__to_real_date( array( 'is_matrix' => $is_matrix, 'view_days_num' => $view_days_num, 'start_month' => $start_month, 'start_day' => $start_day, 'start_year' => $start_year, 'scroll_month' => $scroll_month, 'scroll_day' => $scroll_day, 'd_inc' => $d_inc ) ); |
| 2638 |
|
| 2639 |
?><div class="flex_tl_table_row_bookings"> |
| 2640 |
<div class="flex_tl_collumn_1"><?php |
| 2641 |
|
| 2642 |
// Title in first column of each row in calendar |
| 2643 |
if ( ( $is_matrix ) && ( isset( $bk_resources_id[$d_inc] ) ) && (isset( $booking_types[$bk_resources_id[$d_inc]] )) ) { // Matrix - resource titles |
| 2644 |
|
| 2645 |
$resource_value = $booking_types[$bk_resources_id[$d_inc]]; |
| 2646 |
$bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), array( 'wh_booking_type' ) ); |
| 2647 |
|
| 2648 |
?><div class="flex_tl_resource_title flex_tl_row_height <?php |
| 2649 |
if ( isset( $resource_value->parent ) ) { if ( $resource_value->parent == 0 ) { echo 'parent'; } else { echo 'child'; } } |
| 2650 |
?> "><?php |
| 2651 |
if ( $this->is_frontend ) { |
| 2652 |
|
| 2653 |
if ( ( isset( $this->options['resource_link'] ) ) && ( isset( $this->options['resource_link'][ $resource_value->booking_type_id ] ) ) ){ // FixIn: 7.0.1.50. |
| 2654 |
|
| 2655 |
?><a href="<?php echo esc_url( $this->options['resource_link'][ $resource_value->booking_type_id ] ); ?>" ><?php // FixIn: 7.2.1.14. |
| 2656 |
} |
| 2657 |
|
| 2658 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2659 |
echo wpbc_lang( $resource_value->title ); // FixIn: 7.0.1.11. |
| 2660 |
|
| 2661 |
if ( ( isset( $this->options['resource_link'] ) ) && ( isset( $this->options['resource_link'][ $resource_value->booking_type_id ] ) ) ){ // FixIn: 7.0.1.50. |
| 2662 |
?></a><?php |
| 2663 |
} |
| 2664 |
} else { |
| 2665 |
?><a href="<?php echo esc_url( $bk_admin_url . '&wh_booking_type=' . $bk_resources_id[$d_inc] ); ?>" |
| 2666 |
title="<?php echo esc_attr( wpbc_lang( $resource_value->title ) ); ?>" |
| 2667 |
><?php |
| 2668 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2669 |
echo wpbc_lang( $resource_value->title ); |
| 2670 |
?></a><?php |
| 2671 |
} |
| 2672 |
?></div><?php |
| 2673 |
|
| 2674 |
} else { // Single Resource - Dates titles |
| 2675 |
|
| 2676 |
?><div class="flex_tl_resource_title flex_tl_row_height"><?php |
| 2677 |
|
| 2678 |
switch ( $view_days_num ) { |
| 2679 |
case '90': |
| 2680 |
$end_real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) * 7 + intval( $scroll_day ) ) + 6, intval( $start_year ) ); |
| 2681 |
$date_format = ' j, Y'; //get_bk_option( 'booking_date_format'); |
| 2682 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2683 |
echo wpbc_datetime__no_wp_timezone( "M", $real_date ) . wpbc_datetime__no_wp_timezone( $date_format, $real_date ) . ' - ' . wpbc_datetime__no_wp_timezone( "M", $end_real_date ) . wpbc_datetime__no_wp_timezone( $date_format, $end_real_date ); |
| 2684 |
break; |
| 2685 |
|
| 2686 |
case '365': |
| 2687 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2688 |
echo wpbc_datetime__no_wp_timezone( "F", $real_date ) . ', ' . wpbc_datetime__no_wp_timezone( "Y", $real_date ); |
| 2689 |
break; |
| 2690 |
|
| 2691 |
default: // 30 |
| 2692 |
//$date_format = 'd / m / Y'; |
| 2693 |
$date_format = get_bk_option( 'booking_date_format' ); // FixIn: 5.4.5.13. |
| 2694 |
$ww = wpbc_datetime__no_wp_timezone( "N", $real_date ); //7 |
| 2695 |
?> |
| 2696 |
<div class="flex_tl_resource_title_dates_container"> |
| 2697 |
<div class="flex_tl_resource_title_dates_days flex_tl_weekday<?php echo esc_attr( $ww ); ?>"><?php |
| 2698 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2699 |
echo wpbc_datetime__no_wp_timezone( $date_format, $real_date ); ?></div> |
| 2700 |
<div class="flex_tl_resource_title_dates_weeks flex_tl_weekday<?php echo esc_attr( $ww ); ?>"><?php |
| 2701 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2702 |
echo wpbc_datetime__no_wp_timezone( "D", $real_date ); ?></div> |
| 2703 |
</div> |
| 2704 |
<?php |
| 2705 |
break; |
| 2706 |
} |
| 2707 |
|
| 2708 |
?></div><?php |
| 2709 |
} |
| 2710 |
?> |
| 2711 |
</div> |
| 2712 |
</div><?php |
| 2713 |
} |
| 2714 |
|
| 2715 |
|
| 2716 |
?></div><?php |
| 2717 |
?><div class="flex_tl__scrolling_section2"> |
| 2718 |
<div class="flex_tl_table_titles flex_tl_row_max_width"> |
| 2719 |
<div class="flex_tl_collumn_2"><?php |
| 2720 |
// Header above the calendar table |
| 2721 |
$real_date = mktime( 0, 0, 0, intval( $start_month ), intval( $start_day ), intval( $start_year ) ); |
| 2722 |
|
| 2723 |
// Ger Start Date to real_date variable |
| 2724 |
$real_date = $this->get_start_day__to_real_date( array( 'is_matrix' => $is_matrix, 'view_days_num' => $view_days_num, 'start_month' => $start_month, 'start_day' => $start_day, 'start_year' => $start_year, 'scroll_month' => $scroll_month, 'scroll_day' => $scroll_day, 'd_inc' => $d_inc ) ); |
| 2725 |
|
| 2726 |
$this->wpbc_show_timeline_header_row( $real_date ); |
| 2727 |
?> |
| 2728 |
</div> |
| 2729 |
</div><?php |
| 2730 |
|
| 2731 |
for ( $d_inc = 0; $d_inc < $max_rows_number; $d_inc++ ) { |
| 2732 |
|
| 2733 |
// Skip showing rows of booking resource(s) in TimeLine or Calendar Overview, if no any exist booking(s) for current view |
| 2734 |
if ( ! empty( $this->request_args['only_booked_resources'] ) ) { |
| 2735 |
|
| 2736 |
$resource_id = ( $is_matrix ) ? $bk_resources_id[ $d_inc ] : $this->request_args['wh_booking_type']; |
| 2737 |
|
| 2738 |
if ( ! in_array( $resource_id, $booked_booking_resources ) ) { continue; } |
| 2739 |
} |
| 2740 |
|
| 2741 |
// Ger Start Date to real_date variable |
| 2742 |
$real_date = $this->get_start_day__to_real_date( array( 'is_matrix' => $is_matrix, 'view_days_num' => $view_days_num, 'start_month' => $start_month, 'start_day' => $start_day, 'start_year' => $start_year, 'scroll_month' => $scroll_month, 'scroll_day' => $scroll_day, 'd_inc' => $d_inc ) ); |
| 2743 |
|
| 2744 |
?> |
| 2745 |
<div class="flex_tl_table_row_bookings flex_tl_row_max_width"> |
| 2746 |
|
| 2747 |
<div class="flex_tl_collumn_2"><?php |
| 2748 |
|
| 2749 |
if ( $is_matrix ) { |
| 2750 |
|
| 2751 |
$this->reset_data_in_previous_cell(); |
| 2752 |
|
| 2753 |
$resource_id = $bk_resources_id[ $d_inc ]; |
| 2754 |
|
| 2755 |
} else { |
| 2756 |
$resource_id = $this->request_args['wh_booking_type']; |
| 2757 |
} // Request from GET or REQUEST |
| 2758 |
|
| 2759 |
$booking_arr = array( |
| 2760 |
'current_resource_id' => ( ( ! empty( $resource_id ) ) ? $resource_id : 1 ), // Remove dates and Times from the arrays, which is not belong to the $booking_arr['current_resource_id'] We do not remove it only, when the $booking_arr['current_resource_id'] - is empty - OLD ALL Resources VIEW |
| 2761 |
'booked_dates_array' => $dates_array, |
| 2762 |
'bookings' => $bookings, |
| 2763 |
'booking_types' => $booking_types, |
| 2764 |
'time_array_new' => $time_array_new |
| 2765 |
); |
| 2766 |
|
| 2767 |
/** |
| 2768 |
* FROM: [2019-07-19] => Array ( [0] => Array ( |
| 2769 |
* [id] => 19 |
| 2770 |
[resource] => 3 |
| 2771 |
) |
| 2772 |
[1] => Array ( |
| 2773 |
[id] => 19 |
| 2774 |
[resource] => 3 |
| 2775 |
), .... |
| 2776 |
* TO |
| 2777 |
* |
| 2778 |
* [2019-07-19] => Array ( |
| 2779 |
* [0] => 19 |
| 2780 |
* [1] => 19 |
| 2781 |
* [2] => 18 |
| 2782 |
* [3] => 18 ... |
| 2783 |
*/ |
| 2784 |
$booking_arr['booked_dates_array'] = $this->wpbc_dates_only_of_specific_resource( |
| 2785 |
$booking_arr['booked_dates_array'], |
| 2786 |
$booking_arr['current_resource_id'], |
| 2787 |
$booking_arr['bookings'] |
| 2788 |
); |
| 2789 |
/** |
| 2790 |
* FROM: [2019-07-19] => Array ( ... , [28800] => Array( |
| 2791 |
[0] => Array ( |
| 2792 |
[id] => 15 |
| 2793 |
[resource] => 3 |
| 2794 |
) |
| 2795 |
[1] => Array ( |
| 2796 |
[id] => 16 |
| 2797 |
[resource] => 3 |
| 2798 |
) |
| 2799 |
[2] => Array ( |
| 2800 |
[id] => 13 |
| 2801 |
[resource] => 3 |
| 2802 |
) .... |
| 2803 |
* TO |
| 2804 |
* [2019-07-19] => Array ( ... , [28800] => Array( |
| 2805 |
[0] => 15 |
| 2806 |
[1] => 16 |
| 2807 |
[2] => 13 |
| 2808 |
) |
| 2809 |
*/ |
| 2810 |
$booking_arr['time_array_new'] = $this->wpbc_times_only_of_specific_resource( |
| 2811 |
$booking_arr['time_array_new'], |
| 2812 |
$booking_arr['current_resource_id'], |
| 2813 |
$booking_arr['bookings'] |
| 2814 |
); |
| 2815 |
|
| 2816 |
$this->wpbc_show_timeline_booking_row( $real_date, $booking_arr ); |
| 2817 |
|
| 2818 |
|
| 2819 |
?> |
| 2820 |
</div> |
| 2821 |
</div><?php |
| 2822 |
} |
| 2823 |
?></div><?php |
| 2824 |
?></div><?php |
| 2825 |
|
| 2826 |
?></div></div><?php |
| 2827 |
|
| 2828 |
|
| 2829 |
if ( ! $this->is_frontend ){ |
| 2830 |
$this->show_timeline_header_end__admin_panel(); // FixIn: 10.0.0.25. |
| 2831 |
} |
| 2832 |
|
| 2833 |
} |
| 2834 |
|
| 2835 |
|
| 2836 |
/** |
| 2837 |
* Ger Start Date to real_date variable |
| 2838 |
* |
| 2839 |
* @param $params = array( |
| 2840 |
* 'is_matrix' => $is_matrix, |
| 2841 |
* 'view_days_num' => $view_days_num, |
| 2842 |
* 'start_month' => $start_month, |
| 2843 |
* 'start_day' => $start_day, |
| 2844 |
* 'start_year' => $start_year, |
| 2845 |
* 'scroll_month' => $scroll_month |
| 2846 |
* 'scroll_day' => $scroll_day |
| 2847 |
* 'd_inc' => $d_inc |
| 2848 |
* ) |
| 2849 |
* |
| 2850 |
* @return false|int |
| 2851 |
*/ |
| 2852 |
private function get_start_day__to_real_date( $params ) { |
| 2853 |
|
| 2854 |
if ( $params['is_matrix'] ) { // MATRIX VIEW |
| 2855 |
switch ( $params['view_days_num'] ) { // Set real start date for the rows in calendar |
| 2856 |
case '1': |
| 2857 |
case '7': |
| 2858 |
$real_date = mktime( 0, 0, 0, intval( $params['start_month'] ), ( intval( $params['start_day'] ) + intval( $params['scroll_day'] ) ), intval( $params['start_year'] ) ); |
| 2859 |
break; |
| 2860 |
|
| 2861 |
case '30': |
| 2862 |
case '90': |
| 2863 |
$real_date = mktime( 0, 0, 0, ( intval( $params['start_month'] ) + intval( $params['scroll_month'] ) ), intval( $params['start_day'] ), intval( $params['start_year'] ) ); |
| 2864 |
break; |
| 2865 |
|
| 2866 |
default: // 30 |
| 2867 |
$real_date = mktime( 0, 0, 0, ( intval( $params['start_month'] ) + intval( $params['scroll_month'] ) ), intval( $params['start_day'] ), intval( $params['start_year'] ) ); |
| 2868 |
break; |
| 2869 |
} |
| 2870 |
} else { // Single Resource View |
| 2871 |
switch ( $params['view_days_num'] ) { // Set real start date for the rows in calendar |
| 2872 |
case '90': |
| 2873 |
$real_date = mktime( 0, 0, 0, intval( $params['start_month'] ), ( intval( $params['start_day'] ) + intval( $params['d_inc'] ) * 7 + intval( $params['scroll_day'] ) ), intval( $params['start_year'] ) ); |
| 2874 |
break; |
| 2875 |
|
| 2876 |
case '365': |
| 2877 |
$real_date = mktime( 0, 0, 0, ( intval( $params['start_month'] ) + intval( $params['d_inc'] ) + intval( $params['scroll_month'] ) ), intval( $params['start_day'] ), intval( $params['start_year'] ) ); |
| 2878 |
break; |
| 2879 |
|
| 2880 |
default: // 30 |
| 2881 |
$real_date = mktime( 0, 0, 0, intval( $params['start_month'] ), ( intval( $params['start_day'] ) + intval( $params['d_inc'] ) + intval( $params['scroll_day'] ) ), intval( $params['start_year'] ) ); |
| 2882 |
break; |
| 2883 |
} |
| 2884 |
} |
| 2885 |
|
| 2886 |
return $real_date; |
| 2887 |
} |
| 2888 |
|
| 2889 |
/** |
| 2890 |
* Show timeline |
| 2891 |
* All parameters must be defined. |
| 2892 |
*/ |
| 2893 |
public function show_timeline() { |
| 2894 |
|
| 2895 |
$this->wpbc_show_timeline( $this->dates_array, $this->bookings, $this->booking_types, $this->time_array_new ); |
| 2896 |
|
| 2897 |
//FixIn: 10.0.0.25 // removed loader text from here |
| 2898 |
|
| 2899 |
// FixIn: 9.1.2.4. |
| 2900 |
echo '<script type="text/javascript"> |
| 2901 |
if ( ( document.readyState !== "loading" ) && ( ( "undefined" !== typeof jQuery ) && ( window.jQuery ) ) ){ |
| 2902 |
jQuery( ".flex_tl_table_loading").hide(); |
| 2903 |
jQuery( ".flex_tl_table" ).show(); |
| 2904 |
} else { ' ; |
| 2905 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2906 |
echo wpbc_jq_ready_start(); // FixIn: 10.1.3.7. |
| 2907 |
?> jQuery( '.flex_tl_table_loading').hide(); |
| 2908 |
jQuery( '.flex_tl_table' ).show(); |
| 2909 |
<?php |
| 2910 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2911 |
echo wpbc_jq_ready_end() . ' } </script>'; // FixIn: 10.1.3.7. |
| 2912 |
} |
| 2913 |
|
| 2914 |
/** |
| 2915 |
* Show Header for Timeline in Calendar Overview page in admin panel. Header contain switches of modes and novigation buttons |
| 2916 |
* @return void |
| 2917 |
*/ |
| 2918 |
public function show_timeline_header_start__admin_panel(){ // FixIn: 10.0.0.25. |
| 2919 |
|
| 2920 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 2921 |
$is_show_resources_matrix = ( ( isset( $_REQUEST['wh_booking_type'] ) ) && ( strpos( $_REQUEST['wh_booking_type'], ',' ) !== false ) ) |
| 2922 |
? true : false; |
| 2923 |
|
| 2924 |
$view_days_num = ( isset( $_REQUEST['view_days_num'] ) ) ? intval( $_REQUEST['view_days_num'] ) : get_bk_option( 'booking_view_days_num' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 2925 |
|
| 2926 |
$bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false ), array( 'view_days_num' ) ); |
| 2927 |
|
| 2928 |
?><div class="wpbc_calendar_overview__header" > |
| 2929 |
<div class="wpdvlp-top-tabs "> |
| 2930 |
<div class="wpdvlp-tabs-wrapper"> |
| 2931 |
<div class="nav-tabs"><?php |
| 2932 |
if ( $is_show_resources_matrix ) { |
| 2933 |
?> |
| 2934 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=1' ); ?>" |
| 2935 |
class="nav-tab <?php echo ( 1 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-event"></i> |
| 2936 |
<span class="nav-tab-text"> <?php echo esc_html__('Day', 'booking') ; ?></span> |
| 2937 |
</a> |
| 2938 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=7' ); ?>" |
| 2939 |
class="nav-tab <?php echo ( 7 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-week"></i> |
| 2940 |
<span class="nav-tab-text"> <?php echo esc_html__('Week', 'booking'); ?></span> |
| 2941 |
</a> |
| 2942 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=30' ); ?>" |
| 2943 |
class="nav-tab <?php echo ( 30 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar3"></i> |
| 2944 |
<span class="nav-tab-text"> <?php echo esc_html__('Month', 'booking'); ?></span> |
| 2945 |
</a> |
| 2946 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=60' ); ?>" |
| 2947 |
class="nav-tab <?php echo ( 60 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar2-week"></i> |
| 2948 |
<span class="nav-tab-text"> 2 <?php echo esc_html__('Months', 'booking'); ?></span> |
| 2949 |
</a> |
| 2950 |
<?php |
| 2951 |
} else { |
| 2952 |
?> |
| 2953 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=30' ); ?>" |
| 2954 |
class="nav-tab <?php echo ( 30 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-event"></i> |
| 2955 |
<span class="nav-tab-text"> <?php echo esc_html__('Day', 'booking') ; ?></span> |
| 2956 |
</a> |
| 2957 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=90' ); ?>" |
| 2958 |
class="nav-tab <?php echo ( 90 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-week"></i> |
| 2959 |
<span class="nav-tab-text"> <?php echo esc_html__('Week', 'booking'); ?></span> |
| 2960 |
</a> |
| 2961 |
<a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=365' ); ?>" |
| 2962 |
class="nav-tab <?php echo ( 365 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar3"></i> |
| 2963 |
<span class="nav-tab-text"> <?php echo esc_html__('Month', 'booking'); ?></span> |
| 2964 |
</a> |
| 2965 |
<?php |
| 2966 |
} |
| 2967 |
?><div class="wpbc_calendar_overview__navigation"><?php |
| 2968 |
|
| 2969 |
wpbc_toolbar_btn__timeline_navigation(); |
| 2970 |
|
| 2971 |
?></div> |
| 2972 |
</div><!-- nav-tabs --> |
| 2973 |
</div><!-- wpdvlp-tabs-wrapper --> |
| 2974 |
</div><!-- wpdvlp-top-tabs --> |
| 2975 |
</div> |
| 2976 |
<div class="clear"></div> |
| 2977 |
<div class="wpbc_calendar_overview__container"> |
| 2978 |
<?php |
| 2979 |
} |
| 2980 |
|
| 2981 |
function show_timeline_header_end__admin_panel(){ // FixIn: 10.0.0.25. |
| 2982 |
?></div><?php // End: .wpbc_calendar_overview__container |
| 2983 |
} |
| 2984 |
|
| 2985 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2986 |
// P O P O V E R |
| 2987 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2988 |
|
| 2989 |
//TODO: Refactor this: 2019-07-29 09:01 |
| 2990 |
|
| 2991 |
/** |
| 2992 |
* Get Data for Popover |
| 2993 |
* |
| 2994 |
* @param int $bk_id |
| 2995 |
* @param array $bookings |
| 2996 |
* @param array $booking_types |
| 2997 |
* @param string $text_in_day_cell |
| 2998 |
* @param string $header_title |
| 2999 |
* @param string $content_text |
| 3000 |
* |
| 3001 |
* @return array |
| 3002 |
*/ |
| 3003 |
public function wpbc_get_booking_info_4_popover( $bk_id, $bookings, $booking_types ){ |
| 3004 |
|
| 3005 |
if ( isset( $bookings[ $bk_id ] ) ) { |
| 3006 |
//$bookings[ $bk_id ]->form_show = str_replace( "&", '&', $bookings[ $bk_id ]->form_show ); // FixIn: 7.1.2.12. |
| 3007 |
// We escaping at other place: wpbc__legacy__get_form_content_arr() |
| 3008 |
} |
| 3009 |
|
| 3010 |
if ( count( $bookings[ $bk_id ]->dates ) > 0 ) { |
| 3011 |
$is_approved = $bookings[ $bk_id ]->dates[0]->approved; |
| 3012 |
} else { |
| 3013 |
$is_approved = 0; |
| 3014 |
} |
| 3015 |
|
| 3016 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3017 |
// Title |
| 3018 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3019 |
$header_title = '<div class=\'popover-title-id\' > ID: ' . $bk_id . '</div>'; // ID |
| 3020 |
|
| 3021 |
|
| 3022 |
$is_can = true; //current_user_can( 'edit_posts' ); |
| 3023 |
|
| 3024 |
if ( |
| 3025 |
( ( $is_can ) && ( ! $this->is_frontend ) ) |
| 3026 |
|| ( ( $this->is_frontend ) && ( ! empty( $this->request_args['booking_hash'] ) ) ) |
| 3027 |
) { |
| 3028 |
|
| 3029 |
// Buttons |
| 3030 |
$header_title .= '<div class=\'popover-title-buttons control-group timeline_info_bk_actionsbar_' . $bk_id . '\' >'; |
| 3031 |
|
| 3032 |
|
| 3033 |
if ( ( ! $this->is_frontend ) && ( $is_can ) ) { |
| 3034 |
// Link |
| 3035 |
$header_title .= '<a class=\'button button-secondary\' |
| 3036 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Booking Listing', 'booking' ) ) ) . '\' |
| 3037 |
href=\''.wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&tab=vm_booking_listing\' ><i class=\'wpbc_icn_gps_fixed\'></i></a>'; |
| 3038 |
//Edit |
| 3039 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 3040 |
$bk_url_add = wpbc_get_new_booking_url( true, false ); |
| 3041 |
$bk_hash = (isset( $bookings[$bk_id]->hash )) ? $bookings[$bk_id]->hash : ''; |
| 3042 |
$bk_booking_type = $bookings[$bk_id]->booking_type; |
| 3043 |
$edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1'; |
| 3044 |
// FixIn: 10.10.1.2 $edit_booking_url .= ( 'Off' !== get_bk_option( 'booking_is_resource_no_update__during_editing' ) ) ? '&resource_no_update=1' : ''; // FixIn: 9.4.2.3. |
| 3045 |
|
| 3046 |
$custom_booking_form = ''; |
| 3047 |
if ( ! empty( $bookings[ $bk_id ]->form_data['_all_fields_']['wpbc_custom_booking_form'] ) ) { |
| 3048 |
$custom_booking_form = $bookings[ $bk_id ]->form_data['_all_fields_']['wpbc_custom_booking_form']; |
| 3049 |
$edit_booking_url .= '&booking_form=' . rawurlencode( $custom_booking_form ); // FixIn: 9.4.3.12. |
| 3050 |
} |
| 3051 |
|
| 3052 |
$edit_booking_onclick = "if ( 'function' === typeof wpbc_boo_listing__click__add_booking_modal_from_row ) {" |
| 3053 |
. ' wpbc_boo_listing__click__add_booking_modal_from_row(' |
| 3054 |
. absint( $bk_id ) . ',' |
| 3055 |
. absint( $bk_booking_type ) . ',' |
| 3056 |
. "'" . esc_js( $bk_hash ) . "'," |
| 3057 |
. "'" . esc_js( $custom_booking_form ) . "'" |
| 3058 |
. ' ); return false; }'; |
| 3059 |
|
| 3060 |
$header_title .= '<a class=\'button button-secondary\' |
| 3061 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Edit', 'booking' ) ) ) . '\' |
| 3062 |
href=\'' . esc_url( $edit_booking_url ) . '\' onclick=\'' . esc_attr( $edit_booking_onclick ) . '\' ><i class=\'wpbc_icn_draw\'></i></a>'; |
| 3063 |
|
| 3064 |
|
| 3065 |
$header_title .= '<span class=\'wpbc-buttons-separator\'></span>'; |
| 3066 |
} |
| 3067 |
// Trash |
| 3068 |
//$header_title .= '<a class=\'button button-secondary\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $this->current_user_id . ', "' . wpbc_get_maybe_reloaded_booking_locale() . '" , 1 );\' ><i class=\'wpbc_icn_delete_outline\'></i></a>'; |
| 3069 |
// FixIn: 6.1.1.10. |
| 3070 |
$is_trash = $bookings[$bk_id]->trash; |
| 3071 |
|
| 3072 |
// Trash |
| 3073 |
$header_title .= '<a class=\'button button-secondary trash_bk_link'.(( $is_trash)?' hidden_items ':'').'\' |
| 3074 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Trash / Reject', 'booking' ) ) ) . '\' |
| 3075 |
href=\'javascript:;\' onclick=\'javascript:if ( wpbc_are_you_sure_popup() ) trash__restore_booking(1,' . $bk_id . ', ' . $this->current_user_id . ', "' . wpbc_get_maybe_reloaded_booking_locale() . '" , 1 );\' ><i class=\'wpbc_icn_delete_outline\'></i></a>'; // FixIn: 8.4.7.14. |
| 3076 |
// Restore |
| 3077 |
$header_title .= '<a class=\'button button-secondary restore_bk_link'.((!$is_trash)?' hidden_items ':'').'\' |
| 3078 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Restore', 'booking' ) ) ) . '\' |
| 3079 |
href=\'javascript:;\' onclick=\'javascript:trash__restore_booking(0,' . $bk_id . ', ' . $this->current_user_id . ', "' . wpbc_get_maybe_reloaded_booking_locale() . '" , 1 );\' ><i class=\'wpbc_icn_rotate_left\'></i></a>'; |
| 3080 |
// Delete |
| 3081 |
$header_title .= '<a class=\'button button-secondary delete_bk_link'.((!$is_trash)?' hidden_items ':'').'\' |
| 3082 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Delete', 'booking' ) ) ) . '\' |
| 3083 |
href=\'javascript:;\' onclick=\'javascript:if ( wpbc_are_you_sure_popup() ) delete_booking(' . $bk_id . ', ' . $this->current_user_id . ', "' . wpbc_get_maybe_reloaded_booking_locale() . '" , 1 );\' ><i class=\'wpbc_icn_close\'></i></a>'; // FixIn: 8.4.7.14. |
| 3084 |
//End FixIn: 6.1.1.10 |
| 3085 |
|
| 3086 |
// Approve | Decline |
| 3087 |
$header_title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' |
| 3088 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Approve', 'booking' ) ) ) . '\' |
| 3089 |
href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $this->current_user_id . ', "' . wpbc_get_maybe_reloaded_booking_locale() . '" , 1 );\' ><i class=\'wpbc_icn_check_circle_outline\'></i></a>'; |
| 3090 |
$header_title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' |
| 3091 |
title=\'' . esc_attr( str_replace( "'", '', __( 'Pending', 'booking' ) ) ) . '\' |
| 3092 |
href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $this->current_user_id . ', "' . wpbc_get_maybe_reloaded_booking_locale() . '" , 1 );\' ><i class=\'wpbc_icn_block\'></i></a>'; |
| 3093 |
|
| 3094 |
|
| 3095 |
} |
| 3096 |
|
| 3097 |
else if ( ( $this->is_frontend ) && ( ! empty( $this->request_args['booking_hash'] ) ) ) { // FixIn: 8.1.3.5. |
| 3098 |
// Valid or not valid hash we was checked at beginning of function. |
| 3099 |
|
| 3100 |
//Edit |
| 3101 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 3102 |
|
| 3103 |
// $edit_booking_url_admin = wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&tab=vm_booking_listing'; |
| 3104 |
// $trash_booking_url_admin = wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&tab=vm_booking_listing'; |
| 3105 |
|
| 3106 |
$is_change_hash_after_approvement = get_bk_option( 'booking_is_change_hash_after_approvement' ); // FixIn: 8.6.1.6. |
| 3107 |
if ( ( ! $is_approved ) || ( 'On' != $is_change_hash_after_approvement ) ) { // FixIn: 8.2.1.14. |
| 3108 |
$visitorbookingediturl = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingediturl]', $bk_id ); |
| 3109 |
$visitorbookingcancelurl = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingcancelurl]', $bk_id ); |
| 3110 |
$visitorbookingpayurl = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingpayurl]', $bk_id ); |
| 3111 |
|
| 3112 |
$header_title .= '<a class=\'btn btn-default wpbc_btn_in_timeline\' title=\''. esc_attr( __( 'Edit', 'booking' ) ).'\' href=\'' . $visitorbookingediturl . '\' ><i class=\'wpbc_icn_draw\'></i></a>'; |
| 3113 |
$header_title .= '<a class=\'btn btn-default wpbc_btn_in_timeline\' title=\''. esc_attr( __( 'Cancel', 'booking' ) ).'\' href=\'' . $visitorbookingcancelurl . '\' ><i class=\'wpbc_icn_delete_outline\'></i></a>'; |
| 3114 |
$header_title .= '<a class=\'btn btn-default wpbc_btn_in_timeline\' title=\''. esc_attr( __( 'Pay', 'booking' ) ).'\' href=\'' . $visitorbookingpayurl . '\' ><i class=\'wpbc_icn_forward_to_inbox\'></i></a>'; |
| 3115 |
} |
| 3116 |
} |
| 3117 |
} |
| 3118 |
|
| 3119 |
$header_title .= '</div>'; |
| 3120 |
} |
| 3121 |
|
| 3122 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3123 |
// Content |
| 3124 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3125 |
|
| 3126 |
// Container |
| 3127 |
$content_text = '<div id=\'wpbc-booking-id-'.$bk_id.'\' class=\'flex-popover-content-data\' >'; |
| 3128 |
|
| 3129 |
|
| 3130 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3131 |
// Labels |
| 3132 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3133 |
$content_text .= '<div class=\'flex-popover-bars\' >'; |
| 3134 |
|
| 3135 |
$content_text .= '<div class=\'flex-popover-labels-bar\' >'; |
| 3136 |
|
| 3137 |
// ID |
| 3138 |
$content_text .= '<div class=\'flex-label flex-label-id\'>'; |
| 3139 |
$content_text .= '<span class=\'label0\'>' . $bk_id . '</span>'; |
| 3140 |
$content_text .= '</div>'; |
| 3141 |
|
| 3142 |
// Labels |
| 3143 |
$content_text .= '<div class=\'flex-label flex-label-booking-status label-pending' . ( $is_approved ? ' hidden_items' : '' ) . '\'>' |
| 3144 |
. __('Pending' ,'booking') |
| 3145 |
. '</div>'; |
| 3146 |
$content_text .= '<div class=\'flex-label flex-label-booking-status label-approved' . ( ! $is_approved ? ' hidden_items' : '' ) . '\'>' |
| 3147 |
. __('Approved' ,'booking') |
| 3148 |
. '</div>'; |
| 3149 |
|
| 3150 |
// Resource |
| 3151 |
if ( function_exists( 'wpbc_db__get_resource_title' ) ) { |
| 3152 |
|
| 3153 |
if ( isset( $booking_types[ $bookings[ $bk_id ]->booking_type ] ) ) { |
| 3154 |
$bk_title = wpbc_lang( $booking_types[ $bookings[ $bk_id ]->booking_type ]->title ); |
| 3155 |
} else { |
| 3156 |
$bk_title = wpbc_get_resource_title( $bookings[ $bk_id ]->booking_type ); |
| 3157 |
} |
| 3158 |
|
| 3159 |
$content_text .= '<div class=\'flex-label flex-label-resource\'>'; |
| 3160 |
$content_text .= '<span class=\'\'>' . esc_textarea( $bk_title ) . '</span>'; // FixIn: 7.1.1.2. |
| 3161 |
$content_text .= '</div>'; |
| 3162 |
} |
| 3163 |
|
| 3164 |
// Payment Status |
| 3165 |
if ( ( function_exists( 'wpdev_bk_get_payment_status_simple' ) ) |
| 3166 |
&& ( floatval( $bookings[ $bk_id ]->cost ) > 0 ) |
| 3167 |
) { |
| 3168 |
$pay_status = wpdev_bk_get_payment_status_simple( $bookings[ $bk_id ]->pay_status ); |
| 3169 |
$is_payment_ok = wpbc_is_payment_status_ok( trim( $bookings[ $bk_id ]->pay_status ) ); |
| 3170 |
|
| 3171 |
$payment_label_status = $is_payment_ok ? 'payment-label-success' : 'payment-label-unknown'; |
| 3172 |
|
| 3173 |
$content_text .= '<div class=\'flex-label flex-label-payment '. $payment_label_status .'\'>'; |
| 3174 |
|
| 3175 |
if ( $is_payment_ok ) |
| 3176 |
$content_text .= '<span class=\'label-prefix\'>' . esc_js( __( 'Payment', 'booking' ) ). '</span> ' . esc_js( $pay_status ); |
| 3177 |
else { |
| 3178 |
$content_text .= '<span class=\'label-prefix\'>' . esc_js( __( 'Payment', 'booking' ) ) . '</span> ' . esc_js( $pay_status ); // FixIn: 7.1.1.3. |
| 3179 |
} |
| 3180 |
|
| 3181 |
$content_text .= '</div>'; |
| 3182 |
} |
| 3183 |
|
| 3184 |
if ( ! $this->is_frontend ) { |
| 3185 |
// Trash |
| 3186 |
$content_text .= '<div class=\'flex-label flex-label-trash' . ( ( ! $bookings[$bk_id]->trash ) ? ' hidden_items ' : '' ) . '\'>'; |
| 3187 |
$content_text .= '<span class=\'\'>' . esc_js( __('Trash / Reject' ,'booking') ) . '</span>'; //FixIn: 6.1.1.10 // FixIn: 7.1.1.3. |
| 3188 |
$content_text .= '</div>'; |
| 3189 |
} |
| 3190 |
|
| 3191 |
|
| 3192 |
$content_text .= '</div>'; |
| 3193 |
|
| 3194 |
|
| 3195 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3196 |
// Cost Bar |
| 3197 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3198 |
if ( ( class_exists( 'wpdev_bk_biz_s' ) ) ) { //&& ( ! $this->is_frontend ) ){ |
| 3199 |
|
| 3200 |
$content_text .= '<div class=\'flex-popover-cost-bar\' >'; |
| 3201 |
|
| 3202 |
// FixIn: 8.3.3.9. |
| 3203 |
if ( floatval( $bookings[ $bk_id ]->cost ) > 0 ) { |
| 3204 |
// Cost |
| 3205 |
$booking_cost = wpbc_get_cost_with_currency_for_user( $bookings[ $bk_id ]->cost, $bookings[ $bk_id ]->booking_type ); |
| 3206 |
|
| 3207 |
$content_text .= '<div class=\'flex-label flex-label-cost\' >'; |
| 3208 |
//$content_text .= '<div class=\'text-left field-labels booking-labels\'>'; |
| 3209 |
$content_text .= '<div class=\'\'>' . $booking_cost . '</div>'; |
| 3210 |
//$content_text .= '</div>'; |
| 3211 |
$content_text .= '</div>'; |
| 3212 |
} |
| 3213 |
|
| 3214 |
$content_text .= '</div>'; |
| 3215 |
|
| 3216 |
} |
| 3217 |
|
| 3218 |
$content_text .= '</div>'; |
| 3219 |
|
| 3220 |
|
| 3221 |
|
| 3222 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3223 |
// Booking Data |
| 3224 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3225 |
|
| 3226 |
// Booking Data |
| 3227 |
$content_text .= '<div class=\'clear\'></div>'; // FixIn: 8.7.9.4. |
| 3228 |
$content_text .= '<div class=\'flex-popover-booking-data\'>' . esc_textarea( $bookings[$bk_id]->form_show ) . '</div>'; // FixIn: 7.1.1.2. |
| 3229 |
$content_text .= '<div class=\'clear\'></div>'; // FixIn: 8.7.9.4. |
| 3230 |
|
| 3231 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3232 |
// Notes |
| 3233 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3234 |
|
| 3235 |
// Notes |
| 3236 |
if ( ! empty( $bookings[$bk_id]->remark ) ) { |
| 3237 |
$content_text .= '<div class=\'wpbc-popover-booking-notes\'>' . '<strong>' . esc_js( __('Note', 'booking') ). ':</strong> ' . esc_textarea( $bookings[$bk_id]->remark ) . '</div>'; //FixIn: 7.1.1.2 // FixIn: 7.1.1.3. |
| 3238 |
} |
| 3239 |
|
| 3240 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3241 |
// Dates |
| 3242 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3243 |
|
| 3244 |
$bk_dates_short_id = array(); //BL |
| 3245 |
if ( count( $bookings[$bk_id]->dates ) > 0 ) |
| 3246 |
$bk_dates_short_id = (isset( $bookings[$bk_id]->dates_short_id )) ? $bookings[$bk_id]->dates_short_id : array(); // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 ) |
| 3247 |
|
| 3248 |
$short_dates_content = wpbc_get_short_dates_formated_to_show( $bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types ); |
| 3249 |
$short_dates_content = str_replace( '"', "'", $short_dates_content ); |
| 3250 |
|
| 3251 |
$content_text .= '<div class=\'flex-label-dates \'>'; |
| 3252 |
$content_text .= $short_dates_content; |
| 3253 |
$content_text .= '</div>'; |
| 3254 |
|
| 3255 |
// FixIn: 8.9.4.14. |
| 3256 |
$date_format = get_bk_option( 'booking_date_format' ); |
| 3257 |
if ( empty( $date_format ) ) { |
| 3258 |
$date_format = 'm / d / Y, D'; |
| 3259 |
} |
| 3260 |
$time_format = get_bk_option( 'booking_time_format' ); |
| 3261 |
if ( empty( $time_format ) ) { |
| 3262 |
$time_format = 'h:i a'; |
| 3263 |
} |
| 3264 |
$cr_date = wpbc_datetime__no_wp_timezone( $date_format . ' ' . $time_format, mysql2date( 'U', $bookings[ $bk_id ]->modification_date ) ); |
| 3265 |
$content_text .= '<div class=\'wpbc-listing-collumn field-system-info \'>'; |
| 3266 |
$content_text .= __( 'Created', 'booking' ) . ': ' . $cr_date; |
| 3267 |
$content_text .= '</div>'; |
| 3268 |
|
| 3269 |
|
| 3270 |
$content_text .= '</div>'; // Main Container: 'flex-popover-content-data' |
| 3271 |
|
| 3272 |
return array( |
| 3273 |
'title' => $header_title, |
| 3274 |
'content' => $content_text |
| 3275 |
); |
| 3276 |
} |
| 3277 |
|
| 3278 |
} |
| 3279 |
|
| 3280 |
|
| 3281 |
|
| 3282 |
/** Navigation of Timeline in Ajax request */ |
| 3283 |
function wpbc_ajax_flex_timeline() { |
| 3284 |
/* |
| 3285 |
[timeline_obj] => Array |
| 3286 |
( |
| 3287 |
[is_frontend] => 1 |
| 3288 |
[html_client_id] => wpbc_timeline_1454680376080 |
| 3289 |
[wh_booking_type] => 3,4,1,5,6,7,8,9,2,10,11,12,14 |
| 3290 |
[is_matrix] => 1 |
| 3291 |
[view_days_num] => 30 |
| 3292 |
[scroll_start_date] => |
| 3293 |
[scroll_day] => 0 |
| 3294 |
[scroll_month] => 0 |
| 3295 |
) |
| 3296 |
*/ |
| 3297 |
|
| 3298 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 3299 |
foreach ( $_POST['timeline_obj'] as $tl_key => $tl_value ) { |
| 3300 |
$_POST['timeline_obj'][ $tl_key ] = wpbc_clean_text_value( $tl_value ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 3301 |
} |
| 3302 |
|
| 3303 |
$attr = $_POST['timeline_obj']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated |
| 3304 |
$attr['nav_step'] = wpbc_clean_text_value( $_POST['nav_step'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated |
| 3305 |
|
| 3306 |
// FixIn: 9.9.0.18. |
| 3307 |
$server_zone = date_default_timezone_get(); // If in 'Theme' or 'other plugin' set default timezone other than UTC. Save it. |
| 3308 |
if ( 'UTC' !== $server_zone ) { // Needed for WP date functions - set timezone to UTC. |
| 3309 |
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
| 3310 |
@date_default_timezone_set( 'UTC' ); |
| 3311 |
} |
| 3312 |
|
| 3313 |
ob_start(); |
| 3314 |
|
| 3315 |
$timeline = new WPBC_TimelineFlex(); |
| 3316 |
|
| 3317 |
$html_client_id = $timeline->ajax_init( $attr ); // Define arameters and get bookings |
| 3318 |
//debuge($timeline->options); |
| 3319 |
|
| 3320 |
//echo '<div class="wpbc_timeline_ajax_replace">'; // Replace content of this container |
| 3321 |
$timeline->show_timeline(); |
| 3322 |
|
| 3323 |
|
| 3324 |
$is_show_popover_in_timeline = wpbc_is_show_popover_in_flex_timeline( $attr['is_frontend'], $attr['booking_hash'] ); // FixIn: 8.1.3.5. |
| 3325 |
|
| 3326 |
if ( $is_show_popover_in_timeline ) { // Update New Popovers |
| 3327 |
|
| 3328 |
$html = '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7. |
| 3329 |
$html .= ' wpbc_define_tippy_popover(); '; |
| 3330 |
$html .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7. |
| 3331 |
|
| 3332 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 3333 |
echo $html; |
| 3334 |
|
| 3335 |
/* ?><script type="text/javascript"> wpbc_define_tippy_popover(); </script><?php */ |
| 3336 |
} |
| 3337 |
//echo '</div>'; |
| 3338 |
|
| 3339 |
|
| 3340 |
$timeline_results = ob_get_contents(); |
| 3341 |
|
| 3342 |
ob_end_clean(); |
| 3343 |
|
| 3344 |
// FixIn: 9.9.0.18. |
| 3345 |
if ( 'UTC' !== $server_zone ) { // Back to previos state, if it was changed. |
| 3346 |
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
| 3347 |
@date_default_timezone_set( $server_zone ); |
| 3348 |
} |
| 3349 |
|
| 3350 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 3351 |
echo $timeline_results ; |
| 3352 |
} |
| 3353 |
add_bk_action('wpbc_ajax_flex_timeline', 'wpbc_ajax_flex_timeline'); |
| 3354 |
|
| 3355 |
|
| 3356 |
|
| 3357 |
/** Check if we are showing booking details or not |
| 3358 |
* Admin panel - always show |
| 3359 |
* Timeline - show if activated setting option |
| 3360 |
* Customer listing - show always, if valid hash. |
| 3361 |
* |
| 3362 |
* @param $is_frontend |
| 3363 |
* @param $booking_hash |
| 3364 |
* |
| 3365 |
* @return bool |
| 3366 |
*/ |
| 3367 |
function wpbc_is_show_popover_in_flex_timeline( $is_frontend, $booking_hash ) { |
| 3368 |
|
| 3369 |
// Default for admin. |
| 3370 |
$is_show_popover_in_timeline = true; |
| 3371 |
|
| 3372 |
// For client Timeline. |
| 3373 |
if ( $is_frontend ) { |
| 3374 |
|
| 3375 |
// FixIn: 10.14.11.1. |
| 3376 |
if ( WPBC_DISABLE_POPOVER_IN_TIMELINE ) { |
| 3377 |
$is_show_popover_in_timeline = false; |
| 3378 |
} else { |
| 3379 |
$is_show_popover_in_timeline = ( get_bk_option( 'booking_is_show_popover_in_timeline_front_end' ) == 'On' ) ? true : false; |
| 3380 |
if ( ! class_exists( 'wpdev_bk_personal' ) ) { |
| 3381 |
$is_show_popover_in_timeline = false; // FixIn: 10.14.9.2. |
| 3382 |
} |
| 3383 |
} |
| 3384 |
} |
| 3385 |
|
| 3386 |
// For customer booking listing with ability to edit. |
| 3387 |
// FixIn: 8.1.3.5. |
| 3388 |
if ( ( $is_frontend ) && ( ! empty( $booking_hash ) ) ) { |
| 3389 |
|
| 3390 |
// In case if we have valid valid hash then show booking details. |
| 3391 |
$my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $booking_hash ); |
| 3392 |
|
| 3393 |
if ( ! empty( $my_booking_id_type ) ) { |
| 3394 |
$is_show_popover_in_timeline = true; |
| 3395 |
} else { |
| 3396 |
$is_show_popover_in_timeline = false; |
| 3397 |
} |
| 3398 |
} |
| 3399 |
return $is_show_popover_in_timeline; |
| 3400 |
} |
| 3401 |
|
| 3402 |
|
| 3403 |
|
| 3404 |
/** |
| 3405 |
* TimeLine shortcode |
| 3406 |
* |
| 3407 |
* @param type $attr |
| 3408 |
* @return type |
| 3409 |
* |
| 3410 |
* Shortcodes exmaples: |
| 3411 |
* |
| 3412 |
* |
| 3413 |
** Matrix: |
| 3414 |
* 1 Month View Mode: |
| 3415 |
[bookingtimeline type="3,4,1,5,6,7,8,9,2,10,11,12,14" view_days_num=30 scroll_start_date="" scroll_month=0 header_title='All Bookings'] |
| 3416 |
* 2 Months View Mode: |
| 3417 |
[bookingtimeline type="1,5,6,7,8,9,2,10,11,12,3,4,14" view_days_num=60 scroll_start_date="" scroll_month=-1 header_title='All Bookings'] |
| 3418 |
* 1 Week View Mode: |
| 3419 |
[bookingtimeline type="3,4" view_days_num=7 scroll_start_date="" scroll_day=-7 header_title='All Bookings'] |
| 3420 |
* 1 Day View Mode: |
| 3421 |
[bookingtimeline type="3,4" view_days_num=1 scroll_start_date="" scroll_day=0 header_title='All Bookings'] |
| 3422 |
|
| 3423 |
** Single: |
| 3424 |
* 1 Month View Mode: |
| 3425 |
[bookingtimeline type="4" view_days_num=30 scroll_start_date="" scroll_day=-15 scroll_month=0 header_title='All Bookings'] |
| 3426 |
* 3 Months View Mode: |
| 3427 |
[bookingtimeline type="4" view_days_num=90 scroll_start_date="" scroll_day=-30] |
| 3428 |
* 1 Year View Mode: |
| 3429 |
[bookingtimeline type="4" view_days_num=365 scroll_start_date="" scroll_month=-3] |
| 3430 |
|
| 3431 |
|
| 3432 |
*/ |
| 3433 |
function bookingflextimeline_shortcode($attr) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 3434 |
|
| 3435 |
if ( wpbc_is_on_edit_page() ) { |
| 3436 |
return wpbc_get_preview_for_shortcode( 'bookingflextimeline', $attr ); // FixIn: 9.9.0.39. |
| 3437 |
} |
| 3438 |
|
| 3439 |
$attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 3440 |
|
| 3441 |
if ( '' === $attr ) { |
| 3442 |
$attr = array(); // FixIn: 9.9.0.30. |
| 3443 |
} |
| 3444 |
|
| 3445 |
//if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 3446 |
if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| 3447 |
if ( empty( $attr['type'] ) ) { // 8.7.7.4 |
| 3448 |
if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 3449 |
$br_list = wpbc_get_all_booking_resources_list(); |
| 3450 |
$br_list = array_keys( $br_list ); |
| 3451 |
$br_list = implode( ',', $br_list ); |
| 3452 |
$attr['type'] = $br_list; |
| 3453 |
} else { |
| 3454 |
$attr['type'] = wpbc_get_default_resource(); |
| 3455 |
} |
| 3456 |
} |
| 3457 |
|
| 3458 |
if ( ! isset( $attr['view_days_num' ] ) ) { |
| 3459 |
$attr['view_days_num' ] = 30; |
| 3460 |
} |
| 3461 |
if ( ! isset( $attr['scroll_start_date' ] ) ) { |
| 3462 |
$attr['scroll_start_date' ] = ''; |
| 3463 |
} |
| 3464 |
if ( ! isset( $attr['scroll_day' ] ) ) { |
| 3465 |
$attr['scroll_day' ] = 0; |
| 3466 |
} |
| 3467 |
if ( ! isset( $attr['scroll_month' ] ) ) { |
| 3468 |
$attr['scroll_month' ] = 0; |
| 3469 |
} |
| 3470 |
if ( ! isset( $attr['header_title' ] ) ) { |
| 3471 |
$attr['header_title' ] = ''; |
| 3472 |
} |
| 3473 |
|
| 3474 |
// FixIn: 9.9.0.18. |
| 3475 |
$server_zone = date_default_timezone_get(); // If in 'Theme' or 'other plugin' set default timezone other than UTC. Save it. |
| 3476 |
if ( 'UTC' !== $server_zone ) { // Needed for WP date functions - set timezone to UTC |
| 3477 |
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
| 3478 |
@date_default_timezone_set( 'UTC' ); |
| 3479 |
} |
| 3480 |
|
| 3481 |
ob_start(); |
| 3482 |
|
| 3483 |
$timeline = new WPBC_TimelineFlex(); |
| 3484 |
|
| 3485 |
$html_client_id = $timeline->client_init( $attr ); // Define arameters and get bookings |
| 3486 |
|
| 3487 |
//wpbc_datepicker_js(); // JS Datepicker |
| 3488 |
//wpbc_datepicker_css(); // CSS DatePicker |
| 3489 |
|
| 3490 |
|
| 3491 |
echo '<div class="wpdevelop">'; |
| 3492 |
|
| 3493 |
echo '<div id="' . esc_attr( $html_client_id ) . '" class="wpbc_timeline_client_border">'; |
| 3494 |
|
| 3495 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 3496 |
echo wp_nonce_field( 'WPBC_FLEXTIMELINE_NAV', 'wpbc_nonce_' . esc_attr( $html_client_id ), true, false ); |
| 3497 |
echo '<div id="ajax_respond_insert' . esc_attr( $html_client_id ) . '" class="ajax_respond_insert" style="display:none;"></div>'; |
| 3498 |
|
| 3499 |
echo '<div class="wpbc_timeline_ajax_replace">'; |
| 3500 |
if ( ! WPBC()->booking_obj->popover_front_end_js_is_writed ) { //Write this JS only once at page |
| 3501 |
wpbc_bs_javascript_popover(); // JS Popover |
| 3502 |
WPBC()->booking_obj->popover_front_end_js_is_writed = true; |
| 3503 |
} // FixIn: 9.2.1.3. |
| 3504 |
|
| 3505 |
//Define Global JavaScript Object - array of objects. // FixIn: 9.2.1.3. |
| 3506 |
?> |
| 3507 |
<script type="text/javascript"> |
| 3508 |
var wpbc_timeline_obj; |
| 3509 |
if ( undefined === wpbc_timeline_obj ){ |
| 3510 |
wpbc_timeline_obj = []; |
| 3511 |
} |
| 3512 |
</script> |
| 3513 |
<?php |
| 3514 |
|
| 3515 |
$timeline->show_timeline(); |
| 3516 |
echo '</div>'; |
| 3517 |
|
| 3518 |
echo '</div>'; |
| 3519 |
|
| 3520 |
echo '</div>'; |
| 3521 |
|
| 3522 |
// Fix for "Twenty Two" theme. |
| 3523 |
// Theme incorrectly closing HTML elements with attributes that contain HTML tags in content of the posts and pages. |
| 3524 |
// For example, if the HTML element have tags like this |
| 3525 |
// <div data-content="<div class='flex-popover-content-data'>Data</div>" data-original-title="<div class='popover-title-id' > ID: 19</div>" >My text</div> |
| 3526 |
// Theme show info like this |
| 3527 |
// <div data-content="<div class='flex-popover-content-data'>Data</div>” data-original-title=”<div class='popover-title-id' > ID: 19</div>” >My text</div> |
| 3528 |
/* |
| 3529 |
?><script type="text/javascript"> |
| 3530 |
wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo $html_client_id; ?>'], 0 ); |
| 3531 |
</script><?php |
| 3532 |
*/ |
| 3533 |
|
| 3534 |
$timeline_results = ob_get_contents(); |
| 3535 |
|
| 3536 |
ob_end_clean(); |
| 3537 |
|
| 3538 |
// FixIn: 9.9.0.18. |
| 3539 |
if ( 'UTC' !== $server_zone ) { // Back to previos state, if it was changed. |
| 3540 |
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
| 3541 |
@date_default_timezone_set( $server_zone ); |
| 3542 |
} |
| 3543 |
|
| 3544 |
return $timeline_results ; |
| 3545 |
} |
| 3546 |
add_shortcode( 'bookingflextimeline', 'bookingflextimeline_shortcode' ); |
| 3547 |
|
| 3548 |
|
| 3549 |
|
| 3550 |
/** JSS */ |
| 3551 |
function wpbc_timeline_js_load_files( $where_to_load ) { |
| 3552 |
|
| 3553 |
// FixIn: 8.6.1.13. |
| 3554 |
|
| 3555 |
$is_in_footer = ! true; |
| 3556 |
|
| 3557 |
if ( in_array( $where_to_load, array( 'admin', 'both', 'client' ) ) ) { |
| 3558 |
|
| 3559 |
wp_enqueue_script( 'wpbc-timeline-flex' |
| 3560 |
, trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/timeline_v2.js' /* wpbc_plugin_url( '/core/timeline/wpbc-flex-timeline.js' ) */ |
| 3561 |
, array( 'wpbc_all' /*, 'wp-element'*/ ) |
| 3562 |
, WP_BK_VERSION_NUM |
| 3563 |
, array( 'in_footer' => WPBC_JS_IN_FOOTER ) //, $is_in_footer |
| 3564 |
); |
| 3565 |
} |
| 3566 |
} |
| 3567 |
add_action( 'wpbc_enqueue_js_files', 'wpbc_timeline_js_load_files', 50 ); |
| 3568 |
|
| 3569 |
|
| 3570 |
/** CSS */ |
| 3571 |
function wpbc_timeline_enqueue_css_files( $where_to_load ) { |
| 3572 |
|
| 3573 |
// FixIn: 8.6.1.13. |
| 3574 |
|
| 3575 |
if ( in_array( $where_to_load, array( 'admin', 'both', 'client' ) ) ) { |
| 3576 |
|
| 3577 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 3578 |
if ( ( ( isset($_REQUEST['tab']) ) && ( $_REQUEST['tab']== 'vm_calendar' ) ) || ( 'client' == $where_to_load ) ){ |
| 3579 |
|
| 3580 |
wp_enqueue_style( 'wpbc-flex-timeline' |
| 3581 |
, trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/timeline_v2.1.css' /* wpbc_plugin_url( '/src/css/code_mirror.css' ) */ |
| 3582 |
, array() |
| 3583 |
, WP_BK_VERSION_NUM ); |
| 3584 |
} |
| 3585 |
} |
| 3586 |
} |
| 3587 |
add_action( 'wpbc_enqueue_css_files', 'wpbc_timeline_enqueue_css_files', 50 ); |
| 3588 |
|