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

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

?>

<div id="apbgf-customer-modal" class="modal">
	<div class="modal__content apbgf_fancy_scroll">
		<h2><?php echo esc_html__('Customer Details', 'appointment-and-booking-for-gravity-forms'); ?></h2>
		<form id="apbgf-customer-form" autocomplete="off" class="modal--form">
			
			<div class="form-col-full">
				<label for="apbgf-user"><?php echo esc_html__('Select Customer', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<select id="apbgf-user" name="apbgf_user" class="apbgf-select2" style="width:100%;">
					<option value=""><?php echo esc_html__('Select a Customer', 'appointment-and-booking-for-gravity-forms'); ?></option>
					<?php
					$customers = get_users( array(
						'role'    => 'apbgf-customer',
						'orderby' => 'display_name',
						'order'   => 'ASC',
					) );

					if ( ! empty( $customers ) ) {
						foreach ( $customers as $customer ) {
							echo '<option value="' . esc_attr( $customer->ID ) . '">' . esc_html( $customer->display_name ) . ' (' . esc_html( $customer->user_email ) . ')</option>';
						}
					}
					?>
				</select>
			</div>

			<input type="hidden" class="post_id" name="post_id" value="" />

			<div class="form-col-full">
				<label for="apbgf-phone"><?php echo esc_html__('Phone', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<input type="tel" id="apbgf-phone" name="phone">
			</div>
			
			<div class="form-col-one">
				<label for="apbgf-gender"><?php echo esc_html__('Gender', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<select name="gender" id="apbgf-gender">
					<option value="no"><?php echo esc_html__('Prefer not to respond', 'appointment-and-booking-for-gravity-forms'); ?></option>
					<option value="male"><?php echo esc_html__('Male', 'appointment-and-booking-for-gravity-forms'); ?></option>
					<option value="female"><?php echo esc_html__('Female', 'appointment-and-booking-for-gravity-forms'); ?></option>
				</select>
			</div>
			<div class="form-col-two">
				<label for="apbgf-dob"><?php echo esc_html__('Date of Birth', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<input type="date" id="apbgf-dob" name="dob">
			</div>
			
			<div class="form-col-full">
				<label for="info"><?php echo esc_html__('Note', 'appointment-and-booking-for-gravity-forms'); ?></label>
				<textarea id="apbgf-info" name="info"></textarea>
			</div>

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

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

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