<?php 

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

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

// Logical section of page
$adminObj =  new  admin();

$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['admin_id'])){
	
	if(isset($_REQUEST['status'])){
		$adminObj->changeStatus($_REQUEST['admin_id'],$_REQUEST['status']);
		echo 'Admin Status changed successfully';
	}

	return true;
}

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

	$adminObj->deleteRecord($_REQUEST['admin_id'],$_REQUEST['status']);
	$successMsg = "Admin Deleted successfully";
}

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

if(isset($_POST['search_submit']) && $_POST['search_input']!=''){
	$searchStr = " admin_fname LIKE '".$_POST['search_input']."%'  OR admin_lname LIKE '".$_POST['search_input']."%'  OR  admin_email_address LIKE '".$_POST['search_input']."%' ";
}

$adminDetails = $adminObj->getAllRecords("*",$searchStr);

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

?>