<?php

$edit = $link->hrefquery ();

if ($edit [0] == delete) {
	$deleteid = $edit [1];
	$check = $db->get_row ( 'users', array ('id' => $deleteid ) );
	
	if ($uemail == $check ['email']) {
		$query_check = $db->delete ( 'users', array ('id' => $deleteid ) );
		$session->redirect ( 'logout', Admin );
	}
	$query = $db->delete ( 'users', array ('id' => $deleteid ) );
	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">Success..
						<div class="gritter-close" id="gritterremove"
							style="display: inline;"></div>
					</span>
					<p><?php echo $check['name'];?> deleted successfully...</p>
				</div>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
	
	}
} else {
	?>
 <?php
	
	$actionid = $edit [1];
	$query1 = $db->get_row ( 'users', array ('id' => $actionid ) );
	
	if ($query1 ['suspen_id'] == 0 && $edit [0] == 'deactive_id') {
		$query2 = $db->update ( 'users', array ('suspen_id' => '1' ), array ('id' => $actionid ) );
		
		if ($query2) {
			?>
<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! Your Record Is Updated...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
		
		}
	
	} else {
		if ($edit [0] == 'active') {
			$query3 = $db->update ( 'users', array ('suspen_id' => '0' ), array ('id' => $actionid ) );
			
			if ($query3) {
				?>
<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! Your Record Is Updated...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>
<?php
			
			} else {
				echo "there are some problem in updating in '1' id";
			}
		}
	}
}
?>

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

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