<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">

<?php /* wp_head(); */ ?>
    <style>
        .table-container {
            overflow-y: auto;
            border: 1px solid #ccc;
            width: 97%;
			display: flex;
        }
        table {
            width: 100%;
            border-collapse: collapse;
			margin: 0px;
			position: relative;
			display: table;
        }
        thead th {
            position: sticky!important;
            top: 0!important;
            z-index: 1!important;
        }
        th, td {
            padding: 2px;
            text-align: left!important;
            border: 1px solid #ddd;
			display: table-cell;
        }
    </style>
</head>

<body <?php body_class(); ?>>
<div id="page" class="site">
	<div id="content" class="site-content">

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

			<?php
			$otplogedpostid = emailotpauthn_settingsdetails("emailotpauthn_otplogedpostid");
			if($otplogedpostid > 0){
				//$metavals = wp_delete_post($otplogedpostid,true);
				$metavals = get_post_meta($otplogedpostid);
				if(count($metavals)>0){
					echo '<div align="center"><h3 style="color:#990000;margin-top:10px;">'.esc_html__("Email OTP Authenticator","email-otp-authenticator").'</h3></div>';
					//echo '<pre>';
					echo '<div class="table-container"><table>';
					echo '<thead><tr><th>'.esc_html__("Time","email-otp-authenticator").'</th><th>'.esc_html__("Action","email-otp-authenticator").'</th><th style="text-align:center!important;">'.esc_html__("R.Code","email-otp-authenticator").'</th><th style="text-align:center!important;">'.esc_html__("Status","email-otp-authenticator").'</th><th>'.esc_html__("Email","email-otp-authenticator").'</th><th>'.esc_html__("Response","email-otp-authenticator").'</th></tr></thead><tbody>';
					foreach($metavals as $metakey=>$metaval){
						//echo $metaval[0] . '<br/>';
						$metarry = explode("::splitter::",$metaval[0]);
						$cntmetarry = count($metarry);
						echo '<tr>';
						for ($ii = 0; $ii < 6; $ii++){
							if($cntmetarry > $ii){
								if($ii==2 || $ii==3)
									echo '<td style="text-align:center!important;">' . $metarry[$ii] . '</td>';
								else
									echo '<td>' . $metarry[$ii] . '</td>';
							}else {
								echo '<td>'.esc_html__("Empty","email-otp-authenticator").'</td>';
							}
						}
						echo '</tr>';
					}
					echo '</tbody></table></div>';
					//echo '</pre>';
				} else {
					$otplogedpostid = -1;
				}
			} else {
				$otplogedpostid = -2;
			}
			if($otplogedpostid < 0) {
				echo '<br/><br/><br/><div align="center"><h2 style="color:#990000">'.esc_html__("Email OTP Authenticator","email-otp-authenticator").'</h2><h3>'.esc_html__("There is No Log Available.","email-otp-authenticator").'</h3></div>';
			}
			?>

		</main><!-- #main -->
	</div><!-- #primary -->

	</div><!-- #content -->

</div><!-- #page -->


</body>
</html>