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

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

?>

<div id="apbgf-service-modal" class="modal">
	<div class="modal__content apbgf_fancy_scroll">
		<h2><?php echo esc_html__('Service Details', 'appointment-and-booking-for-gravity-forms'); ?></h2>
		<form id="apbgf-service-form" autocomplete="off" class="modal--form">
			<input type="hidden" class="post_id" name="post_id" value="" />
			<div class="form-col-full">
				<label for="apbgf-name"><?php echo esc_html__('Service Name*', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<input type="text" id="apbgf-name" name="name" required>
			</div>            
			<div class="form-col-full">
				<label for="apbgf-price"><?php echo esc_html__('Service Price', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<input type="number" min="0" pattern="^\d*(\.\d{0,2})?$" class="apbgf-number" id="apbgf-price" name="price">
			</div>
			<div class="form-col-full">
				<label for="apbgf-category"><?php echo esc_html__('Service Category*', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<select name="category" id="apbgf-category" required>
					<option value=""><?php echo esc_html__('Select a Category', 'appointment-and-booking-for-gravity-forms'); ?></option>
					<?php
					$service_categories = APBGF_Service::all_categories();

					if ( is_array($service_categories) && count($service_categories) > 0 ) {
						foreach ( $service_categories as $service_category ) {
							echo '<option value="' . esc_attr( $service_category->term_id ) . '">' . esc_html( $service_category->name ) . '</option>';
						}                        
					}
					?>
				</select>
			</div>

			<?php 
			$all_location = APBGF_Location::all_location();
			?>
				<div class="form-col-full" style="display: none;" >
					<label for="location"><?php echo esc_html__('Location', 'appointment-and-booking-for-gravity-forms'); ?></label>
					<select name="location[]" id="apbgf-location" multiple>
						<?php
						
						echo '<option value="' . esc_attr( $all_location->ID ) . '" selected>' . esc_attr( $all_location->post_title ) . '</option>';
						
						?>
						</select>
				</div>

			<input class="save--modal" type="submit" value="Save">

			<div class="apbgf-response"></div>
		</form>

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