| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php /** |
| 2 | 2 | * @version 1.1 |
| 3 | 3 | * @package Booking Calendar |
| 4 | 4 | * @category Timeline for Admin Panel |
| @@ -31,17 +31,25 @@ | ||
| 31 | 31 | private $week_days_titles; |
| 32 | 32 | private $current_user_id; |
| 33 | 33 | |
| 34 | 34 | private $html_client_id; // ID of border element at client side. |
| 35 | - public $options; //FixIn:7.0.1.50 | |
| 35 | + public $options; // FixIn: 7.0.1.50. | |
| 36 | 36 | |
| 37 | - private $data_in_previous_cell; //FixIn: 8.5.2.6 | |
| 37 | + private $data_in_previous_cell; // FixIn: 8.5.2.6. | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Exact booking scope resolved from a public booking hash. | |
| 41 | + * | |
| 42 | + * @var array|false | |
| 43 | + */ | |
| 44 | + private $booking_hash_scope; | |
| 38 | 45 | |
| 39 | - public function __construct(){// $bookings, $booking_types ) { | |
| 46 | + public function __construct(){// $bookings, $booking_types ) { | |
| 40 | 47 | |
| 41 | - $this->reset_data_in_previous_cell(); | |
| 48 | + $this->reset_data_in_previous_cell(); | |
| 49 | + $this->booking_hash_scope = false; | |
| 42 | 50 | |
| 43 | - $this->options = array(); //FixIn:7.0.1.50 | |
| 51 | + $this->options = array(); // FixIn: 7.0.1.50. | |
| 44 | 52 | |
| 45 | 53 | $this->html_client_id = false; |
| 46 | 54 | |
| 47 | 55 | $this->current_user_id = 0; |
| @@ -47,9 +55,9 @@ | ||
| 47 | 55 | $this->current_user_id = 0; |
| 48 | 56 | |
| 49 | 57 | $this->is_frontend = false; |
| 50 | 58 | |
| 51 | - //FixIn: 8.1.3.31 | |
| 59 | + // FixIn: 8.1.3.31. | |
| 52 | 60 | $calendar_overview_start_time = get_bk_option( 'booking_calendar_overview_start_time' ); |
| 53 | 61 | $calendar_overview_end_time = get_bk_option( 'booking_calendar_overview_end_time' ); |
| 54 | 62 | $hours_limit = ( empty( $calendar_overview_start_time ) ? '0' : $calendar_overview_start_time ) |
| 55 | 63 | . ',' |
| @@ -62,10 +70,10 @@ | ||
| 62 | 70 | , 'scroll_day' => 0 |
| 63 | 71 | , 'scroll_month' => 0 |
| 64 | 72 | , 'wh_trash' => '' |
| 65 | 73 | , '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 //FixIn: 7.0.1.51 | |
| 67 | - , 'booking_hash' => ( isset( $_REQUEST['booking_hash'] ) ) ? $_REQUEST['booking_hash'] : '' //FixIn: 8.1.3.5 | |
| 74 | + , 'only_booked_resources' => ( isset( $_REQUEST['only_booked_resources'] ) ) ? 1 : 0 /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ | |
| 75 | + , '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 | 76 | |
| 69 | 77 | ); |
| 70 | 78 | |
| 71 | 79 | $this->timeline_titles = array( |
| @@ -84,9 +92,9 @@ | ||
| 84 | 92 | , 5 => __( 'Friday', 'booking' ) |
| 85 | 93 | , 6 => __( 'Saturday', 'booking' ) |
| 86 | 94 | , 7 => __( 'Sunday', 'booking' ) |
| 87 | 95 | ) |
| 88 | - , '3' => array( //FixIn: 7.0.1.11 | |
| 96 | + , '3' => array( // FixIn: 7.0.1.11. | |
| 89 | 97 | 1 => __( 'Mon', 'booking' ) |
| 90 | 98 | , 2 => __( 'Tue', 'booking' ) |
| 91 | 99 | , 3 => __( 'Wed', 'booking' ) |
| 92 | 100 | , 4 => __( 'Thu', 'booking' ) |
| @@ -93,9 +101,9 @@ | ||
| 93 | 101 | , 5 => __( 'Fri', 'booking' ) |
| 94 | 102 | , 6 => __( 'Sat', 'booking' ) |
| 95 | 103 | , 7 => __( 'Sun', 'booking' ) |
| 96 | 104 | ) |
| 97 | - , '1' => array( //FixIn: 7.0.1.11 //FixIn: 8.7.7.14 | |
| 105 | + , '1' => array( //FixIn: 7.0.1.11 // FixIn: 8.7.7.14. | |
| 98 | 106 | 1 => mb_substr( __( 'Mon', 'booking' ), 0, -1 ) |
| 99 | 107 | , 2 => mb_substr( __( 'Tue', 'booking' ), 0, -1 ) |
| 100 | 108 | , 3 => mb_substr( __( 'Wed', 'booking' ), 0, -1 ) |
| 101 | 109 | , 4 => mb_substr( __( 'Thu', 'booking' ), 0, -1 ) |
| @@ -114,13 +122,191 @@ | ||
| 114 | 122 | ) |
| 115 | 123 | ); |
| 116 | 124 | |
| 117 | 125 | |
| 118 | - } | |
| 119 | - | |
| 120 | - | |
| 121 | - /** | |
| 122 | - * Rezet data in previos cell | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Validate the server-generated DOM identifier used by Timeline navigation. | |
| 130 | + * | |
| 131 | + * Public AJAX requests may return this value in JavaScript and inline event | |
| 132 | + * attributes. Accepting only the established prefix and decimal suffix keeps | |
| 133 | + * it an identifier rather than caller-controlled markup or selector syntax. | |
| 134 | + * | |
| 135 | + * @param mixed $html_client_id Candidate Timeline DOM identifier. | |
| 136 | + * @return string Valid identifier, or an empty string. | |
| 137 | + */ | |
| 138 | + public static function normalize_html_client_id( $html_client_id ) { | |
| 139 | + if ( ! is_scalar( $html_client_id ) ) { | |
| 140 | + return ''; | |
| 141 | + } | |
| 142 | + | |
| 143 | + $html_client_id = (string) $html_client_id; | |
| 144 | + if ( 64 < strlen( $html_client_id ) ) { | |
| 145 | + return ''; | |
| 146 | + } | |
| 147 | + | |
| 148 | + return preg_match( '/\Awpbc_timeline_[0-9]+\z/D', $html_client_id ) | |
| 149 | + ? $html_client_id | |
| 150 | + : ''; | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * Normalize the public timeline options contract. | |
| 155 | + * | |
| 156 | + * Timeline navigation round-trips options through the browser. Only Resource | |
| 157 | + * links are consumed by the renderer, so every other key is discarded rather | |
| 158 | + * than retained as attacker-controlled state for a later response. | |
| 159 | + * | |
| 160 | + * @param mixed $options Candidate timeline options. | |
| 161 | + * @return array<string,array<int,string>> Valid Resource links keyed by Resource ID. | |
| 162 | + */ | |
| 163 | + public static function normalize_options( $options ) { | |
| 164 | + if ( | |
| 165 | + ! is_array( $options ) | |
| 166 | + || empty( $options['resource_link'] ) | |
| 167 | + || ! is_array( $options['resource_link'] ) | |
| 168 | + ) { | |
| 169 | + return array(); | |
| 170 | + } | |
| 171 | + | |
| 172 | + $resource_links = array(); | |
| 173 | + foreach ( $options['resource_link'] as $resource_key => $resource_url ) { | |
| 174 | + if ( ! is_scalar( $resource_key ) || ! is_scalar( $resource_url ) ) { | |
| 175 | + continue; | |
| 176 | + } | |
| 177 | + | |
| 178 | + $resource_id = absint( $resource_key ); | |
| 179 | + $resource_url = esc_url_raw( (string) $resource_url ); | |
| 180 | + if ( empty( $resource_id ) || '' === $resource_url ) { | |
| 181 | + continue; | |
| 182 | + } | |
| 183 | + | |
| 184 | + $resource_links[ $resource_id ] = $resource_url; | |
| 185 | + } | |
| 186 | + | |
| 187 | + return empty( $resource_links ) | |
| 188 | + ? array() | |
| 189 | + : array( 'resource_link' => $resource_links ); | |
| 190 | + } | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * Decode and normalize browser-submitted timeline options. | |
| 194 | + * | |
| 195 | + * @param mixed $encoded_options JSON text received from the timeline client. | |
| 196 | + * @return array<string,array<int,string>> Valid Resource links, or an empty array. | |
| 197 | + */ | |
| 198 | + public static function decode_options( $encoded_options ) { | |
| 199 | + if ( ! is_scalar( $encoded_options ) ) { | |
| 200 | + return array(); | |
| 201 | + } | |
| 202 | + | |
| 203 | + $decoded_options = json_decode( (string) $encoded_options, true, 32 ); | |
| 204 | + if ( JSON_ERROR_NONE !== json_last_error() ) { | |
| 205 | + return array(); | |
| 206 | + } | |
| 207 | + | |
| 208 | + return self::normalize_options( $decoded_options ); | |
| 209 | + } | |
| 210 | + | |
| 211 | + /** | |
| 212 | + * Encode timeline options as one complete JavaScript string literal. | |
| 213 | + * | |
| 214 | + * The timeline browser contract stores JSON text, rather than an object, in | |
| 215 | + * `timeline_obj.options`. Encoding the normalized options twice preserves that | |
| 216 | + * contract while the hexadecimal flags prevent quotes or HTML delimiters in a | |
| 217 | + * URL from terminating the inline script context. | |
| 218 | + * | |
| 219 | + * @param mixed $options Candidate timeline options. | |
| 220 | + * @return string JavaScript-safe JSON string literal, including its delimiters. | |
| 221 | + */ | |
| 222 | + public static function encode_options_for_inline_script( $options ) { | |
| 223 | + $options_json = wp_json_encode( self::normalize_options( $options ) ); | |
| 224 | + if ( false === $options_json ) { | |
| 225 | + $options_json = '{}'; | |
| 226 | + } | |
| 227 | + | |
| 228 | + $javascript_literal = wp_json_encode( | |
| 229 | + $options_json, | |
| 230 | + JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | |
| 231 | + ); | |
| 232 | + | |
| 233 | + return false === $javascript_literal ? '"{}"' : $javascript_literal; | |
| 234 | + } | |
| 235 | + | |
| 236 | + /** | |
| 237 | + * Apply an exact booking and resource authorization scope to timeline SQL arguments. | |
| 238 | + * | |
| 239 | + * A booking hash is a bearer credential for one booking. It must never be | |
| 240 | + * converted into a customer-data keyword or used to broaden the query. Invalid | |
| 241 | + * hashes deliberately select an impossible booking ID so processing fails closed. | |
| 242 | + * | |
| 243 | + * @param array $query_args Clean timeline query arguments. | |
| 244 | + * @param string $booking_hash Public booking hash supplied by the timeline request. | |
| 245 | + * @return array Query arguments restricted to the authorized booking, when applicable. | |
| 246 | + */ | |
| 247 | + private function wpbc_apply_booking_hash_scope_to_query_args( $query_args, $booking_hash ) { | |
| 248 | + $this->booking_hash_scope = false; | |
| 249 | + $booking_hash = sanitize_text_field( (string) $booking_hash ); | |
| 250 | + | |
| 251 | + if ( empty( $booking_hash ) ) { | |
| 252 | + return $query_args; | |
| 253 | + } | |
| 254 | + | |
| 255 | + $this->request_args['only_booked_resources'] = 1; | |
| 256 | + $booking_scope = wpbc_hash__get_booking_id__resource_id( $booking_hash ); | |
| 257 | + | |
| 258 | + if ( empty( $booking_scope ) || count( $booking_scope ) < 2 ) { | |
| 259 | + $query_args['wh_booking_id'] = '-1'; | |
| 260 | + return $query_args; | |
| 261 | + } | |
| 262 | + | |
| 263 | + $booking_id = absint( $booking_scope[0] ); | |
| 264 | + $resource_id = absint( $booking_scope[1] ); | |
| 265 | + $booking_row = wpbc_db_get_booking_details( $booking_id ); | |
| 266 | + | |
| 267 | + if ( empty( $booking_id ) || empty( $resource_id ) || empty( $booking_row ) || $resource_id !== absint( $booking_row->booking_type ) ) { | |
| 268 | + $query_args['wh_booking_id'] = '-1'; | |
| 269 | + return $query_args; | |
| 270 | + } | |
| 271 | + | |
| 272 | + $this->booking_hash_scope = array( | |
| 273 | + 'booking_id' => $booking_id, | |
| 274 | + 'resource_id' => $resource_id, | |
| 275 | + ); | |
| 276 | + $query_args['wh_booking_id'] = (string) $booking_id; | |
| 277 | + $query_args['wh_booking_type'] = (string) $resource_id; | |
| 278 | + | |
| 279 | + return $query_args; | |
| 280 | + } | |
| 281 | + | |
| 282 | + /** | |
| 283 | + * Verify that a returned booking remains inside the resolved hash scope. | |
| 284 | + * | |
| 285 | + * This rendering-layer check is intentionally independent of the SQL restriction | |
| 286 | + * so a future query regression cannot expose another booking's popover data. | |
| 287 | + * Timelines without a booking hash retain their configured public presentation. | |
| 288 | + * | |
| 289 | + * @param int $booking_id Booking ID about to be rendered. | |
| 290 | + * @param array $bookings Booking objects keyed by booking ID. | |
| 291 | + * @return bool True when popover rendering is authorized for this row. | |
| 292 | + */ | |
| 293 | + private function wpbc_is_booking_authorized_for_hash( $booking_id, $bookings ) { | |
| 294 | + if ( empty( $this->request_args['booking_hash'] ) ) { | |
| 295 | + return true; | |
| 296 | + } | |
| 297 | + | |
| 298 | + $booking_id = absint( $booking_id ); | |
| 299 | + if ( empty( $this->booking_hash_scope ) || $booking_id !== $this->booking_hash_scope['booking_id'] || empty( $bookings[ $booking_id ] ) ) { | |
| 300 | + return false; | |
| 301 | + } | |
| 302 | + | |
| 303 | + return $this->booking_hash_scope['resource_id'] === absint( $bookings[ $booking_id ]->booking_type ); | |
| 304 | + } | |
| 305 | + | |
| 306 | + | |
| 307 | + /** | |
| 308 | + * Rezet data in previos cell | |
| 123 | 309 | */ |
| 124 | 310 | private function reset_data_in_previous_cell(){ |
| 125 | 311 | |
| 126 | 312 | $this->data_in_previous_cell = array( |
| @@ -129,10 +315,9 @@ | ||
| 129 | 315 | ); |
| 130 | 316 | |
| 131 | 317 | } |
| 132 | 318 | |
| 133 | - //////////////////////////////////////////////////////////////////////////// | |
| 134 | - | |
| 319 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 135 | 320 | /** |
| 136 | 321 | * Init Timeline From page shortcode |
| 137 | 322 | * |
| 138 | 323 | * @param array $attr = array( |
| @@ -147,18 +332,18 @@ | ||
| 147 | 332 | public function client_init( $attr ) { |
| 148 | 333 | |
| 149 | 334 | $this->is_frontend = true; |
| 150 | 335 | |
| 151 | - //FixIn:7.0.1.50 | |
| 152 | - if ( isset( $attr['options'] ) ) { | |
| 336 | + // FixIn: 7.0.1.50. | |
| 337 | + if ( isset( $attr['options'] ) ) { | |
| 153 | 338 | |
| 154 | - $bk_otions = $attr['options']; | |
| 155 | - $bk_otions = html_entity_decode( $bk_otions ); //FixIn: 9.8.15.6 | |
| 339 | + $shortcode_param__options = $attr['options']; | |
| 340 | + $shortcode_param__options = html_entity_decode( $shortcode_param__options ); // FixIn: 9.8.15.6. | |
| 156 | 341 | $custom_params = array(); |
| 157 | - if (! empty($bk_otions)) { | |
| 342 | + if (! empty($shortcode_param__options)) { | |
| 158 | 343 | $param ='\s*([^\s]+)=[\'"]{1}([^\'"]+)[\'"]{1}\s*'; // Find all possible options |
| 159 | 344 | $pattern_to_search='%\s*{([^\s]+)' . $param .'}\s*[,]?\s*%'; |
| 160 | - preg_match_all($pattern_to_search, $bk_otions, $matches, PREG_SET_ORDER); | |
| 345 | + preg_match_all($pattern_to_search, $shortcode_param__options, $matches, PREG_SET_ORDER); | |
| 161 | 346 | //debuge($matches); |
| 162 | 347 | /** |
| 163 | 348 | * [bookingtimeline ... options='{resource_link 3="http://beta/resource-apartment3-id3/"},{resource_link 4="http://beta/resource-3-id4/"}' ... ] |
| 164 | 349 | [0] => {resource_link 3="http://beta/resource-apartment3-id3/"}, |
| @@ -174,11 +359,12 @@ | ||
| 174 | 359 | $this->options[ $matche_value[1] ][ $matche_value[2] ] = $matche_value[3]; |
| 175 | 360 | } |
| 176 | 361 | } |
| 177 | 362 | |
| 178 | -//debuge($this->options); | |
| 179 | - } | |
| 180 | - //FixIn:7.0.1.50 | |
| 363 | +//debuge($this->options); | |
| 364 | + } | |
| 365 | + $this->options = self::normalize_options( $this->options ); | |
| 366 | + // FixIn: 7.0.1.50. | |
| 181 | 367 | |
| 182 | 368 | |
| 183 | 369 | //Ovverride some parameters |
| 184 | 370 | //if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| @@ -198,36 +384,12 @@ | ||
| 198 | 384 | // Get clean parameters to request booking data |
| 199 | 385 | $args = $this->wpbc_get_clean_paramas_from_request_for_timeline(); |
| 200 | 386 | |
| 201 | 387 | |
| 202 | - //FixIn: 8.1.3.5 | |
| 203 | - /** Client - Page first load | |
| 204 | - * | |
| 205 | - * If provided valid request_args['booking_hash'] | |
| 206 | - * - Firstly defined in constructor in $_REQUEST['booking_hash'] | |
| 207 | - * - or overwrited in define_request_view_params_from_params from parameters in shortcode 'booking_hash' | |
| 208 | - * then check, if exist booking for this hash. | |
| 209 | - * If exist, get Email of this booking, and | |
| 210 | - * filter getting all other bookings by email keyword. | |
| 211 | - * Addtionly set param ['only_booked_resources'] for showing only booking resources with exist bookings. | |
| 212 | - */ | |
| 213 | - if ( isset( $this->request_args['booking_hash'] ) ) { | |
| 388 | + // A public booking hash authorizes only its exact booking and resource. | |
| 389 | + $args = $this->wpbc_apply_booking_hash_scope_to_query_args( $args, $this->request_args['booking_hash'] ); | |
| 214 | 390 | |
| 215 | - // Get booking details by HASH, and then return Email (or other data of booking, or false if error | |
| 216 | - $booking_details_email = wpbc_get__booking_data_field__by_booking_hash( $this->request_args['booking_hash'] , 'email' ); | |
| 217 | 391 | |
| 218 | - if ( ! empty( $booking_details_email ) ) { | |
| 219 | - | |
| 220 | - // Do not show booking resources with no bookings | |
| 221 | - $this->request_args['only_booked_resources'] = 1; | |
| 222 | - | |
| 223 | - //Set keyword for showing bookings ony relative to this email | |
| 224 | - $args['wh_keyword'] = $booking_details_email; // '[email protected]'; | |
| 225 | - } | |
| 226 | - } | |
| 227 | - //FixIn: 8.1.3.5 - End | |
| 228 | - | |
| 229 | - | |
| 230 | 392 | // Get booking data |
| 231 | 393 | $bk_listing = wpbc_get_bookings_objects( $args ); |
| 232 | 394 | $this->bookings = $bk_listing['bookings']; |
| 233 | 395 | $this->booking_types = $bk_listing['resources']; |
| @@ -240,9 +402,9 @@ | ||
| 240 | 402 | //debuge($this->time_array_new['2017-01-13']); |
| 241 | 403 | |
| 242 | 404 | |
| 243 | 405 | //$milliseconds = round(microtime(true) * 1000); //FixIn: 7.0.Beta.18 |
| 244 | - $milliseconds = rand( 10000, 99999 ); | |
| 406 | + $milliseconds = wp_rand( 10000, 99999 ); | |
| 245 | 407 | |
| 246 | 408 | $this->html_client_id = 'wpbc_timeline_' . $milliseconds; |
| 247 | 409 | |
| 248 | 410 | return $this->html_client_id; |
| @@ -256,12 +418,43 @@ | ||
| 256 | 418 | * @return string html_client_id - exist from input parameters |
| 257 | 419 | */ |
| 258 | 420 | public function ajax_init( $attr ) { |
| 259 | 421 | |
| 260 | - if ( ! defined( 'WPBC_TIMELINE_AJAX' ) ) { define( 'WPBC_TIMELINE_AJAX', true ); } //FixIn: 8.4.7.13 | |
| 422 | + if ( ! defined( 'WPBC_TIMELINE_AJAX' ) ) { define( 'WPBC_TIMELINE_AJAX', true ); } // FixIn: 8.4.7.13. | |
| 261 | 423 | |
| 262 | - $this->is_frontend = (bool) $attr['is_frontend'];; | |
| 424 | + // FixIn: 10.14.14.2. | |
| 425 | + $is_frontend = (bool) $attr['is_frontend']; | |
| 263 | 426 | |
| 427 | + // Not front-end (or possibly changed parameter by attacker to see the bookings). | |
| 428 | + if ( ! $is_frontend ) { | |
| 429 | + | |
| 430 | + // 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. | |
| 431 | + // Get minimum user role to access the Timeline in admin panel (Booking Listing and Timeline Overview (Calendar Overview). | |
| 432 | + $curr_user_role = get_bk_option( 'booking_user_role_booking' ); | |
| 433 | + | |
| 434 | + // Get current user. | |
| 435 | + $current_user = wpbc_get_current_user(); | |
| 436 | + $user_role_map = array( | |
| 437 | + 'administrator' => 10, | |
| 438 | + 'editor' => 7, | |
| 439 | + 'author' => 2, | |
| 440 | + 'contributor' => 1, | |
| 441 | + 'subscriber' => 0, | |
| 442 | + ); | |
| 443 | + | |
| 444 | + $level = 0; | |
| 445 | + if ( isset( $user_role_map[ $curr_user_role ] ) ) { | |
| 446 | + $level = $user_role_map[ $curr_user_role ]; | |
| 447 | + } | |
| 448 | + | |
| 449 | + if ( empty( $current_user ) || empty( $current_user->user_level ) || ( $current_user->user_level < $level ) ) { | |
| 450 | + // Security Fix: Enforce frontend mode for non-admins. | |
| 451 | + $attr['is_frontend'] = 1; | |
| 452 | + } | |
| 453 | + } | |
| 454 | + | |
| 455 | + $this->is_frontend = (bool) $attr['is_frontend']; | |
| 456 | + | |
| 264 | 457 | //Ovverride some parameters |
| 265 | 458 | //if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| 266 | 459 | if ( isset( $attr['type'] ) ) { |
| 267 | 460 | $attr['wh_booking_type'] = $attr['type']; //Instead of 'wh_booking_type' paramter in shortcode is used 'type' parameter |
| @@ -278,9 +471,9 @@ | ||
| 278 | 471 | case '30': |
| 279 | 472 | if ( isset( $this->request_args['scroll_day'] ) ) $scroll_day = intval( $this->request_args['scroll_day'] ); |
| 280 | 473 | else $scroll_day = 0; |
| 281 | 474 | |
| 282 | - //FixIn: 8.9.4.3 | |
| 475 | + // FixIn: 8.9.4.3. | |
| 283 | 476 | // Here we need to define number of days to scroll depends from selected number of days to show. |
| 284 | 477 | $days_num_to_scroll = intval( get_bk_option( 'booking_timeline__month_mode__days_number_show' ) ); |
| 285 | 478 | if ( empty( $days_num_to_scroll ) ) { |
| 286 | 479 | $days_num_to_scroll = 7; |
| @@ -430,37 +623,13 @@ | ||
| 430 | 623 | // Get clean parameters to request booking data |
| 431 | 624 | $args = $this->wpbc_get_clean_paramas_from_request_for_timeline(); |
| 432 | 625 | |
| 433 | 626 | |
| 434 | - //FixIn: 8.1.3.5 | |
| 435 | - /** | |
| 436 | - * If provided valid ['booking_hash'] in timeline_obj in JavaScript param during Ajax request, | |
| 437 | - * then check, if exist booking for this hash. If exist, get Email of this booking, and | |
| 438 | - * filter getting all other bookings by email keyword. | |
| 439 | - * Addtionly set param ['only_booked_resources'] for showing only booking resources with exist bookings | |
| 440 | - */ | |
| 441 | - if ( isset( $attr['booking_hash'] ) ) { | |
| 627 | + // Apply the same exact-booking scope to every unauthenticated navigation request. | |
| 628 | + $booking_hash = isset( $attr['booking_hash'] ) ? $attr['booking_hash'] : ''; | |
| 629 | + $args = $this->wpbc_apply_booking_hash_scope_to_query_args( $args, $booking_hash ); | |
| 442 | 630 | |
| 443 | - // Get booking details by HASH, and then return Email (or other data of booking, or false if error | |
| 444 | - $booking_details_email = wpbc_get__booking_data_field__by_booking_hash( $attr['booking_hash'] , 'email' ); | |
| 445 | -//debuge($attr, $booking_details_email); | |
| 446 | - if ( ! empty( $booking_details_email ) ) { | |
| 447 | 631 | |
| 448 | - // Do not show booking resources with no bookings | |
| 449 | - $this->request_args['only_booked_resources'] = 1; | |
| 450 | - | |
| 451 | - //Set keyword for showing bookings ony relative to this email | |
| 452 | - $args['wh_keyword'] = $booking_details_email; // '[email protected]'; | |
| 453 | - } | |
| 454 | - if ( ( empty( $booking_details_email ) ) && ( ! empty( $attr['booking_hash'] ) ) ) { //FixIn: 8.4.6.1 | |
| 455 | - //FixIn: 8.4.5.13 | |
| 456 | - $this->request_args['only_booked_resources'] = 1; | |
| 457 | - $args['wh_keyword'] = '``^`````^^````^`````````'; | |
| 458 | - } | |
| 459 | - } | |
| 460 | - //FixIn: 8.1.3.5 - End | |
| 461 | - | |
| 462 | - | |
| 463 | 632 | // Get booking data |
| 464 | 633 | $bk_listing = wpbc_get_bookings_objects( $args ); |
| 465 | 634 | |
| 466 | 635 | $this->bookings = $bk_listing['bookings']; |
| @@ -471,9 +640,9 @@ | ||
| 471 | 640 | $this->dates_array = $bookings_date_time[0]; |
| 472 | 641 | $this->time_array_new = $bookings_date_time[1]; |
| 473 | 642 | |
| 474 | 643 | |
| 475 | - $this->html_client_id = $attr['html_client_id']; | |
| 644 | + $this->html_client_id = self::normalize_html_client_id( $attr['html_client_id'] ); | |
| 476 | 645 | |
| 477 | 646 | return $this->html_client_id; |
| 478 | 647 | } |
| 479 | 648 | |
| @@ -509,44 +678,50 @@ | ||
| 509 | 678 | $bookings_date_time = $this->wpbc_get_dates_and_times_for_timeline( $this->bookings ); |
| 510 | 679 | $this->dates_array = $bookings_date_time[0]; |
| 511 | 680 | $this->time_array_new = $bookings_date_time[1]; |
| 512 | 681 | } |
| 682 | + | |
| 683 | + | |
| 684 | + public function client_navigation( $param ) { | |
| 685 | + ?> | |
| 686 | + <script type="text/javascript"> | |
| 687 | + wpbc_timeline_obj["<?php echo esc_js( $this->html_client_id ); ?>"] = { | |
| 688 | + is_frontend : "<?php echo esc_js( $this->is_frontend ? '1' : '0' ); ?>", | |
| 689 | + html_client_id : "<?php echo esc_js( $this->html_client_id ); ?>", | |
| 690 | + wh_booking_type : "<?php echo esc_js( $this->request_args['wh_booking_type'] ); ?>", | |
| 691 | + is_matrix : "<?php echo esc_js( $this->request_args['is_matrix'] ? '1' : '0' ); ?>", | |
| 692 | + view_days_num : "<?php echo esc_js( $this->request_args['view_days_num'] ); ?>", | |
| 693 | + scroll_start_date : "<?php echo esc_js( $this->request_args['scroll_start_date'] ); ?>", | |
| 694 | + scroll_day : "<?php echo esc_js( $this->request_args['scroll_day'] ); ?>", | |
| 695 | + scroll_month : "<?php echo esc_js( $this->request_args['scroll_month'] ); ?>", | |
| 696 | + 'header_column1' : "<?php echo esc_js( $this->timeline_titles['header_column1'] ); ?>", | |
| 697 | + 'header_column2' : "<?php echo esc_js( $this->timeline_titles['header_column2'] ); ?>", | |
| 698 | + 'header_title' : "<?php echo esc_js( $this->timeline_titles['header_title'] ); ?>", | |
| 699 | + 'wh_trash' : "<?php echo esc_js( $this->request_args['wh_trash'] ); ?>", | |
| 700 | + 'limit_hours' : "<?php echo esc_js( $this->request_args['limit_hours'] ); ?>", | |
| 701 | + 'only_booked_resources': "<?php echo esc_js( $this->request_args['only_booked_resources'] ); ?>", | |
| 702 | + 'options' : <?php | |
| 703 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Returns a complete JSON-encoded JavaScript string literal. | |
| 704 | + echo self::encode_options_for_inline_script( $this->options ); | |
| 705 | + ?>, | |
| 706 | + 'booking_hash' : "<?php echo esc_js( $this->request_args['booking_hash'] ); ?>" | |
| 707 | + }; | |
| 708 | + </script> | |
| 709 | + <div class="flex_tl_nav"> | |
| 710 | + <div class="flex_tl_prev" href="javascript:void(0)" | |
| 711 | + onclick="javascript:wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo esc_js( $this->html_client_id ); ?>'], -1 );"> | |
| 712 | + <a>«</a></div> | |
| 713 | + <div class="flex_tl_title"><?php echo esc_html( $param['title'] ); ?></div> | |
| 714 | + <div class="flex_tl_next" href="javascript:void(0)" | |
| 715 | + onclick="javascript:wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo esc_js( $this->html_client_id ); ?>'], 1 );"> | |
| 716 | + <a>»</a></div> | |
| 717 | + </div> | |
| 718 | + <?php | |
| 719 | + } | |
| 513 | 720 | |
| 514 | - | |
| 515 | - public function client_navigation( $param ) { | |
| 516 | - ?> | |
| 517 | - <script type="text/javascript"> | |
| 518 | - wpbc_timeline_obj["<?php echo $this->html_client_id; ?>"] = { | |
| 519 | - is_frontend: "<?php echo ( $this->is_frontend ? '1' : '0' ); ?>" | |
| 520 | - , html_client_id: "<?php echo $this->html_client_id; ?>" | |
| 521 | - , wh_booking_type: "<?php echo $this->request_args['wh_booking_type']; ?>" | |
| 522 | - , is_matrix: "<?php echo ( $this->request_args['is_matrix'] ? '1' : '0' ); ?>" | |
| 523 | - , view_days_num: "<?php echo $this->request_args['view_days_num']; ?>" | |
| 524 | - , scroll_start_date: "<?php echo $this->request_args['scroll_start_date']; ?>" | |
| 525 | - , scroll_day: "<?php echo $this->request_args['scroll_day']; ?>" | |
| 526 | - , scroll_month: "<?php echo $this->request_args['scroll_month']; ?>" | |
| 527 | - , 'header_column1': "<?php echo esc_js( $this->timeline_titles['header_column1'] ); ?>" | |
| 528 | - , 'header_column2': "<?php echo esc_js( $this->timeline_titles['header_column2'] ); ?>" | |
| 529 | - , 'header_title': "<?php echo esc_js( $this->timeline_titles['header_title'] ); ?>" | |
| 530 | - , 'wh_trash': "<?php echo esc_js( $this->request_args['wh_trash'] ); ?>" | |
| 531 | - , 'limit_hours': "<?php echo esc_js( $this->request_args['limit_hours'] ); ?>" //FixIn: 7.0.1.14 | |
| 532 | - , 'only_booked_resources': "<?php echo esc_js( $this->request_args['only_booked_resources'] ); ?>" //FixIn: 7.0.1.51 | |
| 533 | - , 'options': '<?php echo wp_json_encode( $this->options ); ?>' //FixIn: 9.2.1.8 //FixIn: 7.2.1.14 | |
| 534 | - , 'booking_hash': "<?php echo esc_js( $this->request_args['booking_hash'] ); ?>" //FixIn: 8.1.3.5 | |
| 535 | - }; | |
| 536 | - </script> | |
| 537 | - <div class="flex_tl_nav"> | |
| 538 | - <div class="flex_tl_prev" href="javascript:void(0)" onclick="javascript:wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo $this->html_client_id; ?>'], -1 );"><a>«</a></div> | |
| 539 | - <div class="flex_tl_title"><?php echo $param['title'] ?></div> | |
| 540 | - <div class="flex_tl_next" href="javascript:void(0)" onclick="javascript:wpbc_flextimeline_nav( wpbc_timeline_obj['<?php echo $this->html_client_id; ?>'], 1 );"><a>»</a></div> | |
| 541 | - </div> | |
| 542 | - <?php | |
| 543 | - } | |
| 544 | - | |
| 545 | - //////////////////////////////////////////////////////////////////////////// | |
| 721 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 546 | 722 | // S u p p o r t |
| 547 | - //////////////////////////////////////////////////////////////////////////// | |
| 548 | - | |
| 723 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 549 | 724 | /** |
| 550 | 725 | * Get array of cleaned (limited number) paramas from request for getting bookings by "wpbc_get_bookings_objects" |
| 551 | 726 | * |
| 552 | 727 | * @return array |
| @@ -552,9 +727,9 @@ | ||
| 552 | 727 | * @return array |
| 553 | 728 | */ |
| 554 | 729 | public function wpbc_get_clean_paramas_from_request_for_timeline() { |
| 555 | 730 | |
| 556 | - //Replacing in this file from date( to date_i18n( to wpbc_datetime__no_wp_timezone( //FixIn: 9.9.0.18 | |
| 731 | + //Replacing in this file from gmdate( to date_i18n( to wpbc_datetime__no_wp_timezone( // FixIn: 9.9.0.18. | |
| 557 | 732 | $start_year = intval( wpbc_datetime__no_wp_timezone( "Y" ) ); |
| 558 | 733 | $start_month = intval( wpbc_datetime__no_wp_timezone( "m" ) ); |
| 559 | 734 | $start_day = 1; |
| 560 | 735 | //debuge( '1.( $start_year, $start_month, $start_day , $this->request_args ', $start_year, $start_month, $start_day , $this->request_args ); |
| @@ -748,9 +923,9 @@ | ||
| 748 | 923 | 'or_sort' => $or_sort, |
| 749 | 924 | 'page_num' => '1', |
| 750 | 925 | 'wh_trash' => $this->request_args['wh_trash'], |
| 751 | 926 | 'limit_hours' => $this->request_args['limit_hours'], |
| 752 | - 'only_booked_resources' => $this->request_args['only_booked_resources'], //FixIn: 7.0.1.51 | |
| 927 | + 'only_booked_resources' => $this->request_args['only_booked_resources'], // FixIn: 7.0.1.51. | |
| 753 | 928 | 'page_items_count' => '100000' |
| 754 | 929 | ); |
| 755 | 930 | //debuge('8.',$args); |
| 756 | 931 | return $args; |
| @@ -761,61 +936,103 @@ | ||
| 761 | 936 | * Define View Params from $_REQUEST |
| 762 | 937 | */ |
| 763 | 938 | public function define_request_view_params() { |
| 764 | 939 | |
| 765 | - // All other sanitizing and escaping are inside of this function wpbc_check_request_paramters(), which executing before. //FixIn: 8.9.2.1 | |
| 940 | + // All other sanitizing and escaping are inside of this function wpbc_check_request_paramters(), which executing before. // FixIn: 8.9.2.1. | |
| 766 | 941 | |
| 767 | 942 | // Used once for comma seperated resources only. |
| 943 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 768 | 944 | if ( isset( $_REQUEST['wh_booking_type'] ) ) { |
| 769 | - $this->request_args['wh_booking_type'] = wpbc_clean_digit_or_csd( $_REQUEST['wh_booking_type'] ); //FixIn: 8.9.2.1 | |
| 945 | + $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. | |
| 946 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 770 | 947 | } elseif ( isset( $_GET['booking_type'] ) ) { |
| 771 | - $this->request_args['wh_booking_type'] = wpbc_clean_digit_or_csd( $_GET['booking_type'] ); //FixIn: 8.9.2.1 | |
| 948 | + $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. | |
| 772 | 949 | } |
| 773 | - | |
| 774 | - if ( ( isset( $_REQUEST['wh_booking_type'] ) ) && ( strpos( $_REQUEST['wh_booking_type'], ',' ) !== false ) ) | |
| 775 | - $this->request_args['is_matrix'] = true; | |
| 776 | - if ( isset( $_REQUEST['view_days_num'] ) ) $this->request_args['view_days_num'] = $_REQUEST['view_days_num']; | |
| 777 | - if ( isset( $_REQUEST['scroll_start_date'] ) ) $this->request_args['scroll_start_date'] = $_REQUEST['scroll_start_date']; | |
| 778 | - if ( isset( $_REQUEST['scroll_day'] ) ) $this->request_args['scroll_day'] = $_REQUEST['scroll_day']; | |
| 779 | - if ( isset( $_REQUEST['scroll_month'] ) ) $this->request_args['scroll_month'] = $_REQUEST['scroll_month']; | |
| 780 | - if ( isset( $_REQUEST['wh_trash'] ) ) $this->request_args['wh_trash'] = $_REQUEST['wh_trash']; | |
| 781 | - | |
| 782 | - if ( isset( $_REQUEST['limit_hours'] ) ) $this->request_args['limit_hours'] = $_REQUEST['limit_hours']; //FixIn: 7.0.1.14 | |
| 783 | - if ( isset( $_REQUEST['only_booked_resources'] ) ) $this->request_args['only_booked_resources'] = 1;//$_REQUEST['only_booked_resources']; //FixIn: 7.0.1.51 | |
| 950 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash | |
| 951 | + if ( ( isset( $_REQUEST['wh_booking_type'] ) ) && ( strpos( $_REQUEST['wh_booking_type'], ',' ) !== false ) ) { | |
| 952 | + $this->request_args['is_matrix'] = true; | |
| 953 | + } | |
| 954 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 955 | + if ( isset( $_REQUEST['view_days_num'] ) ) { | |
| 956 | + $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 */ | |
| 957 | + } | |
| 958 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 959 | + if ( isset( $_REQUEST['scroll_start_date'] ) ) { | |
| 960 | + $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 */ | |
| 961 | + } | |
| 962 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 963 | + if ( isset( $_REQUEST['scroll_day'] ) ) { | |
| 964 | + $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 */ | |
| 965 | + } | |
| 966 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 967 | + if ( isset( $_REQUEST['scroll_month'] ) ) { | |
| 968 | + $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 */ | |
| 969 | + } | |
| 970 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 971 | + if ( isset( $_REQUEST['wh_trash'] ) ) { | |
| 972 | + $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 */ | |
| 973 | + } | |
| 974 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 975 | + if ( isset( $_REQUEST['limit_hours'] ) ) { | |
| 976 | + $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 */ | |
| 977 | + } // FixIn: 7.0.1.14. | |
| 978 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 979 | + if ( isset( $_REQUEST['only_booked_resources'] ) ) { | |
| 980 | + $this->request_args['only_booked_resources'] = 1; | |
| 981 | + } //$_REQUEST['only_booked_resources']; // FixIn: 7.0.1.51. | |
| 784 | 982 | } |
| 785 | - | |
| 786 | - | |
| 787 | - /** | |
| 983 | + | |
| 984 | + | |
| 985 | + /** | |
| 788 | 986 | * Define Request View Params |
| 789 | - * | |
| 790 | - * @param array $param = = array( | |
| 791 | - 'wh_booking_type' => '' | |
| 792 | - , 'is_matrix' => false | |
| 793 | - , 'view_days_num' => '30' | |
| 794 | - , 'scroll_start_date' => '' | |
| 795 | - , 'scroll_day' => 0 | |
| 796 | - , 'scroll_month' => 0 | |
| 797 | - ); | |
| 798 | - */ | |
| 799 | - public function define_request_view_params_from_params( $param ) { | |
| 800 | - //debuge( $param , $this->options , maybe_unserialize( wp_unslash( $param['options'] ) ) );die; | |
| 801 | - if ( isset( $param['wh_booking_type'] ) ) $this->request_args['wh_booking_type'] = $param['wh_booking_type']; // Used once for comma seperated resources only. | |
| 802 | - | |
| 803 | - if ( ( isset( $param['wh_booking_type'] ) ) && ( strpos( $param['wh_booking_type'], ',' ) !== false ) ) | |
| 804 | - $this->request_args['is_matrix'] = true; | |
| 805 | - if ( isset( $param['view_days_num'] ) ) $this->request_args['view_days_num'] = $param['view_days_num']; | |
| 806 | - if ( isset( $param['scroll_start_date'] ) ) $this->request_args['scroll_start_date'] = $param['scroll_start_date']; | |
| 807 | - if ( isset( $param['scroll_day'] ) ) $this->request_args['scroll_day'] = $param['scroll_day']; | |
| 808 | - if ( isset( $param['scroll_month'] ) ) $this->request_args['scroll_month'] = $param['scroll_month']; | |
| 809 | - if ( isset( $param['wh_trash'] ) ) $this->request_args['wh_trash'] = $param['wh_trash']; | |
| 810 | - if ( isset( $param['limit_hours'] ) ) $this->request_args['limit_hours'] = $param['limit_hours']; //FixIn: 7.0.1.14 | |
| 811 | - if ( isset( $param['only_booked_resources'] ) ) $this->request_args['only_booked_resources'] = $param['only_booked_resources']; //FixIn: 7.0.1.14 | |
| 812 | - if ( isset( $param['booking_hash'] ) ) $this->request_args['booking_hash'] = $param['booking_hash']; //FixIn: 8.1.3.5 | |
| 813 | - if ( ( empty( $this->options ) ) && ( isset( $param['options'] ) ) ) { | |
| 814 | - $this->options = json_decode( wp_unslash( $param['options'] ), true ); //FixIn: 9.2.1.8 | |
| 815 | - } | |
| 816 | - | |
| 817 | - } | |
| 987 | + * | |
| 988 | + * @param array $param = = array( | |
| 989 | + * 'wh_booking_type' => '' | |
| 990 | + * , 'is_matrix' => false | |
| 991 | + * , 'view_days_num' => '30' | |
| 992 | + * , 'scroll_start_date' => '' | |
| 993 | + * , 'scroll_day' => 0 | |
| 994 | + * , 'scroll_month' => 0 | |
| 995 | + * ); | |
| 996 | + */ | |
| 997 | + public function define_request_view_params_from_params( $param ) { | |
| 998 | + //debuge( $param , $this->options , maybe_unserialize( wp_unslash( $param['options'] ) ) );die; | |
| 999 | + if ( isset( $param['wh_booking_type'] ) ) { | |
| 1000 | + $this->request_args['wh_booking_type'] = $param['wh_booking_type']; | |
| 1001 | + } // Used once for comma seperated resources only. | |
| 1002 | + | |
| 1003 | + if ( ( isset( $param['wh_booking_type'] ) ) && ( strpos( $param['wh_booking_type'], ',' ) !== false ) ) { | |
| 1004 | + $this->request_args['is_matrix'] = true; | |
| 1005 | + } | |
| 1006 | + if ( isset( $param['view_days_num'] ) ) { | |
| 1007 | + $this->request_args['view_days_num'] = $param['view_days_num']; | |
| 1008 | + } | |
| 1009 | + if ( isset( $param['scroll_start_date'] ) ) { | |
| 1010 | + $this->request_args['scroll_start_date'] = $param['scroll_start_date']; | |
| 1011 | + } | |
| 1012 | + if ( isset( $param['scroll_day'] ) ) { | |
| 1013 | + $this->request_args['scroll_day'] = $param['scroll_day']; | |
| 1014 | + } | |
| 1015 | + if ( isset( $param['scroll_month'] ) ) { | |
| 1016 | + $this->request_args['scroll_month'] = $param['scroll_month']; | |
| 1017 | + } | |
| 1018 | + if ( isset( $param['wh_trash'] ) ) { | |
| 1019 | + $this->request_args['wh_trash'] = $param['wh_trash']; | |
| 1020 | + } | |
| 1021 | + if ( isset( $param['limit_hours'] ) ) { | |
| 1022 | + $this->request_args['limit_hours'] = $param['limit_hours']; | |
| 1023 | + } // FixIn: 7.0.1.14. | |
| 1024 | + if ( isset( $param['only_booked_resources'] ) ) { | |
| 1025 | + $this->request_args['only_booked_resources'] = $param['only_booked_resources']; | |
| 1026 | + } // FixIn: 7.0.1.14. | |
| 1027 | + if ( isset( $param['booking_hash'] ) ) { | |
| 1028 | + $this->request_args['booking_hash'] = $param['booking_hash']; | |
| 1029 | + } // FixIn: 8.1.3.5. | |
| 1030 | + if ( ( empty( $this->options ) ) && ( isset( $param['options'] ) ) ) { | |
| 1031 | + $this->options = self::decode_options( $param['options'] ); // FixIn: 9.2.1.8. | |
| 1032 | + } | |
| 1033 | + | |
| 1034 | + } | |
| 818 | 1035 | |
| 819 | 1036 | |
| 820 | 1037 | /** |
| 821 | 1038 | * Get D A T E S and T I M E S from B o o k i n g s |
| @@ -894,9 +1111,9 @@ | ||
| 894 | 1111 | case '1': // Start |
| 895 | 1112 | $is_started++; |
| 896 | 1113 | break; |
| 897 | 1114 | case '2': // End |
| 898 | - case '8': //FixIn: 9.0.1.2 | |
| 1115 | + case '8': // FixIn: 9.0.1.2. | |
| 899 | 1116 | $is_started--; |
| 900 | 1117 | break; |
| 901 | 1118 | case '0': // Full |
| 902 | 1119 | default: |
| @@ -918,11 +1135,11 @@ | ||
| 918 | 1135 | } |
| 919 | 1136 | |
| 920 | 1137 | if ( 0 != $is_started ) { |
| 921 | 1138 | ?><div class="warning_check_in_out_not_equal"><?php |
| 922 | - //FixIn: 9.2.4.5 | |
| 1139 | + // FixIn: 9.2.4.5. | |
| 923 | 1140 | ?><div style="margin:0 10px 10px;font-weight:600;font-size:1.1em;"><?php |
| 924 | - printf( 'Warning! Structure of your booking dates has an issue.'); | |
| 1141 | + echo( 'Warning! Structure of your booking dates has an issue.'); | |
| 925 | 1142 | ?></div><?php |
| 926 | 1143 | ?><div style="margin:0 10px 30px;font-weight:400;font-size:1.1em;"><?php |
| 927 | 1144 | 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.' ); |
| 928 | 1145 | ?></div><?php |
| @@ -932,18 +1149,16 @@ | ||
| 932 | 1149 | $bookings_to_del = array(); |
| 933 | 1150 | for( $day_i = 0; $day_i <= ( count( $dates_to_check ) - 1 ); $day_i++) { |
| 934 | 1151 | $bookings_to_del[] = $dates_to_check[$day_i]->booking_id; |
| 935 | 1152 | } |
| 936 | - $bookings_to_del = array_unique ( $bookings_to_del ); | |
| 937 | - for( $bk_i = 0; $bk_i <= ( count( $bookings_to_del ) - 1 ); $bk_i++) { | |
| 938 | - $booking_id__to_del = $bookings_to_del [ $bk_i ]; | |
| 1153 | + $bookings_to_del = array_unique( $bookings_to_del ); | |
| 1154 | + for ( $bk_i = 0; $bk_i <= ( count( $bookings_to_del ) - 1 ); $bk_i ++ ) { | |
| 1155 | + $booking_id__to_del = $bookings_to_del [ $bk_i ]; | |
| 939 | 1156 | |
| 940 | 1157 | ?><div style="margin:10px;font-weight:600;font-size:1.05em;"><?php |
| 941 | 1158 | |
| 942 | - printf( 'Delete booking with %s', htmlspecialchars_decode( | |
| 943 | - '<strong></strong><a href="' . | |
| 944 | - esc_url( wpbc_get_bookings_url() . '&view_mode=vm_listing&tab=actions&wh_booking_id=' . $booking_id__to_del ) | |
| 945 | - . '">' . 'ID = ' . $booking_id__to_del . '</a></strong>' ) ); | |
| 1159 | + 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>' ) ) ); | |
| 1160 | + | |
| 946 | 1161 | ?></div><?php |
| 947 | 1162 | } |
| 948 | 1163 | |
| 949 | 1164 | ?><div style="margin:50px;font-weight:600;font-size:1.05em;"></div><?php |
| @@ -960,9 +1175,9 @@ | ||
| 960 | 1175 | // Transform from MySQL date to PHP date |
| 961 | 1176 | $dt->booking_date = trim( $dt->booking_date ); |
| 962 | 1177 | $dta = explode( ' ', $dt->booking_date ); |
| 963 | 1178 | $tms = $dta[1]; |
| 964 | -//FixIn: 8.2.1.21 | |
| 1179 | +// FixIn: 8.2.1.21. | |
| 965 | 1180 | //if ( substr( $dta[1], - 1 ) == '2' ) { continue; } |
| 966 | 1181 | $tms = explode( ':', $tms ); // array('13','30','40') |
| 967 | 1182 | $dta = $dta[0]; |
| 968 | 1183 | $dta = explode( '-', $dta ); // array('2012','12','30') |
| @@ -987,9 +1202,9 @@ | ||
| 987 | 1202 | |
| 988 | 1203 | $my_time_index = explode( ':', $my_time ); |
| 989 | 1204 | $my_time_index = (int) ($my_time_index[0] * 60 * 60 + $my_time_index[1] * 60 + $my_time_index[2]); |
| 990 | 1205 | |
| 991 | - $my_time = strtotime( $my_time ); //FixIn: 8.1.1.6 | |
| 1206 | + $my_time = strtotime( $my_time ); // FixIn: 8.1.1.6. | |
| 992 | 1207 | |
| 993 | 1208 | if ( !isset( $time_array[$my_date] ) ) { |
| 994 | 1209 | $time_array[$my_date] = array( $my_time_index => array( $my_time => array( 'id' => $bk->booking_id, 'resource' => $date_bk_res_id ) ) ); |
| 995 | 1210 | } else { |
| @@ -1126,9 +1341,9 @@ | ||
| 1126 | 1341 | * but at current date "November 6" (where start other Booking #76: November 6 18:00; November 13; November 27 20:00" |
| 1127 | 1342 | * this booking #77 does not exist at all !!! |
| 1128 | 1343 | * so we nee to remove this booking(s) from array $fill_this_date |
| 1129 | 1344 | */ |
| 1130 | - //FixIn: 8.7.1.1 | |
| 1345 | + // FixIn: 8.7.1.1. | |
| 1131 | 1346 | if(1){ |
| 1132 | 1347 | //////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1133 | 1348 | // Search to remove |
| 1134 | 1349 | $remove_arr_keys = array(); |
| @@ -1196,9 +1411,9 @@ | ||
| 1196 | 1411 | // Fix, when we are having END time but was not having START time (usually when first booking |
| 1197 | 1412 | // was booked for entire day, and last day booking, have the end time. |
| 1198 | 1413 | // So in this case at day with end time we need to fill all "round times" with End time data |
| 1199 | 1414 | */ |
| 1200 | -//FixIn: 8.7.1.1 | |
| 1415 | +// FixIn: 8.7.1.1. | |
| 1201 | 1416 | if(1) |
| 1202 | 1417 | if ( empty( $fill_this_date_keys_to_delete ) ) { |
| 1203 | 1418 | // Fill the date by data $toDelete |
| 1204 | 1419 | foreach ( $time_array_new[ $ddate ] as $time_round_refill => $time_array_new_value_refill ) { |
| @@ -1236,12 +1451,11 @@ | ||
| 1236 | 1451 | return array( $dates_array, $time_array_new ); |
| 1237 | 1452 | } |
| 1238 | 1453 | |
| 1239 | 1454 | |
| 1240 | - //////////////////////////////////////////////////////////////////////////// | |
| 1455 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1241 | 1456 | // C a l e n d a r T i m e l i n e /////////////////////////////// |
| 1242 | - //////////////////////////////////////////////////////////////////////////// | |
| 1243 | - | |
| 1457 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1244 | 1458 | private function wpbc_dates_only_of_specific_resource( $booked_dates_array, $resource_id, $bookings ) { |
| 1245 | 1459 | |
| 1246 | 1460 | foreach ( $booked_dates_array as $key => $value ) { |
| 1247 | 1461 | |
| @@ -1307,12 +1521,11 @@ | ||
| 1307 | 1521 | return $css_class; |
| 1308 | 1522 | } |
| 1309 | 1523 | |
| 1310 | 1524 | |
| 1311 | - //////////////////////////////////////////////////////////////////////////// | |
| 1525 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1312 | 1526 | // Header |
| 1313 | - //////////////////////////////////////////////////////////////////////////// | |
| 1314 | - | |
| 1527 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 1315 | 1528 | /** Header */ |
| 1316 | 1529 | public function wpbc_show_timeline_header_row( $start_date = false ) { |
| 1317 | 1530 | |
| 1318 | 1531 | $current_resource_id = ''; |
| @@ -1317,9 +1530,9 @@ | ||
| 1317 | 1530 | |
| 1318 | 1531 | $current_resource_id = ''; |
| 1319 | 1532 | $is_matrix = $this->request_args['is_matrix']; |
| 1320 | 1533 | $view_days_num = $this->request_args['view_days_num']; |
| 1321 | - $start_hour_for_1day_view = 0; //FixIn: 7.0.1.14 | |
| 1534 | + $start_hour_for_1day_view = 0; // FixIn: 7.0.1.14. | |
| 1322 | 1535 | $end_hour_for_1day_view = 24; |
| 1323 | 1536 | $limit_hours = 24; |
| 1324 | 1537 | |
| 1325 | 1538 | if ( $is_matrix ) { |
| @@ -1329,9 +1542,9 @@ | ||
| 1329 | 1542 | case '1': |
| 1330 | 1543 | $days_num = 1; |
| 1331 | 1544 | $dwa = $this->week_days_titles['full']; |
| 1332 | 1545 | $time_selles_num = 24; |
| 1333 | - if ( isset( $this->request_args[ 'limit_hours' ] ) ) { //FixIn: 7.0.1.14 | |
| 1546 | + if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. | |
| 1334 | 1547 | $limit_hours = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1335 | 1548 | $start_hour_for_1day_view = intval( $limit_hours[0] ); |
| 1336 | 1549 | $end_hour_for_1day_view = intval( $limit_hours[1] ); |
| 1337 | 1550 | $limit_hours = $limit_hours[1] - $limit_hours[0]; |
| @@ -1338,20 +1551,22 @@ | ||
| 1338 | 1551 | } |
| 1339 | 1552 | break; |
| 1340 | 1553 | case '7': |
| 1341 | 1554 | $days_num = 7; |
| 1342 | - $dwa = $this->week_days_titles['3']; | |
| 1555 | + //$dwa = $this->week_days_titles['3']; | |
| 1556 | + $dwa = $this->week_days_titles['1']; | |
| 1343 | 1557 | $time_selles_num = 1; |
| 1344 | 1558 | break; |
| 1345 | 1559 | case '30': |
| 1346 | 1560 | $days_num = 31; |
| 1347 | - $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 | |
| 1561 | + $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. | |
| 1348 | 1562 | $dwa = $this->week_days_titles['1']; |
| 1349 | 1563 | $time_selles_num = 1; |
| 1350 | 1564 | break; |
| 1351 | 1565 | case '60': |
| 1352 | 1566 | $days_num = 62; |
| 1353 | - $dwa = $this->week_days_titles['short']; | |
| 1567 | + //$dwa = $this->week_days_titles['short']; | |
| 1568 | + $dwa = $this->week_days_titles['1']; | |
| 1354 | 1569 | $time_selles_num = 1; |
| 1355 | 1570 | break; |
| 1356 | 1571 | default: // 30 |
| 1357 | 1572 | $days_num = 31; |
| @@ -1368,10 +1583,10 @@ | ||
| 1368 | 1583 | $dwa = $this->week_days_titles['3']; |
| 1369 | 1584 | $time_selles_num = 1; |
| 1370 | 1585 | break; |
| 1371 | 1586 | case '365': |
| 1372 | - $days_num = 31; //FixIn: 8.7.6.5 | |
| 1373 | - //$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 | |
| 1587 | + $days_num = 31; // FixIn: 8.7.6.5. | |
| 1588 | + //$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. | |
| 1374 | 1589 | $dwa = $this->week_days_titles['3']; |
| 1375 | 1590 | $time_selles_num = 1; |
| 1376 | 1591 | break; |
| 1377 | 1592 | default: // 30 |
| @@ -1377,9 +1592,9 @@ | ||
| 1377 | 1592 | default: // 30 |
| 1378 | 1593 | $days_num = 1; |
| 1379 | 1594 | $dwa = $this->week_days_titles['full']; |
| 1380 | 1595 | $time_selles_num = 24; |
| 1381 | - if ( isset( $this->request_args[ 'limit_hours' ] ) ) { //FixIn: 7.0.1.14 | |
| 1596 | + if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. | |
| 1382 | 1597 | $limit_hours = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1383 | 1598 | $start_hour_for_1day_view = intval( $limit_hours[0] ); |
| 1384 | 1599 | $end_hour_for_1day_view = intval( $limit_hours[1] ); |
| 1385 | 1600 | $limit_hours = $limit_hours[1] - $limit_hours[0]; |
| @@ -1413,45 +1628,54 @@ | ||
| 1413 | 1628 | $dd = wpbc_datetime__no_wp_timezone( "d", $real_date ); //31 |
| 1414 | 1629 | $ww = wpbc_datetime__no_wp_timezone( "N", $real_date ); //7 |
| 1415 | 1630 | $day_week = $dwa[$ww]; //Su |
| 1416 | 1631 | |
| 1417 | - if ( ( $previous_month != $mm ) || ( 1 == $dd ) ) { | |
| 1632 | + $month_title = ''; | |
| 1633 | + $month_class = ''; | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + if ( ($view_days_num == 30) || ($view_days_num == 60) ) { | |
| 1637 | + if (( (intval($ww)-1) === intval(get_bk_option( 'booking_start_day_weeek' )) )){ | |
| 1638 | + $month_class = ' new_month '; | |
| 1639 | + } | |
| 1640 | + } else { | |
| 1641 | + if(( $previous_month != $mm ) || ( 1 == $dd )){ | |
| 1642 | + $month_class = ' new_month '; | |
| 1643 | + } | |
| 1644 | + } | |
| 1645 | + if ($month_class == ' new_month '){ | |
| 1418 | 1646 | $previous_month = $mm; |
| 1419 | 1647 | $month_title = wpbc_datetime__no_wp_timezone( "F", $real_date ); //09 |
| 1420 | - $month_class = ' new_month '; | |
| 1421 | - } else { | |
| 1422 | - $month_title = ''; | |
| 1423 | - $month_class = ''; | |
| 1424 | 1648 | } |
| 1649 | + | |
| 1425 | 1650 | ?> |
| 1426 | 1651 | <div class="<?php echo implode(' ', array( |
| 1427 | 1652 | 'flex_tl_day_cell', |
| 1428 | 1653 | 'flex_tl_day_cell_header', |
| 1429 | - 'flex_time_in_days_num_' . $view_days_num, | |
| 1430 | - $month_class | |
| 1654 | + 'flex_time_in_days_num_' . esc_attr( $view_days_num ), | |
| 1655 | + esc_attr( $month_class ) | |
| 1431 | 1656 | )); ?>" |
| 1432 | 1657 | ><?php |
| 1433 | - // New Month ! | |
| 1434 | - if ($month_title != '') { | |
| 1435 | - ?><div class="in_cell_month_year"><?php | |
| 1658 | + // New Month ! | |
| 1659 | + if ( $month_title != '' ) { | |
| 1660 | + ?> | |
| 1661 | + <div class="in_cell_month_year"><?php | |
| 1436 | 1662 | |
| 1437 | - if ( $is_matrix ) { | |
| 1663 | + if ( $is_matrix ) { | |
| 1438 | 1664 | |
| 1439 | - echo $dd . ' ' . $month_title .', ' . $yy ; | |
| 1665 | + echo esc_attr( $dd . ' ' . $month_title . ', ' . $yy ); | |
| 1440 | 1666 | |
| 1441 | - if ( '1' == $view_days_num ) { | |
| 1442 | - echo ' (' . $day_week . ')'; | |
| 1443 | - } | |
| 1667 | + if ( '1' == $view_days_num ) { | |
| 1668 | + echo ' (' . esc_attr( $day_week ) . ')'; | |
| 1669 | + } | |
| 1444 | 1670 | |
| 1445 | - } else { | |
| 1446 | - if ( '30' == $view_days_num ) { | |
| 1447 | - //echo '(' . $day_week . ') ' . $dd . ' '; | |
| 1448 | - } | |
| 1449 | - } | |
| 1450 | - | |
| 1451 | - | |
| 1452 | - ?></div><?php | |
| 1671 | + } else { | |
| 1672 | + if ( '30' == $view_days_num ) { | |
| 1673 | + //echo '(' . esc_attr($day_week) . ') ' . esc_attr($dd) . ' '; | |
| 1674 | + } | |
| 1453 | 1675 | } |
| 1676 | + ?></div><?php | |
| 1677 | + } | |
| 1454 | 1678 | ?> </div> <?php |
| 1455 | 1679 | } |
| 1456 | 1680 | ?> |
| 1457 | 1681 | </div><?php |
| @@ -1459,10 +1683,10 @@ | ||
| 1459 | 1683 | |
| 1460 | 1684 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1461 | 1685 | // Dates / Times Line |
| 1462 | 1686 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1463 | - ?><div class="flex_tl_dates_bar <?php echo $is_matrix ? ' flex_tl_matrix_resources ' : ' flex_tl_single_resource '; ?>" | |
| 1464 | - id="timeline_scroller<?php echo $current_resource_id; ?>" | |
| 1687 | + ?><div class="flex_tl_dates_bar <?php echo esc_attr( $is_matrix ? ' flex_tl_matrix_resources ' : ' flex_tl_single_resource ' ); ?>" | |
| 1688 | + id="timeline_scroller<?php echo esc_attr( $current_resource_id ); ?>" | |
| 1465 | 1689 | ><?php |
| 1466 | 1690 | $previous_month = ''; |
| 1467 | 1691 | |
| 1468 | 1692 | $bk_admin_url_today = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), array( 'scroll_month', 'scroll_day', 'scroll_start_date' ) ); |
| @@ -1484,9 +1708,9 @@ | ||
| 1484 | 1708 | |
| 1485 | 1709 | $day_title = $dd . ' ' . $day_week; |
| 1486 | 1710 | if ( $is_matrix ) { |
| 1487 | 1711 | if ( $view_days_num == 1 ) { |
| 1488 | - $day_title = '<div class="in_cell_day_num">' . __( 'Times', 'booking' ) . '</div>'; | |
| 1712 | + $day_title = '<div class="in_cell_day_num">' . esc_html__( 'Times', 'booking' ) . '</div>'; | |
| 1489 | 1713 | } |
| 1490 | 1714 | if ( $view_days_num == 7 ) { |
| 1491 | 1715 | $day_title = '<div class="in_cell_day_num">' . $dd . '</div><div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1492 | 1716 | } |
| @@ -1497,9 +1721,9 @@ | ||
| 1497 | 1721 | $day_title = '<div class="in_cell_day_num">' . $dd . '</div><div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1498 | 1722 | } |
| 1499 | 1723 | } else { |
| 1500 | 1724 | if ( $view_days_num == 30 ) { |
| 1501 | - $day_title = '<div class="in_cell_day_num">' . __( 'Times', 'booking' ) . '</div>'; | |
| 1725 | + $day_title = '<div class="in_cell_day_num">' . esc_html__( 'Times', 'booking' ) . '</div>'; | |
| 1502 | 1726 | } |
| 1503 | 1727 | if ( $view_days_num == 90 ) { |
| 1504 | 1728 | $day_title = '<div class="in_cell_day_week">' . $day_week . '</div>'; |
| 1505 | 1729 | } |
| @@ -1516,10 +1740,10 @@ | ||
| 1516 | 1740 | $month_class = ''; |
| 1517 | 1741 | } |
| 1518 | 1742 | |
| 1519 | 1743 | ?> |
| 1520 | - <div id="cell_<?php echo $current_resource_id . '_' . $day_filter_id ; ?>" | |
| 1521 | - class="<?php echo implode(' ', array( | |
| 1744 | + <div id="cell_<?php echo esc_attr( $current_resource_id . '_' . $day_filter_id ); ?>" | |
| 1745 | + class="<?php echo esc_attr( implode(' ', array( | |
| 1522 | 1746 | 'flex_tl_day_cell', |
| 1523 | 1747 | 'flex_tl_day_cell_header', |
| 1524 | 1748 | 'flex_time_in_days_num_' . $view_days_num, |
| 1525 | 1749 | 'flex_tl_weekday' . $ww, |
| @@ -1524,19 +1748,19 @@ | ||
| 1524 | 1748 | 'flex_time_in_days_num_' . $view_days_num, |
| 1525 | 1749 | 'flex_tl_weekday' . $ww, |
| 1526 | 1750 | $day_filter_id, |
| 1527 | 1751 | $month_class |
| 1528 | - )); ?>" | |
| 1752 | + ))); ?>" | |
| 1529 | 1753 | ><?php |
| 1530 | 1754 | |
| 1531 | 1755 | if ( ( $is_matrix ) && ( ( $view_days_num == 30 ) || ( $view_days_num == 60 ) ) ) { |
| 1532 | 1756 | |
| 1533 | - ?><div class="in_cell_date_container day_num<?php echo $d_inc ?>"><?php | |
| 1757 | + ?><div class="in_cell_date_container day_num<?php echo esc_attr( $d_inc ); ?>"><?php | |
| 1534 | 1758 | |
| 1535 | 1759 | if ( ! $this->is_frontend ) { |
| 1536 | - ?><a href='<?php echo $bk_admin_url_today . '&scroll_start_date=' . $yy . '-' . $mm . '-' . $dd; ?>'><?php | |
| 1760 | + ?><a href='<?php echo esc_url( $bk_admin_url_today . '&scroll_start_date=' . $yy . '-' . $mm . '-' . $dd ); ?>'><?php | |
| 1537 | 1761 | } |
| 1538 | - echo $day_title; | |
| 1762 | + echo wp_kses_post( $day_title ); | |
| 1539 | 1763 | |
| 1540 | 1764 | if ( ! $this->is_frontend ) { |
| 1541 | 1765 | ?></a><?php |
| 1542 | 1766 | } |
| @@ -1543,9 +1767,10 @@ | ||
| 1543 | 1767 | |
| 1544 | 1768 | ?></div><?php |
| 1545 | 1769 | |
| 1546 | 1770 | } else { |
| 1547 | - ?><div class="in_cell_date_container day_num<?php echo $d_inc ?>"><?php echo $day_title;?></div><?php | |
| 1771 | + ?> | |
| 1772 | + <div class="in_cell_date_container day_num<?php echo esc_attr( $d_inc ); ?>"><?php echo wp_kses_post( $day_title ); ?></div><?php | |
| 1548 | 1773 | } |
| 1549 | 1774 | |
| 1550 | 1775 | //////////////////////////////////////////////////////////////////////////////////////// |
| 1551 | 1776 | // T i m e c e l l s |
| @@ -1551,19 +1776,19 @@ | ||
| 1551 | 1776 | // T i m e c e l l s |
| 1552 | 1777 | //////////////////////////////////////////////////////////////////////////////////////// |
| 1553 | 1778 | $tm = floor( 24 / $time_selles_num ); |
| 1554 | 1779 | if ( $time_selles_num > 1 ) { |
| 1555 | - ?><div class="<?php echo implode(' ', array( | |
| 1780 | + ?><div class="<?php echo esc_attr( implode(' ', array( | |
| 1556 | 1781 | 'in_cell_time_section_in_day', |
| 1557 | 1782 | 'flex_time_section_in_day_header', |
| 1558 | 1783 | 'flex_time_in_days_num_' . $view_days_num |
| 1559 | - )); ?>"><?php | |
| 1784 | + ) ) ); ?>"><?php | |
| 1560 | 1785 | |
| 1561 | 1786 | for ( $tt = 0; $tt < $time_selles_num; $tt++ ) { ?> |
| 1562 | 1787 | |
| 1563 | 1788 | <?php if ( ( $tt < $start_hour_for_1day_view ) || ( $tt > $end_hour_for_1day_view ) ) { continue; } //FixIn: 7.0.1.14 ?> |
| 1564 | 1789 | |
| 1565 | - <div class="<?php echo 'in_cell_time_hour time_hour' . ( $tt * $tm ); ?>" ><?php | |
| 1790 | + <div class="<?php echo esc_attr( 'in_cell_time_hour time_hour' . ( $tt * $tm ) ); ?>" ><?php | |
| 1566 | 1791 | |
| 1567 | 1792 | $this->show_time_number_in_correct_format( $tt * $tm , $view_days_num ); |
| 1568 | 1793 | |
| 1569 | 1794 | ?></div><?php |
| @@ -1609,9 +1834,9 @@ | ||
| 1609 | 1834 | $row_settings['time_selles_num'] = 1; |
| 1610 | 1835 | break; |
| 1611 | 1836 | case '365': |
| 1612 | 1837 | $row_settings['days_num'] = 31; |
| 1613 | - //$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 | |
| 1838 | + //$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. | |
| 1614 | 1839 | $row_settings['dwa'] = $this->week_days_titles['1']; |
| 1615 | 1840 | $row_settings['time_selles_num'] = 1; |
| 1616 | 1841 | break; |
| 1617 | 1842 | default: // 30 |
| @@ -1618,9 +1843,9 @@ | ||
| 1618 | 1843 | $row_settings['days_num'] = 1; |
| 1619 | 1844 | $row_settings['dwa'] = $this->week_days_titles['3']; |
| 1620 | 1845 | $row_settings['time_selles_num'] = 24;//25; |
| 1621 | 1846 | |
| 1622 | - if ( isset( $this->request_args[ 'limit_hours' ] ) ) { //FixIn: 7.0.1.14 | |
| 1847 | + if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. | |
| 1623 | 1848 | $row_settings['limit_hours'] = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1624 | 1849 | $row_settings['start_hour_for_1day_view'] = intval( $row_settings['limit_hours'][0] ); |
| 1625 | 1850 | $row_settings['end_hour_for_1day_view'] = intval( $row_settings['limit_hours'][1] ); |
| 1626 | 1851 | $row_settings['limit_hours'] = $row_settings['limit_hours'][1] - $row_settings['limit_hours'][0]; |
| @@ -1638,9 +1863,9 @@ | ||
| 1638 | 1863 | $row_settings['days_num'] = 1; |
| 1639 | 1864 | $row_settings['dwa'] = $this->week_days_titles['full']; |
| 1640 | 1865 | $row_settings['time_selles_num'] = 24; |
| 1641 | 1866 | |
| 1642 | - if ( isset( $this->request_args[ 'limit_hours' ] ) ) { //FixIn: 7.0.1.14 | |
| 1867 | + if ( isset( $this->request_args[ 'limit_hours' ] ) ) { // FixIn: 7.0.1.14. | |
| 1643 | 1868 | $row_settings['limit_hours'] = explode(',',$this->request_args[ 'limit_hours' ]); |
| 1644 | 1869 | $row_settings['start_hour_for_1day_view'] = intval( $row_settings['limit_hours'][0] ); |
| 1645 | 1870 | $row_settings['end_hour_for_1day_view'] = intval( $row_settings['limit_hours'][1] ); |
| 1646 | 1871 | $row_settings['limit_hours'] = $row_settings['limit_hours'][1] - $row_settings['limit_hours'][0]; |
| @@ -1664,9 +1889,9 @@ | ||
| 1664 | 1889 | break; |
| 1665 | 1890 | |
| 1666 | 1891 | default: // 30 |
| 1667 | 1892 | $row_settings['days_num'] = 32; |
| 1668 | - $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 | |
| 1893 | + $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. | |
| 1669 | 1894 | $row_settings['dwa'] = $this->week_days_titles['3']; |
| 1670 | 1895 | $row_settings['time_selles_num'] = 1;//25; |
| 1671 | 1896 | break; |
| 1672 | 1897 | } |
| @@ -1675,67 +1900,89 @@ | ||
| 1675 | 1900 | return $row_settings; |
| 1676 | 1901 | } |
| 1677 | 1902 | |
| 1678 | 1903 | |
| 1679 | - /** | |
| 1680 | - * Show time in correct format - showing in Header, and in time CELLs | |
| 1681 | - * | |
| 1682 | - * @param $time_milliseconds | |
| 1683 | - * @param $view_days_num | |
| 1684 | - */ | |
| 1685 | - private function show_time_number_in_correct_format( $time_milliseconds , $view_days_num ){ | |
| 1904 | + /** | |
| 1905 | + * Show time in correct format - showing in Header, and in time CELLs | |
| 1906 | + * | |
| 1907 | + * @param $time_milliseconds | |
| 1908 | + * @param $view_days_num | |
| 1909 | + */ | |
| 1910 | + private function show_time_number_in_correct_format( $time_milliseconds, $view_days_num ) { | |
| 1686 | 1911 | |
| 1687 | - //FixIn: 8.1.3.34 | |
| 1688 | - $bc_time_format = get_bk_option( 'booking_time_format' ); | |
| 1689 | - if ( ! empty( $bc_time_format ) ) { //FixIn: 8.2.1.2 | |
| 1690 | - $time_show = wpbc_datetime__no_wp_timezone( str_replace( ':i', '', get_bk_option( 'booking_time_format' ) ), mktime( intval($time_milliseconds), 0, 0 ) ); | |
| 1691 | - echo ( $view_days_num < 31 ) ? $time_show : ''; | |
| 1692 | - } else { | |
| 1693 | - echo( ( $view_days_num < 31 ) ? ( ( ( $time_milliseconds ) < 10 ? '0' : '' ) . ( $time_milliseconds ) . '<sup>:00</sup>' ) : '' ); | |
| 1694 | - } | |
| 1912 | + // FixIn: 8.1.3.34. | |
| 1913 | + $bc_time_format = get_bk_option( 'booking_time_format' ); | |
| 1914 | + if ( ! empty( $bc_time_format ) ) { // FixIn: 8.2.1.2. | |
| 1915 | + $time_show = wpbc_datetime__no_wp_timezone( str_replace( ':i', '', get_bk_option( 'booking_time_format' ) ), mktime( intval( $time_milliseconds ), 0, 0 ) ); | |
| 1916 | + echo wp_kses_post( ( $view_days_num < 31 ) ? $time_show : '' ); | |
| 1917 | + } else { | |
| 1918 | + echo wp_kses_post( ( $view_days_num < 31 ) ? ( ( ( $time_milliseconds ) < 10 ? '0' : '' ) . ( $time_milliseconds ) . '<sup>:00</sup>' ) : '' ); | |
| 1919 | + } | |
| 1920 | + } | |
| 1695 | 1921 | |
| 1922 | + | |
| 1923 | + /** | |
| 1924 | + * Is show Day View ( showing days || times ) | |
| 1925 | + * | |
| 1926 | + * @param $row_settings | |
| 1927 | + * | |
| 1928 | + * @return bool | |
| 1929 | + */ | |
| 1930 | + private function is_show_day_view( $row_settings ) { | |
| 1931 | + if ( | |
| 1932 | + ( ( 30 == $row_settings['view_days_num'] ) && ( ! $row_settings['is_matrix'] ) ) // Day View for Single | |
| 1933 | + || ( ( 1 == $row_settings['view_days_num'] ) && ( $row_settings['is_matrix'] ) ) // Day View for Matrix | |
| 1934 | + ) { | |
| 1935 | + return true; | |
| 1936 | + } else { | |
| 1937 | + return false; | |
| 1696 | 1938 | } |
| 1939 | + } | |
| 1697 | 1940 | |
| 1698 | 1941 | |
| 1699 | - /** | |
| 1700 | - * Is show Day View ( showing days || times ) | |
| 1701 | - * @param $row_settings | |
| 1702 | - * | |
| 1703 | - * @return bool | |
| 1704 | - */ | |
| 1705 | - private function is_show_day_view( $row_settings ){ | |
| 1706 | - if ( | |
| 1707 | - ( ( 30 == $row_settings['view_days_num'] ) && ( ! $row_settings['is_matrix'] ) ) // Day View for Single | |
| 1708 | - || ( ( 1 == $row_settings['view_days_num'] ) && ( $row_settings['is_matrix'] ) ) // Day View for Matrix | |
| 1709 | - ) { | |
| 1710 | - return true; | |
| 1711 | - } else { | |
| 1712 | - return false; | |
| 1713 | - } | |
| 1942 | + /** | |
| 1943 | + * Check, if starting new booking (something changed) relative to previous CELL | |
| 1944 | + * | |
| 1945 | + * @param array $bookings_in_cell | |
| 1946 | + * @param array $previous_bookings_in_cell | |
| 1947 | + * | |
| 1948 | + * @return bool | |
| 1949 | + */ | |
| 1950 | + private function is_start_new_booking_cell( $bookings_in_cell, $previous_bookings_in_cell ) { | |
| 1951 | + | |
| 1952 | + $bookings_in_cell = implode( '|', $bookings_in_cell ); | |
| 1953 | + $previous_bookings_in_cell = implode( '|', $previous_bookings_in_cell ); | |
| 1954 | + | |
| 1955 | + if ( $bookings_in_cell !== $previous_bookings_in_cell ) { | |
| 1956 | + return true; | |
| 1957 | + } else { | |
| 1958 | + return false; | |
| 1714 | 1959 | } |
| 1960 | + } | |
| 1715 | 1961 | |
| 1716 | 1962 | |
| 1717 | - /** | |
| 1718 | - * Check, if starting new booking (something changed) relative to previous CELL | |
| 1719 | - * | |
| 1720 | - * @param array $bookings_in_cell | |
| 1721 | - * @param array $previous_bookings_in_cell | |
| 1722 | - * | |
| 1723 | - * @return bool | |
| 1724 | - */ | |
| 1725 | - private function is_start_new_booking_cell( $bookings_in_cell, $previous_bookings_in_cell ) { | |
| 1963 | + /** | |
| 1964 | + * Check method 2, if starting new booking (something changed) relative to previous CELL | |
| 1965 | + * | |
| 1966 | + * @param array $bookings_in_cell | |
| 1967 | + * @param array $previous_bookings_in_cell | |
| 1968 | + * | |
| 1969 | + * @return bool | |
| 1970 | + */ | |
| 1971 | + private function is_start_new_booking_cell2( $bookings_in_cell, $previous_bookings_in_cell ) { | |
| 1726 | 1972 | |
| 1727 | - $bookings_in_cell = implode( '|', $bookings_in_cell ); | |
| 1728 | - $previous_bookings_in_cell = implode( '|', $previous_bookings_in_cell ); | |
| 1973 | + $bookings_in_cell = implode( '|', $bookings_in_cell ); | |
| 1974 | + $previous_bookings_in_cell = implode( '|', $previous_bookings_in_cell ); | |
| 1729 | 1975 | |
| 1730 | - if ( $bookings_in_cell !== $previous_bookings_in_cell ) { | |
| 1731 | - return true; | |
| 1732 | - } else { | |
| 1733 | - return false; | |
| 1734 | - } | |
| 1735 | - } | |
| 1976 | + $bookings_in_cell_arr = explode( '|', $bookings_in_cell ); | |
| 1977 | + $previous_bookings_in_cell_arr = explode( '|', $previous_bookings_in_cell ); | |
| 1736 | 1978 | |
| 1979 | + $is_check1 = empty( array_diff( $bookings_in_cell_arr, $previous_bookings_in_cell_arr ) ); | |
| 1980 | + $is_check2 = empty( array_diff( $previous_bookings_in_cell_arr, $bookings_in_cell_arr ) ); | |
| 1737 | 1981 | |
| 1982 | + return ( ( ! $is_check1 ) && ( ! $is_check2 ) ); | |
| 1983 | + } | |
| 1984 | + | |
| 1738 | 1985 | /** |
| 1739 | 1986 | * Get Text for booking Title in PIPELINE |
| 1740 | 1987 | * |
| 1741 | 1988 | * @param $bk_id |
| @@ -1750,17 +1997,17 @@ | ||
| 1750 | 1997 | if ( $this->is_frontend ) $what_show_in_day_template = get_bk_option( 'booking_default_title_in_day_for_timeline_front_end' ); |
| 1751 | 1998 | else $what_show_in_day_template = get_bk_option( 'booking_default_title_in_day_for_calendar_view_mode' ); |
| 1752 | 1999 | |
| 1753 | 2000 | if ( function_exists( 'get_title_for_showing_in_day' ) ) { |
| 1754 | - $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 | |
| 2001 | + $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. | |
| 1755 | 2002 | } else { |
| 1756 | 2003 | if ( ! $this->is_frontend ) { |
| 1757 | - // Default Free //FixIn: 7.1.1.2 | |
| 2004 | + // Default Free // FixIn: 7.1.1.2. | |
| 1758 | 2005 | $text_in_day_cell .= $bk_id . ':' ; |
| 1759 | 2006 | if ( isset( $bookings[ $bk_id ]->form_data['_all_fields_']['name'] ) ) { |
| 1760 | 2007 | $text_in_day_cell .= ' ' . esc_textarea( $bookings[ $bk_id ]->form_data['_all_fields_']['name'] ); |
| 1761 | 2008 | } |
| 1762 | - //FixIn: 10.0.0.24 | |
| 2009 | + // FixIn: 10.0.0.24. | |
| 1763 | 2010 | if ( isset( $bookings[ $bk_id ]->form_data['_all_fields_']['secondname'] ) ) { |
| 1764 | 2011 | $text_in_day_cell .= ' ' . esc_textarea( $bookings[ $bk_id ]->form_data['_all_fields_']['secondname'] ); |
| 1765 | 2012 | } |
| 1766 | 2013 | if ( isset( $bookings[ $bk_id ]->form_data['_all_fields_']['lastname'] ) ) { |
| @@ -1780,9 +2027,9 @@ | ||
| 1780 | 2027 | * @param $row_settings |
| 1781 | 2028 | */ |
| 1782 | 2029 | private function show_booking_title_for_pipeline_bar( $booking_id, $row_settings ){ |
| 1783 | 2030 | |
| 1784 | - //FixIn: 8.7.1.4 | |
| 2031 | + // FixIn: 8.7.1.4. | |
| 1785 | 2032 | $bk_title = ''; |
| 1786 | 2033 | |
| 1787 | 2034 | $is_date = wpbc_get_date_in_correct_format( wpbc_datetime__no_wp_timezone( "Y-m-d", $row_settings['real_date'] ) ); |
| 1788 | 2035 | if ( ( is_array( $is_date ) ) && ( ! empty( $is_date ) ) ) { |
| @@ -1790,13 +2037,15 @@ | ||
| 1790 | 2037 | } |
| 1791 | 2038 | |
| 1792 | 2039 | $bk_title .= " \n" . $this->get_booking_title_for_timeline( $booking_id, $row_settings['bookings'] ); |
| 1793 | 2040 | |
| 1794 | - $bk_title .= " \n" . strip_tags( wpbc_get_short_dates_formated_to_show( $row_settings['bookings'][ $booking_id ]->dates_short ) ) ; | |
| 2041 | + $bk_title .= " \n" . wp_strip_all_tags( wpbc_get_short_dates_formated_to_show( $row_settings['bookings'][ $booking_id ]->dates_short ) ) ; | |
| 2042 | + | |
| 2043 | + $bk_title = apply_filters( 'wpbc_timeline_booking_pipeline_title', $bk_title, $booking_id, $row_settings['bookings'] ); | |
| 1795 | 2044 | |
| 1796 | 2045 | ?><a href="javascript:void(0)" |
| 1797 | 2046 | class="in_cell_date_booking_pipeline_a" |
| 1798 | - title="<?php echo str_replace( '"', "", $bk_title ); ?>" | |
| 2047 | + title="<?php echo esc_attr( $bk_title ); ?>" | |
| 1799 | 2048 | ><?php |
| 1800 | 2049 | ?><div class="in_cell_date_booking_pipeline_a_sizer"></div><?php |
| 1801 | 2050 | ?></a><?php |
| 1802 | 2051 | } |
| @@ -1813,19 +2062,20 @@ | ||
| 1813 | 2062 | $bk_a_title_arr = array(); |
| 1814 | 2063 | $popup_content_arr = array(); |
| 1815 | 2064 | $popup_title_arr = array(); |
| 1816 | 2065 | |
| 1817 | - $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 | |
| 2066 | + $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. | |
| 1818 | 2067 | |
| 1819 | 2068 | foreach ( $bookings_in_cell as $booking_id ) { |
| 1820 | 2069 | |
| 1821 | 2070 | $bk_a_title = $this->get_booking_title_for_timeline( $booking_id, $row_settings['bookings'] ); |
| 1822 | - $bk_a_title = htmlspecialchars_decode( $bk_a_title, ENT_NOQUOTES ); //FixIn: 8.7.11.5 | |
| 2071 | + $bk_a_title = htmlspecialchars_decode( $bk_a_title, ENT_NOQUOTES ); // FixIn: 8.7.11.5. | |
| 1823 | 2072 | $bk_a_title_arr[] = $bk_a_title; |
| 1824 | 2073 | |
| 1825 | 2074 | $title_in_day = $title = $title_hint = ''; |
| 1826 | 2075 | |
| 1827 | - if ( $is_show_popover_in_timeline ) { | |
| 2076 | + $can_show_booking_popover = $is_show_popover_in_timeline && $this->wpbc_is_booking_authorized_for_hash( $booking_id, $row_settings['bookings'] ); | |
| 2077 | + if ( $can_show_booking_popover ) { | |
| 1828 | 2078 | $popup_content = $this->wpbc_get_booking_info_4_popover( $booking_id, $row_settings['bookings'], $row_settings['booking_types'] ); |
| 1829 | 2079 | |
| 1830 | 2080 | |
| 1831 | 2081 | $popup_title_arr[] = $popup_content['title']; |
| @@ -1831,9 +2081,9 @@ | ||
| 1831 | 2081 | $popup_title_arr[] = $popup_content['title']; |
| 1832 | 2082 | //FixIn: 9.7.4.1 - escape coded html/xss |
| 1833 | 2083 | $popup_content_arr[] = '<div class="popover-title">' . esc_html($popup_content['title']) . '</div><div class="popover-content">' . esc_html( $popup_content['content'] ) . '</div>'; |
| 1834 | 2084 | } |
| 1835 | - //$popup_content_arr[] = $bk_a_title . ': ' . strip_tags( wpbc_get_short_dates_formated_to_show( $row_settings['bookings'][ $booking_id ]->dates_short ) ) ; | |
| 2085 | + //$popup_content_arr[] = $bk_a_title . ': ' . wp_strip_all_tags( wpbc_get_short_dates_formated_to_show( $row_settings['bookings'][ $booking_id ]->dates_short ) ) ; | |
| 1836 | 2086 | } |
| 1837 | 2087 | |
| 1838 | 2088 | // Title A link |
| 1839 | 2089 | $bk_a_title__text = implode( ', ', $bk_a_title_arr ); |
| @@ -1841,9 +2091,15 @@ | ||
| 1841 | 2091 | if ( strlen( $bk_a_title__text ) > 20 ) { |
| 1842 | 2092 | $bk_a_title__text = substr( $bk_a_title__text, 0, 20 ) . '...'; |
| 1843 | 2093 | } |
| 1844 | 2094 | if ( count( $bookings_in_cell ) > 1 ) { |
| 1845 | - $bk_a_title__text = '<sup>[' . count( $bookings_in_cell ) . ']</sup> ' . $bk_a_title__text; | |
| 2095 | + | |
| 2096 | + if ( ! $this->is_bookings_use_check_in_out( $bookings_in_cell, $row_settings['bookings'] ) ) { | |
| 2097 | + $bk_a_title__text = '<sup>[' . count( $bookings_in_cell ) . ']</sup> ' . $bk_a_title__text; | |
| 2098 | + } else { | |
| 2099 | + //return; // FixIn: 10.6.3.1. | |
| 2100 | + } | |
| 2101 | + | |
| 1846 | 2102 | } |
| 1847 | 2103 | |
| 1848 | 2104 | |
| 1849 | 2105 | if ( ! $this->is_frontend ) { $line_separator = '<div class=\'clear\'></div>'; } |
| @@ -1854,26 +2110,63 @@ | ||
| 1854 | 2110 | $popup_content_arr = implode( $line_separator, $popup_content_arr ); |
| 1855 | 2111 | |
| 1856 | 2112 | // Booking CELL Title |
| 1857 | 2113 | ?><a href="javascript:void(0)" |
| 1858 | - class="<?php echo implode(' ', array( | |
| 2114 | + class="<?php echo esc_attr( implode(' ', array( | |
| 1859 | 2115 | 'in_cell_date_booking_title', |
| 1860 | - ( $is_show_popover_in_timeline ) ? 'popover_bottom' : '', | |
| 1861 | - ( $is_show_popover_in_timeline ) ? 'popover_click' : '', | |
| 2116 | + ( ! empty( $popup_content_arr ) ) ? 'popover_bottom' : '', | |
| 2117 | + ( ! empty( $popup_content_arr ) ) ? 'popover_click' : '', | |
| 1862 | 2118 | ( count( $bookings_in_cell ) > 1 ) ? 'several_bookings_in_cell' : '' |
| 1863 | - )); ?>" | |
| 2119 | + ))); ?>" | |
| 1864 | 2120 | <?php |
| 1865 | - //FixIn: 8.9.3.3 | |
| 1866 | - if ( $is_show_popover_in_timeline ) { ?> | |
| 2121 | + // FixIn: 8.9.3.3. | |
| 2122 | + if ( ! empty( $popup_content_arr ) ) { ?> | |
| 1867 | 2123 | data-content="<?php echo esc_html( str_replace( '"', "", $popup_content_arr ) ); ?>" |
| 1868 | 2124 | data-original-title="<?php echo esc_html( str_replace( '"', "", $popup_title_arr ) ); ?>" |
| 1869 | 2125 | <?php } ?> |
| 1870 | 2126 | ><?php |
| 1871 | - echo $bk_a_title__text; | |
| 2127 | + echo wp_kses_post( $bk_a_title__text ); | |
| 1872 | 2128 | ?></a><?php |
| 1873 | 2129 | } |
| 1874 | 2130 | |
| 2131 | + /** | |
| 2132 | + * Check if some bookings used check in / out functionality | |
| 2133 | + * | |
| 2134 | + * @param $bookings_id_arr | |
| 2135 | + * @param $bookings_obj_arr | |
| 2136 | + * | |
| 2137 | + * @return false | |
| 2138 | + */ | |
| 2139 | + function is_bookings_use_check_in_out( $bookings_id_arr, $bookings_obj_arr ) { | |
| 1875 | 2140 | |
| 2141 | + // ----------------------------------------------------------------------------------------------------- | |
| 2142 | + // Is Check In/out ? | |
| 2143 | + // ----------------------------------------------------------------------------------------------------- | |
| 2144 | + $is_use_check_in_out_time = ( get_bk_option( 'booking_range_selection_time_is_active' ) == 'On' ); | |
| 2145 | + | |
| 2146 | + if ( $is_use_check_in_out_time ) { | |
| 2147 | + foreach ( $bookings_id_arr as $booking_id ) { | |
| 2148 | + | |
| 2149 | + if ( isset( $bookings_obj_arr[ $booking_id ] ) ) { | |
| 2150 | + foreach ( $bookings_obj_arr[ $booking_id ]->dates as $booking_date_obj ) { | |
| 2151 | + $booking_date_ymdhis = $booking_date_obj->booking_date; | |
| 2152 | + | |
| 2153 | + $is_check_in_out__or_full = substr( $booking_date_ymdhis, - 1 ); // '1', '2' (not '0') | |
| 2154 | + | |
| 2155 | + if ( '1' === $is_check_in_out__or_full ) { | |
| 2156 | + return true; | |
| 2157 | + } | |
| 2158 | + if ( '2' === $is_check_in_out__or_full ) { | |
| 2159 | + return true; | |
| 2160 | + } | |
| 2161 | + } | |
| 2162 | + } | |
| 2163 | + } | |
| 2164 | + } | |
| 2165 | + return false; | |
| 2166 | + } | |
| 2167 | + | |
| 2168 | + | |
| 1876 | 2169 | /** |
| 1877 | 2170 | * Get array of CSS classes for booking bar |
| 1878 | 2171 | * @param int $booking_id |
| 1879 | 2172 | * @param array $bookings |
| @@ -1895,10 +2188,45 @@ | ||
| 1895 | 2188 | $is_approved = 0; |
| 1896 | 2189 | } |
| 1897 | 2190 | $class_arr[] = $is_approved ? 'approved_booking' : 'pending_booking'; |
| 1898 | 2191 | |
| 1899 | - ///////////////////////////////////////////////////////////////// | |
| 2192 | + // ----------------------------------------------------------------------------------------------------- | |
| 2193 | + // Is Check In/out ? | |
| 2194 | + // ----------------------------------------------------------------------------------------------------- | |
| 2195 | + $is_use_check_in_out_time = ( get_bk_option( 'booking_range_selection_time_is_active' ) == 'On' ); | |
| 2196 | + $one_date__one_booking__check_in_out__arr = array(); | |
| 2197 | + if ( | |
| 2198 | + ( $is_use_check_in_out_time ) | |
| 2199 | + && ( ( $row_settings['is_matrix'] ) || ( 30 != $row_settings['view_days_num'] ) ) | |
| 2200 | + && ( ( ! $row_settings['is_matrix'] ) || ( 1 != $row_settings['view_days_num'] ) ) | |
| 2201 | + ){ | |
| 2202 | + $real_date_ymd = wpbc_datetime__no_wp_timezone( "Y-m-d", $real_date ); | |
| 2203 | + foreach ( $bookings[ $booking_id ]->dates as $booking_date_obj ) { | |
| 2204 | + $booking_date_ymdhis = $booking_date_obj->booking_date; | |
| 2205 | + if ( substr( $booking_date_ymdhis, 0, 10 ) === $real_date_ymd ) { | |
| 2206 | + $is_check_in_out__or_full = substr( $booking_date_ymdhis, -1 ); // '1', '2' (not '0') | |
| 1900 | 2207 | |
| 2208 | + if ('1'=== $is_check_in_out__or_full ){ | |
| 2209 | + $one_date__one_booking__check_in_out__arr[] = 'booking_check_in'; | |
| 2210 | + } | |
| 2211 | + if ('2'=== $is_check_in_out__or_full ){ | |
| 2212 | + $one_date__one_booking__check_in_out__arr[] = 'booking_check_out'; | |
| 2213 | + } | |
| 2214 | + //break; | |
| 2215 | + } | |
| 2216 | + } | |
| 2217 | + } | |
| 2218 | + // 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 | |
| 2219 | + if ( count( $one_date__one_booking__check_in_out__arr ) == 1 ) { | |
| 2220 | + $class_arr[] = $one_date__one_booking__check_in_out__arr[0]; | |
| 2221 | + $class_arr[] = 'booking_change_over'; | |
| 2222 | + } | |
| 2223 | + if ( count( $one_date__one_booking__check_in_out__arr ) > 1 ) { | |
| 2224 | + $class_arr[] = 'booking_time_slots'; | |
| 2225 | + } | |
| 2226 | + | |
| 2227 | + // ----------------------------------------------------------------------------------------------------- | |
| 2228 | + | |
| 1901 | 2229 | if ( isset( $bookings[ $booking_id ]->trash ) ) { |
| 1902 | 2230 | $is_trash = $bookings[ $booking_id ]->trash; |
| 1903 | 2231 | } else { |
| 1904 | 2232 | $is_trash = false; |
| @@ -1935,9 +2263,9 @@ | ||
| 1935 | 2263 | } |
| 1936 | 2264 | } |
| 1937 | 2265 | ///////////////////////////////////////////////////////////////// |
| 1938 | 2266 | |
| 1939 | - $css_class_additional = apply_filters( 'wpbc_timeline_booking_header_css', '', $booking_id, $bookings ); //FixIn: 7.0.1.41 | |
| 2267 | + $css_class_additional = apply_filters( 'wpbc_timeline_booking_header_css', '', $booking_id, $bookings ); // FixIn: 7.0.1.41. | |
| 1940 | 2268 | $class_arr[] = $css_class_additional; |
| 1941 | 2269 | } |
| 1942 | 2270 | |
| 1943 | 2271 | // Remove empty values from array |
| @@ -2024,10 +2352,10 @@ | ||
| 2024 | 2352 | |
| 2025 | 2353 | // </editor-fold> |
| 2026 | 2354 | |
| 2027 | 2355 | |
| 2028 | - ?><div id="cell_<?php echo $row_settings[ 'current_resource_id' ] . '_' . $row_settings['day_filter_id'] ; ?>" | |
| 2029 | - class="<?php echo implode(' ', $cell_css ); ?>" | |
| 2356 | + ?><div id="cell_<?php echo esc_attr( $row_settings[ 'current_resource_id' ] . '_' . $row_settings['day_filter_id'] ); ?>" | |
| 2357 | + class="<?php echo esc_attr( implode(' ', $cell_css ) ); ?>" | |
| 2030 | 2358 | ><?php |
| 2031 | 2359 | |
| 2032 | 2360 | //////////////////////////////////////////////////////////////////////////////////////// |
| 2033 | 2361 | // T i m e c e l l s |
| @@ -2035,13 +2363,13 @@ | ||
| 2035 | 2363 | $time_selles_num = $row_settings['time_selles_num']; |
| 2036 | 2364 | $tm = floor( 24 / $time_selles_num ); |
| 2037 | 2365 | |
| 2038 | 2366 | |
| 2039 | - ?><div class="<?php echo implode(' ', array( | |
| 2367 | + ?><div class="<?php echo esc_attr(implode(' ', array( | |
| 2040 | 2368 | 'in_cell_time_section_in_day', |
| 2041 | 2369 | 'flex_time_section_in_day_booking', |
| 2042 | 2370 | 'flex_time_in_days_num_' . $row_settings['view_days_num'] |
| 2043 | - )); ?>" | |
| 2371 | + )) ); ?>" | |
| 2044 | 2372 | ><?php |
| 2045 | 2373 | |
| 2046 | 2374 | for ( $tt = 0; $tt < $time_selles_num; $tt++ ) { |
| 2047 | 2375 | |
| @@ -2050,8 +2378,9 @@ | ||
| 2050 | 2378 | |
| 2051 | 2379 | $time_ms = $tt * 60 * 60; |
| 2052 | 2380 | $bookings_in_this_time_arr = empty( $bookings_in__times_arr[ $time_ms ] ) ? array() : $bookings_in__times_arr[ $time_ms ]; |
| 2053 | 2381 | $is_start_new_booking = $this->is_start_new_booking_cell( $bookings_in_this_time_arr, $data_in_previous_cell['bookings_in_cell'] ); |
| 2382 | + $is_start_new_booking2 = $this->is_start_new_booking_cell2( $bookings_in_this_time_arr, $data_in_previous_cell['bookings_in_cell'] ); | |
| 2054 | 2383 | |
| 2055 | 2384 | $bookings_in_day_cell = $bookings_in_this_time_arr; |
| 2056 | 2385 | |
| 2057 | 2386 | } else { // Get bookings for a day |
| @@ -2056,8 +2385,10 @@ | ||
| 2056 | 2385 | |
| 2057 | 2386 | } else { // Get bookings for a day |
| 2058 | 2387 | |
| 2059 | 2388 | $is_start_new_booking = $this->is_start_new_booking_cell( $bookings_in_day_cell, $data_in_previous_cell['bookings_in_cell'] ); |
| 2389 | + $is_start_new_booking2 = $this->is_start_new_booking_cell2( $bookings_in_day_cell, $data_in_previous_cell['bookings_in_cell'] ); | |
| 2390 | + | |
| 2060 | 2391 | } |
| 2061 | 2392 | |
| 2062 | 2393 | // Skip timeslots for day view |
| 2063 | 2394 | if ( $this->is_show_day_view( $row_settings ) ) { |
| @@ -2066,9 +2397,9 @@ | ||
| 2066 | 2397 | } |
| 2067 | 2398 | } |
| 2068 | 2399 | |
| 2069 | 2400 | |
| 2070 | - $today_time_css_class=''; //FixIn: 10.0.0.40 | |
| 2401 | + $today_time_css_class=''; // FixIn: 10.0.0.40. | |
| 2071 | 2402 | if ( wpbc_datetime__use_wp_timezone( 'Y.m.d' ) == wpbc_datetime__use_wp_timezone( "Y.m.d", $row_settings[ 'real_date' ] ) ) { |
| 2072 | 2403 | if ( $this->is_show_day_view( $row_settings ) ) { |
| 2073 | 2404 | if ( ( wpbc_datetime__use_wp_timezone( 'm.d.Y' ) == wpbc_datetime__use_wp_timezone( "m.d.Y", $row_settings[ 'real_date' ] ) ) // Today Date |
| 2074 | 2405 | && ( intval( wpbc_datetime__use_wp_timezone( 'H' ) ) == intval( $tt ) ) ) { |
| @@ -2077,20 +2408,19 @@ | ||
| 2077 | 2408 | } |
| 2078 | 2409 | |
| 2079 | 2410 | } |
| 2080 | 2411 | |
| 2081 | - ?><div class="<?php echo 'in_cell_time_hour time_hour' . ( $tt * $tm ). ' ' . $today_time_css_class; ?>" ><?php | |
| 2412 | + ?><div class="<?php echo esc_attr( 'in_cell_time_hour time_hour' . ( $tt * $tm ) . ' ' . $today_time_css_class ); ?>" ><?php | |
| 2082 | 2413 | |
| 2083 | - | |
| 2084 | 2414 | if ( 'show_dates' == $row_settings['what_to_show'] ) { |
| 2085 | 2415 | |
| 2086 | 2416 | ?> |
| 2087 | - <div class="in_cell_date_container in_cell_date_container_<?php echo $row_settings['what_to_show'] ?>"><?php | |
| 2417 | + <div class="in_cell_date_container in_cell_date_container_<?php echo esc_attr( $row_settings['what_to_show'] ); ?>"><?php | |
| 2088 | 2418 | //if ( empty( $bookings_in_day_cell ) ) { |
| 2089 | 2419 | if ( $this->is_show_day_view( $row_settings ) ) { |
| 2090 | 2420 | $this->show_time_number_in_correct_format( $tt * $tm , $row_settings['view_days_num'] ); |
| 2091 | 2421 | } else { |
| 2092 | - echo $dd; | |
| 2422 | + echo esc_html( $dd ); | |
| 2093 | 2423 | } |
| 2094 | 2424 | //} |
| 2095 | 2425 | ?></div><?php |
| 2096 | 2426 | } |
| @@ -2102,21 +2432,34 @@ | ||
| 2102 | 2432 | |
| 2103 | 2433 | $booking_id_title = array(); |
| 2104 | 2434 | |
| 2105 | 2435 | ?> |
| 2106 | - <div class="in_cell_date_container in_cell_date_container_<?php echo $row_settings['what_to_show'] ?>"><?php | |
| 2436 | + <div class="in_cell_date_container in_cell_date_container_<?php echo esc_attr( $row_settings['what_to_show'] ); | |
| 2107 | 2437 | |
| 2438 | + // FixIn: 10.5.0.1. | |
| 2439 | + if (count($bookings_in_day_cell)>1){ | |
| 2440 | + echo ' in_cell_date_container_has_several_bookings '; | |
| 2441 | + } | |
| 2442 | + | |
| 2443 | + ?>"><?php | |
| 2444 | + | |
| 2108 | 2445 | foreach ( $bookings_in_day_cell as $booking_id ) { |
| 2109 | 2446 | |
| 2110 | 2447 | $booking_css_class_arr = $this->get_booking_class_arr( $booking_id, $row_settings, $row_settings['real_date'], $tt ); |
| 2111 | 2448 | |
| 2449 | + if ( ! in_array( 'booking_change_over', $booking_css_class_arr ) ) { | |
| 2450 | + if ( $is_start_new_booking2 ) { | |
| 2451 | + $booking_css_class_arr[] = 'start_new_booking'; | |
| 2452 | + } | |
| 2453 | + } | |
| 2454 | + | |
| 2112 | 2455 | ?> |
| 2113 | - <div class="<?php echo implode( ' ', array( | |
| 2456 | + <div class="<?php echo esc_attr( implode( ' ', array( | |
| 2114 | 2457 | 'booking_id', |
| 2115 | 2458 | 'booking_id_' . $booking_id, |
| 2116 | - $is_start_new_booking ? 'start_new_booking' : '', | |
| 2117 | - ) ); | |
| 2118 | - echo ' ' . implode( ' ', $booking_css_class_arr ); | |
| 2459 | + //$is_start_new_booking ? 'start_new_booking' : '', | |
| 2460 | + ) ) ); | |
| 2461 | + echo ' ' . esc_attr( implode( ' ', $booking_css_class_arr ) ); | |
| 2119 | 2462 | ?>" |
| 2120 | 2463 | ><?php |
| 2121 | 2464 | |
| 2122 | 2465 | // Booking CELL background |
| @@ -2135,14 +2478,14 @@ | ||
| 2135 | 2478 | |
| 2136 | 2479 | // Title of new booking(s) |
| 2137 | 2480 | if ( $is_start_new_booking ) { |
| 2138 | 2481 | |
| 2139 | - ?><div class="<?php echo implode( ' ', array( | |
| 2482 | + ?><div class="<?php echo esc_attr( implode( ' ', array( | |
| 2140 | 2483 | 'in_cell_date_container', |
| 2141 | 2484 | 'in_cell_date_container_booking_id_title', |
| 2142 | 2485 | 'in_cell_date_container_' . $row_settings['what_to_show'] |
| 2143 | - ) ); | |
| 2144 | - echo ' booking_id_' . implode( '_', $bookings_in_day_cell ); | |
| 2486 | + ) ) ); | |
| 2487 | + echo esc_attr( ' booking_id_' . implode( '_', $bookings_in_day_cell ) ); | |
| 2145 | 2488 | ?>" |
| 2146 | 2489 | ><?php |
| 2147 | 2490 | |
| 2148 | 2491 | $this->show_booking_title_for_timeline( $bookings_in_day_cell, $row_settings ); |
| @@ -2196,14 +2539,14 @@ | ||
| 2196 | 2539 | foreach ( array( 'show_dates', 'show_bookings', 'show_booking_titles' ) as $what_to_show ) { |
| 2197 | 2540 | |
| 2198 | 2541 | $this->data_in_previous_cell = $saved_previos_data_cell; |
| 2199 | 2542 | |
| 2200 | - ?><div id="flex_resource_row_<?php echo $what_to_show . '_' . $booking_arr['current_resource_id']; ?>" | |
| 2201 | - class="<?php echo implode(' ', array( | |
| 2202 | - 'flex_tl_dates_bar', | |
| 2543 | + ?><div id="flex_resource_row_<?php echo esc_attr( $what_to_show . '_' . $booking_arr['current_resource_id'] ); ?>" | |
| 2544 | + class="<?php echo esc_attr( implode(' ', array( | |
| 2545 | + 'flex_tl_dates_bar', 'flex_tl_row_height', | |
| 2203 | 2546 | 'flex_tl_row_bar_' . $what_to_show , |
| 2204 | 2547 | $row_settings['is_matrix'] ? 'flex_tl_matrix_resources' : 'flex_tl_single_resource' |
| 2205 | - ) ); ?>" | |
| 2548 | + ) ) ); ?>" | |
| 2206 | 2549 | ><?php |
| 2207 | 2550 | |
| 2208 | 2551 | for ( $d_inc = 0; $d_inc < $row_settings['days_num']; $d_inc ++ ) { |
| 2209 | 2552 | |
| @@ -2269,9 +2612,9 @@ | ||
| 2269 | 2612 | case '1': |
| 2270 | 2613 | if ( isset( $this->request_args['scroll_day'] ) ) |
| 2271 | 2614 | $scroll_day = $this->request_args['scroll_day']; |
| 2272 | 2615 | if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2273 | - $start_day = wpbc_datetime__no_wp_timezone( "d" ); //FixIn: 7.0.1.13 | |
| 2616 | + $start_day = wpbc_datetime__no_wp_timezone( "d" ); // FixIn: 7.0.1.13. | |
| 2274 | 2617 | break; |
| 2275 | 2618 | |
| 2276 | 2619 | case '30': |
| 2277 | 2620 | case '60': |
| @@ -2286,9 +2629,9 @@ | ||
| 2286 | 2629 | $scroll_day = $this->request_args['scroll_day']; |
| 2287 | 2630 | if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2288 | 2631 | $start_day = wpbc_datetime__no_wp_timezone( "d" ); |
| 2289 | 2632 | $start_week_day_num = wpbc_datetime__no_wp_timezone( "w" ); |
| 2290 | - $start_day_weeek = get_bk_option( 'booking_start_day_weeek' ); //[0]:Sun .. [6]:Sut | |
| 2633 | + $start_day_weeek = esc_js(get_bk_option( 'booking_start_day_weeek' )); //[0]:Sun .. [6]:Sut | |
| 2291 | 2634 | |
| 2292 | 2635 | if ( $start_week_day_num != $start_day_weeek ) { |
| 2293 | 2636 | for ( $d_inc = 1; $d_inc < 8; $d_inc++ ) { // Just get week back |
| 2294 | 2637 | |
| @@ -2325,9 +2668,9 @@ | ||
| 2325 | 2668 | $max_rows_number = 12; |
| 2326 | 2669 | if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2327 | 2670 | $start_day = wpbc_datetime__no_wp_timezone( "d" ); |
| 2328 | 2671 | $start_week_day_num = wpbc_datetime__no_wp_timezone( "w" ); |
| 2329 | - $start_day_weeek = get_bk_option( 'booking_start_day_weeek' ); //[0]:Sun .. [6]:Sut | |
| 2672 | + $start_day_weeek = esc_js(get_bk_option( 'booking_start_day_weeek' )); //[0]:Sun .. [6]:Sut | |
| 2330 | 2673 | |
| 2331 | 2674 | if ( $start_week_day_num != $start_day_weeek ) { |
| 2332 | 2675 | for ( $d_inc = 1; $d_inc < 8; $d_inc++ ) { // Just get week back |
| 2333 | 2676 | $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) - intval( $d_inc ) ), intval( $start_year ) ); |
| @@ -2358,9 +2701,9 @@ | ||
| 2358 | 2701 | $scroll_day = $this->request_args['scroll_day']; |
| 2359 | 2702 | else |
| 2360 | 2703 | $scroll_day = 0; |
| 2361 | 2704 | |
| 2362 | - //FixIn: 8.9.4.3 | |
| 2705 | + // FixIn: 8.9.4.3. | |
| 2363 | 2706 | if ( $this->is_frontend ) { |
| 2364 | 2707 | $max_rows_number = intval( get_bk_option( 'booking_timeline__month_mode__days_number_show' ) ); |
| 2365 | 2708 | } else { |
| 2366 | 2709 | $max_rows_number = intval( get_bk_option( 'booking_calendar_overview__day_mode__days_number_show' ) );; |
| @@ -2369,9 +2712,9 @@ | ||
| 2369 | 2712 | $max_rows_number = 31; |
| 2370 | 2713 | } |
| 2371 | 2714 | |
| 2372 | 2715 | if ( empty( $this->request_args['scroll_start_date'] ) ) |
| 2373 | - $start_day = wpbc_datetime__no_wp_timezone( "d" ); //FixIn: 7.0.1.13 | |
| 2716 | + $start_day = wpbc_datetime__no_wp_timezone( "d" ); // FixIn: 7.0.1.13. | |
| 2374 | 2717 | break; |
| 2375 | 2718 | } |
| 2376 | 2719 | } |
| 2377 | 2720 | |
| @@ -2376,30 +2719,26 @@ | ||
| 2376 | 2719 | } |
| 2377 | 2720 | |
| 2378 | 2721 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 2379 | 2722 | |
| 2380 | - //FixIn: 10.0.0.25 | |
| 2723 | + // FixIn: 10.0.0.25. | |
| 2381 | 2724 | if ( ! $this->is_frontend ){ |
| 2382 | 2725 | $this->show_timeline_header_start__admin_panel(); |
| 2383 | 2726 | } |
| 2384 | - // New Spinner Loader //FixIn: 10.0.0.25 | |
| 2727 | + // New Spinner Loader // FixIn: 10.0.0.25. | |
| 2385 | 2728 | ?><div class="flex_tl_table_loading wpbc_spins_loading_container"> |
| 2386 | - <div class="wpbc_booking_form_spin_loader"><div class="wpbc_spins_loader_wrapper"><div class="wpbc_spins_loader_mini"></div></div></div> | |
| 2729 | + <div class="wpbc_booking_form_spin_loader"><div class="wpbc_spins_loader_wrapper"><div class="wpbc_spin_loader_one_new"></div></div></div> | |
| 2387 | 2730 | <?php // echo '<span class="0glyphicon 0glyphicon-refresh wpbc_icn_autorenew wpbc_spin"></span>' ?> |
| 2388 | - <span><?php _e('Loading','booking'); ?>...</span> | |
| 2731 | + <span><?php esc_html_e('Loading','booking'); ?>...</span> | |
| 2389 | 2732 | </div><?php |
| 2390 | 2733 | |
| 2391 | 2734 | |
| 2392 | 2735 | ?><div class="flex_timeline_frame<?php |
| 2393 | - if ( $this->is_frontend ) echo ' wpbc_timeline_front_end' ?> flex_frame_view_days_num_<?php echo $view_days_num; | |
| 2736 | + if ( $this->is_frontend ) echo ' wpbc_timeline_front_end' ?> flex_frame_view_days_num_<?php echo esc_attr( $view_days_num ); | |
| 2394 | 2737 | if ($is_matrix) { echo ' flex_tl_matrix_resources '; } else { echo ' flex_tl_single_resource '; } |
| 2395 | 2738 | ?>"> |
| 2396 | 2739 | <div class="flex_tl_table"> |
| 2397 | - <div class="flex_tl_table_header" style="<?php | |
| 2398 | -if ( ! $this->is_frontend ) { | |
| 2399 | - echo 'display:none;'; //FixIn: 10.0.0.25 | |
| 2400 | -} | |
| 2401 | - ?>"> | |
| 2740 | + <div class="flex_tl_table_header" style="<?php if ( ! $this->is_frontend ) { echo 'display:none;'; /* //FixIn: 10.0.0.25 */ } ?>"> | |
| 2402 | 2741 | <?php |
| 2403 | 2742 | if ( $this->is_frontend ) { |
| 2404 | 2743 | ?><div class="flex_tl_collumn_2"><?php |
| 2405 | 2744 | |
| @@ -2414,259 +2753,285 @@ | ||
| 2414 | 2753 | } else { |
| 2415 | 2754 | ?> |
| 2416 | 2755 | <div class="flex_tl_collumn_1"><?php |
| 2417 | 2756 | $title = wpbc_lang( $this->timeline_titles['header_column1'] ); |
| 2418 | - echo $title; // Resources | |
| 2757 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2758 | + echo $title; // Resources . | |
| 2419 | 2759 | ?></div> |
| 2420 | 2760 | <div class="flex_tl_collumn_2"><?php |
| 2421 | 2761 | $title = wpbc_lang( $this->timeline_titles['header_column2'] ); |
| 2422 | - echo $title; // Dates | |
| 2762 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2763 | + echo $title; // Dates. | |
| 2423 | 2764 | ?></div> |
| 2424 | 2765 | <?php } ?> |
| 2425 | - </div> | |
| 2426 | - <div class="flex_tl_table_titles"> | |
| 2427 | - <div class="flex_tl_collumn_1"></div> | |
| 2428 | - <div class="flex_tl_collumn_2"><?php | |
| 2429 | - // Header above the calendar table | |
| 2430 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), intval( $start_day ), intval( $start_year ) ); | |
| 2766 | + </div><?php | |
| 2431 | 2767 | |
| 2432 | - if ( $is_matrix ) { // MATRIX VIEW | |
| 2433 | - switch ( $view_days_num ) { // Set real start date for the each rows in calendar | |
| 2434 | - case '1': | |
| 2435 | - case '7': | |
| 2436 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); | |
| 2437 | - break; | |
| 2768 | + ?><div class="flex_tl__scrolling_sections"><?php | |
| 2769 | + ?><div class="flex_tl__scrolling_section1"> | |
| 2770 | + <div class="flex_tl_table_titles"><div class="flex_tl_collumn_1"></div></div><?php | |
| 2771 | + for ( $d_inc = 0; $d_inc < $max_rows_number; $d_inc++ ) { | |
| 2438 | 2772 | |
| 2439 | - case '30': | |
| 2440 | - case '60': | |
| 2441 | - $real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); | |
| 2442 | - break; | |
| 2773 | + // Skip showing rows of booking resource(s) in TimeLine or Calendar Overview, if no any exist booking(s) for current view | |
| 2774 | + if ( ! empty( $this->request_args['only_booked_resources'] ) ) { | |
| 2443 | 2775 | |
| 2444 | - default: // 30 | |
| 2445 | - $real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); | |
| 2446 | - break; | |
| 2447 | - } | |
| 2448 | - } else { // Single Resource View | |
| 2449 | - switch ( $view_days_num ) { // Set real start date for the each rows in calendar | |
| 2450 | - case '90': | |
| 2451 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); | |
| 2452 | - break; | |
| 2776 | + $resource_id = ( $is_matrix ) ? $bk_resources_id[ $d_inc ] : $this->request_args['wh_booking_type']; | |
| 2453 | 2777 | |
| 2454 | - case '365': | |
| 2455 | - $real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); | |
| 2456 | - break; | |
| 2778 | + if ( ! in_array( $resource_id, $booked_booking_resources ) ) { continue; } | |
| 2779 | + } | |
| 2457 | 2780 | |
| 2458 | - default: // 30 | |
| 2459 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); | |
| 2460 | - break; | |
| 2461 | - } | |
| 2462 | - } | |
| 2781 | + // Ger Start Date to real_date variable | |
| 2782 | + $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 ) ); | |
| 2463 | 2783 | |
| 2464 | - $this->wpbc_show_timeline_header_row( $real_date ); | |
| 2465 | - ?> | |
| 2466 | - </div> | |
| 2467 | - </div><?php | |
| 2468 | - | |
| 2469 | - for ( $d_inc = 0; $d_inc < $max_rows_number; $d_inc++ ) { | |
| 2784 | + ?><div class="flex_tl_table_row_bookings"> | |
| 2785 | + <div class="flex_tl_collumn_1"><?php | |
| 2470 | 2786 | |
| 2471 | - // Skip showing rows of booking resource(s) in TimeLine or Calendar Overview, if no any exist booking(s) for current view | |
| 2472 | - if ( ! empty( $this->request_args['only_booked_resources'] ) ) { //FixIn: 7.0.1.51 | |
| 2787 | + // Title in first column of each row in calendar | |
| 2788 | + if ( ( $is_matrix ) && ( isset( $bk_resources_id[$d_inc] ) ) && (isset( $booking_types[$bk_resources_id[$d_inc]] )) ) { // Matrix - resource titles | |
| 2473 | 2789 | |
| 2474 | - if ( $is_matrix ) $resource_id = $bk_resources_id[$d_inc]; | |
| 2475 | - else $resource_id = $this->request_args['wh_booking_type']; // Request from GET or REQUEST | |
| 2790 | + $resource_value = $booking_types[$bk_resources_id[$d_inc]]; | |
| 2791 | + $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), array( 'wh_booking_type' ) ); | |
| 2476 | 2792 | |
| 2477 | - if ( ! in_array( $resource_id, $booked_booking_resources ) ) { | |
| 2478 | - continue; | |
| 2479 | - } | |
| 2480 | - } | |
| 2481 | - | |
| 2482 | - | |
| 2483 | - // Ger Start Date to real_date variabale ///////////////////// | |
| 2484 | - if ( $is_matrix ) { // MATRIX VIEW | |
| 2485 | - switch ( $view_days_num ) { // Set real start date for the rows in calendar | |
| 2486 | - case '1': | |
| 2487 | - case '7': | |
| 2488 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $scroll_day ) ), intval( $start_year ) ); | |
| 2489 | - break; | |
| 2793 | + ?><div class="flex_tl_resource_title flex_tl_row_height <?php | |
| 2794 | + if ( isset( $resource_value->parent ) ) { if ( $resource_value->parent == 0 ) { echo 'parent'; } else { echo 'child'; } } | |
| 2795 | + ?> "><?php | |
| 2796 | + if ( $this->is_frontend ) { | |
| 2490 | 2797 | |
| 2491 | - case '30': | |
| 2492 | - case '90': | |
| 2493 | - $real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); | |
| 2494 | - break; | |
| 2798 | + if ( ( isset( $this->options['resource_link'] ) ) && ( isset( $this->options['resource_link'][ $resource_value->booking_type_id ] ) ) ){ // FixIn: 7.0.1.50. | |
| 2495 | 2799 | |
| 2496 | - default: // 30 | |
| 2497 | - $real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); | |
| 2498 | - break; | |
| 2499 | - } | |
| 2500 | - } else { // Single Resource View | |
| 2501 | - switch ( $view_days_num ) { // Set real start date for the rows in calendar | |
| 2502 | - case '90': | |
| 2503 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) * 7 + intval( $scroll_day ) ), intval( $start_year ) ); | |
| 2504 | - break; | |
| 2800 | + ?><a href="<?php echo esc_url( $this->options['resource_link'][ $resource_value->booking_type_id ] ); ?>" ><?php // FixIn: 7.2.1.14. | |
| 2801 | + } | |
| 2505 | 2802 | |
| 2506 | - case '365': | |
| 2507 | - $real_date = mktime( 0, 0, 0, ( intval( $start_month ) + intval( $d_inc ) + intval( $scroll_month ) ), intval( $start_day ), intval( $start_year ) ); | |
| 2508 | - break; | |
| 2803 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2804 | + echo wpbc_lang( $resource_value->title ); // FixIn: 7.0.1.11. | |
| 2509 | 2805 | |
| 2510 | - default: // 30 | |
| 2511 | - $real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) + intval( $scroll_day ) ), intval( $start_year ) ); | |
| 2512 | - break; | |
| 2513 | - } | |
| 2514 | - } | |
| 2515 | - //////////////////////////////////////////////////////////////// | |
| 2516 | - ?> | |
| 2517 | - <div class="flex_tl_table_row_bookings"> | |
| 2518 | - <div class="flex_tl_collumn_1"><?php | |
| 2806 | + if ( ( isset( $this->options['resource_link'] ) ) && ( isset( $this->options['resource_link'][ $resource_value->booking_type_id ] ) ) ){ // FixIn: 7.0.1.50. | |
| 2807 | + ?></a><?php | |
| 2808 | + } | |
| 2809 | + } else { | |
| 2810 | + ?><a href="<?php echo esc_url( $bk_admin_url . '&wh_booking_type=' . $bk_resources_id[$d_inc] ); ?>" | |
| 2811 | + title="<?php echo esc_attr( wpbc_lang( $resource_value->title ) ); ?>" | |
| 2812 | + ><?php | |
| 2813 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2814 | + echo wpbc_lang( $resource_value->title ); | |
| 2815 | + ?></a><?php | |
| 2816 | + } | |
| 2817 | + ?></div><?php | |
| 2519 | 2818 | |
| 2520 | - // Title in first collumn of the each row in calendar ////// | |
| 2521 | - if ( ( $is_matrix ) && ( isset( $bk_resources_id[$d_inc] ) ) && (isset( $booking_types[$bk_resources_id[$d_inc]] )) ) { // Matrix - resource titles | |
| 2819 | + } else { // Single Resource - Dates titles | |
| 2522 | 2820 | |
| 2523 | - $resource_value = $booking_types[$bk_resources_id[$d_inc]]; | |
| 2524 | - $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false, false ), array( 'wh_booking_type' ) ); | |
| 2525 | - | |
| 2526 | - ?><div class="flex_tl_resource_title <?php | |
| 2527 | - if ( isset( $resource_value->parent ) ) { if ( $resource_value->parent == 0 ) { echo 'parent'; } else { echo 'child'; } } | |
| 2528 | - ?> "><?php | |
| 2529 | - if ( $this->is_frontend ) { | |
| 2821 | + ?><div class="flex_tl_resource_title flex_tl_row_height"><?php | |
| 2530 | 2822 | |
| 2531 | - if ( ( isset( $this->options['resource_link'] ) ) && ( isset( $this->options['resource_link'][ $resource_value->booking_type_id ] ) ) ){ //FixIn: 7.0.1.50 | |
| 2532 | - | |
| 2533 | - ?><a href="<?php echo $this->options['resource_link'][ $resource_value->booking_type_id ]; ?>" ><?php //FixIn: 7.2.1.14 | |
| 2534 | - } | |
| 2823 | + switch ( $view_days_num ) { | |
| 2824 | + case '90': | |
| 2825 | + $end_real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) * 7 + intval( $scroll_day ) ) + 6, intval( $start_year ) ); | |
| 2826 | + $date_format = ' j, Y'; //get_bk_option( 'booking_date_format'); | |
| 2827 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2828 | + 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 ); | |
| 2829 | + break; | |
| 2535 | 2830 | |
| 2536 | - echo wpbc_lang( $resource_value->title ); //FixIn: 7.0.1.11 | |
| 2537 | - | |
| 2538 | - if ( ( isset( $this->options['resource_link'] ) ) && ( isset( $this->options['resource_link'][ $resource_value->booking_type_id ] ) ) ){ //FixIn: 7.0.1.50 | |
| 2539 | - ?></a><?php | |
| 2540 | - } | |
| 2541 | - } else { | |
| 2542 | - ?><a href="<?php echo $bk_admin_url . '&wh_booking_type=' . $bk_resources_id[$d_inc]; ?>" | |
| 2543 | - title="<?php echo wpbc_lang( $resource_value->title ); ?>" | |
| 2544 | - ><?php | |
| 2545 | - echo wpbc_lang( $resource_value->title ); | |
| 2546 | - ?></a><?php | |
| 2547 | - } | |
| 2548 | - ?></div><?php | |
| 2549 | - | |
| 2550 | - } else { // Single Resource - Dates titles | |
| 2551 | - | |
| 2552 | - ?><div class="flex_tl_resource_title"><?php | |
| 2553 | - | |
| 2554 | - switch ( $view_days_num ) { | |
| 2555 | - case '90': | |
| 2556 | - $end_real_date = mktime( 0, 0, 0, intval( $start_month ), ( intval( $start_day ) + intval( $d_inc ) * 7 + intval( $scroll_day ) ) + 6, intval( $start_year ) ); | |
| 2557 | - $date_format = ' j, Y'; //get_bk_option( 'booking_date_format'); | |
| 2558 | - 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 ); | |
| 2559 | - break; | |
| 2831 | + case '365': | |
| 2832 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2833 | + echo wpbc_datetime__no_wp_timezone( "F", $real_date ) . ', ' . wpbc_datetime__no_wp_timezone( "Y", $real_date ); | |
| 2834 | + break; | |
| 2560 | 2835 | |
| 2561 | - case '365': | |
| 2562 | - echo __( wpbc_datetime__no_wp_timezone( "F", $real_date ) ) . ', ' . wpbc_datetime__no_wp_timezone( "Y", $real_date ); | |
| 2563 | - break; | |
| 2836 | + default: // 30 | |
| 2837 | + //$date_format = 'd / m / Y'; | |
| 2838 | + $date_format = get_bk_option( 'booking_date_format' ); // FixIn: 5.4.5.13. | |
| 2839 | + $ww = wpbc_datetime__no_wp_timezone( "N", $real_date ); //7 | |
| 2840 | + ?> | |
| 2841 | + <div class="flex_tl_resource_title_dates_container"> | |
| 2842 | + <div class="flex_tl_resource_title_dates_days flex_tl_weekday<?php echo esc_attr( $ww ); ?>"><?php | |
| 2843 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2844 | + echo wpbc_datetime__no_wp_timezone( $date_format, $real_date ); ?></div> | |
| 2845 | + <div class="flex_tl_resource_title_dates_weeks flex_tl_weekday<?php echo esc_attr( $ww ); ?>"><?php | |
| 2846 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2847 | + echo wpbc_datetime__no_wp_timezone( "D", $real_date ); ?></div> | |
| 2848 | + </div> | |
| 2849 | + <?php | |
| 2850 | + break; | |
| 2851 | + } | |
| 2564 | 2852 | |
| 2565 | - default: // 30 | |
| 2566 | - //$date_format = 'd / m / Y'; | |
| 2567 | - $date_format = get_bk_option( 'booking_date_format' ); //FixIn:5.4.5.13 | |
| 2568 | - $ww = wpbc_datetime__no_wp_timezone( "N", $real_date ); //7 | |
| 2569 | - ?> | |
| 2570 | - <div class="flex_tl_resource_title_dates_container"> | |
| 2571 | - <div class="flex_tl_resource_title_dates_days flex_tl_weekday<?php echo $ww; ?>"><?php echo wpbc_datetime__no_wp_timezone( $date_format, $real_date ); ?></div> | |
| 2572 | - <div class="flex_tl_resource_title_dates_weeks flex_tl_weekday<?php echo $ww; ?>"><?php echo __( wpbc_datetime__no_wp_timezone( "D", $real_date ) ); ?></div> | |
| 2573 | - </div> | |
| 2574 | - <?php | |
| 2575 | - break; | |
| 2576 | - } | |
| 2577 | - | |
| 2578 | - ?></div><?php | |
| 2579 | - } | |
| 2580 | - ?> | |
| 2581 | - </div> | |
| 2582 | - <div class="flex_tl_collumn_2"><?php | |
| 2853 | + ?></div><?php | |
| 2854 | + } | |
| 2855 | + ?> | |
| 2856 | + </div> | |
| 2857 | + </div><?php | |
| 2858 | + } | |
| 2583 | 2859 | |
| 2584 | - if ( $is_matrix ) { | |
| 2585 | 2860 | |
| 2586 | - $this->reset_data_in_previous_cell(); | |
| 2861 | + ?></div><?php | |
| 2862 | + ?><div class="flex_tl__scrolling_section2"> | |
| 2863 | + <div class="flex_tl_table_titles flex_tl_row_max_width"> | |
| 2864 | + <div class="flex_tl_collumn_2"><?php | |
| 2865 | + // Header above the calendar table | |
| 2866 | + $real_date = mktime( 0, 0, 0, intval( $start_month ), intval( $start_day ), intval( $start_year ) ); | |
| 2587 | 2867 | |
| 2588 | - $resource_id = $bk_resources_id[ $d_inc ]; | |
| 2868 | + // Ger Start Date to real_date variable | |
| 2869 | + $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 ) ); | |
| 2589 | 2870 | |
| 2590 | - } else { | |
| 2591 | - $resource_id = $this->request_args['wh_booking_type']; | |
| 2592 | - } // Request from GET or REQUEST | |
| 2871 | + $this->wpbc_show_timeline_header_row( $real_date ); | |
| 2872 | + ?> | |
| 2873 | + </div> | |
| 2874 | + </div><?php | |
| 2593 | 2875 | |
| 2594 | - $booking_arr = array( | |
| 2595 | - '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 | |
| 2596 | - 'booked_dates_array' => $dates_array, | |
| 2597 | - 'bookings' => $bookings, | |
| 2598 | - 'booking_types' => $booking_types, | |
| 2599 | - 'time_array_new' => $time_array_new | |
| 2600 | - ); | |
| 2876 | + for ( $d_inc = 0; $d_inc < $max_rows_number; $d_inc++ ) { | |
| 2601 | 2877 | |
| 2602 | - /** | |
| 2603 | - * FROM: [2019-07-19] => Array ( [0] => Array ( | |
| 2604 | - * [id] => 19 | |
| 2605 | - [resource] => 3 | |
| 2606 | - ) | |
| 2607 | - [1] => Array ( | |
| 2608 | - [id] => 19 | |
| 2609 | - [resource] => 3 | |
| 2610 | - ), .... | |
| 2611 | - * TO | |
| 2612 | - * | |
| 2613 | - * [2019-07-19] => Array ( | |
| 2614 | - * [0] => 19 | |
| 2615 | - * [1] => 19 | |
| 2616 | - * [2] => 18 | |
| 2617 | - * [3] => 18 ... | |
| 2618 | - */ | |
| 2619 | - $booking_arr['booked_dates_array'] = $this->wpbc_dates_only_of_specific_resource( | |
| 2620 | - $booking_arr['booked_dates_array'], | |
| 2621 | - $booking_arr['current_resource_id'], | |
| 2622 | - $booking_arr['bookings'] | |
| 2623 | - ); | |
| 2624 | - /** | |
| 2625 | - * FROM: [2019-07-19] => Array ( ... , [28800] => Array( | |
| 2626 | - [0] => Array ( | |
| 2627 | - [id] => 15 | |
| 2628 | - [resource] => 3 | |
| 2878 | + // Skip showing rows of booking resource(s) in TimeLine or Calendar Overview, if no any exist booking(s) for current view | |
| 2879 | + if ( ! empty( $this->request_args['only_booked_resources'] ) ) { | |
| 2880 | + | |
| 2881 | + $resource_id = ( $is_matrix ) ? $bk_resources_id[ $d_inc ] : $this->request_args['wh_booking_type']; | |
| 2882 | + | |
| 2883 | + if ( ! in_array( $resource_id, $booked_booking_resources ) ) { continue; } | |
| 2884 | + } | |
| 2885 | + | |
| 2886 | + // Ger Start Date to real_date variable | |
| 2887 | + $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 ) ); | |
| 2888 | + | |
| 2889 | + ?> | |
| 2890 | + <div class="flex_tl_table_row_bookings flex_tl_row_max_width"> | |
| 2891 | + | |
| 2892 | + <div class="flex_tl_collumn_2"><?php | |
| 2893 | + | |
| 2894 | + if ( $is_matrix ) { | |
| 2895 | + | |
| 2896 | + $this->reset_data_in_previous_cell(); | |
| 2897 | + | |
| 2898 | + $resource_id = $bk_resources_id[ $d_inc ]; | |
| 2899 | + | |
| 2900 | + } else { | |
| 2901 | + $resource_id = $this->request_args['wh_booking_type']; | |
| 2902 | + } // Request from GET or REQUEST | |
| 2903 | + | |
| 2904 | + $booking_arr = array( | |
| 2905 | + '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 | |
| 2906 | + 'booked_dates_array' => $dates_array, | |
| 2907 | + 'bookings' => $bookings, | |
| 2908 | + 'booking_types' => $booking_types, | |
| 2909 | + 'time_array_new' => $time_array_new | |
| 2910 | + ); | |
| 2911 | + | |
| 2912 | + /** | |
| 2913 | + * FROM: [2019-07-19] => Array ( [0] => Array ( | |
| 2914 | + * [id] => 19 | |
| 2915 | + [resource] => 3 | |
| 2916 | + ) | |
| 2917 | + [1] => Array ( | |
| 2918 | + [id] => 19 | |
| 2919 | + [resource] => 3 | |
| 2920 | + ), .... | |
| 2921 | + * TO | |
| 2922 | + * | |
| 2923 | + * [2019-07-19] => Array ( | |
| 2924 | + * [0] => 19 | |
| 2925 | + * [1] => 19 | |
| 2926 | + * [2] => 18 | |
| 2927 | + * [3] => 18 ... | |
| 2928 | + */ | |
| 2929 | + $booking_arr['booked_dates_array'] = $this->wpbc_dates_only_of_specific_resource( | |
| 2930 | + $booking_arr['booked_dates_array'], | |
| 2931 | + $booking_arr['current_resource_id'], | |
| 2932 | + $booking_arr['bookings'] | |
| 2933 | + ); | |
| 2934 | + /** | |
| 2935 | + * FROM: [2019-07-19] => Array ( ... , [28800] => Array( | |
| 2936 | + [0] => Array ( | |
| 2937 | + [id] => 15 | |
| 2938 | + [resource] => 3 | |
| 2939 | + ) | |
| 2940 | + [1] => Array ( | |
| 2941 | + [id] => 16 | |
| 2942 | + [resource] => 3 | |
| 2943 | + ) | |
| 2944 | + [2] => Array ( | |
| 2945 | + [id] => 13 | |
| 2946 | + [resource] => 3 | |
| 2947 | + ) .... | |
| 2948 | + * TO | |
| 2949 | + * [2019-07-19] => Array ( ... , [28800] => Array( | |
| 2950 | + [0] => 15 | |
| 2951 | + [1] => 16 | |
| 2952 | + [2] => 13 | |
| 2629 | 2953 | ) |
| 2630 | - [1] => Array ( | |
| 2631 | - [id] => 16 | |
| 2632 | - [resource] => 3 | |
| 2633 | - ) | |
| 2634 | - [2] => Array ( | |
| 2635 | - [id] => 13 | |
| 2636 | - [resource] => 3 | |
| 2637 | - ) .... | |
| 2638 | - * TO | |
| 2639 | - * [2019-07-19] => Array ( ... , [28800] => Array( | |
| 2640 | - [0] => 15 | |
| 2641 | - [1] => 16 | |
| 2642 | - [2] => 13 | |
| 2643 | - ) | |
| 2644 | - */ | |
| 2645 | - $booking_arr['time_array_new'] = $this->wpbc_times_only_of_specific_resource( | |
| 2646 | - $booking_arr['time_array_new'], | |
| 2647 | - $booking_arr['current_resource_id'], | |
| 2648 | - $booking_arr['bookings'] | |
| 2649 | - ); | |
| 2954 | + */ | |
| 2955 | + $booking_arr['time_array_new'] = $this->wpbc_times_only_of_specific_resource( | |
| 2956 | + $booking_arr['time_array_new'], | |
| 2957 | + $booking_arr['current_resource_id'], | |
| 2958 | + $booking_arr['bookings'] | |
| 2959 | + ); | |
| 2650 | 2960 | |
| 2651 | - $this->wpbc_show_timeline_booking_row( $real_date, $booking_arr ); | |
| 2961 | + $this->wpbc_show_timeline_booking_row( $real_date, $booking_arr ); | |
| 2652 | 2962 | |
| 2653 | 2963 | |
| 2654 | - ?> | |
| 2655 | - </div> | |
| 2656 | - </div><?php | |
| 2657 | - } | |
| 2964 | + ?> | |
| 2965 | + </div> | |
| 2966 | + </div><?php | |
| 2967 | + } | |
| 2968 | + ?></div><?php | |
| 2969 | + ?></div><?php | |
| 2658 | 2970 | |
| 2659 | 2971 | ?></div></div><?php |
| 2660 | 2972 | |
| 2661 | 2973 | |
| 2662 | 2974 | if ( ! $this->is_frontend ){ |
| 2663 | - $this->show_timeline_header_end__admin_panel(); //FixIn: 10.0.0.25 | |
| 2975 | + $this->show_timeline_header_end__admin_panel(); // FixIn: 10.0.0.25. | |
| 2664 | 2976 | } |
| 2665 | 2977 | |
| 2666 | 2978 | } |
| 2667 | 2979 | |
| 2668 | 2980 | |
| 2981 | + /** | |
| 2982 | + * Ger Start Date to real_date variable | |
| 2983 | + * | |
| 2984 | + * @param $params = array( | |
| 2985 | + * 'is_matrix' => $is_matrix, | |
| 2986 | + * 'view_days_num' => $view_days_num, | |
| 2987 | + * 'start_month' => $start_month, | |
| 2988 | + * 'start_day' => $start_day, | |
| 2989 | + * 'start_year' => $start_year, | |
| 2990 | + * 'scroll_month' => $scroll_month | |
| 2991 | + * 'scroll_day' => $scroll_day | |
| 2992 | + * 'd_inc' => $d_inc | |
| 2993 | + * ) | |
| 2994 | + * | |
| 2995 | + * @return false|int | |
| 2996 | + */ | |
| 2997 | + private function get_start_day__to_real_date( $params ) { | |
| 2998 | + | |
| 2999 | + if ( $params['is_matrix'] ) { // MATRIX VIEW | |
| 3000 | + switch ( $params['view_days_num'] ) { // Set real start date for the rows in calendar | |
| 3001 | + case '1': | |
| 3002 | + case '7': | |
| 3003 | + $real_date = mktime( 0, 0, 0, intval( $params['start_month'] ), ( intval( $params['start_day'] ) + intval( $params['scroll_day'] ) ), intval( $params['start_year'] ) ); | |
| 3004 | + break; | |
| 3005 | + | |
| 3006 | + case '30': | |
| 3007 | + case '90': | |
| 3008 | + $real_date = mktime( 0, 0, 0, ( intval( $params['start_month'] ) + intval( $params['scroll_month'] ) ), intval( $params['start_day'] ), intval( $params['start_year'] ) ); | |
| 3009 | + break; | |
| 3010 | + | |
| 3011 | + default: // 30 | |
| 3012 | + $real_date = mktime( 0, 0, 0, ( intval( $params['start_month'] ) + intval( $params['scroll_month'] ) ), intval( $params['start_day'] ), intval( $params['start_year'] ) ); | |
| 3013 | + break; | |
| 3014 | + } | |
| 3015 | + } else { // Single Resource View | |
| 3016 | + switch ( $params['view_days_num'] ) { // Set real start date for the rows in calendar | |
| 3017 | + case '90': | |
| 3018 | + $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'] ) ); | |
| 3019 | + break; | |
| 3020 | + | |
| 3021 | + case '365': | |
| 3022 | + $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'] ) ); | |
| 3023 | + break; | |
| 3024 | + | |
| 3025 | + default: // 30 | |
| 3026 | + $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'] ) ); | |
| 3027 | + break; | |
| 3028 | + } | |
| 3029 | + } | |
| 3030 | + | |
| 3031 | + return $real_date; | |
| 3032 | + } | |
| 3033 | + | |
| 2669 | 3034 | /** |
| 2670 | 3035 | * Show timeline |
| 2671 | 3036 | * All parameters must be defined. |
| 2672 | 3037 | */ |
| @@ -2675,18 +3040,21 @@ | ||
| 2675 | 3040 | $this->wpbc_show_timeline( $this->dates_array, $this->bookings, $this->booking_types, $this->time_array_new ); |
| 2676 | 3041 | |
| 2677 | 3042 | //FixIn: 10.0.0.25 // removed loader text from here |
| 2678 | 3043 | |
| 2679 | - //FixIn: 9.1.2.4 | |
| 3044 | + // FixIn: 9.1.2.4. | |
| 2680 | 3045 | echo '<script type="text/javascript"> |
| 2681 | 3046 | if ( ( document.readyState !== "loading" ) && ( ( "undefined" !== typeof jQuery ) && ( window.jQuery ) ) ){ |
| 2682 | 3047 | jQuery( ".flex_tl_table_loading").hide(); |
| 2683 | 3048 | jQuery( ".flex_tl_table" ).show(); |
| 2684 | - } else { ' . wpbc_jq_ready_start(); //FixIn: 10.1.3.7 | |
| 3049 | + } else { ' ; | |
| 3050 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 3051 | + echo wpbc_jq_ready_start(); // FixIn: 10.1.3.7. | |
| 2685 | 3052 | ?> jQuery( '.flex_tl_table_loading').hide(); |
| 2686 | 3053 | jQuery( '.flex_tl_table' ).show(); |
| 2687 | 3054 | <?php |
| 2688 | - echo wpbc_jq_ready_end() . ' } </script>'; //FixIn: 10.1.3.7 | |
| 3055 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 3056 | + echo wpbc_jq_ready_end() . ' } </script>'; // FixIn: 10.1.3.7. | |
| 2689 | 3057 | } |
| 2690 | 3058 | |
| 2691 | 3059 | /** |
| 2692 | 3060 | * Show Header for Timeline in Calendar Overview page in admin panel. Header contain switches of modes and novigation buttons |
| @@ -2691,14 +3059,15 @@ | ||
| 2691 | 3059 | /** |
| 2692 | 3060 | * Show Header for Timeline in Calendar Overview page in admin panel. Header contain switches of modes and novigation buttons |
| 2693 | 3061 | * @return void |
| 2694 | 3062 | */ |
| 2695 | - public function show_timeline_header_start__admin_panel(){ //FixIn: 10.0.0.25 | |
| 3063 | + public function show_timeline_header_start__admin_panel(){ // FixIn: 10.0.0.25. | |
| 2696 | 3064 | |
| 3065 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 2697 | 3066 | $is_show_resources_matrix = ( ( isset( $_REQUEST['wh_booking_type'] ) ) && ( strpos( $_REQUEST['wh_booking_type'], ',' ) !== false ) ) |
| 2698 | 3067 | ? true : false; |
| 2699 | 3068 | |
| 2700 | - $view_days_num = ( isset( $_REQUEST['view_days_num'] ) ) ? intval( $_REQUEST['view_days_num'] ) : get_bk_option( 'booking_view_days_num' ); | |
| 3069 | + $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 | |
| 2701 | 3070 | |
| 2702 | 3071 | $bk_admin_url = wpbc_get_params_in_url( wpbc_get_bookings_url( false ), array( 'view_days_num' ) ); |
| 2703 | 3072 | |
| 2704 | 3073 | ?><div class="wpbc_calendar_overview__header" > |
| @@ -2708,21 +3077,21 @@ | ||
| 2708 | 3077 | if ( $is_show_resources_matrix ) { |
| 2709 | 3078 | ?> |
| 2710 | 3079 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=1' ); ?>" |
| 2711 | 3080 | class="nav-tab <?php echo ( 1 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-event"></i> |
| 2712 | - <span class="nav-tab-text"> <?php echo __('Day', 'booking') ; ?></span> | |
| 3081 | + <span class="nav-tab-text"> <?php echo esc_html__('Day', 'booking') ; ?></span> | |
| 2713 | 3082 | </a> |
| 2714 | 3083 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=7' ); ?>" |
| 2715 | 3084 | class="nav-tab <?php echo ( 7 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-week"></i> |
| 2716 | - <span class="nav-tab-text"> <?php echo __('Week', 'booking'); ?></span> | |
| 3085 | + <span class="nav-tab-text"> <?php echo esc_html__('Week', 'booking'); ?></span> | |
| 2717 | 3086 | </a> |
| 2718 | 3087 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=30' ); ?>" |
| 2719 | 3088 | class="nav-tab <?php echo ( 30 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar3"></i> |
| 2720 | - <span class="nav-tab-text"> <?php echo __('Month', 'booking'); ?></span> | |
| 3089 | + <span class="nav-tab-text"> <?php echo esc_html__('Month', 'booking'); ?></span> | |
| 2721 | 3090 | </a> |
| 2722 | 3091 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=60' ); ?>" |
| 2723 | 3092 | class="nav-tab <?php echo ( 60 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar2-week"></i> |
| 2724 | - <span class="nav-tab-text"> 2 <?php echo __('Months', 'booking'); ?></span> | |
| 3093 | + <span class="nav-tab-text"> 2 <?php echo esc_html__('Months', 'booking'); ?></span> | |
| 2725 | 3094 | </a> |
| 2726 | 3095 | <?php |
| 2727 | 3096 | } else { |
| 2728 | 3097 | ?> |
| @@ -2727,17 +3096,17 @@ | ||
| 2727 | 3096 | } else { |
| 2728 | 3097 | ?> |
| 2729 | 3098 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=30' ); ?>" |
| 2730 | 3099 | class="nav-tab <?php echo ( 30 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-event"></i> |
| 2731 | - <span class="nav-tab-text"> <?php echo __('Day', 'booking') ; ?></span> | |
| 3100 | + <span class="nav-tab-text"> <?php echo esc_html__('Day', 'booking') ; ?></span> | |
| 2732 | 3101 | </a> |
| 2733 | 3102 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=90' ); ?>" |
| 2734 | 3103 | class="nav-tab <?php echo ( 90 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar-week"></i> |
| 2735 | - <span class="nav-tab-text"> <?php echo __('Week', 'booking'); ?></span> | |
| 3104 | + <span class="nav-tab-text"> <?php echo esc_html__('Week', 'booking'); ?></span> | |
| 2736 | 3105 | </a> |
| 2737 | 3106 | <a href="<?php echo esc_url( $bk_admin_url . '&view_days_num=365' ); ?>" |
| 2738 | 3107 | class="nav-tab <?php echo ( 365 == $view_days_num ) ? 'nav-tab-active' : ''; ?>"><i class="menu_icon icon-1x wpbc-bi-calendar3"></i> |
| 2739 | - <span class="nav-tab-text"> <?php echo __('Month', 'booking'); ?></span> | |
| 3108 | + <span class="nav-tab-text"> <?php echo esc_html__('Month', 'booking'); ?></span> | |
| 2740 | 3109 | </a> |
| 2741 | 3110 | <?php |
| 2742 | 3111 | } |
| 2743 | 3112 | ?><div class="wpbc_calendar_overview__navigation"><?php |
| @@ -2753,9 +3122,9 @@ | ||
| 2753 | 3122 | <div class="wpbc_calendar_overview__container"> |
| 2754 | 3123 | <?php |
| 2755 | 3124 | } |
| 2756 | 3125 | |
| 2757 | - function show_timeline_header_end__admin_panel(){ //FixIn: 10.0.0.25 | |
| 3126 | + function show_timeline_header_end__admin_panel(){ // FixIn: 10.0.0.25. | |
| 2758 | 3127 | ?></div><?php // End: .wpbc_calendar_overview__container |
| 2759 | 3128 | } |
| 2760 | 3129 | |
| 2761 | 3130 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -2775,12 +3144,19 @@ | ||
| 2775 | 3144 | * @param string $content_text |
| 2776 | 3145 | * |
| 2777 | 3146 | * @return array |
| 2778 | 3147 | */ |
| 2779 | - public function wpbc_get_booking_info_4_popover( $bk_id, $bookings, $booking_types ){ | |
| 2780 | - | |
| 2781 | - if ( isset( $bookings[ $bk_id ] ) ) { | |
| 2782 | - //$bookings[ $bk_id ]->form_show = str_replace( "&", '&', $bookings[ $bk_id ]->form_show ); //FixIn:7.1.2.12 | |
| 3148 | + public function wpbc_get_booking_info_4_popover( $bk_id, $bookings, $booking_types ){ | |
| 3149 | + | |
| 3150 | + if ( ! $this->wpbc_is_booking_authorized_for_hash( $bk_id, $bookings ) ) { | |
| 3151 | + return array( | |
| 3152 | + 'title' => '', | |
| 3153 | + 'content' => '', | |
| 3154 | + ); | |
| 3155 | + } | |
| 3156 | + | |
| 3157 | + if ( isset( $bookings[ $bk_id ] ) ) { | |
| 3158 | + //$bookings[ $bk_id ]->form_show = str_replace( "&", '&', $bookings[ $bk_id ]->form_show ); // FixIn: 7.1.2.12. | |
| 2783 | 3159 | // We escaping at other place: wpbc__legacy__get_form_content_arr() |
| 2784 | 3160 | } |
| 2785 | 3161 | |
| 2786 | 3162 | if ( count( $bookings[ $bk_id ]->dates ) > 0 ) { |
| @@ -2809,37 +3185,50 @@ | ||
| 2809 | 3185 | if ( ( ! $this->is_frontend ) && ( $is_can ) ) { |
| 2810 | 3186 | // Link |
| 2811 | 3187 | $header_title .= '<a class=\'button button-secondary\' |
| 2812 | 3188 | title=\'' . esc_attr( str_replace( "'", '', __( 'Booking Listing', 'booking' ) ) ) . '\' |
| 2813 | - href=\''.wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&view_mode=vm_listing&tab=actions\' ><i class=\'wpbc_icn_gps_fixed\'></i></a>'; | |
| 2814 | - //Edit | |
| 2815 | - if ( class_exists( 'wpdev_bk_personal' ) ) { | |
| 2816 | - $bk_url_add = wpbc_get_new_booking_url( true, false ); | |
| 2817 | - $bk_hash = (isset( $bookings[$bk_id]->hash )) ? $bookings[$bk_id]->hash : ''; | |
| 2818 | - $bk_booking_type = $bookings[$bk_id]->booking_type; | |
| 2819 | - $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1'; | |
| 2820 | - $edit_booking_url .= ( 'Off' !== get_bk_option( 'booking_is_resource_no_update__during_editing' ) ) ? '&resource_no_update=1' : ''; //FixIn: 9.4.2.3 | |
| 3189 | + href=\''.wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&tab=vm_booking_listing\' ><i class=\'wpbc_icn_gps_fixed\'></i></a>'; | |
| 3190 | + //Edit | |
| 3191 | + if ( class_exists( 'wpdev_bk_personal' ) ) { | |
| 3192 | + $bk_hash = (isset( $bookings[$bk_id]->hash )) ? $bookings[$bk_id]->hash : ''; | |
| 3193 | + $bk_booking_type = $bookings[$bk_id]->booking_type; | |
| 3194 | + // 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. | |
| 3195 | + | |
| 3196 | + $custom_booking_form = ''; | |
| 3197 | + if ( ! empty( $bookings[ $bk_id ]->form_data['_all_fields_']['wpbc_custom_booking_form'] ) ) { | |
| 3198 | + $custom_booking_form = $bookings[ $bk_id ]->form_data['_all_fields_']['wpbc_custom_booking_form']; | |
| 3199 | + } | |
| 3200 | + $edit_booking_url = wpbc_get_booking_admin_edit_url( $bk_booking_type, $bk_hash, $custom_booking_form ); | |
| 3201 | + | |
| 3202 | + $edit_booking_onclick = ''; | |
| 3203 | + if ( ! wpbc_is_booking_admin_edit_page_enabled() ) { | |
| 3204 | + $edit_booking_onclick = "if ( 'function' === typeof wpbc_boo_listing__click__add_booking_modal_from_row ) {" | |
| 3205 | + . ' wpbc_boo_listing__click__add_booking_modal_from_row(' | |
| 3206 | + . absint( $bk_id ) . ',' | |
| 3207 | + . absint( $bk_booking_type ) . ',' | |
| 3208 | + . "'" . esc_js( $bk_hash ) . "'," | |
| 3209 | + . "'" . esc_js( $custom_booking_form ) . "'" | |
| 3210 | + . ' ); return false; }'; | |
| 3211 | + } | |
| 3212 | + | |
| 3213 | + $header_title .= '<a class=\'button button-secondary\' | |
| 3214 | + title=\'' . esc_attr( str_replace( "'", '', __( 'Edit', 'booking' ) ) ) . '\' | |
| 3215 | + href=\'' . esc_url( $edit_booking_url ) . '\'' | |
| 3216 | + . ( '' !== $edit_booking_onclick ? ' onclick=\'' . esc_attr( $edit_booking_onclick ) . '\'' : '' ) | |
| 3217 | + . ' ><i class=\'wpbc_icn_draw\'></i></a>'; | |
| 2821 | 3218 | |
| 2822 | - if ( ! empty( $bookings[ $bk_id ]->form_data['_all_fields_']['wpbc_custom_booking_form'] ) ) { | |
| 2823 | - $edit_booking_url .= '&booking_form=' . $bookings[ $bk_id ]->form_data['_all_fields_']['wpbc_custom_booking_form']; //FixIn: 9.4.3.12 | |
| 2824 | - } | |
| 2825 | 3219 | |
| 2826 | - $header_title .= '<a class=\'button button-secondary\' | |
| 2827 | - title=\'' . esc_attr( str_replace( "'", '', __( 'Edit', 'booking' ) ) ) . '\' | |
| 2828 | - href=\'' . esc_url($edit_booking_url) . '\' onclick=\'\' ><i class=\'wpbc_icn_draw\'></i></a>'; | |
| 2829 | - | |
| 2830 | - | |
| 2831 | 3220 | $header_title .= '<span class=\'wpbc-buttons-separator\'></span>'; |
| 2832 | 3221 | } |
| 2833 | 3222 | // Trash |
| 2834 | 3223 | //$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>'; |
| 2835 | - //FixIn: 6.1.1.10 | |
| 3224 | + // FixIn: 6.1.1.10. | |
| 2836 | 3225 | $is_trash = $bookings[$bk_id]->trash; |
| 2837 | 3226 | |
| 2838 | 3227 | // Trash |
| 2839 | 3228 | $header_title .= '<a class=\'button button-secondary trash_bk_link'.(( $is_trash)?' hidden_items ':'').'\' |
| 2840 | 3229 | title=\'' . esc_attr( str_replace( "'", '', __( 'Trash / Reject', 'booking' ) ) ) . '\' |
| 2841 | - 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 | |
| 3230 | + 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. | |
| 2842 | 3231 | // Restore |
| 2843 | 3232 | $header_title .= '<a class=\'button button-secondary restore_bk_link'.((!$is_trash)?' hidden_items ':'').'\' |
| 2844 | 3233 | title=\'' . esc_attr( str_replace( "'", '', __( 'Restore', 'booking' ) ) ) . '\' |
| 2845 | 3234 | 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>'; |
| @@ -2845,9 +3234,9 @@ | ||
| 2845 | 3234 | 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>'; |
| 2846 | 3235 | // Delete |
| 2847 | 3236 | $header_title .= '<a class=\'button button-secondary delete_bk_link'.((!$is_trash)?' hidden_items ':'').'\' |
| 2848 | 3237 | title=\'' . esc_attr( str_replace( "'", '', __( 'Delete', 'booking' ) ) ) . '\' |
| 2849 | - 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 | |
| 3238 | + 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. | |
| 2850 | 3239 | //End FixIn: 6.1.1.10 |
| 2851 | 3240 | |
| 2852 | 3241 | // Approve | Decline |
| 2853 | 3242 | $header_title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' |
| @@ -2859,19 +3248,19 @@ | ||
| 2859 | 3248 | |
| 2860 | 3249 | |
| 2861 | 3250 | } |
| 2862 | 3251 | |
| 2863 | - else if ( ( $this->is_frontend ) && ( ! empty( $this->request_args['booking_hash'] ) ) ) { //FixIn: 8.1.3.5 | |
| 3252 | + else if ( ( $this->is_frontend ) && ( ! empty( $this->request_args['booking_hash'] ) ) ) { // FixIn: 8.1.3.5. | |
| 2864 | 3253 | // Valid or not valid hash we was checked at beginning of function. |
| 2865 | 3254 | |
| 2866 | 3255 | //Edit |
| 2867 | 3256 | if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 2868 | 3257 | |
| 2869 | - // $edit_booking_url_admin = wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&view_mode=vm_listing&tab=actions'; | |
| 2870 | - // $trash_booking_url_admin = wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&view_mode=vm_listing&tab=actions'; | |
| 3258 | + // $edit_booking_url_admin = wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&tab=vm_booking_listing'; | |
| 3259 | + // $trash_booking_url_admin = wpbc_get_bookings_url( true, false ).'&wh_booking_id='.$bk_id.'&tab=vm_booking_listing'; | |
| 2871 | 3260 | |
| 2872 | - $is_change_hash_after_approvement = get_bk_option( 'booking_is_change_hash_after_approvement' ); //FixIn: 8.6.1.6 | |
| 2873 | - if ( ( ! $is_approved ) || ( 'On' != $is_change_hash_after_approvement ) ) { //FixIn: 8.2.1.14 | |
| 3261 | + $is_change_hash_after_approvement = get_bk_option( 'booking_is_change_hash_after_approvement' ); // FixIn: 8.6.1.6. | |
| 3262 | + if ( ( ! $is_approved ) || ( 'On' != $is_change_hash_after_approvement ) ) { // FixIn: 8.2.1.14. | |
| 2874 | 3263 | $visitorbookingediturl = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingediturl]', $bk_id ); |
| 2875 | 3264 | $visitorbookingcancelurl = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingcancelurl]', $bk_id ); |
| 2876 | 3265 | $visitorbookingpayurl = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingpayurl]', $bk_id ); |
| 2877 | 3266 | |
| @@ -2883,17 +3272,17 @@ | ||
| 2883 | 3272 | } |
| 2884 | 3273 | |
| 2885 | 3274 | $header_title .= '</div>'; |
| 2886 | 3275 | } |
| 2887 | - | |
| 3276 | + | |
| 2888 | 3277 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2889 | - // Content | |
| 3278 | + // Content | |
| 2890 | 3279 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2891 | 3280 | |
| 2892 | 3281 | // Container |
| 2893 | 3282 | $content_text = '<div id=\'wpbc-booking-id-'.$bk_id.'\' class=\'flex-popover-content-data\' >'; |
| 2894 | 3283 | |
| 2895 | - | |
| 3284 | + | |
| 2896 | 3285 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2897 | 3286 | // Labels |
| 2898 | 3287 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2899 | 3288 | $content_text .= '<div class=\'flex-popover-bars\' >'; |
| @@ -2922,9 +3311,9 @@ | ||
| 2922 | 3311 | $bk_title = wpbc_get_resource_title( $bookings[ $bk_id ]->booking_type ); |
| 2923 | 3312 | } |
| 2924 | 3313 | |
| 2925 | 3314 | $content_text .= '<div class=\'flex-label flex-label-resource\'>'; |
| 2926 | - $content_text .= '<span class=\'\'>' . esc_textarea( $bk_title ) . '</span>'; //FixIn: 7.1.1.2 | |
| 3315 | + $content_text .= '<span class=\'\'>' . esc_textarea( $bk_title ) . '</span>'; // FixIn: 7.1.1.2. | |
| 2927 | 3316 | $content_text .= '</div>'; |
| 2928 | 3317 | } |
| 2929 | 3318 | |
| 2930 | 3319 | // Payment Status |
| @@ -2940,9 +3329,9 @@ | ||
| 2940 | 3329 | |
| 2941 | 3330 | if ( $is_payment_ok ) |
| 2942 | 3331 | $content_text .= '<span class=\'label-prefix\'>' . esc_js( __( 'Payment', 'booking' ) ). '</span> ' . esc_js( $pay_status ); |
| 2943 | 3332 | else { |
| 2944 | - $content_text .= '<span class=\'label-prefix\'>' . esc_js( __( 'Payment', 'booking' ) ) . '</span> ' . esc_js( $pay_status ); //FixIn: 7.1.1.3 | |
| 3333 | + $content_text .= '<span class=\'label-prefix\'>' . esc_js( __( 'Payment', 'booking' ) ) . '</span> ' . esc_js( $pay_status ); // FixIn: 7.1.1.3. | |
| 2945 | 3334 | } |
| 2946 | 3335 | |
| 2947 | 3336 | $content_text .= '</div>'; |
| 2948 | 3337 | } |
| @@ -2949,9 +3338,9 @@ | ||
| 2949 | 3338 | |
| 2950 | 3339 | if ( ! $this->is_frontend ) { |
| 2951 | 3340 | // Trash |
| 2952 | 3341 | $content_text .= '<div class=\'flex-label flex-label-trash' . ( ( ! $bookings[$bk_id]->trash ) ? ' hidden_items ' : '' ) . '\'>'; |
| 2953 | - $content_text .= '<span class=\'\'>' . esc_js( __('Trash / Reject' ,'booking') ) . '</span>'; //FixIn: 6.1.1.10 //FixIn: 7.1.1.3 | |
| 3342 | + $content_text .= '<span class=\'\'>' . esc_js( __('Trash / Reject' ,'booking') ) . '</span>'; //FixIn: 6.1.1.10 // FixIn: 7.1.1.3. | |
| 2954 | 3343 | $content_text .= '</div>'; |
| 2955 | 3344 | } |
| 2956 | 3345 | |
| 2957 | 3346 | |
| @@ -2964,9 +3353,9 @@ | ||
| 2964 | 3353 | if ( ( class_exists( 'wpdev_bk_biz_s' ) ) ) { //&& ( ! $this->is_frontend ) ){ |
| 2965 | 3354 | |
| 2966 | 3355 | $content_text .= '<div class=\'flex-popover-cost-bar\' >'; |
| 2967 | 3356 | |
| 2968 | - //FixIn: 8.3.3.9 | |
| 3357 | + // FixIn: 8.3.3.9. | |
| 2969 | 3358 | if ( floatval( $bookings[ $bk_id ]->cost ) > 0 ) { |
| 2970 | 3359 | // Cost |
| 2971 | 3360 | $booking_cost = wpbc_get_cost_with_currency_for_user( $bookings[ $bk_id ]->cost, $bookings[ $bk_id ]->booking_type ); |
| 2972 | 3361 | |
| @@ -2989,11 +3378,11 @@ | ||
| 2989 | 3378 | // Booking Data |
| 2990 | 3379 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2991 | 3380 | |
| 2992 | 3381 | // Booking Data |
| 2993 | - $content_text .= '<div class=\'clear\'></div>'; //FixIn: 8.7.9.4 | |
| 2994 | - $content_text .= '<div class=\'flex-popover-booking-data\'>' . esc_textarea( $bookings[$bk_id]->form_show ) . '</div>'; //FixIn: 7.1.1.2 | |
| 2995 | - $content_text .= '<div class=\'clear\'></div>'; //FixIn: 8.7.9.4 | |
| 3382 | + $content_text .= '<div class=\'clear\'></div>'; // FixIn: 8.7.9.4. | |
| 3383 | + $content_text .= '<div class=\'flex-popover-booking-data\'>' . esc_textarea( $bookings[$bk_id]->form_show ) . '</div>'; // FixIn: 7.1.1.2. | |
| 3384 | + $content_text .= '<div class=\'clear\'></div>'; // FixIn: 8.7.9.4. | |
| 2996 | 3385 | |
| 2997 | 3386 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2998 | 3387 | // Notes |
| 2999 | 3388 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -2998,12 +3387,12 @@ | ||
| 2998 | 3387 | // Notes |
| 2999 | 3388 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3000 | 3389 | |
| 3001 | 3390 | // Notes |
| 3002 | - if ( ! empty( $bookings[$bk_id]->remark ) ) { | |
| 3003 | - $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 | |
| 3391 | + if ( ! empty( $bookings[$bk_id]->remark ) ) { | |
| 3392 | + $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. | |
| 3004 | 3393 | } |
| 3005 | - | |
| 3394 | + | |
| 3006 | 3395 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3007 | 3396 | // Dates |
| 3008 | 3397 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 3009 | 3398 | |
| @@ -3009,9 +3398,9 @@ | ||
| 3009 | 3398 | |
| 3010 | 3399 | $bk_dates_short_id = array(); //BL |
| 3011 | 3400 | if ( count( $bookings[$bk_id]->dates ) > 0 ) |
| 3012 | 3401 | $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 ) |
| 3013 | - | |
| 3402 | + | |
| 3014 | 3403 | $short_dates_content = wpbc_get_short_dates_formated_to_show( $bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types ); |
| 3015 | 3404 | $short_dates_content = str_replace( '"', "'", $short_dates_content ); |
| 3016 | 3405 | |
| 3017 | 3406 | $content_text .= '<div class=\'flex-label-dates \'>'; |
| @@ -3017,9 +3406,9 @@ | ||
| 3017 | 3406 | $content_text .= '<div class=\'flex-label-dates \'>'; |
| 3018 | 3407 | $content_text .= $short_dates_content; |
| 3019 | 3408 | $content_text .= '</div>'; |
| 3020 | 3409 | |
| 3021 | - //FixIn: 8.9.4.14 | |
| 3410 | + // FixIn: 8.9.4.14. | |
| 3022 | 3411 | $date_format = get_bk_option( 'booking_date_format' ); |
| 3023 | 3412 | if ( empty( $date_format ) ) { |
| 3024 | 3413 | $date_format = 'm / d / Y, D'; |
| 3025 | 3414 | } |
| @@ -3034,20 +3423,24 @@ | ||
| 3034 | 3423 | |
| 3035 | 3424 | |
| 3036 | 3425 | $content_text .= '</div>'; // Main Container: 'flex-popover-content-data' |
| 3037 | 3426 | |
| 3038 | - return array( | |
| 3039 | - 'title' => $header_title, | |
| 3040 | - 'content' => $content_text | |
| 3041 | - ); | |
| 3042 | - } | |
| 3043 | - | |
| 3427 | + $popover = array( | |
| 3428 | + 'title' => $header_title, | |
| 3429 | + 'content' => $content_text | |
| 3430 | + ); | |
| 3431 | + | |
| 3432 | + $popover = apply_filters( 'wpbc_timeline_booking_popover', $popover, $bk_id, $bookings, $this->is_frontend ); | |
| 3433 | + | |
| 3434 | + return $popover; | |
| 3435 | + } | |
| 3436 | + | |
| 3044 | 3437 | } |
| 3045 | 3438 | |
| 3046 | 3439 | |
| 3047 | 3440 | |
| 3048 | 3441 | /** Navigation of Timeline in Ajax request */ |
| 3049 | -function wpbc_ajax_flex_timeline() { | |
| 3442 | +function wpbc_ajax_flex_timeline() { | |
| 3050 | 3443 | /* |
| 3051 | 3444 | [timeline_obj] => Array |
| 3052 | 3445 | ( |
| 3053 | 3446 | [is_frontend] => 1 |
| @@ -3054,22 +3447,87 @@ | ||
| 3054 | 3447 | [html_client_id] => wpbc_timeline_1454680376080 |
| 3055 | 3448 | [wh_booking_type] => 3,4,1,5,6,7,8,9,2,10,11,12,14 |
| 3056 | 3449 | [is_matrix] => 1 |
| 3057 | 3450 | [view_days_num] => 30 |
| 3058 | - [scroll_start_date] => | |
| 3451 | + [scroll_start_date] => | |
| 3059 | 3452 | [scroll_day] => 0 |
| 3060 | 3453 | [scroll_month] => 0 |
| 3061 | 3454 | ) |
| 3062 | 3455 | */ |
| 3063 | - | |
| 3064 | 3456 | |
| 3065 | - $attr = $_POST['timeline_obj']; | |
| 3066 | - $attr['nav_step'] = $_POST['nav_step']; | |
| 3457 | + // Public timeline navigation accepts only one flat scalar attribute map. | |
| 3458 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 3459 | + if ( ! isset( $_POST['timeline_obj'] ) || ! is_array( $_POST['timeline_obj'] ) ) { | |
| 3460 | + status_header( 400 ); | |
| 3461 | + wp_die( '' ); | |
| 3462 | + } | |
| 3463 | + | |
| 3464 | + $attr = array(); | |
| 3465 | + $allowed_timeline_keys = array_fill_keys( | |
| 3466 | + array( | |
| 3467 | + 'is_frontend', | |
| 3468 | + 'html_client_id', | |
| 3469 | + 'wh_booking_type', | |
| 3470 | + 'is_matrix', | |
| 3471 | + 'view_days_num', | |
| 3472 | + 'scroll_start_date', | |
| 3473 | + 'scroll_day', | |
| 3474 | + 'scroll_month', | |
| 3475 | + 'header_column1', | |
| 3476 | + 'header_column2', | |
| 3477 | + 'header_title', | |
| 3478 | + 'wh_trash', | |
| 3479 | + 'limit_hours', | |
| 3480 | + 'only_booked_resources', | |
| 3481 | + 'options', | |
| 3482 | + 'booking_hash', | |
| 3483 | + ), | |
| 3484 | + true | |
| 3485 | + ); | |
| 3486 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 3487 | + foreach ( $_POST['timeline_obj'] as $tl_key => $tl_value ) { | |
| 3488 | + if ( ! is_scalar( $tl_key ) || ! is_scalar( $tl_value ) ) { | |
| 3489 | + status_header( 400 ); | |
| 3490 | + wp_die( '' ); | |
| 3491 | + } | |
| 3492 | + | |
| 3493 | + $clean_key = sanitize_key( wp_unslash( (string) $tl_key ) ); | |
| 3494 | + if ( '' === $clean_key || ! isset( $allowed_timeline_keys[ $clean_key ] ) ) { | |
| 3495 | + continue; | |
| 3496 | + } | |
| 3497 | + $clean_value = wp_unslash( (string) $tl_value ); | |
| 3498 | + if ( 'options' === $clean_key ) { | |
| 3499 | + $normalized_options = WPBC_TimelineFlex::decode_options( $clean_value ); | |
| 3500 | + $encoded_options = wp_json_encode( $normalized_options ); | |
| 3501 | + $attr[ $clean_key ] = false === $encoded_options ? '{}' : $encoded_options; | |
| 3502 | + continue; | |
| 3503 | + } | |
| 3504 | + | |
| 3505 | + $attr[ $clean_key ] = wpbc_clean_text_value( $clean_value ); | |
| 3506 | + } | |
| 3507 | + | |
| 3508 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 3509 | + if ( isset( $_POST['nav_step'] ) && ! is_scalar( $_POST['nav_step'] ) ) { | |
| 3510 | + status_header( 400 ); | |
| 3511 | + wp_die( '' ); | |
| 3512 | + } | |
| 3513 | + | |
| 3514 | + $attr['nav_step'] = isset( $_POST['nav_step'] ) | |
| 3515 | + ? wpbc_clean_text_value( wp_unslash( (string) $_POST['nav_step'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 3516 | + : '0'; | |
| 3517 | + $attr['is_frontend'] = isset( $attr['is_frontend'] ) ? $attr['is_frontend'] : '1'; | |
| 3518 | + $attr['html_client_id'] = isset( $attr['html_client_id'] ) | |
| 3519 | + ? WPBC_TimelineFlex::normalize_html_client_id( $attr['html_client_id'] ) | |
| 3520 | + : ''; | |
| 3521 | + if ( '' === $attr['html_client_id'] ) { | |
| 3522 | + status_header( 400 ); | |
| 3523 | + wp_die( '' ); | |
| 3524 | + } | |
| 3067 | 3525 | |
| 3068 | - | |
| 3069 | - //FixIn: 9.9.0.18 | |
| 3526 | + // FixIn: 9.9.0.18. | |
| 3070 | 3527 | $server_zone = date_default_timezone_get(); // If in 'Theme' or 'other plugin' set default timezone other than UTC. Save it. |
| 3071 | - if ( 'UTC' !== $server_zone ) { // Needed for WP date functions - set timezone to UTC | |
| 3528 | + if ( 'UTC' !== $server_zone ) { // Needed for WP date functions - set timezone to UTC. | |
| 3529 | + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set | |
| 3072 | 3530 | @date_default_timezone_set( 'UTC' ); |
| 3073 | 3531 | } |
| 3074 | 3532 | |
| 3075 | 3533 | ob_start(); |
| @@ -3076,38 +3534,42 @@ | ||
| 3076 | 3534 | |
| 3077 | 3535 | $timeline = new WPBC_TimelineFlex(); |
| 3078 | 3536 | |
| 3079 | 3537 | $html_client_id = $timeline->ajax_init( $attr ); // Define arameters and get bookings |
| 3080 | -//debuge($timeline->options); | |
| 3081 | - | |
| 3538 | +//debuge($timeline->options); | |
| 3539 | + | |
| 3082 | 3540 | //echo '<div class="wpbc_timeline_ajax_replace">'; // Replace content of this container |
| 3083 | 3541 | $timeline->show_timeline(); |
| 3084 | 3542 | |
| 3085 | 3543 | |
| 3086 | - $is_show_popover_in_timeline = wpbc_is_show_popover_in_flex_timeline( $attr['is_frontend'], $attr['booking_hash'] ); //FixIn: 8.1.3.5 | |
| 3544 | + $is_show_popover_in_timeline = wpbc_is_show_popover_in_flex_timeline( $attr['is_frontend'], $attr['booking_hash'] ); // FixIn: 8.1.3.5. | |
| 3087 | 3545 | |
| 3088 | 3546 | if ( $is_show_popover_in_timeline ) { // Update New Popovers |
| 3089 | 3547 | |
| 3090 | - $html = '<script type="text/javascript"> ' . wpbc_jq_ready_start(); //FixIn: 10.1.3.7 | |
| 3548 | + $html = '<script type="text/javascript"> ' . wpbc_jq_ready_start(); // FixIn: 10.1.3.7. | |
| 3091 | 3549 | $html .= ' wpbc_define_tippy_popover(); '; |
| 3092 | - $html .= wpbc_jq_ready_end() . '</script>'; //FixIn: 10.1.3.7 | |
| 3550 | + $html .= wpbc_jq_ready_end() . '</script>'; // FixIn: 10.1.3.7. | |
| 3551 | + | |
| 3552 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 3093 | 3553 | echo $html; |
| 3094 | 3554 | |
| 3095 | 3555 | /* ?><script type="text/javascript"> wpbc_define_tippy_popover(); </script><?php */ |
| 3096 | 3556 | } |
| 3097 | - //echo '</div>'; | |
| 3557 | + //echo '</div>'; | |
| 3098 | 3558 | |
| 3099 | - | |
| 3559 | + | |
| 3100 | 3560 | $timeline_results = ob_get_contents(); |
| 3101 | 3561 | |
| 3102 | 3562 | ob_end_clean(); |
| 3103 | 3563 | |
| 3104 | - //FixIn: 9.9.0.18 | |
| 3564 | + // FixIn: 9.9.0.18. | |
| 3105 | 3565 | if ( 'UTC' !== $server_zone ) { // Back to previos state, if it was changed. |
| 3566 | + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set | |
| 3106 | 3567 | @date_default_timezone_set( $server_zone ); |
| 3107 | 3568 | } |
| 3108 | 3569 | |
| 3109 | - echo $timeline_results ; | |
| 3570 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 3571 | + echo $timeline_results ; | |
| 3110 | 3572 | } |
| 3111 | 3573 | add_bk_action('wpbc_ajax_flex_timeline', 'wpbc_ajax_flex_timeline'); |
| 3112 | 3574 | |
| 3113 | 3575 | |
| @@ -3121,22 +3583,32 @@ | ||
| 3121 | 3583 | * @param $booking_hash |
| 3122 | 3584 | * |
| 3123 | 3585 | * @return bool |
| 3124 | 3586 | */ |
| 3125 | -function wpbc_is_show_popover_in_flex_timeline( $is_frontend, $booking_hash ){ | |
| 3587 | +function wpbc_is_show_popover_in_flex_timeline( $is_frontend, $booking_hash ) { | |
| 3126 | 3588 | |
| 3127 | - // Default for admin | |
| 3589 | + // Default for admin. | |
| 3128 | 3590 | $is_show_popover_in_timeline = true; |
| 3129 | 3591 | |
| 3130 | - // For client Timeline | |
| 3131 | - if ( $is_frontend ) | |
| 3132 | - $is_show_popover_in_timeline = ( get_bk_option( 'booking_is_show_popover_in_timeline_front_end' ) == 'On' ) ? true : false ; | |
| 3592 | + // For client Timeline. | |
| 3593 | + if ( $is_frontend ) { | |
| 3133 | 3594 | |
| 3134 | - // For customer booking listing with ability to edit | |
| 3135 | - //FixIn: 8.1.3.5 | |
| 3595 | + // FixIn: 10.14.11.1. | |
| 3596 | + if ( WPBC_DISABLE_POPOVER_IN_TIMELINE ) { | |
| 3597 | + $is_show_popover_in_timeline = false; | |
| 3598 | + } else { | |
| 3599 | + $is_show_popover_in_timeline = ( get_bk_option( 'booking_is_show_popover_in_timeline_front_end' ) == 'On' ) ? true : false; | |
| 3600 | + if ( ! class_exists( 'wpdev_bk_personal' ) ) { | |
| 3601 | + $is_show_popover_in_timeline = false; // FixIn: 10.14.9.2. | |
| 3602 | + } | |
| 3603 | + } | |
| 3604 | + } | |
| 3605 | + | |
| 3606 | + // For customer booking listing with ability to edit. | |
| 3607 | + // FixIn: 8.1.3.5. | |
| 3136 | 3608 | if ( ( $is_frontend ) && ( ! empty( $booking_hash ) ) ) { |
| 3137 | 3609 | |
| 3138 | - //In case if we have valid valid hash then show booking details | |
| 3610 | + // In case if we have valid valid hash then show booking details. | |
| 3139 | 3611 | $my_booking_id_type = wpbc_hash__get_booking_id__resource_id( $booking_hash ); |
| 3140 | 3612 | |
| 3141 | 3613 | if ( ! empty( $my_booking_id_type ) ) { |
| 3142 | 3614 | $is_show_popover_in_timeline = true; |
| @@ -3177,18 +3649,18 @@ | ||
| 3177 | 3649 | [bookingtimeline type="4" view_days_num=365 scroll_start_date="" scroll_month=-3] |
| 3178 | 3650 | |
| 3179 | 3651 | |
| 3180 | 3652 | */ |
| 3181 | -function bookingflextimeline_shortcode($attr) { | |
| 3653 | +function bookingflextimeline_shortcode($attr) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound | |
| 3182 | 3654 | |
| 3183 | 3655 | if ( wpbc_is_on_edit_page() ) { |
| 3184 | - return wpbc_get_preview_for_shortcode( 'bookingflextimeline', $attr ); //FixIn: 9.9.0.39 | |
| 3656 | + return wpbc_get_preview_for_shortcode( 'bookingflextimeline', $attr ); // FixIn: 9.9.0.39. | |
| 3185 | 3657 | } |
| 3186 | 3658 | |
| 3187 | 3659 | $attr = wpbc_escape_shortcode_params( $attr ); //FixIn: 9.7.3.6.1 |
| 3188 | 3660 | |
| 3189 | 3661 | if ( '' === $attr ) { |
| 3190 | - $attr = array(); //FixIn: 9.9.0.30 | |
| 3662 | + $attr = array(); // FixIn: 9.9.0.30. | |
| 3191 | 3663 | } |
| 3192 | 3664 | |
| 3193 | 3665 | //if ( function_exists( 'wpbc_br_cache' ) ) $br_cache = wpbc_br_cache(); // Init booking resources cache |
| 3194 | 3666 | if ( isset( $attr['resource_id'] ) ) { $attr['type'] = $attr['resource_id']; } |
| @@ -3218,11 +3690,12 @@ | ||
| 3218 | 3690 | if ( ! isset( $attr['header_title' ] ) ) { |
| 3219 | 3691 | $attr['header_title' ] = ''; |
| 3220 | 3692 | } |
| 3221 | 3693 | |
| 3222 | - //FixIn: 9.9.0.18 | |
| 3694 | + // FixIn: 9.9.0.18. | |
| 3223 | 3695 | $server_zone = date_default_timezone_get(); // If in 'Theme' or 'other plugin' set default timezone other than UTC. Save it. |
| 3224 | 3696 | if ( 'UTC' !== $server_zone ) { // Needed for WP date functions - set timezone to UTC |
| 3697 | + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set | |
| 3225 | 3698 | @date_default_timezone_set( 'UTC' ); |
| 3226 | 3699 | } |
| 3227 | 3700 | |
| 3228 | 3701 | ob_start(); |
| @@ -3236,20 +3709,21 @@ | ||
| 3236 | 3709 | |
| 3237 | 3710 | |
| 3238 | 3711 | echo '<div class="wpdevelop">'; |
| 3239 | 3712 | |
| 3240 | - echo '<div id="'.$html_client_id.'" class="wpbc_timeline_client_border">'; | |
| 3713 | + echo '<div id="' . esc_attr( $html_client_id ) . '" class="wpbc_timeline_client_border">'; | |
| 3241 | 3714 | |
| 3242 | - echo wp_nonce_field( 'WPBC_FLEXTIMELINE_NAV', 'wpbc_nonce_' . $html_client_id , true , false ); | |
| 3243 | - echo '<div id="ajax_respond_insert'.$html_client_id.'" class="ajax_respond_insert" style="display:none;"></div>'; | |
| 3715 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 3716 | + echo wp_nonce_field( 'WPBC_FLEXTIMELINE_NAV', 'wpbc_nonce_' . esc_attr( $html_client_id ), true, false ); | |
| 3717 | + echo '<div id="ajax_respond_insert' . esc_attr( $html_client_id ) . '" class="ajax_respond_insert" style="display:none;"></div>'; | |
| 3244 | 3718 | |
| 3245 | 3719 | echo '<div class="wpbc_timeline_ajax_replace">'; |
| 3246 | 3720 | if ( ! WPBC()->booking_obj->popover_front_end_js_is_writed ) { //Write this JS only once at page |
| 3247 | 3721 | wpbc_bs_javascript_popover(); // JS Popover |
| 3248 | 3722 | WPBC()->booking_obj->popover_front_end_js_is_writed = true; |
| 3249 | - } //FixIn: 9.2.1.3 | |
| 3723 | + } // FixIn: 9.2.1.3. | |
| 3250 | 3724 | |
| 3251 | - //Define Global JavaScript Object - array of objects. //FixIn: 9.2.1.3 | |
| 3725 | + //Define Global JavaScript Object - array of objects. // FixIn: 9.2.1.3. | |
| 3252 | 3726 | ?> |
| 3253 | 3727 | <script type="text/javascript"> |
| 3254 | 3728 | var wpbc_timeline_obj; |
| 3255 | 3729 | if ( undefined === wpbc_timeline_obj ){ |
| @@ -3280,10 +3754,11 @@ | ||
| 3280 | 3754 | $timeline_results = ob_get_contents(); |
| 3281 | 3755 | |
| 3282 | 3756 | ob_end_clean(); |
| 3283 | 3757 | |
| 3284 | - //FixIn: 9.9.0.18 | |
| 3758 | + // FixIn: 9.9.0.18. | |
| 3285 | 3759 | if ( 'UTC' !== $server_zone ) { // Back to previos state, if it was changed. |
| 3760 | + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set | |
| 3286 | 3761 | @date_default_timezone_set( $server_zone ); |
| 3287 | 3762 | } |
| 3288 | 3763 | |
| 3289 | 3764 | return $timeline_results ; |
| @@ -3294,9 +3769,9 @@ | ||
| 3294 | 3769 | |
| 3295 | 3770 | /** JSS */ |
| 3296 | 3771 | function wpbc_timeline_js_load_files( $where_to_load ) { |
| 3297 | 3772 | |
| 3298 | - //FixIn: 8.6.1.13 | |
| 3773 | + // FixIn: 8.6.1.13. | |
| 3299 | 3774 | |
| 3300 | 3775 | $is_in_footer = ! true; |
| 3301 | 3776 | |
| 3302 | 3777 | if ( in_array( $where_to_load, array( 'admin', 'both', 'client' ) ) ) { |
| @@ -3302,11 +3777,11 @@ | ||
| 3302 | 3777 | if ( in_array( $where_to_load, array( 'admin', 'both', 'client' ) ) ) { |
| 3303 | 3778 | |
| 3304 | 3779 | wp_enqueue_script( 'wpbc-timeline-flex' |
| 3305 | 3780 | , trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/timeline_v2.js' /* wpbc_plugin_url( '/core/timeline/wpbc-flex-timeline.js' ) */ |
| 3306 | - , array( 'wpbc-global-vars' /*, 'wp-element'*/ ) | |
| 3781 | + , array( 'wpbc_all' /*, 'wp-element'*/ ) | |
| 3307 | 3782 | , WP_BK_VERSION_NUM |
| 3308 | - , $is_in_footer | |
| 3783 | + , array( 'in_footer' => WPBC_JS_IN_FOOTER ) //, $is_in_footer | |
| 3309 | 3784 | ); |
| 3310 | 3785 | } |
| 3311 | 3786 | } |
| 3312 | 3787 | add_action( 'wpbc_enqueue_js_files', 'wpbc_timeline_js_load_files', 50 ); |
| @@ -3314,24 +3789,19 @@ | ||
| 3314 | 3789 | |
| 3315 | 3790 | /** CSS */ |
| 3316 | 3791 | function wpbc_timeline_enqueue_css_files( $where_to_load ) { |
| 3317 | 3792 | |
| 3318 | - //FixIn: 8.6.1.13 | |
| 3793 | + // FixIn: 8.6.1.13. | |
| 3319 | 3794 | |
| 3320 | 3795 | if ( in_array( $where_to_load, array( 'admin', 'both', 'client' ) ) ) { |
| 3321 | 3796 | |
| 3322 | - if ( ( ( isset($_REQUEST['view_mode']) ) && ( $_REQUEST['view_mode']== 'vm_calendar' ) ) | |
| 3323 | - || ( 'client' == $where_to_load ) ){ | |
| 3324 | -//wp_deregister_style( 'wpbc-admin-timeline'); | |
| 3797 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 3798 | + if ( ( ( isset($_REQUEST['tab']) ) && ( $_REQUEST['tab']== 'vm_calendar' ) ) || ( 'client' == $where_to_load ) ){ | |
| 3799 | + | |
| 3325 | 3800 | wp_enqueue_style( 'wpbc-flex-timeline' |
| 3326 | - , trailingslashit( plugins_url( '', __FILE__ ) ) . 'css/timeline_v2.css' /* wpbc_plugin_url( '/src/css/codemirror.css' ) */ | |
| 3801 | + , trailingslashit( plugins_url( '', __FILE__ ) ) . '_out/timeline_v2.1.css' /* wpbc_plugin_url( '/src/css/code_mirror.css' ) */ | |
| 3327 | 3802 | , array() |
| 3328 | 3803 | , WP_BK_VERSION_NUM ); |
| 3329 | - wp_enqueue_style( 'wpbc-flex-timeline-skin' | |
| 3330 | - , trailingslashit( plugins_url( '', __FILE__ ) ) . 'css/timeline_skin_v2.css' /* wpbc_plugin_url( '/src/css/codemirror.css' ) */ | |
| 3331 | - , array() | |
| 3332 | - , WP_BK_VERSION_NUM ); | |
| 3333 | 3804 | } |
| 3334 | - | |
| 3335 | 3805 | } |
| 3336 | 3806 | } |
| 3337 | -add_action( 'wpbc_enqueue_css_files', 'wpbc_timeline_enqueue_css_files', 50 ); | |
| 3807 | +add_action( 'wpbc_enqueue_css_files', 'wpbc_timeline_enqueue_css_files', 50 ); | |