<?php
if ( ! defined( 'ABSPATH' ) ) exit;
$bingocr_statuses = array( '', 'pending', 'confirmed', 'active', 'cancelled', 'completed' );
$bingocr_labels   = array(
	''           => __( 'All', 'bingocar' ),
	'pending'    => __( 'Pending', 'bingocar' ),
	'confirmed'  => __( 'Confirmed', 'bingocar' ),
	'active'     => __( 'Active', 'bingocar' ),
	'cancelled'  => __( 'Cancelled', 'bingocar' ),
	'completed'  => __( 'Completed', 'bingocar' ),
);
?>
<div class="wrap bingocr-admin-wrap">
	<h1><?php esc_html_e( 'Reservations', 'bingocar' ); ?></h1>

	<div class="bingocr-toolbar">
		<input type="text" id="bingocr-res-search" placeholder="<?php esc_attr_e( 'Search by name, email or reference…', 'bingocar' ); ?>" class="regular-text">
		<select id="bingocr-res-filter">
			<?php foreach ( $bingocr_statuses as $bingocr_s ) : ?>
				<option value="<?php echo esc_attr( $bingocr_s ); ?>"><?php echo esc_html( $bingocr_labels[ $bingocr_s ] ); ?></option>
			<?php endforeach; ?>
		</select>
		<button class="button" id="bingocr-res-refresh"><?php esc_html_e( 'Refresh', 'bingocar' ); ?></button>
	</div>

	<div id="bingocr-reservations-list">
		<p><?php esc_html_e( 'Loading…', 'bingocar' ); ?></p>
	</div>

	<!-- Reservation detail modal -->
	<div id="bingocr-res-modal-wrap" class="bingocr-modal-wrap" style="display:none;">
		<div class="bingocr-modal">
			<h2><?php esc_html_e( 'Reservation Details', 'bingocar' ); ?></h2>
			<div id="bingocr-res-detail"></div>
			<div class="bingocr-form-row">
				<label><?php esc_html_e( 'Status', 'bingocar' ); ?><br>
					<select id="bingocr-res-status-select">
						<?php foreach ( array_filter( $bingocr_statuses ) as $bingocr_s ) : ?>
							<option value="<?php echo esc_attr( $bingocr_s ); ?>"><?php echo esc_html( $bingocr_labels[ $bingocr_s ] ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
			</div>
			<div class="bingocr-form-actions">
				<button class="button button-primary" id="bingocr-res-save"><?php esc_html_e( 'Update Status', 'bingocar' ); ?></button>
				<button class="button" id="bingocr-res-close"><?php esc_html_e( 'Close', 'bingocar' ); ?></button>
			</div>
		</div>
	</div>
</div>
