<?php
   require $_SERVER["DOCUMENT_ROOT"].'/inc/conexao.php';
   require $_SERVER["DOCUMENT_ROOT"].'/inc/functions.php';
   require $_SERVER["DOCUMENT_ROOT"].'/api/api.php';
   if(isset($_COOKIE["usuario_id"]) && !isset($_SESSION["usuario"]) && !isset($_SESSION['auth'])){ header("Location: /auth"); exit; }
   if($_GET["page"] == 'home' && !in_array('36', $_SESSION["usuario"]["permissoes"])){ header("Location: /nova-aposta"); exit; }
   // ini_set('display_errors',1);
   // ini_set('display_startup_erros',1);
   // error_reporting(E_ALL);
?>
<!DOCTYPE html>
<html lang="pt-BR">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
      <meta name="description" content="">
      <meta name="author" content="">
      <link rel="icon" href="/images/favicon.ico">
      <title><?php echo ucwords(str_replace('-', ' ', str_replace('_', ' ', $_GET["title"]))).utf8_encode(' - '.$_SESSION["usuario"]["nome"].' - '.$_SESSION["configs"]["config_nome"]); ?> - Sistema FBET</title>
      <!-- Bootstrap 4.0-->
      <link rel="stylesheet" href="/assets/vendor_components/bootstrap/dist/css/bootstrap.css">
      <!-- Bootstrap-extend -->
      <link rel="stylesheet" href="/css/bootstrap-extend.css">
      <!-- Morris charts -->
      <link rel="stylesheet" href="/assets/vendor_components/morris.js/morris.css">
      <!-- weather weather -->
      <link rel="stylesheet" href="/assets/vendor_components/weather-icons/weather-icons.css">
      <!-- date picker -->
      <link rel="stylesheet" href="/assets/vendor_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.css">
      <!-- daterange picker -->
      <link rel="stylesheet" href="/assets/vendor_components/bootstrap-daterangepicker/daterangepicker.css">
      <!-- bootstrap wysihtml5 - text editor -->
      <link rel="stylesheet" href="/assets/vendor_plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.css">
      <!-- theme style -->
      <link rel="stylesheet" href="/css/master_style.css">
      <link rel="stylesheet" href="/css/personal.css?v=1">
      <!-- Unique_Admin skins -->
      <link rel="stylesheet" href="/css/skins/_all-skins.css">
      <link href="/assets/vendor_components/jquery-toast-plugin-master/src/jquery.toast.css" rel="stylesheet">
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body class="hold-transition skin-yellow sidebar-mini">
      <script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="0d3cd4d4-6a2b-481f-bb14-750c9b48377c";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
      <div class="wrapper">
      <header class="main-header">
         <!-- Logo -->
         <a href="/" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <b class="logo-mini">
               <?php echo utf8_encode($_SESSION["configs"]["config_nome"]); ?>
            </b>
         </a>
         <!-- Header Navbar -->
         <nav class="navbar navbar-static-top">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
            <span class="sr-only">Toggle navigation</span>
            </a>
            <div class="navbar-custom-menu">
               <ul class="nav navbar-nav">
                  <li>
                     <a href="#" style="font-size: 15px;padding: 19px 10px;display: block;"><b>Crédito: R$<?php echo formataReal($_SESSION["usuario"]["credito"]); ?></b></a>
                  </li>
                  <li class="search-box">
                     <a class="nav-link hidden-sm-down" href="javascript:void(0)"><i class="mdi mdi-magnify"></i></a>
                     <form class="app-search" style="display: none;" method="GET" action="/nova-aposta">
                        <input type="text" class="form-control" placeholder="Pesquise por um time..." name="q"> <a class="srh-btn"><i class="ti-close"></i></a>
                     </form>
                  </li>
                  <!-- Control Sidebar Toggle Button -->
                  <li>
                     <?php if(isset($_SESSION["usuario"])){ ?>
                     <a href="/sair" style="font-size: 15px;">Olá, <?php echo utf8_encode($_SESSION["usuario"]["nome"]); ?>! <b>Sair</b></a>
                     <?php } else { ?>
                     <a href="/login" style="font-size: 15px;">Entrar</a>
                     <?php } ?>
                  </li>
               </ul>
            </div>
         </nav>
      </header>

      <?php if(isset($_SESSION["msg"])){ ?>
      <div class="alert alert-<?php echo $_SESSION['tipo_msg']; ?> alert-dismissable" style="z-index: 10000; position: fixed; width: 100%; bottom: -20px; padding: 20px; ">
         <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
         <center><?php echo $_SESSION["msg"]; ?></center>
      </div>
      <?php unset($_SESSION["msg"], $_SESSION["tipo_msg"]); } ?>
