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

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

?>
<div class="apbgf-cal-container">
	<h3>
		<?php
		// Set your timezone
		if ( true === apply_filters('apbgf_staff_timezone_on_calendar', true) ) {
			if ( '' != $staffData['timezone'] ) {
				$show_timezone = get_post_meta($staff_id, 'timezone', true);
			} else {
				$show_timezone = apbgf_timezone_string();
			}
			?>
			<span class="apbgf-timezone"><?php 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" data-month="<?php echo esc_attr($prev); ?>"><i class="fa fa-solid fa-caret-left"></i></a> 
				<?php
			}
		} else {
			?>
			<a href="#" class="apbgf-month-changer" data-month="<?php echo esc_attr($prev); ?>"><i class="fa fa-solid fa-caret-left"></i></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" data-month="<?php echo esc_attr($next); ?>"><i class="fa fa-solid fa-caret-right"></i></a>
				<?php
			}
		} else {
			?>
			<a href="#" class="apbgf-month-changer" data-month="<?php echo esc_attr($next); ?>"><i class="fa fa-solid fa-caret-right"></i></a>
			<?php
		}
		?>
			</h3>
	<div class="apbgf-table-container">        
		<table class="apbgf-cal-table apbgf-cal-table-bordered">
			<thead>
				<tr>
					<?php
					$weekNames = apbgf_translable_name('weeks_short');
					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>
			</thead>
			<?php
			foreach ($weeks as $week) {
				// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
				echo $week;
			}
			?>
		</table>        
	</div>    
</div>
