<?php
/**
 * GFB Calendar Admin View
 *
 * @package GFB.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
?>
<div class="apbgf-cal-container">
	<h3>
		<?php
		// Set your timezone
		if (isset($_POST['nonce']) && wp_verify_nonce(sanitize_text_field( wp_unslash( $_POST['nonce'] )), 'appointment-and-booking-for-gravity-forms') ) {  // none verification
			if ( isset($_POST['staff_id']) && 'all' != sanitize_text_field( wp_unslash( $_POST['staff_id'] )) ) {
				$show_timezone = apbgf_timezone_string(sanitize_text_field( wp_unslash( $_POST['staff_id'] )));
			} 
		} else {
			$show_timezone = apbgf_timezone_string();
		}
		?>
		<span class="apbgf-timezone">
		<?php 
			// Translators: %1$s is for timezon and %2$s is for appear timezon
			printf('%1$s: %2$s', esc_html__('Timezone', 'appointment-and-booking-for-gravity-forms'), esc_attr($show_timezone));
		?>
		</span>
		<?php
		if ( $disabled_prev ) {
			if ( $prev >= $curr ) {
				?>
				<a href="#" class="apbgf-month-changer apbgf-month-changer--prev" data-month="<?php echo esc_attr($prev); ?>" aria-label="<?php esc_attr_e( 'Previous month', 'appointment-and-booking-for-gravity-forms' ); ?>"><span class="apbgf-month-nav-icon" aria-hidden="true"></span></a> 
				<?php
			}
		} else {
			?>
			<a href="#" class="apbgf-month-changer apbgf-month-changer--prev" data-month="<?php echo esc_attr($prev); ?>" aria-label="<?php esc_attr_e( 'Previous month', 'appointment-and-booking-for-gravity-forms' ); ?>"><span class="apbgf-month-nav-icon" aria-hidden="true"></span></a> 
			<?php
		}
		
		$cal_title = apply_filters('apbgf_calendar_title', $html_title);
		echo esc_html( $cal_title );        

		if ( $disabled_next ) {
			if ( $next <= $prior_next ) {
				?>
				<a href="#" class="apbgf-month-changer apbgf-month-changer--next" data-month="<?php echo esc_attr($next); ?>" aria-label="<?php esc_attr_e( 'Next month', 'appointment-and-booking-for-gravity-forms' ); ?>"><span class="apbgf-month-nav-icon" aria-hidden="true"></span></a>
				<?php
			}
		} else {
			?>
			<a href="#" class="apbgf-month-changer apbgf-month-changer--next" data-month="<?php echo esc_attr($next); ?>" aria-label="<?php esc_attr_e( 'Next month', 'appointment-and-booking-for-gravity-forms' ); ?>"><span class="apbgf-month-nav-icon" aria-hidden="true"></span></a>
			<?php
		}
		?>
			</h3>
	<div class="apbgf-table-container">        
		<table class="apbgf-cal-table apbgf-cal-table-bordered">
			<tr>
				<?php
				$weekNames = apbgf_translable_name('weeks');
				if ( isset( get_option('apbgf_settings', array())['general']['gbf_start_of_week'] ) && 'sunday' == get_option('apbgf_settings', array())['general']['gbf_start_of_week'] ) {
					?>
					<th><?php echo esc_html($weekNames['sunday']); ?></th>
					<th><?php echo esc_html($weekNames['monday']); ?></th>
					<th><?php echo esc_html($weekNames['tuesday']); ?></th>
					<th><?php echo esc_html($weekNames['wednesday']); ?></th>
					<th><?php echo esc_html($weekNames['thursday']); ?></th>
					<th><?php echo esc_html($weekNames['friday']); ?></th>
					<th><?php echo esc_html($weekNames['saturday']); ?></th>
					<?php
				} else {
					?>
										<th><?php echo esc_html($weekNames['monday']); ?></th>
					<th><?php echo esc_html($weekNames['tuesday']); ?></th>
					<th><?php echo esc_html($weekNames['wednesday']); ?></th>
					<th><?php echo esc_html($weekNames['thursday']); ?></th>
					<th><?php echo esc_html($weekNames['friday']); ?></th>
					<th><?php echo esc_html($weekNames['saturday']); ?></th>
					<th><?php echo esc_html($weekNames['sunday']); ?></th>
					<?php
				}
				?>
							</tr>
			<?php
			foreach ($weeks as $week) {
				// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
				echo  $week;
			}
			?>
		</table>        
	</div>
</div>
