<?php
/**
 * Created by PhpStorm.
 * User: roysinclair
 * Date: 2016/02/15
 * Time: 7:20 PM

 //20180514 - session ex redirect - pj

 */

	// START BY LOADING SITE CONFIG
   global $SYSTEM;
	require ('config/site.php');


	//20180514 - session ex redirect - pj
	//print_rr($_SESSION);
	if(!$_SESSION || !$_SESSION["USER"]->SYSTEM){
		header("Location: login.php");
	}
   $SYSTEM = $_SESSION["USER"]->SYSTEM;



	// LOAD includes/begin --> Contains: DocType CSS and JS
	require (INCLUDES.'/begin.php');


	if(($_SERVER["SERVER_NAME"] == "lamp" && false) || ($_SERVER["SERVER_NAME"] == "sabullion.overdriveqa.co.za" && false) || ($_SERVER["SERVER_NAME"] == "sabullion-staging.overdriveqa.co.za" && false) ){
		vd($_SERVER["SERVER_NAME"]);
		print_rr($_SESSION["USER"]);
		print_rr($_SESSION[$SYSTEM]);
	}
	// LOAD HELPER Requests -- > This will load Client Information and Templates
	require(HELPERS . '/requests.php');



	// INSERT CUSTOM CSS OR JS BEFORE </head> closing TAG
	//echo '';

	// LOAD includes/header --> Contains: Closing </head> AND Top Navigation
	require (INCLUDES.'/header.php');

	// SET THE PAGE TITLE
	//$PageTitle = $PageTitle;


	//var_dump($PageTemplate);


	// SET THE BREAD CRUMBS
	$BreadCrumbs = 'SA BULL DASH';

	// LOAD includes/container --> Contains: container-fluid and Bread Crumbs
	// NOTE: DOES NOT CLOSE container-fluid
	require (INCLUDES.'/container.php');



	// LOAD includes/sidebar --> Contains: All SideBar Information
	//vd($SYSTEM);
	if (!isset($SideBar)) {
		$SideBar = "";
	}

	if($SideBar == null || $SideBar == ""){
      switch($SYSTEM){
      	case "GLOBAL_ADMIN":
            $SideBar = "/global_admin/sidebar.php";
            break;

        case "HOUSE":
            $SideBar = "/house/sidebar.php";
            break;

        case "IFA":
            $SideBar = "/ifa/sidebar.php";
            break;

        case "CLIENT":
            $SideBar = "/client/sidebar.php";
            break;

        case "UNAPPROVED-CLIENT":
        	$PageTemplate = "/client/docs.php";
			//$PageTitle = "Documents Upload";
			$displayName = $_SESSION["USER"]->DISPLAY_NAME;
		   	$TradingName = $_SESSION["USER"]->TRADING_NAME;
			$SideBar = "/client/sidebar-new-client.php";
			$showAlert = "hidden";
            break;
      }
   }


	require (TEMPLATES.$SideBar);



	/* *
	 * LOAD THE TEMPLATES CONTENT FILES
	 * */

	// What information to request from the API
	$apiREQUEST = '';

	// Assign Page Template to Load
	//$PageTemplate = 'NUT BUNNIES';

	// LOAD includes/sidebar --> Contains: All SideBar Informationif($PageTemplate == null){
	
	require (INCLUDES.'/content.php');


	// INSERT CUSTOM CSS OR JS BEFORE </body> closing TAG
	//echo '';

	// LOAD includes/footer --> Contains: FOOTER and JS scripts
	require (INCLUDES.'/footer.php');

	// LOAD includes/end --> Contains: Contains: Closing </body> AND </html> TAGS
	require (INCLUDES.'/end.php');

?>