<?php
/**
 * Smart Report Maker
 * Version 9.0.0
 * Author : Webuccino
 * All copyrights are preserved to Webuccino
 * URL : http://mysqlreports.com/
 */
/*
 * #################################################################################################
 * Enable and disable steps to ease navigation , and prevent direct access
 * ################################################################################################
 */

defined ( 'DIRECTACESS' ) or die ( "Error 301: Access denied!" );
	
	// check and set last page in array for navigation reason
    //which step to be disabled
if(!$_SESSION[Session_wizard_key]["edit_mode"]){
    //case insert
	if(isset($_SESSION[Session_wizard_key]['page_key']) && in_array($_SESSION[Session_wizard_key]['page_key'], $pagesName)){
		if((isset($_SESSION[Session_wizard_key]['active_pages']) && is_array($_SESSION[Session_wizard_key]['active_pages']) 
			&& !in_array($_SESSION[Session_wizard_key]['page_key'], $_SESSION[Session_wizard_key]['active_pages'])) || !isset($_SESSION[Session_wizard_key]['active_pages']))
		{
			if(isset($_SESSION[Session_wizard_key]['active_pages'])) 
			{
				$keyOfLastActivePage = array_search($_SESSION[Session_wizard_key]['active_pages'][(count($_SESSION[Session_wizard_key]['active_pages']) - 1)], $pagesName);
				$keyOfCurrentPage = array_search($_SESSION[Session_wizard_key]['page_key'], $pagesName);
				if($keyOfLastActivePage < $keyOfCurrentPage) $_SESSION[Session_wizard_key]['active_pages'][] = $_SESSION[Session_wizard_key]['page_key'];
			}
			else $_SESSION[Session_wizard_key]['active_pages'][] = $_SESSION[Session_wizard_key]['page_key'];
		}
	}
}else{
    //case edit
         $_SESSION[Session_wizard_key]["page_key"] = 'step_2';
		$_SESSION[Session_wizard_key]["active_pages"] = array (
				"step_6"
		);
}