<?php
/**
 * Template to display a View of create Eods.
 *
 * @package voidempo
 */

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

?>
<?php
if ( ! is_user_logged_in() ) {
	wp_safe_redirect( wp_login_url() );
	exit;
}
global $wpdb;

?>
		
<div class="mt-5">
	<?php
	// Nonce check for non-AJAX form submissions.
	// This will stop execution with a proper WP error if nonce is invalid.
	if ( isset( $_POST['voidempo_eod_nonce'] ) ) {
		check_ajax_referer( 'voidempo_submit_eod_action', 'voidempo_eod_nonce' );

		// Only read posted date if nonce is valid.
		$voidempo_value = isset( $_POST['voidempo_eod_date'] ) ? sanitize_text_field( wp_unslash( $_POST['voidempo_eod_date'] ) ) : gmdate( 'm/d/Y' );
	} else {
		$voidempo_value = gmdate( 'm/d/Y' );
	}


	?>
<form id="eodform">
	<h3 style="color:#000;">
		<center>EOD</center>
	</h3>
	<div class="row p-2"style="background-color: #F3F3F3; border-radius: 12px 12px 0 0; width: 100%; margin-left: 0; box-shadow: 0 -1px 12px rgb(0 0 0 / 25%); padding: 16px;">
	<div class="col-md-6">
		<div class="form-group">
			<label for="voidempo_eod_date"
			style="font-weight: 600; color: #000; margin-bottom: 6px; display:flex; font-size: 15px;"><p style="font-size:19px;margin-bottom: 0px;">📅</p> &nbsp;&nbsp;EOD Date</label>
			
			<input type="text"id="voidempo_eod_date" name="voidempo_eod_date" value="<?php echo esc_attr( $voidempo_value ); ?>"
			style="width: 100%; border-radius: 8px; border: 1px solid #a7a7a7; padding: 10px 14px; font-size: 15px; background-color: #fafafa; transition: border-color 0.3s ease;" />
		</div>
	</div>
	<div class="col-md-6">
		<div class="form-group">
			<label for="voidempo_eod_todays_hours"style="font-weight: 600; color: #000; margin-bottom: 6px; display:flex; font-size: 15px;"><p style="font-size:20px;margin-bottom: -1px;">⏱️</p> &nbsp;Today's Hours</label>
			<input type="text"id="voidempo_eod_todays_hours" name="voidempo_eod_todays_hours" style="width: 100%; border-radius: 8px; border: 1px solid #a7a7a7; padding: 10px 14px; font-size: 15px; background-color: #fff; color: #555;" readonly>
		</div>
	</div>
</div>

	<div class="voidempo_eod_task_div">
			<?php
			require VOIDEMPO_PLUGIN_PATH . '/templates/create-eodin.php';
			?>
			</div>
			<?php wp_nonce_field( 'voidempo_submit_eod_action', 'voidempo_eod_nonce' ); ?>
		</form>
	</div>

<div class="lp-ad-screen" style="display:none;">
	<span><img src="<?php echo esc_url( get_site_url() . '/wp-content/plugins/voidek-employee-portal/assets/images/loader.gif' ); ?>" alt="Loading..."></span>
</div>


