<?php
function loadView($view_path,$pageData = array(),$isLoginPage = false){
	$CI = &get_instance();

	if(isset($pageData['header'])){
		$CI->load->view('common/header',$pageData['header']);
	}else{
		$CI->load->view('common/header');
	}

	if($isLoginPage==false){
		$CI->load->view('common/sidebar');
	}

	if(isset($pageData['body'])){
		$CI->load->view($view_path,$pageData['body']);
	}else{
		$CI->load->view($view_path);
	}

	if($isLoginPage==false){
		$CI->load->view('common/footer');
	}

	

	// $userDetails = $LoginModel->checkLogin($_SESSION['isUserLoggedIn']['fsEmail']);
	// 		if(count($userDetails) < 0){
	// 			redirect(base_url('/login'));
	// 		}
}


function isUserLoggedIn(){
	$CI = &get_instance();
	
	$userLoginStatus = $CI->session->userdata('isUserLoggedIn');
	if(isset($_SESSION['isUserLoggedIn'])){
		$whereArray = array(
				'fsEmail'=>$_SESSION['isUserLoggedIn']['fsEmail'],
				'fsPassword'=> $_SESSION['isUserLoggedIn']['fsPassword']
			);
			$userDetails = $CI->db->select('*')->from('hotels')->where($whereArray)->get();
			$userDetails = $userDetails->row_array();
		if($userDetails == 0 && $_SESSION['isUserLoggedIn']['isUserType'] == 'hotel'){
			session_unset('isUserLoggedIn');
			redirect(base_url('/'));
		}
	}
	if(!empty($userLoginStatus)){
		return true;
	}else{
		return false;
	}
}

function getUserDetails(){
	$CI = &get_instance();
	return $userLoginStatus = $CI->session->userdata('isUserLoggedIn');
}
