<?php 
// Include main file
include_once('../libs/main.php');

// Check testimonial Login
include_once('checkLogin.php');

// Logical section of testimonial
$testimonialObj =  new  testimonial();

$successMsg = '';

if(isset($_REQUEST['successMsg'])){
	$successMsg = $_REQUEST['successMsg'];
}

if(isset($_REQUEST['failedMsg'])){
	$failedMsg = $_REQUEST['failedMsg'];
}

if(isset($_REQUEST['act']) && $_REQUEST['act']=='change_status' && isset($_REQUEST['testimonial_id'])){
	
	if(isset($_REQUEST['status'])){
		$testimonialObj->changeStatus($_REQUEST['testimonial_id'],$_REQUEST['status']);
		echo 'testimonial Status changed successfully';
	}

	return true;
}

if ($_REQUEST['act']=="order"){
	$testimonialObj->changeOrder($_REQUEST['testimonial_id'],$_REQUEST['testimonial_order'],$_REQUEST['position']);
	header('Location:testimoniallist.php');
	exit;
}

if(isset($_REQUEST['act']) && $_REQUEST['act']=='delete' && isset($_REQUEST['testimonial_id'])){

	$testimonialObj->deleteRecord($_REQUEST['testimonial_id'],$_REQUEST['status']);
	$successMsg = "testimonial Deleted successfully";
}

if(isset($_REQUEST['submit'])){
	$act_val = $_REQUEST['action_val'];
	$testimonialObj->allAction($act_val,$_POST['check']);
	
	
	if($act_val=='delete_all'){
		$successMsg = "selected testimonial deleted successfully";
	}else  if($act_val=='activate_all'){
		$successMsg = "selected testimonial activated successfully";
	}else if($act_val=='inactivate_all'){
		$successMsg = "selected testimonial inactivated successfully";
	}
}


$testimonialDetails = $testimonialObj->getAllRecords('*','');

// Include Template 
include_once('../libs/routs.php')
?>