<?php
$getid = $link->hrefquery ();
$id = $getid [1];
if ($id != '') {
	$query = $db->delete ( 'departments', array ('id' => $id ) );
	if ($query) {
		?>
<div id="hide">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">

				<div class="gritter-without-image">
					<span class="gritter-title">Cheers..
						<div class="gritter-close" id="gritterremove"
							style="display: inline;"></div>
					</span>
					<p>Your Record Is Deleted...</p>
				</div>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
	
	} else {
		?>
<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 Are Some Problem In Deleted...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
	
	}
}
?>
<?php

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

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