PageSourceSearch

https://gemeinde-schiphorst.de/wp-content/plugins/booking/js/wpbc_times.js?ver=11.4.3

js gemeinde-schiphorst.de collected 2026-10-03 02:43:46 UTC 29,003 bytes, 777 lines download raw bytes

1var start_time_checking_index;
2
3/**
4 * Check if the date has only Working Time limits, without real bookings or manually blocked time slots.
5 *
6 * Working Time intervals still have to stay in the booking data for validation and tooltips,
7 * but they should not produce the small dots inside calendar day cells.
8 *
9 * @param {Object} date_bookings_obj
10 * @param {Array} child_resources_arr
11 * @returns {boolean}
12 */
13function wpbc_is_date_has_only_working_time_limits_for_dots( date_bookings_obj, child_resources_arr ) {
14
15	var has_working_time_limits = false;
16	var has_real_time_limits = false;
17	var resource_day_obj;
18	var time_details_obj;
19	var time_details;
20	var source_type;
21
22	if ( ( ! date_bookings_obj ) || ( null === child_resources_arr ) ) {
23		return false;
24	}
25
26	if (
27		   ( date_bookings_obj[ 'summary' ] )
28		&& ( date_bookings_obj[ 'summary' ][ 'status_for_bookings' ] )
29		&& ( '' !== date_bookings_obj[ 'summary' ][ 'status_for_bookings' ] )
30	) {
31		return false;
32	}
33
34	for ( var i = 0; i < child_resources_arr.length; i++ ) {
35
36		resource_day_obj = date_bookings_obj[ child_resources_arr[ i ] ];
37
38		if ( ! resource_day_obj ) {
39			continue;
40		}
41
42		time_details_obj = resource_day_obj[ '__booked__times__details' ];
43
44		if ( ! time_details_obj ) {
45			if (
46				   ( resource_day_obj.booked_time_slots )
47				&& ( resource_day_obj.booked_time_slots.merged_seconds )
48				&& ( resource_day_obj.booked_time_slots.merged_seconds.length > 0 )
49			) {
50				has_real_time_limits = true;
51			}
52			continue;
53		}
54
55		for ( var time_key in time_details_obj ) {
56
57			if ( ! time_details_obj.hasOwnProperty( time_key ) ) {
58				continue;
59			}
60
61			time_details = time_details_obj[ time_key ];
62			source_type = ( time_details && ( 'undefined' !== typeof( time_details[ 'source_type' ] ) ) ) ? time_details[ 'source_type' ] : 'booking';
63
64			if ( 'working_time' === source_type ) {
65				has_working_time_limits = true;
66			} else {
67				has_real_time_limits = true;
68			}
69		}
70	}
71
72	return ( has_working_time_limits && ! has_real_time_limits );
73}
74
75/**
76 * Get dots for partially  booked dates.
77 *    For parent booking resources with  specific capacity,
78 *    System do not show partially booked dates,  if at least one child booking resource fully  available
79 *    Otherwise it show maximum number of time-slot in one specific child booking resource
80 *
81 * @param param_calendar_id				ID of booking resource
82 * @param my_thisDateTime				timestamp of date
83 * @returns {string}
84 */
85function wpbc_show_date_info_top( param_calendar_id, my_thisDateTime ) {
86
87	var resource_id = parseInt(param_calendar_id.replace("calendar_booking", ''));
88
89	if (isNaN(resource_id)) {
90		return '';  // FixIn: 10.9.5.2.
91	}
92
93	// console.log( _wpbc.bookings_in_calendar__get( resource_id ) );		// for debug
94
95	// 1. Get child booking resources  or single booking resource  that  exist  in dates :	[1] | [1,14,15,17]
96	var child_resources_arr = wpbc_clone_obj(_wpbc.booking__get_param_value(resource_id, 'resources_id_arr__in_dates'));
97
98	// '2023-08-21'
99	var sql_date = wpbc__get__sql_class_date(new Date(my_thisDateTime));
100	var date_bookings_obj = _wpbc.bookings_in_calendar__get_for_date(resource_id, sql_date);
101
102	if ( wpbc_is_date_has_only_working_time_limits_for_dots( date_bookings_obj, child_resources_arr ) ) {
103		return '';
104	}
105
106	var child_resource_id;
107	var merged_seconds;
108	var dots_count = 0;
109
110	var dots_in__resources = [];
111
112	// Loop all resources ID.
113	if (child_resources_arr !== null) {
114		for (child_resource_id of child_resources_arr) {                                                                    // FixIn: 10.9.5.1.
115
116			// _wpbc.bookings_in_calendar__get_for_date(2,'2023-08-21')[12].booked_time_slots.merged_seconds		= [ "07:00:11 - 07:30:02", "10:00:11 - 00:00:00" ]
117			// _wpbc.bookings_in_calendar__get_for_date(2,'2023-08-21')[2].booked_time_slots.merged_seconds			= [  [ 25211, 27002 ], [ 36011, 86400 ]  ]
118
119			if (false !== date_bookings_obj) {
120				merged_seconds = date_bookings_obj[child_resource_id].booked_time_slots.merged_seconds;		// [  [ 25211, 27002 ], [ 36011, 86400 ]  ]
121			} else {
122				merged_seconds = [];
123			}
124
125			if (0 === merged_seconds.length) {
126				return ''; 																		// Day available
127			}
128
129			for (var i = 0; i < merged_seconds.length; i++) {
130				if (!wpbc_is_this_timeslot__full_day_booked(merged_seconds[i])) {			// Check  if this fully  booked date. If yes,  then  do not count it
131					dots_count++;
132				}
133			}
134
135			dots_in__resources.push(dots_count);
136			dots_count = 0;
137		}
138	}
139	var dots_count_max = Math.max.apply( Math, dots_in__resources );						// Get maximum value in array [ 1, 5, 3]  ->  5
140
141	var dot_content = '';
142	for ( var d = 0; d < dots_count_max; d++ ){
143		dot_content += '&centerdot;';
144	}
145
146	dot_content = ( '' !== dot_content ) ? '<div class="wpbc_time_dots">
146' + dot_content + '</div>' : '';
147
148	return dot_content;
149}
150
151/**
152 * Show Date Info at  bottom  of the  Day Cell
153 *
154 * @param param_calendar_id		'calendar_booking1'
155 * @param my_thisDateTime		56567557757
156 * @returns {string}
157 */
158function wpbc_show_date_info_bottom( param_calendar_id, my_thisDateTime ) {
159
160	var bottom_hint_arr = [];
161
162	// Cost Hint
163	if ( typeof (wpbc_show_day_cost_in_date_bottom) == 'function' ) {
164		var cost_hint = wpbc_show_day_cost_in_date_bottom( param_calendar_id, my_thisDateTime );
165		if ( '' !== cost_hint ) {
166			bottom_hint_arr.push( wpbc_show_day_cost_in_date_bottom( param_calendar_id, my_thisDateTime ) );
167		}
168	}
169
170	// Availability Hint		// FixIn: 10.6.4.1.
171	var availability = wpbc_get_in_date_availability_hint( param_calendar_id, my_thisDateTime )
172	if ( '' !== availability ) {
173		bottom_hint_arr.push( availability );
174	}
175
176	var bottom_hint = bottom_hint_arr.join( '' );
177	return bottom_hint;
178}
179
180/**
181 * Get Availability Hint for in Day Cell
182 *
183 * @param param_calendar_id
184 * @param my_thisDateTime
185 * @returns {string}
186 */
187function wpbc_get_in_date_availability_hint( param_calendar_id, my_thisDateTime ) {								        // FixIn: 10.6.4.1.
188
189	/*
190	var sql_date 	= wpbc__get__sql_class_date( new Date( my_thisDateTime ) );						// '2023-08-21'
191	var resource_id = parseInt( param_calendar_id.replace( "calendar_booking", '' ) );				// 1
192	var day_availability_obj = _wpbc.bookings_in_calendar__get_for_date( resource_id, sql_date );	// obj
193
194	if ( 'undefined' !== typeof (day_availability_obj.day_availability) ) {
195		return '<strong>' + day_availability_obj.day_availability + '</strong> ' + 'available';
196	} else {
197		return '';
198	}
199	*/
200
201	var resource_id = parseInt( param_calendar_id.replace( "calendar_booking", '' ) );
202
203	// console.log( _wpbc.bookings_in_calendar__get( resource_id ) );		// for debug
204
205	// 1. Get child booking resources  or single booking resource  that  exist  in dates :	[1] | [1,14,15,17]
206	// var child_resources_arr = wpbc_clone_obj( _wpbc.booking__get_param_value( resource_id, 'resources_id_arr__in_dates' ) );
207
208	// '2023-08-21'
209	var sql_date = wpbc__get__sql_class_date( new Date( my_thisDateTime ) );
210
211    var hint__in_day__availability = '';
212
213    var get_for_date_obj = _wpbc.bookings_in_calendar__get_for_date( resource_id, sql_date );
214
215    if ( false !== get_for_date_obj ){
216
217        if (
218               (undefined != get_for_date_obj[ 'summary' ])
219            && (undefined != get_for_date_obj[ 'summary' ].hint__in_day__availability)
220        ){
221            hint__in_day__availability = get_for_date_obj[ 'summary' ].hint__in_day__availability;		// "5 available"
222        }
223
224    }
225
226    return hint__in_day__availability;
227}
228
229
230/**
231 * Hide Tippy tooltip on scroll, to prevent issue on mobile touch devices of showing tooltip at top left corner!
232 * @param evt
233 */
234jQuery( window ).on( 'scroll', function ( event ){													//FixIn: 9.2.1.5	// FixIn: 9.4.3.3.
235	if ( 'function' === typeof( wpbc_tippy ) ){
236		wpbc_tippy.hideAll();
237	}
238} );
239
240
241/**
242 * Check if in booking form  exist  times fields for booking for specific time-slot
243 * @param resource_id
244 * @param form_elements
245 * @returns {boolean}
246 */
247function wpbc_is_time_field_in_booking_form( resource_id, form_elements ){											// FixIn: 8.2.1.28.
248
249	var count = form_elements.length;
250	var start_time = false;
251	var end_time = false;
252	var duration = false;
253	var element;
254
255	/**
256	 *  Get from booking form  'rangetime', 'durationtime', 'starttime', 'endtime',  if exists.
257	 */
258	for ( var i = 0; i < count; i++ ){
259
260		element = form_elements[ i ];
261
262		// Skip elements from garbage
263		if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){											// FixIn: 7.1.2.14.
264			continue;
265		}
266
267		if (
268			   ( element.name != undefined )
269			&& ( element.name.indexOf( 'hint' ) !== -1 )				// FixIn: 9.5.5.2.
270		){
271			var my_element = element.name; //.toString();
272			if ( my_element.indexOf( 'rangetime' ) !== -1 ){                       	// Range Time
273
274				return true;
275			}
276			if ( (my_element.indexOf( 'durationtime' ) !== -1) ){                	// Duration
277				duration = element.value;
278			}
279			if ( my_element.indexOf( 'starttime' ) !== -1 ){                     	// Start Time
280				start_time = element.value;
281			}
282			if ( my_element.indexOf( 'endtime' ) !== -1 ){                        	// End Time
283				end_time = element.value;
284			}
285		}
286	}
287
288	// Duration get Values
289	if ( ( duration !== false ) && ( start_time !== false ) ){  // we have Duration and Start time
290		return true;
291	}
292
293	if ( ( start_time !== false ) && ( end_time !== false ) ){  // we have End time and Start time
294		return true;
295	}
296
297	return false;
298}
299
300function wpbc_is_change_over_enabled_for_resource( resource_id ) {
301
302	if ( ( 'undefined' !== typeof resource_id ) && ( null !== resource_id ) ) {
303		var resource_change_over = _wpbc.calendar__get_param_value( resource_id, 'is_enabled_change_over' );
304		if ( '' !== resource_change_over ) {
305			return ( true === resource_change_over ) || ( 'true' === resource_change_over );
306		}
307	}
308
309	return true === _wpbc.get_other_param( 'is_enabled_change_over' );
310}
311
312
313/**
314 * Check if the selected date/time is already in the past compared to "today_arr".
315 *
316 * Behavior notes:
317 * - If "is_enabled_change_over" is enabled, always returns false (no restriction).
318 * - `sort_date_array[0]` is expected to be the earliest selected date (sorted ascending).
319 * - `today_arr` is expected to be: [YYYY, MM, DD, HH, mm] (strings or numbers).
320 * - `myTime` is expected to be "HH:MM" (24h).
321 *
322 * @param {string} myTime Time string in "HH:MM" format.
323 * @param {Array<Array<string|number>>} sort_date_array Array of date arrays; first element is used as date to check.
324 * @returns {boolean} True if selected date/time is in the past, otherwise false.
325 */
326function wpbc_is_time_in_the_past_for_today(myTime, sort_date_array, resource_id) {
327
328	var allow_past_context = _wpbc.get_other_param( 'this_page_allow_past' );
329	var edit_booking_hash_context = _wpbc.get_other_param( 'this_page_booking_hash' );
330	if (
331		   ( '1' === String( allow_past_context ) )
332		|| ( 1 === allow_past_context )
333		|| ( true === allow_past_context )
334		|| ( '' !== String( edit_booking_hash_context || '' ) )
335		|| ( location.href.indexOf( 'booking_hash' ) > -1 )
336		|| ( location.href.indexOf( 'allow_past' ) > -1 )
337	) {
338		return false;
339	}
340
341	// FixIn: 10.14.10.2.
342	if ( true === wpbc_is_change_over_enabled_for_resource( resource_id ) ) {
343		return false;
344	}
345	var date_to_check = sort_date_array[0];
346	if ( parseInt( date_to_check[0] ) < parseInt( _wpbc.get_other_param( 'today_arr' )[0] ) ) {
347		return true;
348	}
349	if (
350		(parseInt( date_to_check[0] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[0] )) &&
351		(parseInt( date_to_check[1] ) < parseInt( _wpbc.get_other_param( 'today_arr' )[1] ))
352	) {
353		return true;
354	}
355	if (
356		(parseInt( date_to_check[0] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[0] )) &&
357		(parseInt( date_to_check[1] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[1] )) &&
358		(parseInt( date_to_check[2] ) < parseInt( _wpbc.get_other_param( 'today_arr' )[2] ))
359	) {
360		return true;
361	}
362	if (
363		(parseInt( date_to_check[0] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[0] )) &&
364		(parseInt( date_to_check[1] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[1] )) &&
365		(parseInt( date_to_check[2] ) == parseInt( _wpbc.get_other_param( 'today_arr' )[2] ))
366	) {
367		var mytime_value = myTime.split( ":" );
368		mytime_value     = parseInt( mytime_value[0] ) * 60 + parseInt( mytime_value[1] );
369
370		var current_time_value = parseInt( _wpbc.get_other_param( 'today_arr' )[3] ) * 60 + parseInt( _wpbc.get_other_param( 'today_arr' )[4] );
371
372		if ( current_time_value > mytime_value ) {
373			return true;
374		}
375	}
376	return false;
377}
378
379/**
380 * Validate a time string.
381 *
382 * Supported formats:
383 *  - 24-hour time: "H:MM" or "HH:MM"
384 *      Examples: "0:00", "09:30", "23:59", "24:00"
385 *      Notes: "24:00" is allowed, but "24:01" is not.
386 *
387 *  - 12-hour time: "H:MM AM/PM" (AM/PM is case-insensitive; spaces are optional)
388 *      Examples: "9:30 AM", "09:30pm", "12:05 PM"
389 *
390 * @param {string} time_str Raw time string entered by the user.
391 * @returns {boolean} True if the string matches a valid supported time format.
392 */
393function wpbc_is_valid_time_string(time_str) {
394
395	if ( typeof time_str !== 'string' ) {
396		return false;
397	}
398
399	const str = time_str.trim();
400	if ( str === '' ) {
401		return false;
402	}
403
404	// 1-2 digit hours, 2 digit minutes, optional AM/PM (case-insensitive).
405	const match = str.match( /^(\d{1,2}):(\d{2})(?:\s*([AaPp][Mm]))?$/ );
406	if ( ! match ) {
407		return false;
408	}
409
410	const hour   = Number( match[1] );
411	const minute = Number( match[2] );
412	const ampm   = match[3] ? match[3].toUpperCase() : null;
413
414	if ( ! Number.isInteger( hour ) || ! Number.isInteger( minute ) ) {
415		return false;
416	}
417
418	if ( minute < 0 || minute > 59 ) {
419		return false;
420	}
421
422	// 12-hour mode (AM/PM provided): hour must be 1..12.
423	if ( ampm ) {
424		return hour >= 1 && hour <= 12;
425	}
426
427	// 24-hour mode (no AM/PM): hour must be 0..24, but 24 only allowed with :00.
428	if ( hour < 0 || hour > 24 ) {
429		return false;
430	}
431	if ( hour === 24 && minute !== 0 ) {
432		return false;
433	}
434
435	return true;
436}
437
438
439//TODO: Continue Refactoring here 2018-04-21
440
441	//PS: This function  from personal.js
442	function wpbc_is_this_time_selection_not_available( resource_id, form_elements ){
443
444		// Skip this checking if we are in the Admin  panel at Add booking page
445		if ( ( location.href.indexOf( 'page=wpbc' ) > 0 ) && ( location.href.indexOf( 'tab=add-booking' ) > 0 ) ) {
446			return false;
447		}
448
449		var count = form_elements.length;
450		var start_time = false;
451		var end_time = false;
452		var duration = false;
453		var element;
454		var element_start = false;
455		var element_end = false;
456		var element_duration = false;
457		var element_rangetime = false;
458
459		/**
460		 *  Get from booking form  'rangetime', 'durationtime', 'starttime', 'endtime',  if exists.
461		 */
462		for ( var i = 0; i < count; i++ ){
463
464			element = form_elements[ i ];
465
466			// Skip elements from garbage
467			if ( jQuery( element ).closest( '.booking_form_garbage' ).length ){											// FixIn: 7.1.2.14.
468				continue;
469			}
470
471			if ( '1' === String( jQuery( element ).attr( 'data-wpbc-booking-submit-ignore' ) || '' ) ) {
472				continue;
473			}
474
475			if (
476				   ( element.name != undefined )
477				&& ( element.name.indexOf( 'hint' ) === -1 )				//FixIn: 9.5.5.2		// FixIn: 9.6.3.9.
478			){
479				var my_element = element.name; //.toString();
480				if ( my_element.indexOf( 'rangetime' ) !== -1 ){                       	// Range Time
481					if ( element.value == '' ){                                 										//FixIn: 7.0.Beta.19
482					 	var notice_message_id = wpbc_front_end__show_message__warning( element, _wpbc.get_message( 'message_check_required' ), 'text' );
483						return true;
484					}
485					var my_rangetime = element.value.split( '-' );
486					if ( my_rangetime.length > 1 ){
487						start_time = my_rangetime[ 0 ].replace( /(^\s+)|(\s+$)/g, "" ); 	// Trim
488						end_time = my_rangetime[ 1 ].replace( /(^\s+)|(\s+$)/g, "" );
489						element_rangetime = element;
490					}
491				}
492				if ( (my_element.indexOf( 'durationtime' ) !== -1) ){                	// Duration
493					duration = element.value;
494					element_duration = element;
495				}
496				if ( my_element.indexOf( 'starttime' ) !== -1 ){                     	// Start Time
497					start_time = element.value;
498					element_start = element;
499				}
500				if ( my_element.indexOf( 'endtime' ) !== -1 ){                        	// End Time
501					end_time = element.value;
502					element_end = element;
503				}
504			}
505		}
506
507
508		// Duration get Values
509		if ( (duration !== false) && (start_time !== false) ){  // we have Duration and Start time so  try to get End time
510
511			var mylocalstarttime = start_time.split( ':' );
512			var d = new Date( 1980, 1, 1, mylocalstarttime[ 0 ], mylocalstarttime[ 1 ], 0 );
513
514			var my_duration = duration.split( ':' );
515			my_duration = my_duration[ 0 ] * 60 * 60 * 1000 + my_duration[ 1 ] * 60 * 1000;
516			d.setTime( d.getTime() + my_duration );
517
518			var my_hours = d.getHours();
519			if ( my_hours < 10 ) my_hours = '0' + (my_hours + '');
520			var my_minutes = d.getMinutes();
521			if ( my_minutes < 10 ) my_minutes = '0' + (my_minutes + '');
522
523			// We are get end time
524			end_time = (my_hours + '') + ':' + (my_minutes + '');
525			if ( end_time == '00:00' ) end_time = '23:59';
526		}
527
528
529		if ( (start_time === false) || (end_time === false) ){                     // We do not have Start or End time or Both of them, so do not check it
530
531			return false;
532
533		} else {
534
535			var valid_time = true;
536			if ( (start_time == '') || (end_time == '') ) valid_time = false;
537
538			if ( !wpbc_is_valid_time_string( start_time ) ) valid_time = false;
539			if ( !wpbc_is_valid_time_string( end_time ) ) valid_time = false;
540
541			if ( valid_time === true )
542				if (
543					(typeof(checkRecurentTimeInside) == 'function') &&
544
545					( _wpbc.get_other_param( 'is_enabled_booking_recurrent_time' ) == true )
546				){                                                                // Recheck Time here !!!
547					valid_time = checkRecurentTimeInside( [ start_time, end_time ], resource_id );
548				} else {
549
550					if ( typeof(checkTimeInside) == 'function' ){
551						valid_time = checkTimeInside( start_time, true, resource_id );
552					}
553
554					if ( valid_time === true ){
555						if ( typeof(checkTimeInside) == 'function' ){
556							valid_time = checkTimeInside( end_time, false, resource_id );
557						}
558					}
559				}
560
561			if ( valid_time !== true ){
562				//return false;                                                  // do not show warning for setting pending days selectable,  if making booking for time-slot   // FixIn: 7.0.1.23.
563				if ( ( wpbc_is_change_over_enabled_for_resource( resource_id ) ) && (element_start !== false) && (element_end !== false) ){      // FixIn: 6.1.1.1.
564					wpbc_front_end__show_message__warning( '#booking_form_div' + resource_id + ' .bk_calendar_frame', _wpbc.get_message( 'message_check_no_selected_dates' ), 'text' );
565				}
566				if ( element_rangetime !== false ){ wpbc_front_end__show_message__warning_under_element
566( element_rangetime, _wpbc.get_message( 'message_error_range_time' ), 'text' ); }
567				if ( element_duration !== false ){  wpbc_front_end__show_message__warning_under_element( element_duration, _wpbc.get_message( 'message_error_duration_time' ), 'text' ); }
568				if ( element_start !== false ){ 	wpbc_front_end__show_message__warning_under_element( element_start, _wpbc.get_message( 'message_error_start_time' ), 'text' ); }
569				if ( element_end !== false ){ 		wpbc_front_end__show_message__warning_under_element( element_end, _wpbc.get_message( 'message_error_end_time' ), 'text' ); }
570
571				return true;
572
573			} else {
574				return false;
575			}
576
577		}
578
579
580	}
581
582	function checkTimeInside( mytime, is_start_time, bk_type ){
583
584		var my_dates_str = document.getElementById( 'date_booking' + bk_type ).value;                 // GET DATES From TEXTAREA
585
586		if ( my_dates_str.indexOf( ' - ' ) != 0 ){
587
588			my_dates_str = my_dates_str.replace( ' - ', ', ' );										// FixIn: 10.2.3.2.
589		}
590
591		return checkTimeInsideProcess( mytime, is_start_time, bk_type, my_dates_str );
592	}
593
594	function checkRecurentTimeInside( my_rangetime, bk_type ){
595
596		var valid_time = true;
597		var my_dates_str = document.getElementById( 'date_booking' + bk_type ).value;                 // GET DATES From TEXTAREA
598		// recurrent time check for all days in loop
599
600		var date_array = my_dates_str.split( ", " );
601		if ( date_array.length == 2 ){ // This recheck is need for editing booking, with single day
602			if ( date_array[ 0 ] == date_array[ 1 ] ){
603				date_array = [ date_array[ 0 ] ];
604			}
605		}
606		var temp_date_str = '';
607		for ( var i = 0; i < date_array.length; i++ ){  // Get SORTED selected days array
608			temp_date_str = date_array[ i ];
609			if ( checkTimeInsideProcess( my_rangetime[ 0 ], true, bk_type, temp_date_str ) == false ) valid_time = false;
610			if ( checkTimeInsideProcess( my_rangetime[ 1 ], false, bk_type, temp_date_str ) == false ) valid_time = false;
611
612		}
613
614		return valid_time;
615	}
616
617	// Function check start and end time at selected days.
618	function checkTimeInsideProcess( mytime, is_start_time, bk_type, my_dates_str ){
619		var i, h, s, m;	// FixIn: 9.1.5.1.
620
621		var date_array = my_dates_str.split( ',' );
622		date_array = date_array.map( function (s) {
623			return s.trim();
624		} );
625		if ( date_array.length == 2 ){ // This recheck is need for editing booking, with single day
626			if ( date_array[ 0 ] == date_array[ 1 ] ){
627				date_array = [ date_array[ 0 ] ];
628			}
629		}
630
631		var temp_elemnt;
632		var td_class;
633		var sort_date_array = [];
634		var work_date_array = [];
635		var times_array = [];
636		var is_check_for_time;
637
638		for ( var i = 0; i < date_array.length; i++ ){  // Get SORTED selected days array
639			temp_elemnt = date_array[ i ].split( "." );
640			sort_date_array[ i ] = [ temp_elemnt[ 2 ], temp_elemnt[ 1 ] + '', temp_elemnt[ 0 ] + '' ]; // [2009,7,1],...
641		}
642		sort_date_array.sort();                                                                   // SORT    D a t e s
643		for ( i = 0; i < sort_date_array.length; i++ ){                                  // trnasform to integers
644			sort_date_array[ i ] = [ parseInt( sort_date_array[ i ][ 0 ] * 1 ), parseInt( sort_date_array[ i ][ 1 ] * 1 ), parseInt( sort_date_array[ i ][ 2 ] * 1 ) ]; // [2009,7,1],...
645		}
646
647		if ( is_start_time ) {
648			if ( wpbc_is_time_in_the_past_for_today( mytime, sort_date_array, bk_type ) ) {
649				return false;
650			}
651		}
652
653		//  CHECK FOR BOOKING INSIDE OF     S E L E C T E D    DAY RANGE AND FOR TOTALLY BOOKED DAYS AT THE START AND END OF RANGE
654		work_date_array = sort_date_array;
655		for ( var j = 0; j < work_date_array.length; j++ ){
656			td_class = work_date_array[ j ][ 1 ] + '-' + work_date_array[ j ][ 2 ] + '-' + work_date_array[ j ][ 0 ];
657
658			if ( (j == 0) || (j == (work_date_array.length - 1)) ) is_check_for_time = true;         // Check for time only start and end time
659			else is_check_for_time = false;
660
661
662		}  ///////////////////////////////////////////////////////////////////////////////////////////////////////
663
664
665		// Check    START   OR    END   time for time no in correct fee range
666		if ( is_start_time ) work_date_array = sort_date_array[ 0 ];
667		else work_date_array = sort_date_array[ sort_date_array.length - 1 ];
668
669		td_class = work_date_array[ 1 ] + '-' + work_date_array[ 2 ] + '-' + work_date_array[ 0 ];
670
671		// Get dates and time from pending dates
672		//deleted
673		// Get dates and time from pending dates
674		//deleted
675
676
677		times_array.sort();                     // SORT TIMES
678
679		var times_in_day = [];                  // array with all times
680		var times_in_day_interval_marks = [];   // array with time interval marks 1- stsrt time 2 - end time
681
682
683		for ( i = 0; i < times_array.length; i++ ){
684			s = times_array[ i ][ 2 ];         // s = 2 - end time,   s = 1 - start time
685			// Start close interval
686			if ( (s == 2) && (i == 0) ){
687				times_in_day[ times_in_day.length ] = 0;
688				times_in_day_interval_marks[ times_in_day_interval_marks.length ] = 1;
689			}
690			// Normal
691			times_in_day[ times_in_day.length ] = times_array[ i ][ 0 ] * 60 + parseInt( times_array[ i ][ 1 ] );
692			times_in_day_interval_marks[ times_in_day_interval_marks.length ] = s;
693			// End close interval
694			if ( (s == 1) && (i == (times_array.length - 1)) ){
695				times_in_day[ times_in_day.length ] = (24 * 60);
696				times_in_day_interval_marks[ times_in_day_interval_marks.length ] = 2;
697			}
698		}
699
700		// Get time from entered time
701		var mytime_value = mytime.split( ":" );
702		mytime_value = mytime_value[ 0 ] * 60 + parseInt( mytime_value[ 1 ] );
703
704//alert('My time:'+ mytime_value + '  List of times: '+ times_in_day + '  Saved indexes: ' + start_time_checking_index + ' Days: ' + sort_date_array ) ;
705
706		var start_i = 0;
707		if ( start_time_checking_index != undefined )
708			if ( start_time_checking_index[ 0 ] != undefined )
709				if ( (!is_start_time) && (sort_date_array.length == 1) ){
710					start_i = start_time_checking_index[ 0 ];
711					/*start_i++;*/
712				}
713		i = start_i;
714
715		// Main checking inside a day
716		for ( i = start_i; i < times_in_day.length; i++ ){
717			times_in_day[ i ] = parseInt( times_in_day[ i ] );
718			mytime_value = parseInt( mytime_value );
719			if ( is_start_time ){
720				if ( mytime_value > times_in_day[ i ] ){
721					// Its Ok, lets Loop to next item
722				} else if ( mytime_value == times_in_day[ i ] ){
723					if ( times_in_day_interval_marks[ i ] == 1 ){
724						return false;     //start time is begin with some other interval
725					} else {
726						if ( (i + 1) <= (times_in_day.length - 1) ){
727							if ( times_in_day[ i + 1 ] <= mytime_value ) return false;  //start time  is begin with next elemnt interval
728							else {                                                 // start time from end of some other
729								if ( sort_date_array.length > 1 )
730									if ( (i + 1) <= (times_in_day.length - 1) ) return false;   // Its mean that we make end booking at some other day then this and we have some booking time at this day after start booking  - its wrong
731								start_time_checking_index = [ i, td_class, mytime_value ];
732								return true;
733							}
734						}
735						if ( sort_date_array.length > 1 )
736							if ( (i + 1) <= (times_in_day.length - 1) ) return false;   // Its mean that we make end booking at some other day then this and we have some booking time at this day after start booking  - its wrong
737						start_time_checking_index = [ i, td_class, mytime_value ];
738						return true;                                            // start time from end of some other
739					}
740				} else if ( mytime_value < times_in_day[ i ] ){
741					if ( times_in_day_interval_marks[ i ] == 2 ){
742						return false;     // start time inside of some interval
743					} else {
744						if ( sort_date_array.length > 1 )
745							if ( (i + 1) <= (times_in_day.length - 1) ) return false;   // Its mean that we make end booking at some other day then this and we have some booking time at this day after start booking  - its wrong
746						start_time_checking_index = [ i, td_class, mytime_value ];
747						return true;
748					}
749				}
750			} else {
751				if ( sort_date_array.length == 1 ){
752
753					if ( start_time_checking_index != undefined )
754						if ( start_time_checking_index[ 2 ] != undefined )
755
756							if ( (start_time_checking_index[ 2 ] == times_in_day[ i ]) && (times_in_day_interval_marks[ i ] == 2) ){    // Good, because start time = end of some other interval and we need to get next interval for current end time.
757							} else if ( times_in_day[ i ] < mytime_value ) return false;                 // some interval begins before end of curent "end time"
758							else {
759								if ( start_time_checking_index[ 2 ] >= mytime_value ) return false;  // we are select only one day and end time is earlythe starttime its wrong
760								return true;                                                    // if we selected only one day so evrything is fine and end time no inside some other intervals
761							}
762				} else {
763					if ( times_in_day[ i ] < mytime_value ) return false;                 // Some other interval start before we make end time in the booking at the end day selection
764					else return true;
765				}
766
767			}
768		}
769
770		if ( is_start_time ) start_time_checking_index = [ i, td_class, mytime_value ];
771		else {
772			if ( start_time_checking_index != undefined )
773				if ( start_time_checking_index[ 2 ] != undefined )
774					if ( (sort_date_array.length == 1) && (start_time_checking_index[ 2 ] >= mytime_value) ) return false;  // we are select only one day and end time is earlythe starttime its wrong
775		}
776		return true;
777	}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.