<?php
/**
 * GFB Staff Modal
 *
 * @package GFB.
 */

if (!defined('ABSPATH')) {
	exit; // Exit if accessed directly.
}

?>
<?php
//delete_post_meta( 3509, 'apbgf_staff_holidays' ); 
//echo '<pre>apbgf_staff_dayoffapbgf_staff_dayoff'; print_r(get_post_meta(3509, 'apbgf_staff_holidays', true)); echo '</pre>'; 
?>


<div id="apbgf-staff-modal" class="modal">
	<div class="modal__content apbgf_fancy_scroll">
		<div class="staff_tabs">
			<ul class="tabs">
				<li class="active" ><a href="#services"><?php echo esc_html__('Services', 'appointment-and-booking-for-gravity-forms'); ?></a></li>
				<li><a href="#timings"><?php echo esc_html__('Timings', 'appointment-and-booking-for-gravity-forms'); ?></a></li>
				<li><a href="#spl_day"><?php echo esc_html__('Special Day', 'appointment-and-booking-for-gravity-forms'); ?></a></li>
				<li><a href="#add_holidays"><?php echo esc_html__('Add Holidays', 'appointment-and-booking-for-gravity-forms'); ?></a></li>
				<li><a href="#remove_holidays"><?php echo esc_html__('Remove Holidays', 'appointment-and-booking-for-gravity-forms'); ?></a></li>
			</ul>
			<div class="tabsContainer">
				<div class="tabWrapper">                    
					
					<div id="services" class="tabContent">

						<?php 
						// echo '<pre>all_categoriesall_categories';
						// print_r(APBGF_Service::all_categories());
						// echo '</pre>';                        

						$categories = APBGF_Service::all_categories();
						
						if ( is_array( $categories ) && count($categories) > 0 ) {
							?>
							<p class="search-box" style="margin:0; width:50%; float:right;">
								<input type="text" id="search-service" value="" data-filter placeholder="Search" />
							</p>
							<div style="clear:both; height:0.1px"></div>
							<form id="apbgf-staff-form-services" autocomplete="off" class="modal--form">
								<input type="hidden" class="post_id" name="post_id" value=""/>
								<?php
								foreach ( $categories as $category ) {
									if ( 0 < $category->category_count ) {
										?>
										<label for="<?php echo esc_attr($category->slug); ?>" data-to-filter class="apbgf-cat-title"><?php echo esc_attr($category->name); ?></label>
										<div class="apbgf-timer">
											<?php
											$services = APBGF_Service::get_services_by_cat($category->term_id);

											if ( is_array( $services ) && count($services) > 0 ) {
												foreach ( $services as $service ) {
													$service_price = get_post_meta($service->ID, 'price', true);
													?>
													<div class="apbgf-timer-box" data-to-filter>
														<div class="apbgf-timer-col-row">
															<div class="timer-box-col-one">
																<label for="root-canal"><?php echo esc_attr($service->post_title); ?></label>
																<input type="checkbox" id="apbgf_staff_service_aval_<?php echo esc_attr($service->ID); ?>" name="apbgf_staff_service[<?php echo esc_attr($service->ID); ?>][available]" value="yes" />
															</div>
															<div class="timer-box-col-two">
																<?php
																if ( current_user_can( 'apbgf-staff' ) && ! current_user_can( 'manage_options' ) ) {
																	$apbgf_settings = APBGF_Setting::get_settings();
																	if ( isset($apbgf_settings['apbgf_price_policy']) && 'staff' == $apbgf_settings['apbgf_price_policy'] ) {
																		?>
																		<input type="number" min="0" class="apbgf-number" pattern="^\d*(\.\d{0,2})?$" id="apbgf_staff_service_price_<?php echo esc_attr($service->ID); ?>" name="apbgf_staff_service[<?php echo esc_attr($service->ID); ?>][price]" value="" placeholder="<?php echo esc_attr(apbgf_price_format($service_price, false)); ?>" />
																		<?php /* Translators: %1$s is currency symbol */ ?>
																		<small><?php printf(esc_html__('(in %1$s)', 'appointment-and-booking-for-gravity-forms'), esc_attr( apbgf_currency_symbol() ) ); ?></small>
																		<?php
																	} else {
																		?>
																		<input type="number" min="0" class="apbgf-number" pattern="^\d*(\.\d{0,2})?$" id="apbgf_staff_service_price_<?php echo esc_attr($service->ID); ?>" value="" placeholder="<?php echo esc_attr(apbgf_price_format($service_price, false)); ?>" disabled />
																		<?php /* Translators: %1$s is currency symbol */ ?>
																		<small><?php printf( esc_html__('(in %1$s)', 'appointment-and-booking-for-gravity-forms'), esc_attr( apbgf_currency_symbol() )); ?></small>
																		<?php
																	}
																} else {
																	?>
																	<input type="number" min="0" class="apbgf-number" pattern="^\d*(\.\d{0,2})?$" id="apbgf_staff_service_price_<?php echo esc_attr($service->ID); ?>" name="apbgf_staff_service[<?php echo esc_attr($service->ID); ?>][price]" value="" placeholder="<?php echo esc_attr(apbgf_price_format($service_price, false)); ?>" />
																	<?php /* Translators: %1$s is currency symbol */ ?>
																	<small><?php printf(esc_html__('(in %1$s)', 'appointment-and-booking-for-gravity-forms'), esc_attr( apbgf_currency_symbol() )); ?></small>
																	<?php                                                                    
																}
																?>
																															</div>
														</div>
													</div>
													<?php
												}
											}
											?>
										</div>
										<?php
									}
									?>
									<?php
								}
								?>
																<input class="save--modal" type="submit" value="Save">
								<div class="apbgf-response"></div>
							</form>
							<?php
						} else {
							echo esc_html__('No Services found.', 'appointment-and-booking-for-gravity-forms');
						}
						?>
					</div>
					<div id="timings" class="tabContent">
						<?php 
						$general_settings = APBGF_Setting::get_settings();
						?>
						<form id="apbgf-staff-form-timings" autocomplete="off" class="modal--form">
							<input type="hidden" class="post_id" name="post_id" value=""/>
							<div class="form-col-full">
								<label for="apbgf-timezone"><?php echo esc_html__('Select Time Zone', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<select name="apbgf-timezone" id="apbgf-timezone">
									<?php echo wp_timezone_choice(''); ?>
								</select>
							</div>
							<div class="form-col-full">
								<label for="apbgf-booking_type"><?php echo esc_html__('Booking Type', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<select name="booking_type" id="apbgf-booking_type">                                    
									<option value="custom"><?php echo esc_html__('Custom Slots', 'appointment-and-booking-for-gravity-forms'); ?></option>
									<option value="fullday"><?php echo esc_html__('Full Day', 'appointment-and-booking-for-gravity-forms'); ?></option>
								</select>
								<small><?php esc_html_e('If Full day is selected, Time slots will be ignored.', 'appointment-and-booking-for-gravity-forms'); ?></small>
							</div>
						   
				
						   <div class="form-col-full" id="apbgf-lead-time-container">
								<label for="apbgf-lead-time"><?php echo esc_html__('Lead Time', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<input type="number" id="apbgf-lead-time" name="apbgf-lead-time" data-general="<?php echo esc_attr($general_settings['gbf_lead_time']); ?>" placeholder="<?php echo esc_attr($general_settings['gbf_lead_time']); ?>" class="apbgf-lead-time-disabled" disabled >
								<small><?php esc_html_e('Each Staff Lead Time. Ex: 180 = 3 hours. Default is set as general settings.', 'appointment-and-booking-for-gravity-forms'); ?></small>
							</div>


							<div class="form-col-full" id="apbgf-multiple_booking" >
								<label class="apbgf-pro-feature-heading"><?php echo esc_html__('Multiple Booking', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<div class="apbgf-flexbox">
									<label for="apbgf-multiple_booking-enabled"><input type="radio" name="" id="apbgf-multiple_booking-enabled" value="enabled"  disabled/> <?php esc_html_e('Enable', 'appointment-and-booking-for-gravity-forms'); ?></label>
									<label for="apbgf-multiple_booking-disabled"><input type="radio" name="" id="apbgf-multiple_booking-disabled" value="disabled" disabled/> <?php esc_html_e('Disabled', 'appointment-and-booking-for-gravity-forms'); ?></label>
								</div>
							</div>
							<div class="form-col-full">
								<label for="apbgf-duration"><?php echo esc_html__('Time Slot Duration', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<input type="number" id="apbgf-duration" name="apbgf-time-slot-duration" min="1" data-general="<?php echo esc_attr( $general_settings['gbf_time_duration'] ); ?>" placeholder="<?php echo esc_attr( $general_settings['gbf_time_duration'] ); ?>">
								<small><?php esc_html_e('Each time slot duration. Ex: 180 = 3 hours.  Default is set as general settings.', 'appointment-and-booking-for-gravity-forms'); ?></small>
							</div>
							<div class="form-col-full">
								<label for="apbgf-interval"><?php echo esc_html__('Time Slot Interval', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<input type="number" id="apbgf-interval" name="apbgf-time-slot-interval" min="0" data-general="<?php echo esc_attr( $general_settings['gbf_time_interval'] ); ?>" placeholder="<?php echo esc_attr( $general_settings['gbf_time_interval'] ); ?>">
								<small><?php esc_html_e('Gap between each time slots. Ex: 60 = 1 hour. Default is set as general settings.', 'appointment-and-booking-for-gravity-forms'); ?></small>
							</div>                          
							<div class="form-time-slot-sec">
								<label for="add-time-slot"><?php echo esc_html__('Add Time Slot', 'appointment-and-booking-for-gravity-forms'); ?></label>
								<div class="form-time-slot-box">
									<div class="form-time-slots-title-row">
										<div class="form-time-slots-title">
											<span><?php echo esc_html__('Start Time', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
										<div class="form-time-slots-title">
											<span><?php echo esc_html__('End Time', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
										<div class="form-time-slots-title">
											<span><?php echo esc_html__('Slot Capacity', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<!-- MONDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_mon_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_mon_switch" name="apbgf_staff_timing[mon][switch]" value="1" />
											<span><?php echo esc_html__('Mon', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[mon][start]" id="apbgf_staff_timing_mon_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[mon][end]" id="apbgf_staff_timing_mon_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[mon][capacity]" id="apbgf_staff_timing_mon_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="mon"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-mon" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[mon][break][]" id="apbgf_staff_timing_mon_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
									<!-- TUESDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_tue_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_tue_switch" name="apbgf_staff_timing[tue][switch]" value="1" />
											<span><?php echo esc_html__('Tue', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[tue][start]" id="apbgf_staff_timing_tue_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[tue][end]" id="apbgf_staff_timing_tue_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[tue][capacity]" id="apbgf_staff_timing_tue_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="tue"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-tue" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[tue][break][]" id="apbgf_staff_timing_tue_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
									<!-- WEDNESDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_wed_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_wed_switch" name="apbgf_staff_timing[wed][switch]" value="1" />
											<span><?php echo esc_html__('Wed', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[wed][start]" id="apbgf_staff_timing_wed_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[wed][end]" id="apbgf_staff_timing_wed_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[wed][capacity]" id="apbgf_staff_timing_wed_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="wed"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-wed" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[wed][break][]" id="apbgf_staff_timing_wed_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
									<!-- THURSDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_thu_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_thu_switch" name="apbgf_staff_timing[thu][switch]" value="1" />
											<span><?php echo esc_html__('Thu', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[thu][start]" id="apbgf_staff_timing_thu_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[thu][end]" id="apbgf_staff_timing_thu_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[thu][capacity]" id="apbgf_staff_timing_thu_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="thu"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-thu" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[thu][break][]" id="apbgf_staff_timing_thu_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
									<!-- FRIDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_fri_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_fri_switch" name="apbgf_staff_timing[fri][switch]" value="1" />
											<span><?php echo esc_html__('Fri', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[fri][start]" id="apbgf_staff_timing_fri_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[fri][end]" id="apbgf_staff_timing_fri_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[fri][capacity]" id="apbgf_staff_timing_fri_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="fri"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-fri" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[fri][break][]" id="apbgf_staff_timing_fri_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
									<!-- SATURDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_sat_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_sat_switch" name="apbgf_staff_timing[sat][switch]" value="1" />
											<span><?php echo esc_html__('Sat', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[sat][start]" id="apbgf_staff_timing_sat_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[sat][end]" id="apbgf_staff_timing_sat_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[sat][capacity]" id="apbgf_staff_timing_sat_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="sat"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-sat" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[sat][break][]" id="apbgf_staff_timing_sat_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
									<!-- SUNDAY -->
									<div class="form-time-slots-content-row">
										<label class="form-time-slots-days" for="apbgf_staff_timing_sun_switch">
											<input type="checkbox" class="apbgf_staff_time_toggle" id="apbgf_staff_timing_sun_switch" name="apbgf_staff_timing[sun][switch]" value="1" />
											<span><?php echo esc_html__('Sun', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</label>
										<div class="form-start-time-slots">
											<input type="time" name="apbgf_staff_timing[sun][start]" id="apbgf_staff_timing_sun_start">
										</div>
										<div class="form-end-time-slots">
											<input type="time" name="apbgf_staff_timing[sun][end]" id="apbgf_staff_timing_sun_end">
										</div>
										<div class="form-slots-capacity">
											<input type="number" name="apbgf_staff_timing[sun][capacity]" id="apbgf_staff_timing_sun_capacity" min="0">
										</div>
										<div class="add-break-btn">
											<span data-id="sun"><i class="fa fa-plus-circle"></i> <?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></span>
										</div>
									</div>
									<div id="break-sun" class="form-time-slots-break-box">
										<div class="form-col-full">
											<label for="add-break"><?php echo esc_html__('Add Break', 'appointment-and-booking-for-gravity-forms'); ?></label>
											<select name="apbgf_staff_timing[sun][break][]" id="apbgf_staff_timing_sun_break" class="apbgf-slot-break" multiple></select>
										</div>
									</div>
								</div>
							</div>
							<input class="save--modal" type="submit" value="Save">
							<div class="apbgf-response"></div>
						</form>
					</div>
					<div id="spl_day" class="tabContent disabled-block">
						<?php 
						$general_settings = APBGF_Setting::get_settings();
						// echo '<pre>$general_settings$general_settings';
						// print_r($general_settings);
						// echo '</pre>';
						?>
						<form id="apbgf-staff-form-spl-day" autocomplete="off" class="modal--form">
							<input type="hidden" class="post_id" name="post_id" value=""/>
							<div class="form-time-slot-sec">
								<label for="add-time-slot" class="disabled-add-time-slot">
									<span><?php echo esc_html__('Add Special Time Slot', 'appointment-and-booking-for-gravity-forms'); ?></span>
									<a href="#" id="add_spl_date" class="disabled-link">
										<?php echo esc_html__('Add New Date', 'appointment-and-booking-for-gravity-forms'); ?>
									</a>
								</label>                              
								<!-- Repeater Field -->
								<div id="spl_day_repeater_wrapper">
									<!--spl date fields add dynamically-->
								</div>                                
							</div>
							<input class="save--modal" type="submit" value="Save">
							<div class="apbgf-response"></div>
						</form>
					</div>
					<div id="add_holidays" class="tabContent disabled-block">                        
						<form id="apbgf-staff-form-add-holidays" autocomplete="off" class="modal--form">
							<input type="hidden" class="post_id" name="post_id" value=""/>
							<div class="datepicker_box">
								<input type="hidden" name="apbgf_staff_holidays" id="datepicker">
							</div>
							<!-- <input class="save--modal" type="submit" value="Save"> -->
							<div class="apbgf-response"></div>
						</form>

					</div>
					<div id="remove_holidays" class="tabContent disabled-block">                        
						<form id="apbgf-staff-form-remove-holidays" autocomplete="off" class="modal--form">
							<input type="hidden" class="post_id" name="post_id" value=""/>
							<div class="datepicker_box">
								<input type="hidden" name="apbgf_staff_holidays" id="datepicker-2">
							</div>
							<!-- <input class="save--modal" type="submit" value="Save"> -->
							<div class="apbgf-response"></div>
						</form>

					</div>
				</div>
			</div>
		</div>
		<a href="#" class="modal__close">&times;</a>
	</div>
</div>
