<?php
$id = $link->hrefquery ();
if ($id [1] != '') {
	$getid = $id ['1'];
	
	$delete = $db->delete ( 'employees', array ('e_id' => $getid ) );
	$delete1 = $db->delete ( 'payslip', array ('empname' => $getid ) );
	$delete3 = $db->delete ( 'loan_module', array ('e_id' => $getid ) );
	$delete2 = $db->delete ( 'attendence', array ('e_id' => $getid ) );
	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, Record Are Deleted...</h5>
				<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, Record Are Not Deleted...</h5>
				<div style='clear: both'></div>
			</div>
			<div class='gritter-bottom'></div>
		</div>
	</div>
</div>
<?php
	
	}
} else {
}
?>
<?php

if (isset ( $_POST ['submit'] ) && $_POST ['check'] == 'date') {
	
	$employeedate = $_POST ['date'];
	
	$final = explode ( '-', $employeedate ['final'] );
	$employeedate ['date1'] = $final [0];
	$employeedate ['date2'] = $final [1];
	
	$employeedate1 = strtotime ( $employeedate ['date1'] );
	
	$employeedate2 = strtotime ( $employeedate ['date2'] );
	
	// $query = $db->get_col ( 'users', array ('email' => $uemail ), 'id' );
	
	$all = $db->get_all ( 'employees');
	// $db->debug();
	foreach ( $all as $row ) {
		$dtime = $row ['time'];
		$employeedatenew = date ( "d-m-Y", strtotime ( $dtime ) );
		$db_time = strtotime ( $employeedatenew );
		
		if ($employeedate1 <= $db_time && $employeedate2 >= $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;
		$all = $db->get_all ( 'employees', array ('user_id' => 0 ) );
	
	} else {
		$all = $select;
		// print_r($all);
	}
} 

else {
	$query = $db->get_col ( 'users', array ('email' => $uemail ), 'id' );
	$usertype = $db->get_col ( "users", array ("email" => $uemail ), 'type' );
	if ($usertype [0] == '0') {
		$all = $db->get_all ( 'employees', array ('user_id' => $query [0] ) );
	}
	if ($usertype [0] == '2') {
		$all = $db->get_all ( 'employees');
	}
}
?>