PluginProbe
Booking Calendar / 10.11
Booking Calendar v10.11
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / includes / _capacity / capacity.php

capacity.php in Booking Calendar 10.11, at includes/_capacity/capacity.php

1,881 lines 101.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // FixIn: 9.8.0.4.
4
5
6 // <editor-fold defaultstate="collapsed" desc=" == SQL - Get Dates array from DB == " >
7
8 // -----------------------------------------------------------------------------------------------------------------
9 // SQL - Get Dates array from DB
10 // -----------------------------------------------------------------------------------------------------------------
11
12 /**
13 * Get SQL dates array from DB as: [ [0] => std_object( booking_date:'2023-08-08 10:00:01', approved:0, booking_id:45, type:1 ... ), [1] => std_object( ), ... ]
14 *
15 * @param array $params = array(
16 'approved' => 'all' | 0 | 1 default 'all'
17 , 'resource_id' => array, CSD, int if empty then default '1'
18 , 'additional_bk_types' => array, CSD, int OPTIONAL default array()
19 , 'skip_booking_id' => CSD default ''
20 )
21 *
22 * @return array Array ( [0] => stdClass Object ( [booking_date] => 2023-08-08 10:00:01
23 [approved] => 0
24 [date_res_type] =>
25 [booking_id] => 45
26 [form] => selectbox-one^rangetime2^10:00 - 12:00~text^selected_short_dates_hint2^...
27 [parent] => 0
28 [prioritet] => 20
29 [type] => 2
30 )
31 [1] => stdClass Object (
32 [booking_date] => 2023-08-08 10:00:01
33 [approved] => 0
34 [date_res_type] =>
35 [booking_id] => 46
36 [form] => selectbox-one^rangetime10^10:00 - 12:00~text^selected_short_dates_hint10^...
37 [parent] => 2
38 [prioritet] => 1
39 [type] => 10
40 ), ...
41 *
42 *
43 * Example:
44
45 $sql_dates_params = array(
46 'approved' => ( ( 'On' == get_bk_option( 'booking_is_show_pending_days_as_available' ) ) ? '1' : 'all' )
47 , 'resource_id' => $type_id
48 , 'skip_booking_id' => wpbc_get_booking_id__from_hash_in_url() // int | '' // Booking IDs to skip getting from DB
49 );
50 $dates_approve = wpbc__sql__get_booking_dates( $sql_dates_params );
51
52 */
53 function wpbc__sql__get_booking_dates( $params ){
54
55 //TODO: think about pre-caching SQL request for all booking resources - useful for [bookingselect shortcode ...] $params['resource_id'] = implode(',',range(1,17));
56
57 // <editor-fold defaultstate="collapsed" desc=" = CACHE - GET :: check if such request was cached and get it = " >
58
59 $params_for_cache = maybe_serialize( $params );
60 $cache_result = wpbc_cache__get( 'wpbc__sql__get_booking_dates', $params_for_cache );
61 if ( ! is_null( $cache_result ) ) {
62 return $cache_result;
63 }
64
65 // </editor-fold>
66
67 global $wpdb;
68
69 $defaults = array(
70 'dates_to_check' => 'CURDATE' // 'CURDATE' | 'ALL' | [ '2023-07-15' , '2023-07-21' ]
71 , 'approved' => 'all' // 'all' | 0 | 1
72 , 'resource_id' => '' // INT
73 , 'additional_bk_types' => array() // arrays only
74 , 'skip_booking_id' => '' // CSD '3,5'
75 , 'as_single_resource' => false // get dates as for 'single resource' or 'parent' resource including bookings in all 'child booking resources'
76 );
77 $params = wp_parse_args( $params, $defaults );
78
79
80 // Convert $params['additional_bk_types'] and $params['resource_id'] to one CSD variable or default '1' if all empty
81 $resource_id__arr = wpbc_get_unique_array_of_resources_id( $params['resource_id'], $params['additional_bk_types'] );
82 $resource_id__csd = implode( ',', $resource_id__arr );
83
84 // S a n i t i z e
85 $resource_id__csd = wpbc_sanitize_digit_or_csd( $resource_id__csd );
86 $params['skip_booking_id'] = wpbc_sanitize_digit_or_csd( $params['skip_booking_id'] );
87 $params['approved'] = ( 'all' == $params['approved'] ) ? 'all' : intval( $params['approved'] );
88
89
90 $sql_trash_bookings = ' AND bk.trash != 1 ';
91 $sql_skip_bookings = ( '' == $params['skip_booking_id'] ) ? '' : " AND dt.booking_id NOT IN ( {$params['skip_booking_id']} ) ";
92 $sql_approved_bookings = ( 'all' == $params['approved'] ) ? '' : " AND dt.approved = {$params['approved']} ";
93
94 $or__sql_child_bookings_4_parent = ( ! $params['as_single_resource'] ) ? " OR bt.parent IN ( {$resource_id__csd} ) " : '' ;
95
96 $where_dates = wpbc_get__sql_where__for__dates( $params );
97
98 /**
99 * Description:
100 * OR dt.type_id IN ( {$resource_id__csd} )
101 * It is means that sometimes bookings can be started in one booking resource,
102 * and in future dates can be finished in other 'child' booking resource(s).
103 * It's possible, when 'main' booking resource, where booking was started
104 * has future dates as 'unavailable' or booked
105 *
106 * OR dt.type_id IN ( {$resource_id__csd} )
107 * It's means that this booking belong to child booking resource, and do not belong to parent booking resource!
108 */
109
110 if ( class_exists('wpdev_bk_biz_l') ) {
111
112 $my_sql = "SELECT DISTINCT dt.booking_date, dt.approved, dt.type_id as date_res_type, dt.booking_id, bk.form, bt.parent, bt.prioritet, bt.booking_type_id as type
113 FROM {$wpdb->prefix}bookingdates as dt
114
115 INNER JOIN {$wpdb->prefix}booking as bk
116 ON bk.booking_id = dt.booking_id
117
118 INNER JOIN {$wpdb->prefix}bookingtypes as bt
119 ON bk.booking_type = bt.booking_type_id
120
121 WHERE 1 = 1
122 {$where_dates}
123 AND (
124 bk.booking_type IN ( {$resource_id__csd} )
125 OR dt.type_id IN ( {$resource_id__csd} )
126 {$or__sql_child_bookings_4_parent}
127 )
128 {$sql_approved_bookings}
129 {$sql_trash_bookings}
130 {$sql_skip_bookings}
131 ORDER BY dt.booking_date";
132
133 // Explanation:
134 // OR bt.parent IN ( ... ) -> Bookings from CHILD booking resources
135 // OR dt.type_id IN ( ... ) -> Dates from other booking resources, which belong to this booking resource
136
137 } else if ( class_exists('wpdev_bk_biz_m') ) { // Here we get form for booking details.
138
139 $my_sql = "SELECT DISTINCT dt.booking_date, dt.approved, dt.booking_id, bk.booking_type as type, bk.form
140 FROM {$wpdb->prefix}bookingdates as dt
141
142 INNER JOIN {$wpdb->prefix}booking as bk
143 ON bk.booking_id = dt.booking_id
144
145 WHERE 1 = 1
146 {$where_dates}
147 AND bk.booking_type IN ( {$resource_id__csd} )
148 {$sql_approved_bookings}
149 {$sql_trash_bookings}
150 {$sql_skip_bookings}
151 ORDER BY dt.booking_date";
152
153 } else { // Fast request only for dates
154 $my_sql = "SELECT DISTINCT dt.booking_date, dt.approved, dt.booking_id, bk.booking_type as type
155 FROM {$wpdb->prefix}bookingdates as dt
156
157 INNER JOIN {$wpdb->prefix}booking as bk
158 ON bk.booking_id = dt.booking_id
159
160 WHERE 1 = 1
161 {$where_dates}
162 AND bk.booking_type IN ( {$resource_id__csd} )
163 {$sql_approved_bookings}
164 {$sql_trash_bookings}
165 {$sql_skip_bookings}
166 ORDER BY dt.booking_date";
167 }
168
169 // Show past bookings, as well
170 // $my_sql = str_replace( 'AND dt.booking_date >= CURDATE()', '', $my_sql );
171
172 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
173 $sql__dates_obj__arr = $wpdb->get_results( $my_sql );
174
175
176 // <editor-fold defaultstate="collapsed" desc=" = CACHE - SAVE :: = " >
177 $cache_result = wpbc_cache__save( 'wpbc__sql__get_booking_dates', $params_for_cache, $sql__dates_obj__arr );
178 // </editor-fold>
179
180 return $sql__dates_obj__arr;
181 }
182
183
184 /**
185 * Get SQL WHERE condition for Dates
186 *
187 * @param array $params [ 'dates_to_check' => 'CURDATE' ] | [ 'dates_to_check' => 'ALL' ] | [ 'dates_to_check' => [ '2023-07-15' , '2023-07-21' ] ]
188 *
189 * @return string ' AND ( dt.booking_date >= CURDATE() ) '
190 */
191 function wpbc_get__sql_where__for__dates( $params ){
192
193 $defaults = array(
194 'dates_to_check' => 'CURDATE' // 'CURDATE' | 'ALL' | [ '2023-07-15' , '2023-07-21' ]
195 );
196 $params = wp_parse_args( $params, $defaults );
197
198
199 if ( 'ALL' == $params['dates_to_check'] ) { // All dates -> ''
200
201 return '';
202
203 } else if ( 'CURDATE' == $params['dates_to_check'] ) { // Current dates -> CURDATE()
204
205 return ' AND ( dt.booking_date >= CURDATE() ) ' ;
206
207 } else if ( is_array( $params['dates_to_check'] ) ) { // Specific Date(s) -> [ '2023-07-15' , '2023-07-21' ]
208
209 $dates_sql_array = array();
210
211 for( $i = 0; $i < count( $params['dates_to_check'] ); $i++) {
212
213 $dates_sql_array[] = "( ( dt.booking_date >= '{$params['dates_to_check'][$i]} 00:00:00' ) AND ( dt.booking_date <= '{$params['dates_to_check'][$i]} 23:59:59' ) )";
214 }
215
216 $dates_sql_str = implode( ' OR ', $dates_sql_array );
217
218 return " AND ( {$dates_sql_str} ) " ;
219
220 }
221
222 // Default CURDATE
223 return ' AND ( dt.booking_date >= CURDATE() ) ';
224 }
225
226
227
228 /**
229 * Get array of "Booked Dates" as: ['2023-08-30'][ > resource_id < ][ > time_seconds_range < ] => booking_date_obj[ booking_id:45, approved:1, ...
230 *
231 * @param array $params array(
232 * 'approved' => 'all' // 'all' | 0 | 1
233 * , 'resource_id' => '1' // arrays | CSD | int
234 * , 'additional_bk_types' => array() OPTIONAL // arrays | CSD | int
235 * , 'skip_booking_id' => '' // CSD '3,5'
236 * )
237 *
238 * @return array [ [2023-08-09]: [ [3]: [ '43211 - 86392': object( 'booking_date' => 2023-08-09 12:00:01 ... ), ... ], ... ], [2023-08-10]: ... ]
239 *
240 * Explanation:
241 * [2023-08-09]: [
242 * [3]: [
243 * '43211 - 86392': object(
244 * [booking_date] => 2023-08-09 12:00:01
245 * [approved] => 0
246 * [date_res_type] =>
247 * [booking_id] => 65
248 * [form] => text^selected_short_dates_hint3^August 10...
249 * [parent] => 0
250 * [prioritet] => 30
251 * [type] => 3
252 * [__summary__booking] : [
253 *
254 * [sql__booking_dates__arr] : [
255 * [1691668811] => 2023-08-10 12:00:01
256 * [1691675992] => 2023-08-10 14:00:02
257 * ]
258 * [__dates_obj] => WPBC_BOOKING_DATE Object(
259 * [readable_dates]: [ '2023-08-10': [ 12:00:01 - 14:00:02 ] ]
260 * [is_debug] => 0
261 * )
262 * [__dates_obj__bm__extended] => WPBC_BOOKING_DATE_EXTENDED Object (
263 * [readable_dates] : [
264 * [2023-08-09] : [ 12:00:01 - 24:00:00 ]
265 * [2023-08-10] : [ 00:00:00 - 24:00:00 ]
266 * [2023-08-11] : [ 00:00:00 - 24:00:00 ]
267 * [2023-08-12] : [ 00:00:00 - 24:00:00 ]
268 * [2023-08-13] : [ 00:00:00 - 14:00:02 ]
269 * ]
270 * [is_debug] => 0
271 * [extended_dates_times_arr] : []
272 * [debug_dates_times_arr] : []
273 * )
274 * [sql__booking_dates__arr__extended] : [
275 * [1691582401] => 2023-08-09 12:00:01
276 * [1691625600] => 2023-08-10 00:00:00
277 * [1691712000] => 2023-08-11 00:00:00
278 * [1691798400] => 2023-08-12 00:00:00
279 * [1691935202] => 2023-08-13 14:00:02
280 * ]
281 *
282 * ]
283 * )
284 * '64811 - 86392': object(
285 * [booking_date] => 2023-08-09 18:00:01
286 * [approved] => 0
287 * [date_res_type] =>
288 * [booking_id] => 66
289 * ....
290 * )
291 *
292 * ]
293 *
294 * ]
295 *
296 * [2023-08-10]: [ ... ]
297 * ...
298 *
299 * Example 1:
300 * $booked_dates__per_resources__arr = wpbc_get__booked_dates__per_resources__arr( array( 'resource_id' => $type_id ) );
301 * Example 2:
302 * $booked_dates__per_resources__arr = wpbc_get__booked_dates__per_resources__arr(
303 * 'approved' => 'all' // 'all' | 0 | 1
304 * , 'resource_id' => '1' // arrays | CSD | int
305 * , 'additional_bk_types' => array() // arrays | CSD | int
306 * , 'skip_booking_id' => '' // int | '' // CSD
307 * );
308 *
309 *
310 *
311 *
312 * $booked_dates__resources__seconds__arr[ '2023-08-08' ][ 'resource_id' ][ 'time_seconds_range' ] = Booking Date Object()
313 *
314 * Seconds: [36011 - 43192] - [start_time_second - end_time_second]
315 * Seconds: [0] - FULL DAY Booking
316 *
317 * Day start at ( 10 + 1 ) second
318 * Day End at ( ( 24 * 60 * 60 ) - 10 + 2 ) second
319 *
320 * To prevent intersections:
321 * Each booking Start time has +10 seconds
322 * Each booking End time has -10 seconds
323 * So real time here [36011 - 43192] is [ 36001 - 43202 ]
324 *
325 * Full day booking end with 0
326 * Start time booking end with 1
327 * End time booking end with 2
328 */
329 function wpbc_get__booked_dates__per_resources__arr( $params ){
330
331 $defaults = array(
332 'dates_to_check' => 'CURDATE' // 'CURDATE' | 'ALL' | [ '2023-07-15' , '2023-07-21' ]
333 , 'approved' => ( ( get_bk_option( 'booking_is_show_pending_days_as_available' ) == 'On' ) ? '1' : 'all' ) // 'all' | 0 | 1
334 , 'resource_id' => '1' // arrays | CSD | int
335 , 'additional_bk_types' => array() // arrays | CSD | int // OPTIONAL
336 , 'skip_booking_id' => wpbc_get_booking_id__from_hash_in_url() // int | '' // CSD '3,5'
337 , 'as_single_resource' => false // get dates as for 'single resource' or 'parent' resource including bookings in all 'child booking resources'
338 , 'is_days_always_available' => ( ( 'On' == get_bk_option( 'booking_is_days_always_available' ) ) ? true : false )
339
340 , 'aggregate_params' => array() //Optional. It can contain: [ 'aggregate_resource_id_arr' => [ 4 ] , 'resource_id__with_children__arr' => [3,25] ]
341 );
342 $params_for_dates = wp_parse_args( $params, $defaults );
343
344
345 if ( $params_for_dates['is_days_always_available'] ) { // All bookings showing as available dates.
346 return array();
347 }
348
349
350 /**
351 * 1. SQL - get array of all booked dates for our booking resource(s): [ [0] => date_object{ [booking_date] => 2023-08-08 10:00:01, [approved] => 0, .. }, .. ]
352 *
353 * Example: [
354 [0] => stdClass Object ( [booking_date] => 2023-08-08 10:00:01
355 [approved] => 0
356 [date_res_type] =>
357 [booking_id] => 45
358 [form] => selectbox-one^rangetime2^10:00 - 12:00~text^selected_short_dates_hint2^...
359 [parent] => 0
360 [prioritet] => 20
361 [type] => 2
362 )
363 [1] => stdClass Object (
364 [booking_date] => 2023-08-08 10:00:01
365 [approved] => 0
366 [date_res_type] =>
367 [booking_id] => 46
368 [form] => selectbox-one^rangetime10^10:00 - 12:00~text^selected_short_dates_hint10^...
369 [parent] => 2
370 [prioritet] => 1
371 [type] => 10
372 ), ...
373 ]
374 */
375 $sql__b_dates__arr = wpbc__sql__get_booking_dates( $params_for_dates );
376
377
378 /**
379 * 2. From SQL dates into: [ > resource_id < ][ > booking_id < ] -> __summary__booking['sql__booking_dates__arr'] = [ [ '>seconds<' ]: '> SQL DATE <' , ... ]
380 * [1693303211] => 2023-08-29 10:00:01
381 * [1693353600] => 2023-08-30 00:00:00
382 * [1693483192] => 2023-08-31 12:00:02
383 * ]
384 */
385 $resources__booking_id__obj = wpbc_support__transform__into__resource_booking_dates__arr(
386 array( 'sql_dates_arr' => wpbc_clone_array_of_objects( $sql__b_dates__arr ) , 'is_sort__dates_arr' => true , 'is_apply__check_in_out__10s' => true ) );
387
388
389 /**
390 * 2.0 Transfer AGGREGATE resource bookings to Main resources
391 *
392 *
393 */
394 if ( ! empty( $params['aggregate_params'] ) ) {
395 $resources__booking_id__obj = wpbc_aggregate__merge_bookings__from_aggregate__in_source_resource__arr(
396 $resources__booking_id__obj,
397 $params['aggregate_params']['resource_id__with_children__arr'],
398 $params['aggregate_params']['aggregate_resource_id_arr']
399 );
400 }
401
402
403 /**
404 * 2.1 Get [ > resource_id < ][ > booking_id < ] -> __summary__booking[ '_readable_dates' ] = [ '2023-08-01': [ 0: "10:00:01 - 12:00:02" ], ...
405 * '2023-08-05': [ 0: "10:00:01 - 12:00:02" ], ...
406 * ]
407 */
408 $resources__booking_id__obj = wpbc__in_all_bookings__create_WPBC_BOOKING_DATE( $resources__booking_id__obj );
409
410
411 /**
412 * 2.2 Extend check in/out dates [ > resource_id < ][ > booking_id < ] -> __summary__booking[ 'sql__booking_dates__arr__extended' ]
413 */
414 if ( function_exists( 'wpbc__extend_availability__before_after__check_in_out' ) ) {
415
416 $resources__booking_id__obj = wpbc__extend_availability__before_after__check_in_out( $resources__booking_id__obj );
417 }
418
419
420 /**
421 * 3. Into: ['2024-01-28'][ > resource_id < ][ > booking_id < ][ > only_time_seconds < ] => obj( booking_date: "2024-01-28 10:00:01", ... )
422 *
423 * From: [ > resource_id < ][ > booking_id < ] => obj( booking_date: "2024-01-28 10:00:01", ['__summary__booking']['sql__booking_dates__arr'][] , ... )
424 */
425 $dt__res__bk__seconds__arr = wpbc_support__transform__into__date_resource_booking_timesec__arr(
426 array( 'resource_booking_dates_arr' => $resources__booking_id__obj , 'is_apply__check_in_out__10s' => true ) );
427
428
429 /**
430 * 4. Into: ['2023-08-30'][ > resource_id < ][ > time_seconds_range < ] => booking_date_obj[ booking_id:45, approved:1, ...
431 *
432 * , where 'time_seconds_range' can be: '0' | '36011 - 43192', ...
433 */
434 $dt__res__time_seconds_range__arr = wpbc_support__transform__into__date_resource_timesec_range__arr(
435 array( 'date_resource_booking_timesec_arr' => $dt__res__bk__seconds__arr , 'is_apply__check_in_out__10s' => true ) );
436
437 return $dt__res__time_seconds_range__arr;
438 }
439
440 // </editor-fold>
441
442
443 // -----------------------------------------------------------------------------------------------------------------
444 // Get Resource array filled by booked Dates
445 // -----------------------------------------------------------------------------------------------------------------
446
447
448 /**
449 * Get all dates STATUSES as: ['2023-08-30'][ 'summary']['status_for_day':'available', 'day_availability':3, [ > resource_id < ] => std_object( '_day_status':'full_day_booking', '__booked__times__details':[ '1 - 43192': std_object( booking_id:46, 'approved':0, ... ), '50300 - 63192': ], 'is_day_unavailable':1, ...
450 *
451 * @param int $single_or_parent__resource_id // 1 --- INT (currently it's works only for one resource (single or parent)
452 * array $params[ 'timeslots_to_check_intersect' ] // [ '10:00 - 12:00' ] if bookings intersect with all time slots in array, then the date unavailable, if empty array then it's skipped
453 *
454 * @return array {
455 * calendar_2: {
456 * id: 2
457 * dates: { "2023-07-21": {…}
458 * "2023-07-22": {
459 * ['summary']['status_for_bookings']: "pending"
460 * ['summary']['status_for_day']: "available"
461 * day_availability: 4
462 * max_capacity: 4
463 * statuses: Object { day: "check_in|check_in|available|available", bookings: "approved|pending||" }
464 *
465 * 2: Object { is_day_unavailable: false, _day_status: "check_in", check_in_out: "check_in", … }
466 * 10: Object { is_day_unavailable: false, _day_status: "check_in", check_in_out: "check_in", … }
467 * 11: Object { is_day_unavailable: false, _day_status: "available", pending_approved: [] }
468 * 12: Object { is_day_unavailable: false, _day_status: "available", pending_approved: [] }
469 * }
470 * , "2023-07-23": {…}
471 * , …
472 * }
473 * }
474 * calendar_5: {...}
475 * , ...
476 * }
477 *
478 *
479 * Important Dates properties:
480 *
481 * ['summary']['status_for_bookings']: "" | "pending" | "approved"
482 * ['summary']['status_for_day']: | 'available';
483 * | 'time_slots_booking';
484 * | 'full_day_booking';
485 * | 'season_filter';
486 * | 'resource_availability';
487 * | 'weekday_unavailable'; 'from_today_unavailable' | 'limit_available_from_today'
488 * | 'change_over';
489 * | 'check_in';
490 * | 'check_out';
491 * | 'change_over check_out' .... variations....
492 *
493 *
494 * @return array array(
495 'dates' => $availability_per_day like ['2023-08-17'] = ...
496 , 'resources_id_arr__in_dates' => $source__resource_id_arr like [ 1,10,11,12,14]
497 )
498 */
499 function wpbc_get_availability_per_days_arr( $params ) {
500
501 if ( 0 ) { // FixIn: 9.8.3.1 ?
502 wpbc_set_limit_php( 300 ); // Set 300 seconds for php execution.
503 }
504
505 $server_request_uri = ( ( isset( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */
506 $server_http_referer_uri = ( ( isset( $_SERVER['HTTP_REFERER'] ) ) ? sanitize_text_field( $_SERVER['HTTP_REFERER'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */
507
508 $defaults = array(
509 'dates_to_check' => 'CURDATE', // v: 'CURDATE' | 'ALL' | arr: '2023-07-15' , '2023-07-21'.
510 'approved' => ( ( 'On' === get_bk_option( 'booking_is_show_pending_days_as_available' ) ) ? '1' : 'all' ), // v: 'all' | 0 | 1.
511 'resource_id' => '1', // Single or parent booking resource!!!! // arrays | CSD | int ???.
512 'additional_bk_types' => array(), // arrays | CSD | int // OPTIONAL -> aggregate_resource_id_arr ... it is array of booking resources from aggregate shortcode parameter.
513 'skip_booking_id' => wpbc_get_booking_id__from_hash_in_url(), // int | '' // CSD '3,5'.
514 'as_single_resource' => false, // get dates as for 'single resource' or 'parent' resource including bookings in all 'child booking resources'.
515 'max_days_count' => wpbc_get_max_visible_days_in_calendar(), // 365.
516 'timeslots_to_check_intersect' => array(), // arr: '12:20 - 12:55', '13:00 - 14:00' ) // TODO: ? do we really need it, because below we get it from function.
517 'request_uri' => ( ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ) ? $server_http_referer_uri : $server_request_uri ), // front-end: $server_request_uri | ajax: $server_http_referer_uri // It different in Ajax requests. It's used for change-over days to detect for exception at specific pages.
518 'custom_form' => '', // Required for checking all available time-slots and compare with booked time slots.
519 );
520
521 $params = wp_parse_args( $params, $defaults );
522
523 // FixIn: 10.7.1.2. //FixIn: 10.10.3.2.
524 if (
525 ( false !== strpos( $params['request_uri'], 'allow_past' ) ) ||
526 (
527 ( false !== strpos( $params['request_uri'], 'page=wpbc-new' ) ) &&
528 ( false !== strpos( $params['request_uri'], 'booking_hash' ) )
529 )
530 ) {
531 $params['dates_to_check'] = 'ALL';
532 }
533
534 // -----------------------------------------------------------------------------------------------------------------
535 // R e s o u r c e (s) D a t a
536 // -----------------------------------------------------------------------------------------------------------------
537 // Get array of booking resource ID [1, 13, 8, 6, 7] or default: [ 1 ]
538 $source__resource_id_arr = wpbc_get_unique_array_of_resources_id( $params['resource_id'] ); // [1, 13, 8, 6, 7]
539 //$source__resource_id_arr = wpbc_get_unique_array_of_resources_id( $params['resource_id'], $params['additional_bk_types'] ); // [1, 13, 8, 6, 7]
540 $first_resource_id = $source__resource_id_arr[0]; // First from the list, or 1 if not provided.
541
542 // Get here Obj. of booking resource (which can include CHILD booking resources)
543 $resources_obj = new WPBC_RESOURCE_SUPPORT( array(
544 'resource_id' => $source__resource_id_arr, //CSD | D
545 'as_single_resource' => $params['as_single_resource'] // If true, then skip child booking resources
546 ));
547 // Resource ID arr (Can be Parent and Child resource ID)
548 $resource_id__with_children__arr = $resources_obj->get_resource_id_arr(); // [ 2, 10, 11, 12 ]
549
550 // Get Maximum capacity of resource
551 $resource_obj = $resources_obj->get__booking_resource_obj( $first_resource_id );
552 $max_resource_capacity_int = empty( $resource_obj ) ? 1 : $resource_obj->capacity; // 1 | 4
553
554 // Get base cost of resource
555 $resource_base_cost = $resources_obj->get_resources_base_cost_arr(); // [ 0, 25, 100, 99]
556
557
558
559
560 // -----------------------------------------------------------------------------------------------------------------
561 // Get real AGGREGATE resource ID arr
562 // -----------------------------------------------------------------------------------------------------------------
563 $real_resource_id_arr = wpbc_get_unique_array_of_resources_id( $params['resource_id'] ); // [ 1 ]
564 if ( empty( $params['additional_bk_types'] ) ) {
565 $aggregate_resource_id_arr = array();
566 } else {
567 $aggregate_resource_id_arr = wpbc_get_unique_array_of_resources_id( $params['additional_bk_types'] ); // [1, 13, 8, 6, 7]
568 }
569 // Excluding from 'additional_bk_types' all resources in 'resource_id'
570 $aggregate_resource_id_arr = array_diff( $aggregate_resource_id_arr, $real_resource_id_arr ); // [ 13, 8, 6, 7 ]
571 $aggregate_resource_id_arr = array_values( $aggregate_resource_id_arr ); // reindex array, for ability to transfer array instead of obj to JS client side.
572
573 $params['aggregate_params'] = array(
574 'aggregate_resource_id_arr' => $aggregate_resource_id_arr,
575 'resource_id__with_children__arr' => $resource_id__with_children__arr
576 );
577
578 // -----------------------------------------------------------------------------------------------------------------
579 // B o o k i n g s
580 // -----------------------------------------------------------------------------------------------------------------
581 // Main function to get "Bookings": ['2023-08-30'][ > resource_id < ][ > time_seconds_range < ] => booking_date_obj[ booking_id:45, approved:1, ...
582 $bookings__in_dates = wpbc_get__booked_dates__per_resources__arr( $params );
583
584
585
586 // -----------------------------------------------------------------------------------------------------------------
587 // Booking > Availability page
588 // -----------------------------------------------------------------------------------------------------------------
589 $search_dates = $params['dates_to_check']; // 'CURDATE' | 'ALL' | [ "2023-08-03" , "2023-08-04" , "2023-08-05" ]
590
591 //FixIn: 9.8.15.10 Aggregate or not Aggregate Booking > Availability ? aggregate_type = 'all' | 'bookings_only'
592 if ( ( ! empty( $params['aggregate_type'] ) ) && ( 'bookings_only' === $params['aggregate_type'] ) ) { // FixIn: 9.9.0.16.
593 $unavailable_dates__per_resources__arr = wpbc_for_resources_arr__get_unavailable_dates(
594 $resource_id__with_children__arr, // Only One Primary Resource !!
595 $search_dates
596 ); // [ 2: ['2023-08-01', '2023-08-02'], 10: ['2023-08-05', '2023-08-06'] ]
597 } else {
598 $unavailable_dates__per_resources__arr = wpbc_for_resources_arr__get_unavailable_dates(
599 wpbc_get_unique_array_of_resources_id( $resource_id__with_children__arr, $aggregate_resource_id_arr ), // Get unavailable dates for primary and aggregate booking resources
600 $search_dates
601 ); // [ 2: ['2023-08-01', '2023-08-02'], 10: ['2023-08-05', '2023-08-06'] ]
602 }
603 $unavailable_dates__per_resources__arr = wpbc_aggregate_merge_availability( $unavailable_dates__per_resources__arr,
604 $resource_id__with_children__arr,
605 $aggregate_resource_id_arr );
606
607 // -----------------------------------------------------------------------------------------------------------------
608 // Booking > Resources > Availability page
609 // -----------------------------------------------------------------------------------------------------------------
610 $season_filters_availability = array();
611 if ( class_exists('wpdev_bk_biz_m') ) {
612 foreach ( $resource_id__with_children__arr as $resource_id_for_season ) {
613 $season_filters_availability[ $resource_id_for_season ] = apply_bk_filter( 'get_available_days', $resource_id_for_season );
614 }
615 }
616
617
618
619
620 // -----------------------------------------------------------------------------------------------------------------
621 // P a r a m e t e r s f o r L O O P
622 // -----------------------------------------------------------------------------------------------------------------
623
624 // - Is this Booking > Add booking page ? --------------------------------------------------------------------------
625 $is_this_bap_page = ( false !== strpos( $params['request_uri'], 'page=wpbc-new' ) ) ? true : false;
626 $is_this_hash_page = ( false !== strpos( $params['request_uri'], 'booking_hash' ) ) ? true : false; // Set it to TRUE for adding booking in past at Booking > Add booking page
627
628 // FixIn: 10.7.1.2.
629 if ( ! $is_this_hash_page ) {
630 $is_this_hash_page = ( false !== strpos( $params['request_uri'], 'allow_past' ) ) ? true : false;
631 }
632
633 if ( ( $is_this_bap_page ) && ( $is_this_hash_page ) ) { // Start days in calendar from = PAST
634 $params['dates_to_check'] = 'ALL';
635 }
636
637 if ( 'ALL' == $params['dates_to_check'] ) { // All dates -> ''
638
639 $start_day_number = - 1 * $params['max_days_count'];
640 //$today_inix_timestamp = strtotime( '-' . intval( $params['max_days_count'] ) . ' days' ); // - 300 days
641
642 // Get time, relative to Timezone from WordPress > Settings General page // FixIn: 9.9.0.17.
643 $start_date_unix = strtotime( '-' . intval( $params['max_days_count'] ) . ' days' ); // - 365 days
644 $date_with_wp_timezone = wpbc_datetime_localized__use_wp_timezone( gmdate( 'Y-m-d H:i:s', $start_date_unix ), 'Y-m-d 00:00:00' );
645 $today_inix_timestamp = strtotime( $date_with_wp_timezone );
646
647 } else if ( 'CURDATE' == $params['dates_to_check'] ) { // Current dates -> CURDATE()
648
649 $start_day_number = 1;
650 // $today_inix_timestamp = strtotime( gmdate( 'Y-m-d 00:00:00', strtotime( 'now' ) ) ); // Today 00:00:00
651
652 // Get time, relative to Timezone from WordPress > Settings General page // FixIn: 9.9.0.17.
653 $start_date_unix = strtotime( 'now' );
654 $date_with_wp_timezone = wpbc_datetime_localized__use_wp_timezone( gmdate( 'Y-m-d H:i:s', $start_date_unix ), 'Y-m-d 00:00:00' );
655 $today_inix_timestamp = strtotime( $date_with_wp_timezone );
656
657 } else if ( is_array( $params['dates_to_check'] ) ) {
658
659 $start_day_number = 1;
660
661 $today_inix_timestamp = strtotime( $params['dates_to_check'][0] . ' 00:00:00' ); // '2023-09-03 00:00:00'
662
663 $dif_in_days = strtotime( $params['dates_to_check'][ ( count( $params['dates_to_check'] ) - 1 ) ] . ' 00:00:00' )
664 - strtotime( $params['dates_to_check'][0] . ' 00:00:00' );
665
666 $dif_in_days = $dif_in_days / ( 24 * 60 * 60 );
667 $params['max_days_count'] = ceil( $dif_in_days ) + 1;
668 }
669
670
671 // Get Time Slots from booking form for Each date: [ '2023-10-25' => [ '12:20 - 12:55', '13:00 - 14:00' ], '2023-10-26' => [ ... ], ... ]
672 $readable_timeslots_arr__in_dates_arr__to_check_intersect = wpbc_get_times_fields_configuration__by_dates(
673 $first_resource_id, // Resource ID (used in case of MultiUser version for getting specific form for regular users)
674 $params['custom_form'], // Form name for getting time slots configuration
675 $today_inix_timestamp, // start_date_unix_timestamp
676 ( $params['max_days_count'] - $start_day_number ) // days_count
677 );
678
679 // =================================================================================================================
680 // -- Here are GO
681 // =================================================================================================================
682 $availability_per_day = array();
683
684 for ( $day_num = $start_day_number; $day_num <= $params['max_days_count']; $day_num ++ ) {
685
686 $my_day_tag = gmdate( 'Y-m-d', $today_inix_timestamp ); // '2023-07-19'
687
688
689 //--------------------------------------------------------------------------------------------------------------
690 // Get Time-Slots from booking form to CHECK INTERSECT :: Convert readable time slot to time slot as seconds [ '12:20 - 12:55', '13:00 - 14:00' ] OR [] if not time slots
691 $as_seconds_timeslots_arr__to_check_intersect = wpbc_get__time_range_in_seconds_arr__for_date( $readable_timeslots_arr__in_dates_arr__to_check_intersect, $my_day_tag );
692 /*
693 // TODO: check this, if it's required ? // If empty, maybe get default 'timeslots_to_check_intersect' from root of this function parameters ????
694 if ( empty( $as_seconds_timeslots_arr__to_check_intersect ) ) {
695
696
697 if ( ! is_array( $params[ 'timeslots_to_check_intersect' ] ) ) { // Root parameters from this function
698 $params[ 'timeslots_to_check_intersect' ] = array( $params[ 'timeslots_to_check_intersect' ] );
699 }
700
701 $as_seconds_timeslots_arr__to_check_intersect = array();
702 foreach ( $params[ 'timeslots_to_check_intersect' ] as $time_slot_readable ) {
703 $as_seconds_timeslots_arr__to_check_intersect[] = wpbc_convert__readable_time_slot__to__time_range_in_seconds( $time_slot_readable );
704 }
705 }
706 */
707 //--------------------------------------------------------------------------------------------------------------
708
709
710 $availability_per_day[ $my_day_tag ] = array();
711
712 // Helpful tip. Definition here variables in such order, useful for having such order in _wpbc JS variable for showing it with _wpbc.bookings_in_calendars__get_all(); command
713 $availability_per_day[ $my_day_tag ]['day_availability'] = $max_resource_capacity_int; // 4
714 $availability_per_day[ $my_day_tag ]['max_capacity'] = $max_resource_capacity_int; // 4
715 $availability_per_day[ $my_day_tag ]['statuses'] = array();
716 $availability_per_day[ $my_day_tag ]['statuses']['day_status'] = array(); // per each child booking resource
717 $availability_per_day[ $my_day_tag ]['statuses']['bookings_status'] = array(); // per each child booking resource
718 $availability_per_day[ $my_day_tag ]['summary'] = array();
719 $availability_per_day[ $my_day_tag ]['summary']['status_for_day'] = ''; // available | time_slots_booking | full_day_booking | ...
720 $availability_per_day[ $my_day_tag ]['summary']['status_for_bookings'] = ''; // pending | approved | CO: pending_pending | pending_approved | approved_pending | approved_approved
721 $availability_per_day[ $my_day_tag ]['summary']['tooltip_times'] = '';
722 $availability_per_day[ $my_day_tag ]['summary']['tooltip_availability'] = '';
723 $availability_per_day[ $my_day_tag ]['summary']['tooltip_day_cost'] = '';
724 $availability_per_day[ $my_day_tag ]['summary']['tooltip_booking_details'] = '';
725
726
727 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
728 // R E S O U R C E S - S t a r t
729 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
730 foreach ( $resource_id__with_children__arr as $resource_id ) { // [1, 13, 8, 6, 7]
731
732 $availability_per_day[ $my_day_tag ][ $resource_id ] = new stdClass();
733 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = false;
734 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'available';
735 $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved = array();
736 $availability_per_day[ $my_day_tag ][ $resource_id ]->tooltips = array(
737 'resource_title' => $resources_obj->get_resource_title( $resource_id ),
738 'times' => '',
739 'details' => array()
740 );
741 $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots = array(
742 'in_seconds' => array(), // seconds
743 'readable24h' => array(), // readable 24H - for debug only
744 'merged_seconds' => array(), // seconds (reduced number of time_ranges)
745 'merged_readable' => array() // readable 12AM
746 );
747 // Day Cost / Rates ---------------------------------------------------------------------------------------
748 $fin_day_cost = wpbc_support_capacity__get_day_cost( $my_day_tag, $resource_id, $resource_base_cost[ $resource_id ] );
749 $availability_per_day[ $my_day_tag ][ $resource_id ]->date_cost_rate = $fin_day_cost;
750
751
752 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
753 // B O O K I N G S - S t a r t
754 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
755
756 if ( ( isset( $bookings__in_dates[ $my_day_tag ] ) )
757 && ( isset( $bookings__in_dates[ $my_day_tag ][ $resource_id ] ) ) ){
758
759 $this_date_bookings = $bookings__in_dates[ $my_day_tag ][ $resource_id ]; // [ [36011 - 86392] => stdClass Object( [approved] => 1 , ... ) ,... ]
760 ksort( $this_date_bookings );
761 $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details = $this_date_bookings;
762
763 } else {
764 $this_date_bookings = array();
765 }
766
767
768 /**
769 * If bookings exist then:
770 * 1. Removing some properties here to hide personal details,
771 * 2. Set Approved / Pending status of the bookings
772 * 3. By default, set "_day_status" as 'time_slots_booking' ( later we will change to 'full_day_booking', if applied )
773 */
774 if ( ! empty( $this_date_bookings ) ) {
775
776 // =====================================================================================================
777 // T i m e s - Start
778 // =====================================================================================================
779 foreach ( $this_date_bookings as $booked_times__key => $booked_times__value ) {
780
781 // By default, set "_day_status" as 'time_slots_booking' ( later we will change to 'full_day_booking', if applied )
782 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'time_slots_booking';
783
784 // -------------------------------------------------------------------------------------------------
785 // Get Time-Slot
786 if ( false === strpos( $booked_times__key, '-' ) ) { // Full day ? - 0 == $booked_times__key
787 $time_range__seconds__arr = array( 0, 86400 ); // 24 * 60 * 60
788 } else {
789 $time_range__seconds__arr = wpbc_transform_timerange__s_range__in__seconds_arr( $booked_times__key ); // '43211 - 86392' into [43211, 86400]
790 }
791
792 // Real time: [43211, 86400]
793 $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['in_seconds'][] = $time_range__seconds__arr;
794
795 // For DEBUG only -- Readable 24H: '10:00:01 - 12:30:02'
796 $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['readable24h'][] = wpbc_transform_timerange__seconds_arr__in__24_hours_range( $time_range__seconds__arr );
797
798 // -------------------------------------------------------------------------------------------------
799 // Pending | Approved :: for correct order of all statuses - make it based on start time index / $time_range__seconds__arr[0] == 0 in situation of FULL day booking
800 $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved[ $time_range__seconds__arr[0] ] = ( '1' == $booked_times__value->approved ) ? 'approved' : 'pending';
801
802
803 // T O O L T I P :: Booking Details
804 $booked_time_title = ( ( 0 == $time_range__seconds__arr[0] ) && ( $time_range__seconds__arr[1] >= 86400 ) )
805 ? __( 'Full day', 'booking' )
806 : wpbc_transform_timerange__seconds_arr__in__formated_hours( $time_range__seconds__arr );
807 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__tooltip__set_for_details( $availability_per_day, $my_day_tag, $resource_id,
808 $this_date_bookings, $booked_times__key, $resources_obj, $booked_time_title );
809
810 // Unset ...->form and other fields...
811 $this_date_bookings[ $booked_times__key ] = wpbc_support_capacity__unset_some_fields( $this_date_bookings[ $booked_times__key ] );
812
813 } // T i m e s - E n d Booked Times Loop - for current resource
814
815
816 // =====================================================================================================
817 // Merge intersected time intervals =
818 // =====================================================================================================
819 $merged_seconds_arr = wpbc_merge_intersected_intervals( $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['in_seconds'] );
820
821 $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['merged_seconds'] = $merged_seconds_arr;
822
823 foreach ( $merged_seconds_arr as $booked_time_slots__in_seconds ) {
824 $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['merged_readable'][] = wpbc_transform_timerange__seconds_arr__in__formated_hours( $booked_time_slots__in_seconds );
825 }
826
827 // T O O L T I P :: Times
828 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__tooltip_times__set_for_times( $availability_per_day, $my_day_tag, $resource_id, $resource_id__with_children__arr );
829
830 // =====================================================================================================
831 // End times
832 // =====================================================================================================
833
834
835 // For correct order of all booking statuses - we will make it based on start time index - Sort array starting from 1 second 00:00 to 12:00 to 23:00 etc...
836 ksort( $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved );
837
838 // array_keys( $booked_time_slots ) can be: [0] -> 'Full day' | ['36011 - 43192', '56011 - 86392'] -> '10:00 - 12:00', '15:55 - 24:00'
839 $booked_time_slots = array_keys( $this_date_bookings );
840
841
842 // =====================================================================================================
843 // Full day booking ----------------------------------------------------------------------------------- full_by_bookings
844 // =====================================================================================================
845 if ( in_array( '0', $booked_time_slots ) ) {
846
847 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
848 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'full_day_booking';
849
850 // Reset all other possible time slot statuses, in general they must not exist, but for some case
851 $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved = array();
852
853 // Pending or approved, for full day booking: $this_date_bookings['0']
854 $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved[] = ( '1' == $this_date_bookings['0']->approved ) ? 'approved' : 'pending';
855
856 // T O O L T I P :: Times - Full Day Booked
857 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__tooltip_times__set_full_day( $availability_per_day, $my_day_tag, $resource_id
858 , $resource_id__with_children__arr, __( 'Full day', 'booking' ) );
859
860 } // end 'full day' if
861
862
863 // =====================================================================================================
864 // All time slots booked ? -----------------------------------------------------------------------------
865 // =====================================================================================================
866 if (
867 ( ! empty( $as_seconds_timeslots_arr__to_check_intersect ) ) // We need to check intersection with some time slot '36011 - 43192'
868 && ( ! $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable ) // And this date still free false
869 ){
870
871 $is_some_timeslot_available = wpbc_is_some_timeslot__available__in_arr( $as_seconds_timeslots_arr__to_check_intersect, $booked_time_slots );
872
873 // ------------------------------------------------------------------------------------------------- full_by_bookings
874 if ( ! $is_some_timeslot_available ) {
875 // All time slots booked !!!
876
877 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
878 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'full_day_booking';
879 $availability_per_day[ $my_day_tag ][ $resource_id ]->_booking_form_timeslots_unavailable = implode( '|', $params[ 'timeslots_to_check_intersect' ] );
880
881 // T O O L T I P :: Times - Full Day Booked
882 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__tooltip_times__set_full_day( $availability_per_day, $my_day_tag, $resource_id
883 , $resource_id__with_children__arr, __( 'Full day', 'booking' ) );
884 } else {
885 // Some time slots available or there is no time slot passed in this function
886 }
887
888 } // end 'all time slots booked' if
889
890
891
892 // =====================================================================================================
893 // Change over days =
894 // =====================================================================================================
895 if (
896 ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) )
897 && ( wpbc_is_booking_used_check_in_out_time( $params[ 'request_uri' ] ) )
898 && ( ! $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable ) // And this date still free false
899 ) {
900
901 /**
902 * "Change over days" - possible situations: check_in | check_out | change_over | ...
903 *
904 * $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = check_in
905 * | check_out
906 * | change_over
907 * | 'mixed'
908 * 'mixed' - e.g. 'change_over check_out' where several child resources and some is 'change_over' and others are 'check_out'
909 *
910 *
911 * Possible situations for change-over days:
912 *
913 * // A. If in $booked_time_slots array one of values (or in $this_date_bookings one of keys)
914 * // 1. Started with time that is ended with 1 second
915 * // 2. and Ended with '24:00' it is means '86392', like this: '28811 - 86392'
916 * // then it's means that we have 'check_in' time here
917 *
918 * // B. If in $booked_time_slots array one of values (or in $this_date_bookings one of keys)
919 * // 1. Started with '00:00' it is means '1'
920 * // 2. and Ended time that is ended with 2 second
921 * // like this: '1 - 32402'
922 * // then it's means that we have 'check_out' time here
923 *
924 * // C. If we have A. and B. then we have 'change_over' here
925 */
926
927 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out = array();
928
929 foreach ( $this_date_bookings as $booked_times__key => $booked_times__value ) {
930
931 if ( false === strpos( $booked_times__key, '-' ) ) {
932 continue; // for situation with FULL day booking, here $booked_times__key = 0
933 }
934
935 $rangeA_arr = explode( '-', $booked_times__key );
936 $rangeA_arr[0] = intval( trim( $rangeA_arr[0] ) );
937 $rangeA_arr[1] = intval( trim( $rangeA_arr[1] ) );
938
939 // start time
940 $is_starttime__check_in = $rangeA_arr[0] % 10; // 0, 1, 2
941 $is_starttime__check_in = ( 1 == $is_starttime__check_in ) ? true : false;
942
943 // end time
944 $is_endtime__check_out = $rangeA_arr[1] % 10;
945 $is_endtime__check_out = ( 2 == $is_endtime__check_out ) ? true : false;
946
947
948 if ( ( $is_starttime__check_in ) && ( WPBC_FULL_DAY_TIME_OUT == $rangeA_arr[1] ) ) { // A :: start_time - 86392 e.g. 14:00 - 24:00
949 // only "check in" time here
950 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out[] = 'check_in';
951
952 } else if ( ( WPBC_FULL_DAY_TIME_IN == $rangeA_arr[0] ) && ( $is_endtime__check_out ) ) { // B :: 1 - end_time e.g. 00:00 - 10:00
953 // only "check out" time here
954 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out[] = 'check_out';
955 }
956
957 }
958 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out = array_unique( $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out );
959 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out = array_filter( $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out ); // All entries of array equal to FALSE (0, '', '0' ) will be removed.
960
961 if (
962 ( in_array( 'check_in', $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out ) )
963 && ( in_array( 'check_out', $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out ) )
964 ) {
965 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out = array( 'change_over' ); // both check in / out times here
966 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
967
968 // Possible statuses: pending_pending | pending_approved | approved_pending | approved_approved
969 $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved = array( implode( '_', $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved ) );
970 }
971
972 $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out = implode( '|', $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out );
973
974 if ( ! empty( $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out ) ) {
975 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = $availability_per_day[ $my_day_tag ][ $resource_id ]->check_in_out;
976 }
977 } // end change-over if
978
979
980 }
981 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
982 // B O O K I N G S - E n d
983 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
984
985 //==========================================================================================================
986 // $availability_per_day[..]->_day_status = 'season_filter' | ...
987 //==========================================================================================================
988 // Booking > Resources > Availability page >>> 'season_filter'
989 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__day_status__season_filter( $availability_per_day, $my_day_tag, $resource_id, $season_filters_availability );
990
991 // Booking > Availability page >>> 'resource_availability'
992 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__day_status__resource_availability( $availability_per_day, $my_day_tag, $resource_id, $unavailable_dates__per_resources__arr );
993
994 // Week Days unavailable >>> 'weekday_unavailable'
995 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__day_status__weekday_unavailable( $availability_per_day, $my_day_tag, $resource_id );
996
997 if ( ( ! $is_this_bap_page ) || ( ! $is_this_hash_page ) ) {
998 // Do not apply these settings at Booking > Add booking page, when we edit booking - e.g. exist 'booking_hash'
999
1000 // Unavailable days from today >>> 'from_today_unavailable'
1001 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__day_status__from_today_unavailable( $availability_per_day, $my_day_tag, $resource_id );
1002
1003 // Limit available days from today >>> 'limit_available_from_today'
1004 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__day_status__limit_available_from_today( $availability_per_day, $my_day_tag, $resource_id );
1005 }
1006 //==========================================================================================================
1007
1008
1009 // T O O L T I P :: Times - Unavailable Day
1010 if ( in_array( $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status, array( 'season_filter',
1011 'resource_availability',
1012 'weekday_unavailable',
1013 'from_today_unavailable',
1014 'limit_available_from_today'
1015 ) )
1016 ){
1017 $availability_per_day[ $my_day_tag ][ $resource_id ] = wpbc_support_capacity__tooltip_times__set_full_day( $availability_per_day, $my_day_tag, $resource_id
1018 , $resource_id__with_children__arr, __( 'Unavailable', 'booking' ) );
1019 }
1020
1021
1022 // =========================================================================================================
1023 // Entire D A Y statuses
1024 // =========================================================================================================
1025
1026 if ( $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable ) {
1027 // Reduce DAY day_availability, if some season or days unavailable or full by bookings
1028 $availability_per_day[ $my_day_tag ][ 'day_availability' ]--;
1029 }
1030
1031 // 'resource_availability' | 'weekday_unavailable' | 'from_today_unavailable' | 'limit_available_from_today' | 'season_filter' | 'full_day_booking' | 'time_slots_booking' | 'available'
1032 $availability_per_day[ $my_day_tag ]['statuses']['day_status'][] = $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status;
1033
1034 // 'approved' | 'pending'
1035 $availability_per_day[ $my_day_tag ]['statuses']['bookings_status'][] = implode( '|', $availability_per_day[ $my_day_tag ][ $resource_id ]->pending_approved );
1036
1037 // Go to next child booking resource
1038 }
1039 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1040 // R E S O U R C E S - E n d
1041 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1042
1043
1044 // -------------------------------------------------------------------------------------------------------------
1045 // Day summary :
1046 // -------------------------------------------------------------------------------------------------------------
1047 $availability_per_day[ $my_day_tag ] = wpbc_update_summary_availability_per_this_day( $availability_per_day[ $my_day_tag ], $my_day_tag, $resource_id__with_children__arr );
1048
1049 // Go next day + 1 day
1050 $today_inix_timestamp += 24 * 60 * 60;
1051 }
1052
1053
1054 return array(
1055 'dates' => $availability_per_day
1056 , 'resources_id_arr__in_dates' => $resource_id__with_children__arr
1057 , 'aggregate_resource_id_arr' => $aggregate_resource_id_arr
1058 );
1059 }
1060
1061
1062 // <editor-fold defaultstate="collapsed" desc=" == S U P P O R T == " >
1063
1064
1065 // S U P P O R T
1066
1067 /**
1068 * Update Summary statuses for the Day
1069 *
1070 * @param $availability_per_this_day
1071 * @param $my_day_tag
1072 * @param $resource_id_arr
1073 *
1074 * @return mixed
1075 *
1076 *
1077 * Dates Status Concept Strategy ::
1078 *
1079 * Check date booking status based on 'all booking resources':
1080 * ( and as one common situation, when we have only 1 resource )
1081 *
1082 * | 'approved' - when all booking resources has approved FULL day bookings or some booking resource unavailable
1083 * | 'pending' - when at least one booking in one booking resource has pending status and there is no available booking resources
1084 * | 'times_partially_booked' - when at least one booking in one booking resource has time bookings and there is no available booking resources
1085 * and if all time slot approved then status approved
1086 * otherwise if at least one time slot booking has pending status then it has pending status
1087 *
1088 * if all 'time_slots' booked (it's time slot passed into function as parameter)
1089 * then such date in specific booking resource has pending or approved status, based on 'pending'|'approved' rule
1090 *
1091 * | 'check_in' - if activated 'change over days' and all bookings have 'check-in' status
1092 * | 'check_out' - if activated 'change over days' and all bookings have 'check-out' status
1093 * | if in booking resource exist both check in/out bookings, and activated 'change over days'
1094 * then such booking resource date has approved or pending status depends on from status of these bookings
1095 * | 'season_unavailable' - if all booking resources defined as unavailable at Booking > Resources > Availability page
1096 * | 'resource_unavailable' - if all booking resources defined as unavailable at Booking > Availability page
1097 * | 'other_unavailable' - if all booking resources defined as unavailable at Booking > Settings General page in "Availability" section
1098 *
1099 */
1100 function wpbc_update_summary_availability_per_this_day( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1101
1102 // -------------------------------------------------------------------------------------------------------------
1103 // Summary Tooltips
1104 // -------------------------------------------------------------------------------------------------------------
1105 $availability_per_this_day['summary']['tooltip_times'] = wpbc_support_capacity__tooltip__summary__times( $availability_per_this_day, $my_day_tag, $resource_id_arr );
1106 $availability_per_this_day['summary']['tooltip_booking_details'] = wpbc_support_capacity__tooltip__summary__booked_details( $availability_per_this_day, $my_day_tag, $resource_id_arr );
1107 $availability_per_this_day['summary']['tooltip_day_cost'] = wpbc_support_capacity__tooltip__summary__day_cost( $availability_per_this_day, $my_day_tag, $resource_id_arr );
1108 $availability_per_this_day['summary']['tooltip_availability'] = wpbc_support_capacity__tooltip__summary__availability( $availability_per_this_day, $my_day_tag, $resource_id_arr );
1109
1110
1111 $availability_per_this_day['summary']['hint__in_day__cost'] = wpbc_support_capacity__in_day_hint__summary__day_cost( $availability_per_this_day, $my_day_tag, $resource_id_arr );
1112 $availability_per_this_day['summary']['hint__in_day__availability'] = wpbc_support_capacity__in_day_hint__summary__availability( $availability_per_this_day, $my_day_tag, $resource_id_arr ); // FixIn: 10.6.4.1.
1113
1114 // -------------------------------------------------------------------------------------------------------------
1115 // ['summary']['status_for_day']
1116 // -------------------------------------------------------------------------------------------------------------
1117 $temp_status = array();
1118 foreach ( $availability_per_this_day['statuses']['day_status'] as $bookings_status_arr ) {
1119 $bookings_status_arr = explode( '|', $bookings_status_arr );
1120 foreach ( $bookings_status_arr as $bookings_status_element ) {
1121 $temp_status[] = $bookings_status_element;
1122 }
1123 }
1124 $temp_status = array_filter( $temp_status ); // All entries of array equal to FALSE (0, '', '0' ) will be removed.
1125 $temp_status = array_unique( $temp_status ); // Erase duplicates
1126 $availability_per_this_day['summary']['status_for_day'] = $temp_status;
1127
1128 /**
1129 * Possible day statuses (searched by value of _day_status):
1130 *
1131 * available
1132 * time_slots_booking
1133 * full_day_booking
1134 *
1135 * limit_available_from_today
1136 * from_today_unavailable
1137 * weekday_unavailable
1138 * resource_availability
1139 * season_filter
1140 *
1141 * change_over
1142 * check_out
1143 * check_in
1144 * 'mixed' from check_in/check_out/change_over
1145 */
1146
1147 // Priority: available > time_slots_booking > full_day_booking
1148 // > season_filter > resource_availability
1149 // > weekday_unavailable > from_today_unavailable > limit_available_from_today
1150
1151 // if at least one booking "available" then day has this status
1152 if ( in_array( 'available', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'available';
1153 } else if ( in_array( 'time_slots_booking', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'time_slots_booking';
1154 } else if ( ( ! in_array( 'check_out', $availability_per_this_day['summary']['status_for_day'] ) )
1155 && ( in_array( 'check_in', $availability_per_this_day['summary']['status_for_day'] ) ) ) { $availability_per_this_day['summary']['status_for_day'] = 'check_in';
1156 } else if ( ( ! in_array( 'check_in', $availability_per_this_day['summary']['status_for_day'] ) )
1157 && ( in_array( 'check_out', $availability_per_this_day['summary']['status_for_day'] ) ) ) { $availability_per_this_day['summary']['status_for_day'] = 'check_out';
1158 } else if ( in_array( 'full_day_booking', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'full_day_booking';
1159 } else if ( in_array( 'season_filter', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'season_filter';
1160 } else if ( in_array( 'resource_availability', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'resource_availability';
1161 } else if ( in_array( 'weekday_unavailable', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'weekday_unavailable';
1162 } else if ( in_array( 'from_today_unavailable', $availability_per_this_day['summary']['status_for_day'] ) ) { $availability_per_this_day['summary']['status_for_day'] = 'from_today_unavailable';
1163 } else if ( in_array( 'limit_available_from_today', $availability_per_this_day['summary']['status_for_day'])){ $availability_per_this_day['summary']['status_for_day'] = 'limit_available_from_today';
1164 } else {
1165 $availability_per_this_day['summary']['status_for_day'] = implode( ' ', $availability_per_this_day['summary']['status_for_day'] );
1166 }
1167
1168
1169 // -------------------------------------------------------------------------------------------------------------
1170 // ['summary']['status_for_bookings']
1171 // -------------------------------------------------------------------------------------------------------------
1172 $temp_status = array();
1173 foreach ( $availability_per_this_day['statuses']['bookings_status'] as $bookings_status_arr ) {
1174 $bookings_status_arr = explode( '|', $bookings_status_arr );
1175 foreach ( $bookings_status_arr as $bookings_status_element ) {
1176 $temp_status[] = $bookings_status_element;
1177 }
1178 }
1179 $temp_status = array_filter( $temp_status ); // All entries of array equal to FALSE (0, '', '0' ) will be removed.
1180 $temp_status = array_unique( $temp_status );
1181 $availability_per_this_day['summary']['status_for_bookings'] = $temp_status;
1182
1183 // Priority: pending > approved > ''
1184
1185 // if at least one booking pending then day is pending
1186 if ( in_array( 'pending', $availability_per_this_day['summary']['status_for_bookings'] ) ) { $availability_per_this_day['summary']['status_for_bookings'] = 'pending';
1187 } else if ( in_array( 'pending_pending', $availability_per_this_day['summary']['status_for_bookings'] ) ) { $availability_per_this_day['summary']['status_for_bookings'] = 'pending_pending';
1188 // Usual situations for change over days: pending_pending | pending_approved | approved_pending | approved_approved
1189 } else {
1190 $availability_per_this_day['summary']['status_for_bookings'] = implode( ' ', $availability_per_this_day['summary']['status_for_bookings'] );
1191 }
1192
1193
1194 // -------------------------------------------------------------------------------------------------------------
1195 return $availability_per_this_day;
1196 }
1197
1198
1199 // T O O L T I P s
1200
1201 /**
1202 * Set tooltip summary -- Time-Slots
1203 *
1204 * @param $availability_per_this_day
1205 * @param $my_day_tag
1206 * @param $resource_id_arr
1207 *
1208 * @return string - tooltip content or ''
1209 */
1210 function wpbc_support_capacity__tooltip__summary__times( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1211
1212 $tooltip = '';
1213
1214 if ( 'On' != get_bk_option( 'booking_disable_timeslots_in_tooltip' ) ) { //FixIn: 9.5.0.2.2
1215
1216 $tooltip_title_word = get_bk_option( 'booking_highlight_timeslot_word' );
1217 $tooltip_title_word = wpbc_lang( $tooltip_title_word );
1218 $tooltip_title_word = ( empty( $tooltip_title_word ) )
1219 ? ''
1220 : '<div class="wpbc_tooltip_title">' . $tooltip_title_word . '</div>' . ' ';
1221
1222 $status_summary_tooltip_times = array();
1223 foreach ( $resource_id_arr as $resource_id ) {
1224 if ( ! empty( $availability_per_this_day[ $resource_id ]->tooltips['times'] ) ) {
1225 $status_summary_tooltip_times[] = $availability_per_this_day[ $resource_id ]->tooltips['times'];
1226 }
1227 }
1228
1229 if ( ! empty( $status_summary_tooltip_times ) ) {
1230
1231 $tooltip = '<div class="wpbc_tooltip_section tooltip__times">'
1232 . $tooltip_title_word
1233 . implode( '', $status_summary_tooltip_times )
1234 . '</div>';
1235 }
1236 }
1237
1238 return $tooltip;
1239 }
1240
1241 function wpbc_support_capacity__tooltip__summary__availability( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1242
1243 $tooltip = '';
1244
1245 if ( ( 'On' == get_bk_option( 'booking_is_show_availability_in_tooltips' ) ) && ( $availability_per_this_day['max_capacity'] > 1 ) ) {
1246
1247 $tooltip_title_word = get_bk_option( 'booking_highlight_availability_word' );
1248 $tooltip_title_word = wpbc_lang( $tooltip_title_word );
1249 $tooltip_title_word = ( empty( $tooltip_title_word ) )
1250 ? ''
1251 : '<div class="wpbc_tooltip_title">' . $tooltip_title_word . '</div>' . ' ';
1252
1253 $tooltip_content_header = '';
1254
1255 if ( ! empty( $availability_per_this_day['day_availability'] ) ) {
1256
1257 $tooltip = '<div class="wpbc_tooltip_section tooltip__availability">'
1258 . $tooltip_title_word
1259 . '<div class="wpbc_tooltip_resource_container">'
1260 . $tooltip_content_header
1261 . '<div class="wpbc_tooltip_item">'
1262 . $availability_per_this_day['day_availability']
1263 . '</div>'
1264 . '</div>'
1265 . '</div>';
1266 }
1267 }
1268 return $tooltip;
1269 }
1270
1271 function wpbc_support_capacity__tooltip__summary__day_cost( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1272
1273 $tooltip = '';
1274 if (
1275 ( ! empty( $availability_per_this_day['day_availability'] ) )
1276 && ( 'On' == get_bk_option( 'booking_is_show_cost_in_tooltips' ) )
1277 ){
1278
1279 $tooltip_title_word = get_bk_option( 'booking_highlight_cost_word' );
1280 $tooltip_title_word = wpbc_lang( $tooltip_title_word );
1281 $tooltip_title_word = ( empty( $tooltip_title_word ) )
1282 ? ''
1283 : '<div class="wpbc_tooltip_title">' . $tooltip_title_word . '</div>' . ' ';
1284
1285 $id_of_first_resource = $resource_id_arr[0];
1286 $tooltip_content_header = '';
1287
1288 if ( ! empty( $availability_per_this_day[ $id_of_first_resource ]->date_cost_rate ) ) {
1289
1290 $cur_sym = get_bk_option( 'booking_cost_in_date_cell_currency' ); // in Booking > Settings General page in "Calendar" section
1291 //$cur_sym = wpbc_get_currency_symbol(); // in Booking > Settings > Payment page
1292
1293 $cost_text = wpbc_formate_cost_hint__no_html( $availability_per_this_day[ $id_of_first_resource ]->date_cost_rate, $cur_sym );
1294 $cost_text = html_entity_decode( $cost_text );
1295
1296 $tooltip = '<div class="wpbc_tooltip_section tooltip__day_cost">'
1297 . $tooltip_title_word
1298 . '<div class="wpbc_tooltip_resource_container">'
1299 . $tooltip_content_header
1300 . '<div class="wpbc_tooltip_item">'
1301 . $cost_text
1302 . '</div>'
1303 . '</div>'
1304 . '</div>';
1305 }
1306 }
1307 return $tooltip;
1308 }
1309
1310
1311 function wpbc_support_capacity__in_day_hint__summary__day_cost( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1312
1313 $tooltip = '';
1314 if (
1315 ( ! empty( $availability_per_this_day['day_availability'] ) )
1316 && ( 'On' == get_bk_option( 'booking_is_show_cost_in_date_cell' ) )
1317 ){
1318
1319 $id_of_first_resource = $resource_id_arr[0];
1320
1321 if ( ! empty( $availability_per_this_day[ $id_of_first_resource ]->date_cost_rate ) ) {
1322
1323 $cur_sym = get_bk_option( 'booking_cost_in_date_cell_currency' ); // in Booking > Settings General page in "Calendar" section
1324 //$cur_sym = wpbc_get_currency_symbol(); // in Booking > Settings > Payment page
1325
1326 $cost_text = $availability_per_this_day[ $id_of_first_resource ]->date_cost_rate;
1327 $cost_text = number_format( floatval( $cost_text ), wpbc_get_cost_decimals(), '.', '' );
1328 $cost_text = wp_strip_all_tags( wpbc_cost_show( $cost_text, array( 'currency' => 'CURRENCY_SYMBOL' ) ) );
1329 $cost_text = str_replace( array( 'CURRENCY_SYMBOL', '&' ), array( $cur_sym, '&amp;' ), $cost_text );
1330 $cost_text = html_entity_decode($cost_text);
1331
1332 $tooltip = '<span class="wpbc_in_date_hint__cost">' . $cost_text . '</span>';;
1333 }
1334 }
1335 return $tooltip;
1336 }
1337
1338 // FixIn: 10.6.4.1.
1339 /**
1340 * Get availability for in Day cells
1341 *
1342 * @param $availability_per_this_day
1343 * @param $my_day_tag
1344 * @param $resource_id_arr
1345 *
1346 * @return string
1347 */
1348 function wpbc_support_capacity__in_day_hint__summary__availability( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1349
1350 $tooltip = '';
1351
1352 if (
1353 ( 'On' == get_bk_option( 'booking_is_show_availability_in_date_cell' ) ) &&
1354 ( $availability_per_this_day['max_capacity'] > 1 )
1355 ) {
1356
1357 $tooltip_title_word = get_bk_option( 'booking_highlight_availability_word_in_date_cell' );
1358 $tooltip_title_word = wpbc_lang( $tooltip_title_word );
1359 $tooltip_title_word = ( empty( $tooltip_title_word ) )
1360 ? ''
1361 : '<span class="wpbc_in_date_hint__availability_title">' . $tooltip_title_word . '</span>';
1362
1363
1364 if ( ! empty( $availability_per_this_day['day_availability'] ) ) {
1365
1366 $tooltip = '<span class="wpbc_in_date_hint__availability">'
1367 . '<span class="wpbc_in_date_hint__availability_number">'
1368 . intval( $availability_per_this_day['day_availability'] )
1369 . '&nbsp;'
1370 . '</span>'
1371 . $tooltip_title_word
1372 . '</span>';
1373 $tooltip = html_entity_decode($tooltip);
1374 }
1375 }
1376 return $tooltip;
1377 }
1378
1379
1380
1381 /**
1382 * Set tooltip summary -- Booking Details
1383 *
1384 * @param $availability_per_this_day
1385 * @param $my_day_tag
1386 * @param $resource_id_arr
1387 *
1388 * @return string - tooltip content or ''
1389 */
1390 function wpbc_support_capacity__tooltip__summary__booked_details( $availability_per_this_day, $my_day_tag, $resource_id_arr ){
1391
1392 $tooltip = '';
1393
1394 if ( 'On' == get_bk_option( 'booking_is_show_booked_data_in_tooltips' ) ) { //FixIn: 9.5.0.2.2
1395
1396 $tooltip_title_word = '<div class="wpbc_tooltip_title">' . esc_html__('Booking details','booking') . '</div>';
1397
1398 $status_summary_tooltip_times = array();
1399 foreach ( $resource_id_arr as $resource_id ) {
1400 if ( ! empty( $availability_per_this_day[ $resource_id ]->tooltips['details'] ) ) {
1401
1402 if ( ! empty( $availability_per_this_day[ $resource_id ]->tooltips['resource_title'] ) ){
1403 $tooltip_content_header = '<div class="wpbc_tooltip_header">'
1404 . $availability_per_this_day[ $resource_id ]->tooltips['resource_title'] . ': '
1405 . '</div>';
1406 } else{
1407 $tooltip_content_header = '';
1408 }
1409
1410 $booking_details_text = '<div class="wpbc_tooltip_resource_container">'
1411 . $tooltip_content_header
1412 . implode( ' ', $availability_per_this_day[ $resource_id ]->tooltips['details'] )
1413 . '</div>';
1414
1415 $status_summary_tooltip_times[] = $booking_details_text;
1416 }
1417 }
1418
1419 if ( ! empty( $status_summary_tooltip_times ) ) {
1420
1421 $tooltip = '<div class="wpbc_tooltip_section tooltip__booking_details">'
1422 . $tooltip_title_word
1423 . implode( '', $status_summary_tooltip_times )
1424 . '</div>';
1425 }
1426 }
1427 return $tooltip;
1428 }
1429
1430 /**
1431 * Set Tooltip -- Booking Details
1432 *
1433 * @param $availability_per_day
1434 * @param $my_day_tag
1435 * @param $resource_id
1436 * @param $this_date_bookings
1437 * @param $booked_times__key
1438 * @param $resources_obj
1439 *
1440 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ];
1441 */
1442 function wpbc_support_capacity__tooltip__set_for_details( $availability_per_day, $my_day_tag, $resource_id, $this_date_bookings, $booked_times__key, $resources_obj, $booked_time ) {
1443
1444 // Get booking details for tooltip, if needed
1445 if ( 'On' == get_bk_option( 'booking_is_show_booked_data_in_tooltips' ) ) {
1446
1447 $booking_id = $this_date_bookings[ $booked_times__key ]->booking_id;
1448 $this_booking_resource_id = $this_date_bookings[ $booked_times__key ]->type;
1449
1450 $booking_details_text = wpbc_support_capacity__get_booking_details(
1451 $this_date_bookings[ $booked_times__key ],
1452 $resources_obj->get__booking_resource_obj( $this_booking_resource_id )
1453 );
1454 $tooltip_text = '';
1455 $tooltip_text .= '<div class="wpbc_tooltip_item tooltip_booked_time">' . $booked_time . '</div>'; // Booked time
1456 $tooltip_text .= '<div class="wpbc_tooltip_item">' . $booking_details_text . '</div>'; // Booking details
1457
1458 $availability_per_day[ $my_day_tag ][ $resource_id ]->tooltips['details'][ $booking_id ] = $tooltip_text;
1459 }
1460
1461 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1462 }
1463
1464 /**
1465 * Set Tooltip Times -- Time-Slots
1466 *
1467 * @param $availability_per_day
1468 * @param $my_day_tag
1469 * @param $resource_id
1470 * @param $resource_id_arr
1471 *
1472 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ];
1473 */
1474 function wpbc_support_capacity__tooltip_times__set_for_times( $availability_per_day, $my_day_tag, $resource_id, $resource_id_arr ){
1475
1476 // Times Tooltip - time slot list --------------------------------------------------------------------
1477 $tooltip_content_header = '';
1478
1479 if ( count( $resource_id_arr ) > 1 ) {
1480
1481 $class_name = 'tooltip_items_count_' . count( $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['merged_readable'] );
1482
1483 $tooltip_content_header = '<div class="wpbc_tooltip_header ' . $class_name . ' ">'
1484 . $availability_per_day[ $my_day_tag ][ $resource_id ]->tooltips['resource_title'] . ': '
1485 . '</div>';
1486 }
1487
1488 $tooltip_content_arr = array_map( function ( $item ) {
1489 return '<div class="wpbc_tooltip_item">' . $item . '</div>';
1490 }
1491 , $availability_per_day[ $my_day_tag ][ $resource_id ]->booked_time_slots['merged_readable']
1492 );
1493
1494 $availability_per_day[ $my_day_tag ][ $resource_id ]->tooltips['times'] = '<div class="wpbc_tooltip_resource_container">'
1495 . $tooltip_content_header
1496 . implode( '', $tooltip_content_arr )
1497 . '</div>';
1498 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1499 }
1500
1501 /**
1502 * Set Tooltip Times -- Full Day
1503 *
1504 * @param $availability_per_day
1505 * @param $my_day_tag
1506 * @param $resource_id
1507 * @param $resource_id_arr
1508 * @param $status_title
1509 *
1510 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ];
1511 */
1512 function wpbc_support_capacity__tooltip_times__set_full_day( $availability_per_day, $my_day_tag, $resource_id, $resource_id_arr, $status_title ){
1513
1514 // Times Tooltip - FULL DAY --------------------------------------------------------------------
1515 $tooltip_content_header = '';
1516
1517 if ( count( $resource_id_arr ) > 1 ) {
1518
1519 $class_name = 'tooltip_items_count_1';
1520
1521 $tooltip_content_header = '<div class="wpbc_tooltip_header ' . $class_name . ' ">'
1522 . $availability_per_day[ $my_day_tag ][ $resource_id ]->tooltips['resource_title'] . ': '
1523 . '</div>';
1524 }
1525
1526 $tooltip_content_text = '<div class="wpbc_tooltip_item">' . $status_title . '</div>';
1527
1528 $availability_per_day[ $my_day_tag ][ $resource_id ]->tooltips['times'] = '<div class="wpbc_tooltip_resource_container">'
1529 . $tooltip_content_header
1530 . $tooltip_content_text
1531 . '</div>';
1532 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1533 }
1534
1535
1536
1537 /**
1538 * Get parsed booking data, if required
1539 *
1540 * @param object $this_date_bookings
1541 * @param object $resource_obj
1542 *
1543 * @return string
1544 */
1545 function wpbc_support_capacity__get_booking_details( $this_date_bookings, $resource_obj ) {
1546
1547 if ( ( ! class_exists( 'wpdev_bk_biz_m' ) )
1548 || ( 'On' !== get_bk_option( 'booking_is_show_booked_data_in_tooltips' ) )
1549 ){
1550 return '';
1551 }
1552
1553 $booking_details_for_hint = '';
1554
1555 if ( isset( $this_date_bookings->form ) ) {
1556
1557 // Get shortcodes
1558 $booking_shortcodes_in_tooltips = get_bk_option( 'booking_booked_data_in_tooltips' ); // '[name] [secondname]'
1559
1560 $resource_id = $this_date_bookings->type;
1561
1562 // Get parsed booking data field values -- e.g.: [ "rangetime":"12:00 - 14:00", "secondname":"Smith",... ]
1563 $booking_data_arr = wpbc_get_parsed_booking_data_arr( $this_date_bookings->form, $resource_id, array( 'get' => 'value' ) );
1564 $booking_data_arr['booking_id'] = $this_date_bookings->booking_id;
1565 $booking_data_arr['resource_id'] = $resource_id;
1566 $booking_data_arr['resource_title'] = ( ! empty( $resource_obj ) ) ? wpbc_lang( $resource_obj->title ) : '';
1567
1568 // Replace existing shortcodes
1569 foreach ( $booking_data_arr as $replace_shortcode => $replace_value ) {
1570
1571 if ( is_null( $replace_value ) ) { $replace_value = ''; };
1572
1573 $replace_value = wpbc_replace__true_false__to__yes_no( $replace_value ); // FixIn: 9.8.9.1.
1574
1575 $booking_shortcodes_in_tooltips = str_replace( array(
1576 '[' . $replace_shortcode . ']'
1577 , '{' . $replace_shortcode . '}'
1578 )
1579 , $replace_value
1580 , $booking_shortcodes_in_tooltips
1581 );
1582 }
1583
1584 $booking_details_for_hint = $booking_shortcodes_in_tooltips;
1585
1586 // Remove all shortcodes, which is not replaced early.
1587 $booking_details_for_hint = preg_replace( '/[\[\{][a-zA-Z0-9.,_-]{0,}[\]\}]/', '', $booking_details_for_hint );
1588 }
1589
1590 return $booking_details_for_hint;
1591 }
1592
1593
1594 /**
1595 * Unset some fields from booking data for do not show personal data at front-end side
1596 *
1597 * @param object $this_date_bookings
1598 *
1599 * @return object
1600 */
1601 function wpbc_support_capacity__unset_some_fields( $this_date_bookings ) {
1602
1603 if ( isset( $this_date_bookings->form ) ) {
1604 unset( $this_date_bookings->form ); // Hide booking details
1605 }
1606
1607 if ( isset( $this_date_bookings->booking_date ) ) {
1608 unset( $this_date_bookings->booking_date ); // Confusing property of last end booking date, because we have 'sql summary booking dates arrays' for all dates and times
1609 }
1610
1611 return $this_date_bookings;
1612 }
1613
1614
1615 // D A Y S T A T U S U N A V A I L A B L E
1616
1617 /**
1618 * Set > _day_status = 'limit_available_from_today' depends on Booking > Settings General page ---> "Limit available days from today"
1619 *
1620 * @param $availability_per_day [ ... ]
1621 * @param $my_day_tag - '2023-08-08'
1622 * @param $resource_id - 2
1623 *
1624 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ]
1625 */
1626 function wpbc_support_capacity__day_status__limit_available_from_today( $availability_per_day, $my_day_tag, $resource_id ){
1627
1628 // ----------------------------------------------------------------------------------------------------- // limit_available_from_today
1629 // 3. Limit available days from today
1630 if ( function_exists( 'wpbc_is_day_available__relative__limit_available_from_today' ) ) {
1631 if ( ! wpbc_is_day_available__relative__limit_available_from_today( $my_day_tag ) ) {
1632 // this date unavailable
1633 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
1634 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'limit_available_from_today';
1635
1636 if ( empty( $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details ) ) {
1637 $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details = array(); // Reset bookings details
1638 }
1639 }
1640 }
1641
1642 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1643 }
1644
1645
1646 /**
1647 * Set > _day_status = 'from_today_unavailable' depends on Booking > Settings General page ---> "Unavailable days from today"
1648 *
1649 * @param $availability_per_day [ ... ]
1650 * @param $my_day_tag - '2023-08-08'
1651 * @param $resource_id - 2
1652 *
1653 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ]
1654 */
1655 function wpbc_support_capacity__day_status__from_today_unavailable( $availability_per_day, $my_day_tag, $resource_id ){
1656
1657 // FixIn: 10.8.1.4.
1658
1659 // ----------------------------------------------------------------------------------------------------- // from_today_unavailable
1660 // 2. Unavailable days from today
1661 $unavailable_days_num_from_today = get_bk_option( 'booking_unavailable_days_num_from_today' );
1662
1663 // FixIn: 10.8.1.4.
1664 if ( ! empty( $unavailable_days_num_from_today ) ) {
1665 if ( 'm' === substr( $unavailable_days_num_from_today, - 1 ) ) {
1666 $start_date_unix = strtotime( '+' . ( intval( $unavailable_days_num_from_today ) - 1 ) . ' minutes' ); // + 0 days
1667 } else {
1668 $start_date_unix = strtotime( '+' . intval( $unavailable_days_num_from_today ) . ' days' ); // + 0 days
1669 }
1670 } else {
1671 $start_date_unix = strtotime( 'now' );
1672 }
1673
1674 $date_start__gmt = gmdate( 'Y-m-d H:i:s', $start_date_unix ); // '2025-01-25 12:50:10'
1675 $date_start__midnight__wp_timezone = wpbc_datetime_localized__use_wp_timezone( $date_start__gmt, 'Y-m-d 00:00:00' ); // Local Midnight.
1676
1677 // 'Today Midnight' - 'Calendar Day Cell' .
1678 $days_number = intval( ( strtotime( $date_start__midnight__wp_timezone ) - strtotime( $my_day_tag ) ) / 86400 );
1679
1680 if ( $days_number > 0 ) {
1681 // This date Unavailable.
1682 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
1683 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'from_today_unavailable';
1684
1685 if ( empty( $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details ) ) {
1686 $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details = array(); // Reset bookings details
1687 }
1688 }
1689
1690 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1691 }
1692
1693
1694 /**
1695 * Set > _day_status = 'weekday_unavailable' depends on Booking > Settings General page ---> "Week Days unavailable"
1696 *
1697 * @param $availability_per_day [ ... ]
1698 * @param $my_day_tag - '2023-08-08'
1699 * @param $resource_id - 2
1700 *
1701 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ]
1702 */
1703 function wpbc_support_capacity__day_status__weekday_unavailable( $availability_per_day, $my_day_tag, $resource_id ){
1704
1705 // 1. Week Days unavailable -------------------------------------------------------------------------------- // weekday_unavailable
1706 $unavailable_weekdays = array();
1707 foreach ( range( 0, 6 ) as $week_day_num ) {
1708 $unavailable_weekdays[ $week_day_num ] = ( 'On' == get_bk_option( 'booking_unavailable_day' . $week_day_num ) ) ? true : false;
1709 }
1710
1711 $this_day_week_num = gmdate( 'w', strtotime( $my_day_tag ) ); // 0 - 6
1712
1713 if ( $unavailable_weekdays[ $this_day_week_num ] ) {
1714 // this date unavailable
1715 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
1716 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'weekday_unavailable';
1717
1718 if ( empty( $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details ) ) {
1719 $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details = array(); // Reset bookings details
1720 }
1721 }
1722
1723 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1724 }
1725
1726
1727 /**
1728 * Set > _day_status = 'resource_availability' depends on Booking > Availability page
1729 *
1730 * @param $availability_per_day [ ... ]
1731 * @param $my_day_tag - '2023-08-08'
1732 * @param $resource_id - 2
1733 * @param array $unavailable_dates__per_resources__arr - [ 2: ['2023-08-01', '2023-08-02'], 10: ['2023-08-05', '2023-08-06'] ]
1734 *
1735 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ]
1736 */
1737 function wpbc_support_capacity__day_status__resource_availability( $availability_per_day, $my_day_tag, $resource_id, $unavailable_dates__per_resources__arr ){
1738
1739 // Booking > Availability page ----------------------------------------------------------------------------- // resource_availability
1740 /**
1741 * $unavailable_dates__per_resources__arr = Array ( [2] => Array( [0] => 2023-08-01
1742 [1] => 2023-08-02
1743 )
1744 [10] => Array( [0] => 2023-08-05
1745 [1] => 2023-08-06
1746 )
1747 )
1748 */
1749 if (
1750 ( isset( $unavailable_dates__per_resources__arr[ $resource_id ] ) )
1751 && ( in_array( $my_day_tag, $unavailable_dates__per_resources__arr[ $resource_id ] ) )
1752 ) {
1753
1754 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
1755 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'resource_availability';
1756
1757 if ( empty( $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details ) ) {
1758 $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details = array(); // Reset bookings details
1759 }
1760 }
1761
1762 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1763 }
1764
1765
1766 /**
1767 * Set > _day_status = 'season_filter' depends on Booking > Resources > Availability page
1768 *
1769 * @param $availability_per_day [ ... ]
1770 * @param $my_day_tag - '2023-08-08'
1771 * @param $resource_id - 2
1772 * @param array $season_filters_availability - [...]
1773 *
1774 * @return array - $availability_per_day[ $my_day_tag ][ $resource_id ]
1775 */
1776 function wpbc_support_capacity__day_status__season_filter( $availability_per_day, $my_day_tag, $resource_id, $season_filters_availability ){
1777
1778 if ( function_exists( 'wpbc_is_this_day_available_in_season_filters' ) ) { // BM and higher
1779
1780 $is_date_available = wpbc_is_this_day_available_in_season_filters( $my_day_tag, $resource_id, $season_filters_availability[ $resource_id ] ); // Get availability
1781 if ( ! $is_date_available ) {
1782
1783 $availability_per_day[ $my_day_tag ][ $resource_id ]->is_day_unavailable = true;
1784 $availability_per_day[ $my_day_tag ][ $resource_id ]->_day_status = 'season_filter';
1785
1786 if ( empty( $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details ) ) {
1787 $availability_per_day[ $my_day_tag ][ $resource_id ]->__booked__times__details = array(); // Reset bookings details
1788 }
1789 }
1790 }
1791
1792 return $availability_per_day[ $my_day_tag ][ $resource_id ];
1793 }
1794
1795
1796 // D A Y C O S T
1797
1798 /**
1799 * Get day cost depend on Rates
1800 * @param $my_day_tag - '2023-08-08'
1801 * @param $resource_id - 2
1802 * @param $base_cost - 25
1803 *
1804 * @return int|string
1805 */
1806 function wpbc_support_capacity__get_day_cost( $my_day_tag, $resource_id, $base_cost ) {
1807
1808 $fin_day_cost = 0;
1809 if ( function_exists( 'wpbc_get_1_day_cost_apply_rates' ) ) {
1810
1811 list( $year, $month, $day ) = explode( '-', $my_day_tag );
1812
1813 $day = intval( $day );
1814 $month = intval( $month );
1815 $year = intval( $year );
1816
1817 $fin_day_cost = wpbc_get_1_day_cost_apply_rates( $resource_id, $base_cost, $day, $month, $year );
1818 }
1819
1820 return $fin_day_cost;
1821 }
1822
1823
1824 // </editor-fold>
1825
1826
1827
1828 //TODO: M I G R A T E to 9.8
1829 // .
1830 // instead of this: <script type="text/javascript"> wpbc_settings.set_option( 'pending_days_selectable', true ); </script>
1831 // use this: <script type="text/javascript"> _wpbc.calendar__set_param_value( " . intval( $resource_id ) . ", 'pending_days_selectable' , true ); </script>
1832 // Booking Calendar - JavaScript Settings
1833 // Example or redefine some settings:
1834 // <script type="text/javascript"> wpbc_settings.set_option( 'pending_days_selectable', true ); </script>
1835 // [booking type=1]
1836 // .
1837 // .
1838 // 1. Define parameters for calendar(s):
1839 // _wpbc.calendar__set_parameters( " . intval( $resource_id ) . ", {'days_select_mode': 'single'} );
1840 // _wpbc.calendar__set_parameters( " . intval( $resource_id ) . ", {'days_select_mode': 'multiple'} );
1841 // _wpbc.calendar__set_parameters( " . intval( $resource_id ) . ", {'days_select_mode': 'fixed'} );
1842 // _wpbc.calendar__set_parameters( " . intval( $resource_id ) . ", {'fixed__days_num' : 7 } );
1843 // _wpbc.calendar__set_parameters( " . intval( $resource_id ) . ", {'fixed__week_days__start': [-1] } ); // { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat }
1844 // _wpbc.calendar__set_parameters( " . intval( $resource_id ) . ", {'days_select_mode': 'dynamic'} );
1845 // _wpbc.calendar__set_param_value( " . intval( $resource_id ) . ", 'dynamic__days_min' , 7 );
1846 // _wpbc.calendar__set_param_value( " . intval( $resource_id ) . ", 'dynamic__days_max' , 14 );
1847 // _wpbc.calendar__set_param_value( " . intval( $resource_id ) . ", 'dynamic__days_specific' , [] ); // Example [5,7]
1848 // _wpbc.calendar__set_param_value( " . intval( $resource_id ) . ", 'dynamic__week_days__start' , [-1] ); // { -1 - Any | 0 - Su, 1 - Mo, 2 - Tu, 3 - We, 4 - Th, 5 - Fr, 6 - Sat }
1849 // JavaScript functions changes:
1850 // wpbc_unselect_all_days( resource_id ) -> wpbc_calendar__unselect_all_dates( resource_id )
1851 // showErrorMessage( element , errorMessage , isScrollStop ); -> wpbc_front_end__show_message__warning( jq_node, message );
1852 // showMessageUnderElement( element , errorMessage , message_type); -> wpbc_front_end__show_message__warning_under_element( jq_node, message );
1853 // makeScroll( object_name ); -> wpbc_do_scroll( jq_node );
1854 // .
1855 // JavaScript hooks changes:
1856 // jQuery( ".booking_form_div" ).trigger( "date_selected", [ resource_id, date ] );
1857 // become
1858 // jQuery( ".booking_form_div" ).trigger( "date_selected", [ resource_id, mouse_clicked_dates, all_selected_dates_arr ] );
1859 // where:
1860 // mouse_clicked_dates Can be: "05.10.2023 - 07.10.2023" | "10.10.2023 - 10.10.2023" |
1861 // all_selected_dates_arr Can be: [ "2023-10-05", "2023-10-06", "2023-10-07", … ]
1862 // PHP actions:
1863 // from: make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) , $formdata );
1864 // removed!
1865 // .
1866 // from: apply_filters('wpdev_booking_form_content', $form , $resource_id);
1867 // to: apply_filters( 'wpbc_booking_form_html__update__append_change_over_times', $form, $resource_id );
1868 // .
1869 // Removed PHP actions:
1870 // . 'show_payment_forms__for_ajax'
1871 // * make_bk_action('wpbc_ add_new_booking' , array(
1872 // * 'bktype' => 1
1873 // * , 'dates' => '27.08.2014, 28.08.2014, 29.08.2014'
1874 // * , 'form' => 'selectbox-one^rangetime1^10:00 - 12:00~text^name1^Jo~text^secondname1^Smith~email^email1^smith@gmail.com~text^phone1^678676678~text^address1^Linkoln Street~text^city1^London~text^postcode1^78788~selectbox-one^country1^GB~selectbox-one^visitors1^1~selectbox-one^children1^1~textarea^details1^Rooms with sea view~checkbox^term_and_condition1[]^I Accept term and conditions'
1875 // * , 'is_send_emeils' => 0
1876 // * // , 'booking_form_type' => ''
1877 // * // , 'wpdev_active_locale' => 'en_US'
1878 // * ) );
1879 // .
1880 // add_bk_filter('wpbc_add_new_booking_filter' , 'wpbc_add_new_booking' );
1881 // TODO: recheck hooks in wpbc-dev-api.php