<?php
/*==============================================
|| ############################################# 
|| Copyright Pike Admin - www.pikeadmin.com
|| ############################################# 
==============================================*/
session_start();
require("config.php");
require_once ABSPATH."/core/checklogin.php";

$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING);
if(!$page) 
	$page = 'inicio';
$msg = filter_input(INPUT_GET, 'msg', FILTER_SANITIZE_STRING);
$pagenum = filter_input(INPUT_GET, 'pagenum', FILTER_SANITIZE_NUMBER_INT);
?>
<!DOCTYPE html>
<html>
<head>
<title>Moversa</title>
<meta name="description" content="Free Bootstrap 4 Admin Theme | Pike Admin">
<meta name="keywords" content="Bootstrap 4, admin, theme, template, pike admin">
<?php include ("global-head.php");?>
</head>

<body class="adminbody">

<div id="main">

	<?php include ("navigation.php");?>
	
	<?php
	
		//include ("sidebar.php");
		
		$user = json_decode($_SESSION['user']);

		if($user->rol === "1"){
			include ("sidebarAgenciaUser.php");
		}else{
			include ("sidebar.php");
		}
	?>
	
		<script>
	
	var json_request = {
		tipoOperacion: "consultaNombre" 
	};
	
	$.ajax({
		type: "POST",
		data: json_request,
		url: "/sippre/dataAccess/login.php",
		dataType: "json",
		async: true,
		success: function (resp) {			
			$("#spanNombreUsuario").text(resp.datos[0].nombre +" " + resp.datos[0].paterno);
		},
		error: function (xhr, ajaxOptions, thrownError) {
			console.log(xhr);
			console.log(ajaxOptions);
			console.log(thrownError);
			
		}
	});	
		
	</script>

	
    <div class="content-page">
	
		<!-- Start content -->
        <div class="content">
            
			<div class="container-fluid">

				<?php 				
				
				
					$user = json_decode($_SESSION['user']);


                    
					//Si es cliente
					if($user->rol === "1"){
					    
						switch ($page)
						{    					
							case $page:
								include ("formasAgencia/".$page.".php");
								break;					
														
							default:
								include ("formasAgencia/inicio.php");
								break;						
						}
					}else{//Si es ADMIN

						switch ($page)
						{    					
							case $page:
								include ("formas/".$page.".php");
								break;					
														
							default:
								include ("formas/inicio.php");
								break;						
						}
					}
		
		

				?>

            </div>
			<!-- END container-fluid -->

		</div>
		<!-- END content -->

    </div>
	<!-- END content-page -->
    
		
	<?php include ("footer.php");?>
</div>
<!-- END main -->

<?php include ("global-footer.php");?>

</body>
</html>