<?php
	require_once "config/config.php";
	require_once "config/functions.php";
	
	// connect to the Database
	makeconnection();
	
	// Session verification
	/////////////////////////////////////////////////////////////////
	$sql = "SELECT * FROM admin_log 
			WHERE session_id = '$PHPSESSID' AND ip_address = '". USER_IP ."' and ((". time() ." - times) < ". ADMIN_TIMEOUT .")";

    $rs = mysql_query($sql);
	
    if (!$rs)
    {
        redirect("logout.php");
        exit;
    }

    if (empty($_SESSION) || mysql_num_rows($rs) <= 0)
    {
        redirect("login.php");
        exit;
    }

    $sql = "UPDATE admin_log SET times = '" . time() . "' 
			WHERE session_id = '".$PHPSESSID."' and ip_address = '".USER_IP."'";

    if (!(mysql_query($sql)))
    {
        p("Update Not Set");
    }
	/////////////////////////////////////////////////////////////////
	
	include "switch.php";
	
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8"/>
<title><?php echo $rubrique_title;?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="" name="description"/>
<meta content="" name="author"/>
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/plugins.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
<link href="assets/css/custom.css" rel="stylesheet" type="text/css"/>
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="assets/plugins/data-tables/DT_bootstrap.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrap-modal/css/bootstrap-modal-bs3patch.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrap-modal/css/bootstrap-modal.css" rel="stylesheet" type="text/css"/>
<!-- END PAGE LEVEL STYLES -->
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed page-full-width">
<!-- BEGIN HEADER -->
<div class="header navbar navbar-fixed-top mega-menu">
    <!-- BEGIN TOP NAVIGATION BAR -->
    <div class="header-inner">
        <!-- BEGIN LOGO -->
        <a class="navbar-brand" href="./">
            <img src="assets/img/logo-gris.png" alt="logo" class="img-responsive"/>
        </a>
        <!-- END LOGO -->
        <!-- BEGIN HORIZANTAL MENU -->
        <?
        if($rubrique_menu!="password_change")		// ne pas afficher le menu horizontal sur la rubrique "change-password"
		{
		?>
        <div class="hor-menu hidden-sm hidden-xs">
            <ul class="nav navbar-nav">
                <li <? if($rubrique_menu=="customer") 	echo "class=\"classic-menu-dropdown active\"";?> ><a href="./?p=customer">Clients<? if($rubrique_menu=="customer") 			echo "<span class=\"selected\"></span>"; ?></a></li>
                <li <? if($rubrique_menu=="stock") 		echo "class=\"classic-menu-dropdown active\""; ?> ><a href="./?p=stock">Stock<? if($rubrique_menu=="stock") 				echo "<span class=\"selected\"></span>"; ?></a></li>
                <li <? if($rubrique_menu=="facture") 	echo "class=\"classic-menu-dropdown active\""; ?> ><a href="./?p=facture">Facturation<? if($rubrique_menu=="facture") 		echo "<span class=\"selected\"></span>"; ?></a></li>
                <li <? if($rubrique_menu=="statistic") 	echo "class=\"classic-menu-dropdown active\""; ?> ><a href="./?p=statistic">Statistiques<? if($rubrique_menu=="statistic") 	echo "<span class=\"selected\"></span>"; ?></a></li>
            </ul>
        </div>
        <?
		}
		?>
        <!-- BEGIN TOP NAVIGATION MENU -->
        <ul class="nav navbar-nav pull-right">
            <!-- BEGIN NOTIFICATION DROPDOWN -->						
            <li class="dropdown user">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
                    <span class="username hidden-1024">
                        <?php echo $_SESSION["admin_user_name"]; ?>
                    </span>
                    <i class="fa fa-angle-down"></i>
                </a>
                <ul class="dropdown-menu">
                    <li>
                        <a href="javascript:;" id="trigger_fullscreen"><i class="fa fa-arrows"></i> Full Screen</a>
                    </li>
                    <li>
                        <a href="./?p=password_change"><i class="fa fa-lock"></i> Change Password</a>
                    </li>
                    <li>
                        <a href="logout.php"><i class="fa fa-key"></i> Log Out</a>
                    </li>
                </ul>
            </li>
            <!-- END USER LOGIN DROPDOWN -->
        </ul>
        <!-- END TOP NAVIGATION MENU -->
    </div>
    <!-- END TOP NAVIGATION BAR -->
</div>
<!-- END HEADER -->
<div class="clearfix">
</div>		            
<?php include $rubrique_filename;?>

<div class="footer">
    <div class="footer-inner">
        <?php echo date("Y"); ?> &copy; SOS Recup.
    </div>
    <div class="footer-tools">
        <span class="go-top">
            <i class="fa fa-angle-up"></i>
        </span>
    </div>
</div>
<!-- END FOOTER -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
  <script src="assets/plugins/excanvas.min.js"></script>
  <script src="assets/plugins/respond.min.js"></script>  
  <![endif]-->
<script src="assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script type="text/javascript" src="assets/plugins/data-tables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="assets/plugins/data-tables/dataTables.fnReloadAjax.js"></script>
<script type="text/javascript" src="assets/plugins/data-tables/DT_bootstrap.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="assets/scripts/core/app.js"></script>
<script src="assets/scripts/custom/<?php echo $_GET["p"];?>.js"></script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>
