public function meta_box_inner($post)
    {
        wp_nonce_field('wc_bookings_details_meta_box', 'wc_bookings_details_meta_box_nonce');
        // Scripts.
        wp_enqueue_script('ajax-chosen');
        wp_enqueue_script('chosen');
        wp_enqueue_script('jquery-ui-datepicker');
        $customer_id = get_post_meta($post->ID, '_booking_customer_id', true);
        $order_parent_id = apply_filters('woocommerce_order_number', _x('#', 'hash before order number', 'woocommerce-bookings') . $post->post_parent, $post->post_parent);
        ?>
		<style type="text/css">
			#post-body-content, #titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none }
		</style>
		<div class="panel-wrap woocommerce">
			<div id="booking_data" class="panel">

			<h2><?php 
        _e('Booking Details', 'woocommerce-bookings');
        ?>
</h2>
			<p class="booking_number"><?php 
        printf(__('Booking number: #%s.', 'woocommerce-bookings'), esc_html($post->ID));
        if ($post->post_parent) {
            $order = new WC_Order($post->post_parent);
            printf(' ' . __('Order number: %s.', 'woocommerce-bookings'), '<a href="' . admin_url('post.php?post=' . absint($post->post_parent) . '&action=edit') . '">' . esc_html($order->get_order_number()) . '</a>');
        }
        ?>
</p>

			<div class="booking_data_column_container">
				<div class="booking_data_column">

					<h4><?php 
        _e('General Details', 'woocommerce-bookings');
        ?>
</h4>

					<p class="form-field form-field-wide">
						<label for="_booking_order_id"><?php 
        _e('Order ID:', 'woocommerce-bookings');
        ?>
</label>
						<select id="_booking_order_id" name="_booking_order_id" class="ajax_chosen_select_booking_order_id" data-placeholder="<?php 
        _e('Select an order&hellip;', 'woocommerce-bookings');
        ?>
">
							<?php 
        if ($post->post_parent) {
            echo '<option value="' . esc_attr($post->post_parent) . '" ' . selected(1, 1, false) . '>' . $order_parent_id . ' &ndash; ' . esc_html(get_the_title($post->post_parent)) . '</option>';
        }
        ?>
						</select>
					</p>

					<p class="form-field form-field-wide"><label for="booking_date"><?php 
        _e('Date created:', 'woocommerce-bookings');
        ?>
</label>
						<input type="text" class="date-picker-field" name="booking_date" id="booking_date" maxlength="10" value="<?php 
        echo date_i18n('Y-m-d', strtotime($post->post_date));
        ?>
" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" /> @ <input type="text" class="hour" placeholder="<?php 
        _e('h', 'woocommerce-bookings');
        ?>
" name="booking_date_hour" id="booking_date_hour" maxlength="2" size="2" value="<?php 
        echo date_i18n('H', strtotime($post->post_date));
        ?>
" pattern="\-?\d+(\.\d{0,})?" />:<input type="text" class="minute" placeholder="<?php 
        _e('m', 'woocommerce-bookings');
        ?>
" name="booking_date_minute" id="booking_date_minute" maxlength="2" size="2" value="<?php 
        echo date_i18n('i', strtotime($post->post_date));
        ?>
" pattern="\-?\d+(\.\d{0,})?" />
					</p>

					<?php 
        $statuses = array('unpaid' => __('unpaid', 'woocommerce-bookings'), 'pending' => __('pending', 'woocommerce-bookings'), 'confirmed' => __('confirmed', 'woocommerce-bookings'), 'paid' => __('paid', 'woocommerce-bookings'), 'cancelled' => __('cancelled', 'woocommerce-bookings'), 'complete' => __('complete', 'woocommerce-bookings'));
        ?>

					<p class="form-field form-field-wide">
						<label for="_booking_status"><?php 
        _e('Booking Status:', 'woocommerce-bookings');
        ?>
</label>
						<select id="_booking_status" name="_booking_status">
							<?php 
        foreach ($statuses as $key => $value) {
            echo '<option value="' . esc_attr($key) . '" ' . selected($key, $post->post_status, false) . '>' . esc_html__($value, 'woocommerce-bookings') . '</option>';
        }
        ?>
						</select>
					</p>

					<p class="form-field form-field-wide">
						<label for="_booking_customer_id"><?php 
        _e('Customer:', 'woocommerce-bookings');
        ?>
</label>
						<select id="_booking_customer_id" name="_booking_customer_id" class="ajax_chosen_select_customer">
							<option value=""><?php 
        _e('Guest', 'woocommerce-bookings');
        ?>
</option>
							<?php 
        if ($customer_id) {
            $user = get_user_by('id', $customer_id);
            echo '<option value="' . esc_attr($user->ID) . '" ' . selected(1, 1, false) . '>' . esc_html($user->display_name) . ' (#' . absint($user->ID) . ' &ndash; ' . esc_html($user->user_email) . ')</option>';
        }
        ?>
						</select>
					</p>

					<?php 
        do_action('woocommerce_admin_booking_data_after_booking_details', $post->ID);
        ?>

				</div>
				<div class="booking_data_column">

					<h4><?php 
        _e('Booking Specification', 'woocommerce-bookings');
        ?>
</h4>

					<?php 
        $bookable_products = array('' => __('N/A', 'woocommerce-bookings'));
        $products = WC_Bookings_Admin::get_booking_products();
        foreach ($products as $product) {
            $bookable_products[$product->ID] = $product->post_title;
            $resources = wc_booking_get_product_resources($product->ID);
            foreach ($resources as $resource) {
                $bookable_products[$product->ID . '=>' . $resource->ID] = '&nbsp;&nbsp;&nbsp;' . $resource->post_title;
            }
        }
        $product_id = get_post_meta($post->ID, '_booking_product_id', true);
        $resource_id = get_post_meta($post->ID, '_booking_resource_id', true);
        woocommerce_wp_select(array('id' => 'product_or_resource_id', 'label' => __('Booked Product', 'woocommerce-bookings'), 'options' => $bookable_products, 'value' => $resource_id ? $product_id . '=>' . $resource_id : $product_id));
        woocommerce_wp_text_input(array('id' => '_booking_parent_id', 'label' => __('Parent Booking ID', 'woocommerce-bookings'), 'placeholder' => 'N/A'));
        $persons = get_post_meta($post->ID, '_booking_persons', true);
        if (!empty($persons) && is_array($persons)) {
            echo '<br class="clear" />';
            echo '<h4>' . __('Person(s)', 'woocommerce-bookings') . '</h4>';
            foreach ($persons as $person_id => $person_count) {
                woocommerce_wp_text_input(array('id' => '_booking_person_' . $person_id, 'label' => get_the_title($person_id), 'placeholder' => '0', 'value' => $person_count, 'wrapper_class' => 'booking-person'));
            }
        }
        ?>
				</div>
				<div class="booking_data_column">

					<h4><?php 
        _e('Booking Date/Time', 'woocommerce-bookings');
        ?>
</h4>

					<?php 
        woocommerce_wp_text_input(array('id' => 'booking_start_date', 'label' => __('Start date', 'woocommerce-bookings'), 'placeholder' => 'yyyy-mm-dd', 'value' => date('Y-m-d', strtotime(get_post_meta($post->ID, '_booking_start', true))), 'class' => 'date-picker-field'));
        woocommerce_wp_text_input(array('id' => 'booking_end_date', 'label' => __('End date', 'woocommerce-bookings'), 'placeholder' => 'yyyy-mm-dd', 'value' => date('Y-m-d', strtotime(get_post_meta($post->ID, '_booking_end', true))), 'class' => 'date-picker-field'));
        woocommerce_wp_checkbox(array('id' => '_booking_all_day', 'label' => __('All day', 'woocommerce-bookings'), 'description' => __('Check this box if the booking is for all day.', 'woocommerce-bookings'), 'value' => get_post_meta($post->ID, '_booking_all_day', true) ? 'yes' : 'no'));
        woocommerce_wp_text_input(array('id' => 'booking_start_time', 'label' => __('Start time', 'woocommerce-bookings'), 'placeholder' => 'hh:mm', 'value' => date('H:i', strtotime(get_post_meta($post->ID, '_booking_start', true))), 'class' => 'datepicker'));
        woocommerce_wp_text_input(array('id' => 'booking_end_time', 'label' => __('End time', 'woocommerce-bookings'), 'placeholder' => 'hh:mm', 'value' => date('H:i', strtotime(get_post_meta($post->ID, '_booking_end', true)))));
        ?>

				</div>
			</div>
			<div class="clear"></div>
		</div>

		<?php 
        wc_enqueue_js("\n\t\t\t\t\$( '#_booking_all_day' ).change( function () {\n\t\t\t\t\tif ( \$( this ).is( ':checked' ) ) {\n\t\t\t\t\t\t\$( '#booking_start_time, #booking_end_time' ).closest( 'p' ).hide();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\$( '#booking_start_time, #booking_end_time' ).closest( 'p' ).show();\n\t\t\t\t\t}\n\t\t\t\t}).change();\n\n\t\t\t\t\$( 'select#_booking_order_id' ).ajaxChosen({\n\t\t\t\t\tmethod:         'GET',\n\t\t\t\t\turl:            '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\tdataType:       'json',\n\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\tminTermLength:  1,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\taction:   'wc_bookings_json_search_order',\n\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-booking-order') . "'\n\t\t\t\t\t}\n\t\t\t\t}, function ( data ) {\n\n\t\t\t\t\tvar orders = {};\n\n\t\t\t\t\t\$.each( data, function ( i, val ) {\n\t\t\t\t\t\torders[i] = val;\n\t\t\t\t\t});\n\n\t\t\t\t\treturn orders;\n\t\t\t\t});\n\n\t\t\t\t\$( 'select#_booking_status' ).chosen({\n\t\t\t\t\tdisable_search: true\n\t\t\t\t});\n\n\t\t\t\t\$( 'select.ajax_chosen_select_customer' ).ajaxChosen({\n\t\t\t\t\tmethod:         'GET',\n\t\t\t\t\turl:            '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\tdataType:       'json',\n\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\tminTermLength:  1,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\taction:   'woocommerce_json_search_customers',\n\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-customers') . "'\n\t\t\t\t\t}\n\t\t\t\t}, function ( data ) {\n\n\t\t\t\t\tvar terms = {};\n\n\t\t\t\t\t\$.each( data, function ( i, val ) {\n\t\t\t\t\t\tterms[i] = val;\n\t\t\t\t\t});\n\n\t\t\t\t\treturn terms;\n\t\t\t\t});\n\n\t\t\t\t\$( 'select#product_or_resource_id' ).chosen();\n\n\t\t\t\t\$( '.date-picker-field' ).datepicker({\n\t\t\t\t\tdateFormat: 'yy-mm-dd',\n\t\t\t\t\tnumberOfMonths: 1,\n\t\t\t\t\tshowButtonPanel: true,\n\t\t\t\t});\n\t\t\t");
    }
 /**
  * Filters resources for narrowing search
  */
 public function resources_filters()
 {
     $filters = array();
     $resources = WC_Bookings_Admin::get_booking_resources();
     foreach ($resources as $resource) {
         $filters[$resource->ID] = $resource->post_title;
     }
     return $filters;
 }
    public function meta_box_inner($post)
    {
        wp_nonce_field('wc_bookings_details_meta_box', 'wc_bookings_details_meta_box_nonce');
        // Scripts.
        if (version_compare(WOOCOMMERCE_VERSION, '2.3', '<')) {
            wp_enqueue_script('ajax-chosen');
            wp_enqueue_script('chosen');
        } else {
            wp_enqueue_script('wc-enhanced-select');
        }
        wp_enqueue_script('jquery-ui-datepicker');
        $customer_id = get_post_meta($post->ID, '_booking_customer_id', true);
        $order_parent_id = apply_filters('woocommerce_order_number', _x('#', 'hash before order number', 'woocommerce-bookings') . $post->post_parent, $post->post_parent);
        // Sanity check saved dates
        $start_date = get_post_meta($post->ID, '_booking_start', true);
        $end_date = get_post_meta($post->ID, '_booking_end', true);
        $product_id = get_post_meta($post->ID, '_booking_product_id', true);
        if ($start_date && strtotime($start_date) > strtotime('+ 2 year', current_time('timestamp'))) {
            echo '<div class="updated highlight"><p>' . __('This booking is scheduled over 2 years into the future. Please ensure this is correct.', 'woocommerce-bookings') . '</p></div>';
        }
        if ($product_id && ($product = get_product($product_id)) && ($max = $product->get_max_date())) {
            $max_date = strtotime("+{$max['value']} {$max['unit']}", current_time('timestamp'));
            if (strtotime($start_date) > $max_date || strtotime($end_date) > $max_date) {
                echo '<div class="updated highlight"><p>' . sprintf(__('This booking is scheduled over the products allowed max booking date (%s). Please ensure this is correct.', 'woocommerce-bookings'), date_i18n(wc_date_format(), $max_date)) . '</p></div>';
            }
        }
        if (strtotime($start_date) && strtotime($end_date) && strtotime($start_date) > strtotime($end_date)) {
            echo '<div class="error"><p>' . __('This booking has an end date set before the start date.', 'woocommerce-bookings') . '</p></div>';
        }
        ?>
		<style type="text/css">
			#post-body-content, #titlediv, #major-publishing-actions, #minor-publishing-actions, #visibility, #submitdiv { display:none }
		</style>
		<div class="panel-wrap woocommerce">
			<div id="booking_data" class="panel">

			<h2><?php 
        _e('Booking Details', 'woocommerce-bookings');
        ?>
</h2>
			<p class="booking_number"><?php 
        printf(__('Booking number: #%s.', 'woocommerce-bookings'), esc_html($post->ID));
        if ($post->post_parent) {
            $order = new WC_Order($post->post_parent);
            printf(' ' . __('Order number: %s.', 'woocommerce-bookings'), '<a href="' . admin_url('post.php?post=' . absint($post->post_parent) . '&action=edit') . '">#' . esc_html($order->get_order_number()) . '</a>');
        }
        ?>
</p>

			<div class="booking_data_column_container">
				<div class="booking_data_column">

					<h4><?php 
        _e('General Details', 'woocommerce-bookings');
        ?>
</h4>

					<p class="form-field form-field-wide">
						<label for="_booking_order_id"><?php 
        _e('Order ID:', 'woocommerce-bookings');
        ?>
</label>
						<?php 
        $order_string = '';
        if (!empty($post->post_parent)) {
            $order_string = $order_parent_id . ' &ndash; ' . esc_html(get_the_title($post->post_parent));
        }
        if (version_compare(WOOCOMMERCE_VERSION, '2.3', '<')) {
            ?>
							<select id="_booking_order_id" name="_booking_order_id" data-placeholder="<?php 
            _e('Select an order&hellip;', 'woocommerce-bookings');
            ?>
">
								<option value=""><?php 
            _e('N/A', 'woocommerce-bookings');
            ?>
</option>
								<?php 
            if ($post->post_parent) {
                echo '<option value="' . esc_attr($post->post_parent) . '" ' . selected(1, 1, false) . '>' . esc_attr($order_string) . '</option>';
            }
            ?>
							</select>
						<?php 
        } else {
            ?>
							<input type="hidden" id="_booking_order_id" name="_booking_order_id" data-placeholder="<?php 
            _e('N/A', 'woocommerce-bookings');
            ?>
" data-selected="<?php 
            echo esc_attr($order_string);
            ?>
" value="<?php 
            echo esc_attr($post->post_parent ? $post->post_parent : '');
            ?>
" data-allow_clear="true" />
						<?php 
        }
        ?>
					</p>

					<p class="form-field form-field-wide"><label for="booking_date"><?php 
        _e('Date created:', 'woocommerce-bookings');
        ?>
</label>
						<input type="text" class="date-picker-field" name="booking_date" id="booking_date" maxlength="10" value="<?php 
        echo date_i18n('Y-m-d', strtotime($post->post_date));
        ?>
" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" /> @ <input type="number" class="hour" placeholder="<?php 
        _e('h', 'woocommerce-bookings');
        ?>
" name="booking_date_hour" id="booking_date_hour" maxlength="2" size="2" value="<?php 
        echo date_i18n('H', strtotime($post->post_date));
        ?>
" pattern="\-?\d+(\.\d{0,})?" />:<input type="number" class="minute" placeholder="<?php 
        _e('m', 'woocommerce-bookings');
        ?>
" name="booking_date_minute" id="booking_date_minute" maxlength="2" size="2" value="<?php 
        echo date_i18n('i', strtotime($post->post_date));
        ?>
" pattern="\-?\d+(\.\d{0,})?" />
					</p>

					<?php 
        $statuses = array('unpaid' => __('unpaid', 'woocommerce-bookings'), 'in-cart' => __('in-cart', 'woocommerce-bookings'), 'pending-confirmation' => __('pending-confirmation', 'woocommerce-bookings'), 'confirmed' => __('confirmed', 'woocommerce-bookings'), 'paid' => __('paid', 'woocommerce-bookings'), 'cancelled' => __('cancelled', 'woocommerce-bookings'), 'complete' => __('complete', 'woocommerce-bookings'));
        ?>

					<p class="form-field form-field-wide">
						<label for="_booking_status"><?php 
        _e('Booking Status:', 'woocommerce-bookings');
        ?>
</label>
						<select id="_booking_status" name="_booking_status" class="wc-enhanced-select">
							<?php 
        foreach ($statuses as $key => $value) {
            echo '<option value="' . esc_attr($key) . '" ' . selected($key, $post->post_status, false) . '>' . esc_html__($value, 'woocommerce-bookings') . '</option>';
        }
        ?>
						</select>
					</p>

					<p class="form-field form-field-wide">
						<label for="_booking_customer_id"><?php 
        _e('Customer:', 'woocommerce-bookings');
        ?>
</label>
						<?php 
        $user_string = '';
        if (!empty($customer_id)) {
            $user = get_user_by('id', $customer_id);
            $user_string = esc_html($user->display_name) . ' (#' . absint($user->ID) . ' &ndash; ' . esc_html($user->user_email);
        }
        if (version_compare(WOOCOMMERCE_VERSION, '2.3', '<')) {
            ?>
							<select id="_booking_customer_id" name="_booking_customer_id" class="ajax_chosen_select_customer">
								<option value=""><?php 
            _e('Guest', 'woocommerce-bookings');
            ?>
</option>
								<?php 
            if ($customer_id) {
                $user = get_user_by('id', $customer_id);
                echo '<option value="' . esc_attr($customer_id) . '" ' . selected(1, 1, false) . '>' . esc_html($user_string) . ')</option>';
            }
            ?>
							</select>
						<?php 
        } else {
            ?>
							<input type="hidden" class="wc-customer-search" id="_booking_customer_id" name="_booking_customer_id" data-placeholder="<?php 
            _e('Guest', 'woocommerce-bookings');
            ?>
" data-selected="<?php 
            echo esc_attr($user_string);
            ?>
" value="<?php 
            echo $customer_id;
            ?>
" data-allow_clear="true" />
						<?php 
        }
        ?>
					</p>

					<?php 
        do_action('woocommerce_admin_booking_data_after_booking_details', $post->ID);
        ?>

				</div>
				<div class="booking_data_column">

					<h4><?php 
        _e('Booking Specification', 'woocommerce-bookings');
        ?>
</h4>

					<?php 
        $bookable_products = array('' => __('N/A', 'woocommerce-bookings'));
        $products = WC_Bookings_Admin::get_booking_products();
        foreach ($products as $product) {
            $bookable_products[$product->ID] = $product->post_title;
            $resources = wc_booking_get_product_resources($product->ID);
            foreach ($resources as $resource) {
                $bookable_products[$product->ID . '=>' . $resource->ID] = '&nbsp;&nbsp;&nbsp;' . $resource->post_title;
            }
        }
        $product_id = get_post_meta($post->ID, '_booking_product_id', true);
        $resource_id = get_post_meta($post->ID, '_booking_resource_id', true);
        woocommerce_wp_select(array('id' => 'product_or_resource_id', 'class' => 'wc-enhanced-select', 'label' => __('Booked Product', 'woocommerce-bookings'), 'options' => $bookable_products, 'value' => $resource_id ? $product_id . '=>' . $resource_id : $product_id));
        woocommerce_wp_text_input(array('id' => '_booking_parent_id', 'label' => __('Parent Booking ID', 'woocommerce-bookings'), 'placeholder' => 'N/A'));
        $saved_persons = get_post_meta($post->ID, '_booking_persons', true);
        $product = wc_get_product($product_id);
        $person_types = $product->get_person_types();
        if (!empty($person_types) && is_array($person_types)) {
            echo '<br class="clear" />';
            echo '<h4>' . __('Person(s)', 'woocommerce-bookings') . '</h4>';
            foreach ($person_types as $person_type) {
                $person_count = isset($saved_persons[$person_type->ID]) ? $saved_persons[$person_type->ID] : 0;
                woocommerce_wp_text_input(array('id' => '_booking_person_' . $person_type->ID, 'label' => $person_type->post_title, 'type' => 'number', 'placeholder' => '0', 'value' => $person_count, 'wrapper_class' => 'booking-person'));
            }
        } else {
            if (empty($person_types) && !empty($saved_persons) && is_array($saved_persons)) {
                echo '<br class="clear" />';
                echo '<h4>' . __('Person(s)', 'woocommerce-bookings') . '</h4>';
                foreach ($saved_persons as $person_id => $person_count) {
                    woocommerce_wp_text_input(array('id' => '_booking_person_' . $person_id, 'label' => get_the_title($person_id), 'type' => 'number', 'placeholder' => '0', 'value' => $person_count, 'wrapper_class' => 'booking-person'));
                }
            }
        }
        ?>
				</div>
				<div class="booking_data_column">

					<h4><?php 
        _e('Booking Date/Time', 'woocommerce-bookings');
        ?>
</h4>

					<?php 
        woocommerce_wp_text_input(array('id' => 'booking_start_date', 'label' => __('Start Date', 'woocommerce-bookings'), 'placeholder' => 'yyyy-mm-dd', 'value' => date('Y-m-d', strtotime(get_post_meta($post->ID, '_booking_start', true))), 'class' => 'date-picker-field'));
        woocommerce_wp_text_input(array('id' => 'booking_end_date', 'label' => __('End Date', 'woocommerce-bookings'), 'placeholder' => 'yyyy-mm-dd', 'value' => date('Y-m-d', strtotime(get_post_meta($post->ID, '_booking_end', true))), 'class' => 'date-picker-field'));
        woocommerce_wp_checkbox(array('id' => '_booking_all_day', 'label' => __('All Day', 'woocommerce-bookings'), 'description' => __('Check this box if the booking is for all day.', 'woocommerce-bookings'), 'value' => get_post_meta($post->ID, '_booking_all_day', true) ? 'yes' : 'no'));
        woocommerce_wp_text_input(array('id' => 'booking_start_time', 'label' => __('Start Time', 'woocommerce-bookings'), 'placeholder' => 'hh:mm', 'value' => date('H:i', strtotime(get_post_meta($post->ID, '_booking_start', true))), 'class' => 'datepicker'));
        woocommerce_wp_text_input(array('id' => 'booking_end_time', 'label' => __('End Time', 'woocommerce-bookings'), 'placeholder' => 'hh:mm', 'value' => date('H:i', strtotime(get_post_meta($post->ID, '_booking_end', true)))));
        ?>

				</div>
			</div>
			<div class="clear"></div>
		</div>

		<?php 
        if (version_compare(WOOCOMMERCE_VERSION, '2.3', '<')) {
            wc_enqueue_js("\n\t\t\t\t\t\$( 'select#_booking_status' ).chosen({\n\t\t\t\t\t\tdisable_search: true\n\t\t\t\t\t});\n\t\t\t\t\t\$( 'select#product_or_resource_id' ).chosen();\n\t\t\t\t\t\$( 'select#_booking_order_id' ).ajaxChosen({\n\t\t\t\t\t\tmethod:         'GET',\n\t\t\t\t\t\turl:            '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\t\tdataType:       'json',\n\t\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\t\tminTermLength:  1,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\taction:   'wc_bookings_json_search_order',\n\t\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-booking-order') . "'\n\t\t\t\t\t\t}\n\t\t\t\t\t}, function ( data ) {\n\n\t\t\t\t\t\tvar orders = {};\n\n\t\t\t\t\t\t\$.each( data, function ( i, val ) {\n\t\t\t\t\t\t\torders[i] = val;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn orders;\n\t\t\t\t\t});\n\t\t\t\t\t\$( 'select.ajax_chosen_select_customer' ).ajaxChosen({\n\t\t\t\t\t\tmethod:         'GET',\n\t\t\t\t\t\turl:            '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\t\tdataType:       'json',\n\t\t\t\t\t\tafterTypeDelay: 100,\n\t\t\t\t\t\tminTermLength:  1,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\taction:   'woocommerce_json_search_customers',\n\t\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-customers') . "'\n\t\t\t\t\t\t}\n\t\t\t\t\t}, function ( data ) {\n\n\t\t\t\t\t\tvar terms = {};\n\n\t\t\t\t\t\t\$.each( data, function ( i, val ) {\n\t\t\t\t\t\t\tterms[i] = val;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn terms;\n\t\t\t\t\t});\n\t\t\t\t");
        } else {
            wc_enqueue_js("\n\t\t\t\t\t\$( '#_booking_order_id' ).filter( ':not(.enhanced)' ).each( function() {\n\t\t\t\t\t\tvar select2_args = {\n\t\t\t\t\t\t\tallowClear:  true,\n\t\t\t\t\t\t\tplaceholder: \$( this ).data( 'placeholder' ),\n\t\t\t\t\t\t\tminimumInputLength: \$( this ).data( 'minimum_input_length' ) ? \$( this ).data( 'minimum_input_length' ) : '3',\n\t\t\t\t\t\t\tescapeMarkup: function( m ) {\n\t\t\t\t\t\t\t\treturn m;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tajax: {\n\t\t\t\t\t\t        url:         '" . admin_url('admin-ajax.php') . "',\n\t\t\t\t\t\t        dataType:    'json',\n\t\t\t\t\t\t        quietMillis: 250,\n\t\t\t\t\t\t        data: function( term, page ) {\n\t\t\t\t\t\t            return {\n\t\t\t\t\t\t\t\t\t\tterm:     term,\n\t\t\t\t\t\t\t\t\t\taction:   'wc_bookings_json_search_order',\n\t\t\t\t\t\t\t\t\t\tsecurity: '" . wp_create_nonce('search-booking-order') . "'\n\t\t\t\t\t\t            };\n\t\t\t\t\t\t        },\n\t\t\t\t\t\t        results: function( data, page ) {\n\t\t\t\t\t\t        \tvar terms = [];\n\t\t\t\t\t\t\t        if ( data ) {\n\t\t\t\t\t\t\t\t\t\t\$.each( data, function( id, text ) {\n\t\t\t\t\t\t\t\t\t\t\tterms.push( { id: id, text: text } );\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t            return { results: terms };\n\t\t\t\t\t\t        },\n\t\t\t\t\t\t        cache: true\n\t\t\t\t\t\t    }\n\t\t\t\t\t\t};\n\t\t\t\t\t\tselect2_args.multiple = false;\n\t\t\t\t\t\tselect2_args.initSelection = function( element, callback ) {\n\t\t\t\t\t\t\tvar data = {id: element.val(), text: element.attr( 'data-selected' )};\n\t\t\t\t\t\t\treturn callback( data );\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\$( this ).select2( select2_args ).addClass( 'enhanced' );\n\t\t\t\t\t});\n\t\t\t\t");
        }
        wc_enqueue_js("\n\t\t\t\t\$( '#_booking_all_day' ).change( function () {\n\t\t\t\t\tif ( \$( this ).is( ':checked' ) ) {\n\t\t\t\t\t\t\$( '#booking_start_time, #booking_end_time' ).closest( 'p' ).hide();\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\$( '#booking_start_time, #booking_end_time' ).closest( 'p' ).show();\n\t\t\t\t\t}\n\t\t\t\t}).change();\n\t\t\t\t\$( '.date-picker-field' ).datepicker({\n\t\t\t\t\tdateFormat: 'yy-mm-dd',\n\t\t\t\t\tnumberOfMonths: 1,\n\t\t\t\t\tshowButtonPanel: true,\n\t\t\t\t});\n\t\t\t");
    }
 /**
  * Show a filter box
  */
 public function booking_filters()
 {
     global $typenow, $wp_query;
     if ($typenow != $this->type) {
         return;
     }
     $filters = array();
     $products = WC_Bookings_Admin::get_booking_products();
     foreach ($products as $product) {
         $filters[$product->ID] = $product->post_title;
         $resources = wc_booking_get_product_resources($product->ID);
         foreach ($resources as $resource) {
             $filters[$resource->ID] = '&nbsp;&nbsp;&nbsp;' . $resource->post_title;
         }
     }
     $output = '';
     if ($filters) {
         $output .= '<select name="filter_bookings">';
         $output .= '<option value="">' . __('All Bookable Products', 'woocommerce-bookings') . '</option>';
         foreach ($filters as $filter_id => $filter) {
             $output .= '<option value="' . absint($filter_id) . '" ';
             if (isset($_REQUEST['filter_bookings'])) {
                 $output .= selected($filter_id, $_REQUEST['filter_bookings'], false);
             }
             $output .= '>' . esc_html($filter) . '</option>';
         }
         $output .= '</select>';
     }
     echo $output;
 }
				</tr>
				<tr valign="top">
					<th scope="row">
						<label for="bookable_product_id"><?php 
_e('Bookable Product', 'woocommerce-bookings');
?>
</label>
					</th>
					<td>
						<select id="bookable_product_id" name="bookable_product_id" class="chosen_select" style="width:300px">
							<option value=""><?php 
_e('Select a bookable product...', 'woocommerce-bookings');
?>
</option>
							<?php 
foreach (WC_Bookings_Admin::get_booking_products() as $product) {
    ?>
								<option value="<?php 
    echo $product->ID;
    ?>
"><?php 
    echo $product->post_title;
    ?>
</option>
							<?php 
}
?>
						</select>
					</td>
				</tr>
				<tr valign="top">
 /**
  * Provides an email notification form
  */
 public function notifications_page()
 {
     global $woocommerce;
     if (!empty($_POST) && check_admin_referer('send_booking_notification')) {
         $notification_product_id = absint($_POST['notification_product_id']);
         $notification_subject = wc_clean(stripslashes($_POST['notification_subject']));
         $notification_message = wp_kses_post(stripslashes($_POST['notification_message']));
         try {
             if (!$notification_product_id) {
                 throw new Exception(__('Please choose a product', 'woocommerce-bookings'));
             }
             if (!$notification_message) {
                 throw new Exception(__('Please enter a message', 'woocommerce-bookings'));
             }
             if (!$notification_subject) {
                 throw new Exception(__('Please enter a subject', 'woocommerce-bookings'));
             }
             $bookings = WC_Bookings_Controller::get_bookings_for_product($notification_product_id);
             $mailer = $woocommerce->mailer();
             $notification = $mailer->emails['WC_Email_Booking_Notification'];
             $attachments = array();
             foreach ($bookings as $booking) {
                 // Add .ics file
                 if (isset($_POST['notification_ics'])) {
                     $generate = new WC_Bookings_ICS_Exporter();
                     $attachments[] = $generate->get_booking_ics($booking);
                 }
                 $notification->trigger($booking->id, $notification_subject, $notification_message, $attachments);
             }
             echo '<div class="updated fade"><p>' . __('Notification sent successfully', 'woocommerce-bookings') . '</p></div>';
         } catch (Exception $e) {
             echo '<div class="error"><p>' . $e->getMessage() . '</p></div>';
         }
     }
     $booking_products = WC_Bookings_Admin::get_booking_products();
     include 'views/html-notifications-page.php';
 }