<?php
/*
* date last modified 03-10-2017
* Edited by PI-Digi Logical Solutions
* HTML Files - manage_staff.html.php
* Mysql Tables - tbl_admin, tbl_purchase_order, tbl_admin_type
*/
require_once('./classes/class.noseo_pagination.php'); # pagination class
require_once('./includes/functions.php'); # general functions

if(isset($_REQUEST['p']) && $_REQUEST['p']!=''){
	$p = trim($_REQUEST['p']);
} else {
	$p = 1;
}

if(isset($_REQUEST['user_id']) && $_REQUEST['user_id']!=''){
	$userId = trim($_REQUEST['user_id']);
} else {
	?>
	        <script language="javascript" type="text/javascript">			
				window.location='index.php?page=manage_user';
			</script>
 <?php 
}

if(isset($_GET['action']) && $_GET['action'] == 'activate') {	
	if(isset($_GET['id']) && $_GET['id']!=''){
		$update = mysqli_query($con,"UPDATE tbl_tech_review SET status = '' WHERE id='".$_GET['id']."'");
		if($update) {
			$success = 'The review has been enabled';
			?>
	        <script language="javascript" type="text/javascript">			
				window.location='index.php?page=<?php echo $page;?>&user_id=<?php echo $userId; ?>&success=<?php echo $success; ?>';
			</script>
	        <?php
		}
	}
}

if(isset($_GET['action']) && $_GET['action'] == 'disable') {	
	if(isset($_GET['id']) && $_GET['id']!=''){
		$update = mysqli_query($con,"UPDATE tbl_tech_review SET status = 'disabled' WHERE id='".$_GET['id']."'");
		if($update) {
			$success = 'The review has been disabled';
			?>
	        <script language="javascript" type="text/javascript">			
				window.location='index.php?page=<?php echo $page;?>&user_id=<?php echo $userId; ?>&success=<?php echo $success; ?>';
			</script>
	        <?php
		}
	}
}

if(isset($_GET['action']) && $_GET['action'] == 'delete') {	
	if(isset($_GET['del_id']) && $_GET['del_id']!=''){
		$delete = mysqli_query($con,'DELETE FROM tbl_tech_review WHERE id='.$_GET['del_id']);
		if($delete) {
			$success = 'Deleted the review';
			?>
	        <script language="javascript" type="text/javascript">			
				window.location='index.php?page=<?php echo $page;?>&user_id=<?php echo $userId; ?>&success=<?php echo $success; ?>';
			</script>
	        <?php
		}
	}
}

$pageVars = '';


$select = "SELECT * FROM tbl_tech_review WHERE user_id = '".$userId."' ORDER BY id DESC";
//echo $select;
// Using pagination class
$pagination = new pagination_noseo($select);
$execDetails = $pagination->createPages(30);

$pageLnk = 'index.php?page='.$page.'&'.$pageVars;
$pageNums = $pagination->pageNumber(5, $pageLnk);
?>