<?php
$getid = $link->hrefquery ();
if ($getid [0] == 'delete') {
	$delete = $db->delete ( "earlier_award", array ("id" => $getid [1] ) );
	
	if ($delete) {
		?>
<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>Cheers! Deleted Successfully...</h5>
				<div style='clear: both'></div>
			</div>
			<div class='gritter-bottom'></div>
		</div>
	</div>
</div>
<?php
	
}

}
?>
<?php

if (isset ( $_POST ['submit'] ) && $_POST ['check'] == 'date') {
	
	$earlier = $_POST ['date'];
	
	$final = explode ( '-', $earlier ['final'] );
	$earlier ['date1'] = $final [0];
	$earlier ['date2'] = $final [1];
	
	$earlier1 = strtotime ( $earlier ['date1'] );
	
	$earlier2 = strtotime ( $earlier ['date2'] );
	
	$query = $db->get_all ( 'earlier_award' );
	
	foreach ( $query as $row ) {
		$dtime = $row ['time'];
		$earliernew = date ( "d-m-Y", strtotime ( $dtime ) );
		$db_time = strtotime ( $earliernew );
		
		if ($earlier1 <= $db_time && $earlier2 >= $db_time) {
			
			$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;
		$query = $db->get_all ( "earlier_award", array ('id' => 0 ) );
	} else {
		$query = $select;
	}
} 

else {
	$query = $db->get_all ( 'earlier_award' );
}
?>