<?php
	header("Cache-Control: no-store, no-cache, must-revalidate");
	//REQUIRE_ONCE("PERMISSION.PHP");
	class PageCreater extends Access
	{
		var $header_string = '';
		var $page_body = '';
		var $cssIncludes='';
		var	$jsIncludes='';
		
		function outerHeader($text=''){
		    $this->page_body .= '
		    <!DOCTYPE html>
                <html lang="en">
                
                <head>
                    <!-- Required meta tags-->
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
                    <meta name="description" content="pos laravel">
                    <meta name="author" content="Samir Gotur">
                    <meta name="keywords" content="pos laravel">
                
                    <!-- Title Page-->
                    <title>'.$text.'</title>
                
                    <!-- Fontfaces CSS-->
                    <link href="'.BASE_URL.'css/font-face.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">
                
                    <!-- Bootstrap CSS-->
                    <link href="'.BASE_URL.'vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">
                
                    <!-- Vendor CSS-->
                    <link href="'.BASE_URL.'vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/wow/animate.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/slick/slick.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/select2/select2.min.css" rel="stylesheet" media="all">
                    <link href="'.BASE_URL.'vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">
                
                    <!-- Main CSS-->
                    <link href="'.BASE_URL.'css/theme.css" rel="stylesheet" media="all">
                    <style>
					
						#wait {
							margin: 0px;
							padding: 0px;
							position: fixed;
							right: 0px;
							top: 0px;
							width: 100%;
							height: 100%;
							background-color: rgb(102, 102, 102);
							z-index: 30001;
							opacity: 0.5;
							display:none;
						}
						
						#wait img {
							top: 30%;
							left: 45%;
							position: absolute;
							width: 120px;
						}
					</style>
					<script>var base_url = "'.ROOT.'";</script>
                
                </head>
                <body class="animsition">
                    <div class="page-wrapper">';
        			if($text!='remove_loader'){
        				 $this->page_body .= '<div class="ajax-wrapper" id="wait"><img src="'.IMAGE.'Ajax-loader.gif"></div>';
        			}
		}

		function includeGoogleWebFont($css)
		{
			$this->page_body .= "
				<!-- Google Web Font -->
    			<link href='".BASE_URL.$css."' rel='stylesheet' type='text/css'>
				";
		}

		function includeCustomCss($css)
		{
			$this->page_body .= '
			<link href="'.BASE_URL.$css.'" rel="stylesheet">
			';
		}
		
		function includeCustomJs($js)
		{
			$this->page_body .= '
			<script type="text/javascript" src="'.BASE_URL.$js.'?='.date('ymdhis').'"></script>
			';
		}
		function CustomJs($js)
		{
			$this->page_body .= '
			<script type="text/javascript" src="'.$js.'"></script>
			';
		}
		
		function generateBody($page_content){
			$this->page_body .= $page_content;
		}

		function endBodyContent(){
			$this->page_body .= '';
		}


		function buildPage(){
			
			return $this->page_body;
		}

		function buildFullPage($body)
		{
			$class = '';
			$header = new Header();
			$this->page_body .=$header->header($body['pageTitle']);
			if(isset($body['bodyClass']) && !empty($body['bodyClass']))
			{
				$class = $body['bodyClass'];
			}
			$this->page_body .= $this->cssIncludes;
			if(!isset($body['pageType']))
			{	
			    $sidebar = new SideBar();
				if(isset($body['parentPage']) && $body['parentPage']){
				$this->page_body .=$sidebar->side_bar($body['parentPage']);	
				}else{
				$this->page_body .=$sidebar->side_bar($body['pageTitle']);
				}
			}
			
			if(isset($body['customcss']) && !empty($body['customcss']))
			{
				$customCount = count($body['customcss']);
				$customcss = $body['customcss'];
				for($cusjs=0;$customCount>$cusjs;$cusjs++)
				{
					$cssname=  $customcss[$cusjs];
					$this->includeCustomCss($cssname);
				}
			}
			$this->generateBody($body['content']);	
			
			$this->endBodyContent();
		
			
			$this->page_body .= $this->jsIncludes;
		
			if(isset($body['custom_js']) && !empty($body['custom_js']))
			{
				$customCount = count($body['custom_js']);
				$customjs = $body['custom_js'];
				for($cusjs=0;$customCount>$cusjs;$cusjs++)
				{
					$pluginName=  $customjs[$cusjs];
					$this->CustomJs($pluginName);
				}
			}
			if(isset($body['customjs']) && !empty($body['customjs']))
			{
				$customCount = count($body['customjs']);
				$customjs = $body['customjs'];
				for($cusjs=0;$customCount>$cusjs;$cusjs++)
				{
					$pluginName=  $customjs[$cusjs];
					$this->includeCustomJs($pluginName);
				}
			}
			$footer = new Footer();
			$this->page_body .=$footer->footer();
			return $this->buildPage();
		}
		
		function buildOuterPage($body)
		{
			$class = '';
			$this->outerHeader($body['pageTitle']);
			if(isset($body['bodyClass']) && !empty($body['bodyClass']))
			{
				$class = $body['bodyClass'];
			}
			$this->page_body .= $this->cssIncludes;
			if(!isset($body['pageType']))
			{	
			    $sidebar = new SideBar();
				if($body['parentPage']){
				$this->page_body .=$sidebar->side_bar($body['parentPage']);	
				}else{
				$this->page_body .=$sidebar->side_bar($body['pageTitle']);
				}
			}
			
			if(isset($body['customcss']) && !empty($body['customcss']))
			{
				$customCount = count($body['customcss']);
				$customcss = $body['customcss'];
				for($cusjs=0;$customCount>$cusjs;$cusjs++)
				{
					$cssname=  $customcss[$cusjs];
					$this->includeCustomCss($cssname);
				}
			}
			$this->generateBody($body['content']);	
			
			$this->endBodyContent();
		
			
			$this->page_body .= $this->jsIncludes;
		
			if(isset($body['custom_js']) && !empty($body['custom_js']))
			{
				$customCount = count($body['custom_js']);
				$customjs = $body['custom_js'];
				for($cusjs=0;$customCount>$cusjs;$cusjs++)
				{
					$pluginName=  $customjs[$cusjs];
					$this->CustomJs($pluginName);
				}
			}
			if(isset($body['customjs']) && !empty($body['customjs']))
			{
				$customCount = count($body['customjs']);
				$customjs = $body['customjs'];
				for($cusjs=0;$customCount>$cusjs;$cusjs++)
				{
					$pluginName=  $customjs[$cusjs];
					$this->includeCustomJs($pluginName);
				}
			}
			$footer = new Footer();
			$this->page_body .=$footer->footer();
			return $this->buildPage();
		}
		function buildModalPage($body)
		{
			$this->generateBody($body['content']);	
			$this->page_body .= $this->jsIncludes;
			return $this->buildPage();
		}
		function buildFullModalPage($body)
		{
			$sidebar = new SideBar();
			$sidebar->side_bar();
			$this->generateBody($body['content']);	
			$this->endBodyContent();
			$this->page_body .= $this->jsIncludes;
			return $this->buildPage();
		}
	}
?>
