<?php
if (isset ( $_POST ['submit'] ) && $_POST ['check'] == 'date') {
	
	$awardsdate = $_POST ['date'];
	
	$final = explode ( '-', $awardsdate ['final'] );
	$awardsdate ['date1'] = $final [0];
	$awardsdate ['date2'] = $final [1];
	
	$awardsdate1 = strtotime ( $date ['date1'] );
	
	$awardsdate2 = strtotime ( $awardsdate ['date2'] );
	
	$time = $db->get_all ( 'employees' );
	
	foreach ( $time as $row ) {
		$dtime = $row ['time'];
		$awardsdatenew = date ( "d-m-Y", strtotime ( $dtime ) );
		$db_time = strtotime ( $awardsdatenew );
		
		$check = $db->exists ( 'earlier_award', array ('e_id' => $row ['e_id'] ) );
		
		if ($awardsdate1 <= $db_time && $awardsdate2 >= $db_time && $check) {
			
			$select [] = $row;
		
		} else {
			$warning = "<div class='hide1'>
				  <div id='gritter-notice-wrapper'>
					<div id='gritter-item-2' class='gritter-item-wrapper gritter-warning' style=''>
						<div class='gritter-top'></div>
						<div class='gritter-item'>
							<div class='gritter-close' id='gritterremove' style='display: inline;'></div>
								<h5>
									Oops! There Is No Data For Required Date...
								</h5>
							 <div style='clear:both'></div>
						</div>
						<div class='gritter-bottom'></div>
					</div>
				  </div>
			    </div>";
		}
	}
	if ($select == '') {
		echo $warning;
		$employee = $db->get_all ( "employees", array ('e_id' => 0 ) );
	} else {
		
		$employee = $select;
	}
} 

else {
	$employee = $db->get_all ( 'employees' );
}
?>