<?php
/**
 * Availability search form.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/hbfwc/availability-search.php.
 *
 * @package HBFWC\Templates
 * @version 1.0.0
 */

defined( 'ABSPATH' ) || exit;

do_action( 'hbfwc_template_before_availability_search_form', $query_args );
?>

<form id="hbfwc-availability-filter__form" method="get" action="<?php print esc_attr( $link ); ?>">
	<div class="availability-filter__dates" data-mindate="<?php print esc_attr(wp_date( 'm/d/Y', hbfwc_default_checkin_date() ) ); ?>" data-output-format="<?php print esc_attr( hbfwc_get_date_format() ); ?>">
		<input type="hidden" name="checkin" value="<?php print esc_attr( $query_args['checkin'] ); ?>" />
		<input type="hidden" name="checkout" value="<?php print esc_attr( $query_args['checkout'] ); ?>" />
		<div class="availability-filter__output availability-filter__output-dates">
			<h4 class="availability-filter__label"><?php print esc_html__( 'Checkin &amp; Checkout', 'hotel-booking-for-woocommerce' ); ?></h4>
			<div class="availability-filter__content">
				<?php print esc_html( $query_args['checkin_date']->format( hbfwc_get_date_format() ) ) . ' &ndash; ' . esc_html( $query_args['checkout_date']->format( hbfwc_get_date_format() ) ); ?>
			</div>
		</div>
	</div>
	<div class="availability-filter__room">
		<div class="availability-filter__output">
			<h4 class="availability-filter__label">
				<?php
				if ( hbfwc_show_rooms_field() ) {
					print esc_html__( 'Rooms &amp; Guests', 'hotel-booking-for-woocommerce' );
				} else {
					print esc_html__( 'Guests', 'hotel-booking-for-woocommerce' );
				}
				?>
			</h4>
			<div class="availability-filter__content">
			<?php
				if ( hbfwc_show_rooms_field() ) {
					print '<span class="availability-filter__content_span content-rooms">' . esc_html__( '1 Room', 'hotel-booking-for-woocommerce' ) . '</span>';
				}

				print '<span class="availability-filter__content_span content-adults">' . esc_html__( '1 Adult', 'hotel-booking-for-woocommerce' ) . '</span>';

				print '<span class="availability-filter__content_span content-children">' . esc_html__( '0 Children', 'hotel-booking-for-woocommerce' ) . '</span>';
			?>
			</div>
		</div>
		<div class="availability-filter__dd">
			<?php if ( hbfwc_show_rooms_field() ) : ?>
			<div>
				<label for="rooms"><?php print esc_html__( 'Rooms', 'hotel-booking-for-woocommerce' ); ?></label>
				<input type="number" name="rooms" id="rooms" class="hbfgwc-with-buttons" value="1" min="1" step="1" />
			</div>
			<?php endif; ?>
			<div>
				<label for="adults"><?php print esc_html__( 'Adults', 'hotel-booking-for-woocommerce' ); ?></label>
				<input type="number" name="adults" id="adults" class="hbfgwc-with-buttons" value="1" min="1" step="1" />			
			</div>
			<div>
				<label for="children"><?php print esc_html__( 'Children', 'hotel-booking-for-woocommerce' ); ?></label>
				<input type="number" name="children" id="children" class="hbfgwc-with-buttons" value="0" min="0" step="1" />			
			</div>
		</div>

	</div>
	<div class="availability-filter__button">
		<button type="submit" class="hbfwc-filter-button button wc-forward wp-element-button"><?php print esc_html( hbfwc_filter_button_text() ); ?></button>
	</div>
</form>

<?php
do_action( 'hbfwc_template_after_availability_search_form' );
