<?php
session_start();
//--------------------  check session ----------------
if (empty($_SESSION['user_id'])) {
	echo '<script>window.location="index.php";</script>';
	exit();
}
//-------------------- check url params and sesstion -----------------
//-------------------- check url params and sesstion -----------------
include 'get_controller.php';
$dataSend = array();




$login_status = checkAccountActivateDeactivate1($_SESSION['user_id']);

//echo "<pre> i m line no 18=";print_r($login_status);die; 

if ($login_status == 0) {
	unset($_SESSION['user_id']);
	echo '<script>
    alert("Your Account is Deactive By Admin!");
    window.location.href="index.php";
    </script>';
}
//----------------------------- get Admin Profile ----------------------
$dataSend = array('action' => 'edit_admin_profile', 'id' => $_SESSION['user_id']);
$getData = getEditAdminProfile($dataSend);
$getEditDataAll = json_decode($getData, true);
if ($getEditDataAll['success'] <= 0) {
	echo '<script>window.location="dashboard.php";</script>';
}
$getEditDataAdmin  = $getEditDataAll['data'];
//----------------------------- get Admin Profile end ----------------------
$page_name = basename($_SERVER['PHP_SELF']);
if ($page_name == 'dashboard.php') {
	$dataSend = array('action' => 'get_dashboard', 'id' => $_SESSION['user_id']);
	$getData = getDashboard($dataSend);
	$getEditDataAll = json_decode($getData, true);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getDataDashboard  = $getEditDataAll['data'];
} else if ($page_name == 'profile.php') {

	$dataSend = array('action' => 'edit_admin_profile', 'id' => $_SESSION['user_id']);
	$getData = getEditAdminProfile($dataSend);
	$getEditDataAll = json_decode($getData, true);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];
// print_r($getEditData);exit();
} else if ($page_name == 'manage_contents.php') {
	$dataSend = array('action' => 'get_content', 'id' => $_SESSION['user_id']);
	$getData = getContent($dataSend);
	$getEditDataAll = json_decode($getData, true);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];
	// echo "<pre>";
	// print_r($getEditData);
} else if ($page_name == 'view_user.php' ||$page_name == 'view_user1.php' || $page_name == 'view_deleted_user.php' ||$page_name == 'change_user_password.php') {
	$dataSend = array('id' => $_GET['id']);
	$getData = getViewUsersData($dataSend);
	$getUsersDataAll = json_decode($getData, true);
	if ($getUsersDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getUsersData  = $getUsersDataAll['data'];

	 // echo "<pre>";
	 // print_r($getUsersData);
	 // exit;

	  

}




 else if ($page_name == 'manage_broadcast.php') {
	$dataSend = array('action' => 'get_broadcast', 'id' => $_SESSION['user_id']);
	$getData = getBroadcast($dataSend);
	$getEditDataAll = json_decode($getData, true);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];
	  //echo '<pre>';print_r($getEditData);exit;
} else if ($page_name == 'contact_us_reply.php') {
	$dataSend = array('id' => $_GET['id']);
	$getData = getContactUsDataById($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];
}
//-----------------new code starts------------------------------------------------------//

else if ($page_name == 'add_subadmin.php') {
	
	$getData = getRoleData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getEditData);
	 // exit;
}


else if ($page_name == 'add_equipment.php') {

	
	
	$getData = getEquipmentTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getEditData);
	 // exit;
}

else if ( $page_name == 'edit_equipment.php') {

	$dataSend = array('equipment_id' => $_GET['id']);

	$getData = getEquipmentData($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditEqData  = $getEditDataAll['data'];
	
	$getData = getEquipmentTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getEditEqData);
	 // exit;
}

else if ($page_name == 'view_equipment_type.php') {

	$dataSend = array('equipment_type_id' => $_GET['id']);
	
	$getData = getEquipmentTypeDataall($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getEditData);
	 // exit;
}

else if ($page_name == 'add_inspection.php') {

	
	
	$getData = getEquipmentTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData1  = $getEditDataAll['data'];

	$getData = getUserEnginnerData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	$getData = getInspectionTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData2  = $getEditDataAll['data'];


	 // echo "<pre>";
	 // print_r($getEditData);
	 // exit;
}


else if ( $page_name == 'edit_inspection.php' ) {

	$dataSend = array('inspection_id' => $_GET['id']);

	$getData = getInspectionData($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditEqData  = $getEditDataAll['data'];
	
	$getData = getEquipmentTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData1  = $getEditDataAll['data'];

	$getData = getUserEnginnerData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	$getData = getInspectionTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData2  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getEditEqData);
	 // exit;
}


else if ($page_name == 'add_maintainance.php') {

	
	
	$getData = getEquipmentTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getEditData);
	 // exit;
}


else if ( $page_name == 'edit_maintainance.php') {

	$dataSend = array('maintainance_id' => $_GET['id']);

	$getData = getMaintainanceData($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditEqData1  = $getEditDataAll['data'];
	 // echo "<pre>";
	 // print_r($getEditEqData1);
	 // exit;
	
	$getData = getEquipmentTypeData();
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getEditData  = $getEditDataAll['data'];

	




	 // echo "<pre>";
	 // print_r($getEditData1);
	 // exit;
}

else if ($page_name == 'view_inspection.php' || $page_name == 'edit_inspection_request.php' || $page_name == 'view_inspection_request.php') {

	
	$dataSend = array('inspection_id' => $_GET['id']);
	$getData = getInspectionDataByID($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getUsersData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getUsersData);
	 // exit;
}


else if ($page_name == 'view_inspection_history.php') {

	
	$dataSend = array('inspection_id' => $_GET['id']);
	$getData = getInspectionHistoryDataByID($dataSend);
	$getEditDataAll = json_decode($getData, true);
	//echo 'data=='.print_r($getEditDataAll);
	if ($getEditDataAll['success'] <= 0) {
		echo '<script>window.location="dashboard.php";</script>';
	}
	$getUsersData  = $getEditDataAll['data'];

	 // echo "<pre>";
	 // print_r($getUsersData);
	 // exit;
}





 
 










  





 
