<?php
/**
 * Goodmeet google meet single Template sidebar
 *
 * @package goodmeet
 */

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

?>

<div class="goodmeet-sidebar-col">
	<div class="goodmeet-sidebar">
		<div class="goodmeet-single-widget goodmeet-single-widget-countdown">
			<h4 class="goodmeet-widget-title"><?php esc_html_e( 'Time to go', 'goodmeet' ); ?></h4>
			<div class="goodmeet-widget-inner">

					<?php if ( 'end' !== $goodmeet_meeting_status ) { ?>
						<?php if ( $goodmeet_is_schedule ) { ?>
							<div class="goodmeet-start_time" data-meeting-start-time="<?php echo esc_attr( $goodmeet_next_meeting_time ); ?>" data-meeting-time-offset="<?php echo esc_attr( $goodmeet_gmt_offset_val ); ?>" > </div>
							<?php } else { ?>
								<span class="goodmeet-countdown-wrapper">
									<span class="goodmeet-countdown-value"><?php esc_html_e( 'Meeting is running', 'goodmeet' ); ?></span>
									<span class="goodmeet-countdown-label"><?php esc_html_e( 'The meeting is started and running', 'goodmeet' ); ?></span>
								</span>
							<?php } ?>
					<?php } else { ?>
						<span class="goodmeet-countdown-wrapper">
							<span class="goodmeet-countdown-value"><?php esc_html_e( 'Meeting is finished', 'goodmeet' ); ?></span>
							<span class="goodmeet-countdown-label"><?php esc_html_e( 'This meeting has been ended by the host.', 'goodmeet' ); ?></span>
						</span>
					<?php } ?>
			</div>
		</div>

		<?php if ( current_user_can( 'manage_options' ) ) { ?>
			<div class="goodmeet-single-widget goodmeet-single-widget-host-actions">
				<div class="goodmeet-widget-inner">
					<?php if ( 'end' !== $goodmeet_meeting_status ) { ?>
					<button  class="goodmeet-meeting-status" data-meeting-status="end" data-post-id="<?php echo esc_attr( $post->ID ); ?>" data-meeting-id="<?php echo esc_attr( $goodmeet_meeting_id ); ?>"><?php esc_html_e( 'End Meeting ?', 'goodmeet' ); ?>
					</button>
				<?php } else { ?>
					<button  class="goodmeet-meeting-status" data-meeting-status="resume" data-post-id="<?php echo esc_attr( $post->ID ); ?>" data-meeting-id="<?php echo esc_attr( $goodmeet_meeting_id ); ?>"><?php esc_html_e( 'Enable Meeting Join ?', 'goodmeet' ); ?>
					</button>
				<?php } ?>
					<p><?php esc_html_e( 'You are seeing this because you are the author of this meeting', 'goodmeet' ); ?></p>
				</div>
			</div>
		<?php } ?>

		<div class="goodmeet-single-widget goodmeet-single-widget-detail">
			<h4 class="goodmeet-widget-title"><?php esc_html_e( 'Details', 'goodmeet' ); ?></h4>
			<div class="goodmeet-widget-inner">
				<dl>
					<dt><?php esc_html_e( 'Topic:', 'goodmeet' ); ?></dt>
					<dd><?php echo esc_html( the_title() ); ?></dd>
					<dt><?php esc_html_e( 'Hosted By:', 'goodmeet' ); ?></dt>
					<dd>
					<?php
						echo esc_html( $goodmeet_current_user_name );
					?>
					</dd>
					<?php if ( $goodmeet_options['enable_recurring_meeting'] && goodmeet_fs()->can_use_premium_code__premium_only() && function_exists( 'goodmeet_pro_get_recurrence_description' ) ) { ?>
					<dt><?php esc_html_e( 'Meeting recurrence:', 'goodmeet' ); ?></dt>
					<dd> <?php echo esc_html( $goodmeet_recurrence_info ); ?> </dd>
					<?php } ?>

					<dt><?php esc_html_e( 'Start Time:', 'goodmeet' ); ?></dt>
					<dd class="mhbu-tm">
					<?php
					echo esc_html( gmdate( 'l, F j, Y g:i A', strtotime( $goodmeet_start_time ) ) );
					?>
					</dd>

					<dt><?php esc_html_e( 'Duration:', 'goodmeet' ); ?></dt>
					<dd class="goodmeet-duration">
						<?php
						if ( 60 <= $goodmeet_meeting_duration ) {
							$goodmeet_hours   = floor( $goodmeet_meeting_duration / 60 );
							$goodmeet_minutes = $goodmeet_meeting_duration % 60;

							// Get the correct translation for "hour" or "hours".
							$goodmeet_hour_text   = ( 1 === $goodmeet_hours ) ? __( 'hour', 'goodmeet' ) : __( 'hours', 'goodmeet' );
							$goodmeet_minute_text = ( 1 === $goodmeet_minutes ) ? __( 'minute', 'goodmeet' ) : __( 'minutes', 'goodmeet' );

							// Print hours.
							echo esc_html( number_format_i18n( $goodmeet_hours ) ) . ' ' . esc_html( $goodmeet_hour_text );

							// Print minutes if greater than 0.
							if ( $goodmeet_minutes > 0 ) {
								echo ' ' . esc_html( number_format_i18n( $goodmeet_minutes ) ) . ' ' . esc_html( $goodmeet_minute_text );
							}
						} else {
							// Get the correct translation for "minute" or "minutes".
							$goodmeet_minute_text = ( 1 === (int) $goodmeet_meeting_duration ) ? __( 'minute', 'goodmeet' ) : __( 'minutes', 'goodmeet' );

							// Print minutes only.
							echo esc_html( number_format_i18n( $goodmeet_meeting_duration ) ) . ' ' . esc_html( $goodmeet_minute_text );
						}
						?>
					</dd>

					<dt><?php esc_html_e( 'Current Timezone:', 'goodmeet' ); ?></dt>
					<dd class="goodmeet-tz">
					<?php
						echo esc_html( $goodmeet_time_zone );
					?>
					</dd>

				</dl>
			</div>
		</div>

		<?php
		if ( goodmeet_fs()->can_use_premium_code__premium_only() && ! empty( $goodmeet_integration_settings ) && ! empty( $goodmeet_integration_settings['google_calendar'] ) ) {
			require_once GOODMEET_PRO_INCLUDES . '/Templates/goodmeet-calander.php';
		}
		?>

		<div class="goodmeet-buy-btn-wpapper">
			<?php
			if ( ! empty( $goodmeet_product_id ) && 'yes' === $goodmeet_meeting_as_product && ! current_user_can( 'manage_options' ) ) {
				$goodmeet_product_link = get_permalink( $goodmeet_product_id );
				?>
				<a href="<?php echo esc_url( $goodmeet_product_link ); ?>" class="goodmeet-buy-button" target="__blank"> <?php esc_attr_e( 'Buy Now !', 'goodmeet' ); ?></a>

			<?php } ?>
		</div>
	</div>
</div>
