<?php
include "../../../wp-config.php";
if (!is_user_logged_in() ) {
    // exit();
}

echo "<h3>60 Days License Expiry Alerts</h3>";
$expiry_date = gmdate("Ymd", strtotime('+ 4 hours')); // UAE +4
display_expiry_data("license", $expiry_date,0);

function display_expiry_data($type, $expiry_date,$days){
	$args = array(
		'post_type'      => 'cus_rec', 'posts_per_page' => 10000, 'meta_query'     => array(
			array('key'     => $type.'_expiry_date','value'   => array($expiry_date,$expiry_date+$days),'compare' => 'BETWEEN','type'    => 'NUMERIC',), ),
		);
		 print_r ($args);
		// echo "<br/>";
	$query = new WP_Query($args);?>
	<table>
		<tr>
				<td><strong>Name</strong></td>
				<td><strong>Email</strong></td>
				<td><strong>Cell number</strong></td>
				<td><strong>Expiry date</strong></td>
			<tr>
	<?php
	while ($query->have_posts()) : $query->the_post();
		?><tr>
				<td><?php echo get_the_title();?></td>
				<td><?php echo get_field("email");?></td>
				<td><?php echo get_field("cell_number");?></td>
				<td><?php echo get_field($type."_expiry_date");?></td>
			<tr><?php
	endwhile;
	?>

	<table>
	<?php
}
?>
