<?php
if (strlen(session_id()) < 1)
  session_start();
?>
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title> HC MEDICA</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.5 -->
  <link rel="stylesheet" href="../public/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../public/css/font-awesome.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../public/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="../public/css/_all-skins.min.css">
  <link rel="apple-touch-icon" href="../public/img/apple-touch-icon.png">
  <link rel="shortcut icon" href="../public/img/favicon.ico">

  <!-- DATATABLES -->
  <link rel="stylesheet" type="text/css" href="../public/datatables/jquery.dataTables.min.css">
  <link href="../public/datatables/buttons.dataTables.min.css" rel="stylesheet" />
  <link href="../public/datatables/responsive.dataTables.min.css" rel="stylesheet" />
  <link href="../public/css/dropdown.css" rel="stylesheet" />

  <link rel="stylesheet" type="text/css" href="../public/css/bootstrap-select.min.css">
  <link rel="stylesheet" type="text/css" href="../public/css/msp_formatos.css?v=<?php echo time(); ?>">

  <!-- SELECT2 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  <style>
    /* Fix Select2 in Bootstrap */
    .select2-container .select2-selection--single {
      height: 34px !important;
    }

    .select2-container--default .select2-selection--single {
      border: 1px solid #ccc !important;
      border-radius: 0 !important;
    }
  </style>

  <!-- jQuery UI for Autocomplete -->
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <!-- Estilos Personalizados HC MEDICA -->
  <style>
    .skin-blue .main-header .navbar {
      background-color: #00aced !important;
    }

    .skin-blue .main-header .logo {
      background-color: #0088cc !important;
    }

    .skin-blue .main-header .logo:hover {
      background-color: #0077b3 !important;
    }

    .skin-blue .sidebar-menu>li.header {
      color: #8aa4af;
      background: #1a2226;
    }

    .skin-blue .sidebar-menu>li>a {
      border-left: 3px solid transparent;
    }

    .skin-blue .sidebar-menu>li:hover>a,
    .skin-blue .sidebar-menu>li.active>a {
      color: #fdfdfd;
      background: #1e282c;
      border-left-color: #00aced;
    }

    .main-sidebar {
      background-color: #222d32 !important;
      font-family: 'Outfit', sans-serif !important;
    }

    .content-wrapper {
      background-color: #f4f7f6 !important;
    }

    .btn-primary {
      background-color: #00aced !important;
      border-color: #0099d3 !important;
    }

    .btn-primary:hover {
      background-color: #0099d3 !important;
    }

    .box.box-primary {
      border-top-color: #00aced !important;
    }
  </style>

  <script src="../public/plugins/chartjs/Chart.min.js"></script>
  <!-- Driver.js (tutorial guiado) -->
  <link rel="stylesheet" href="../public/driver/driver.css">
  <!-- Persistencia del sidebar (localStorage por dispositivo) -->
  <script src="scripts/sidebar_persist.js"></script>
</head>

<body class="hold-transition skin-blue sidebar-mini">
  <div class="wrapper">

    <header class="main-header">

      <!-- Logo -->
      <a href="escritorio.php" class="logo">
        <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini"><b>HC</b></span>
        <!-- logo for regular state and mobile devices -->
        <span class="logo-lg"><b>HC MEDICA</b></span>
      </a>

      <!-- Header Navbar: style can be found in header.less -->
      <nav class="navbar navbar-static-top" role="navigation">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
          <span class="sr-only">Navegación</span>
        </a>
        <!-- Navbar Right Menu -->
        <div class="navbar-custom-menu">
          <ul class="nav navbar-nav">
            <!-- Messages: style can be found in dropdown.less-->

            <!-- INVENTARIO ALERTA MENU (NUEVO) -->
            <li class="dropdown tasks-menu" id="inventory-alerts-menu">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <i class="fa fa-warning"></i>
                <span class="label label-danger" id="alert-count"></span>
              </a>
              <ul class="dropdown-menu">
                <li class="header" id="alert-header">No hay alertas</li>
                <li>
                  <!-- inner menu: contains the actual data -->
                  <ul class="menu" id="alert-list">
                    <!-- JS will populate this -->
                    <li><a href="#"><i class="fa fa-spinner fa-spin"></i> Cargando alertas...</a></li>
                  </ul>
                </li>
                <li class="footer">
                  <a href="inventario.php">Ver Inventario Completo</a>
                </li>
              </ul>
            </li>

            <!-- Notifications Menu -->
            <li class="dropdown notifications-menu">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <i class="fa fa-bell-o"></i>
                <span class="label label-warning" id="notif-count"></span>
              </a>
              <ul class="dropdown-menu">
                <li class="header" id="notif-header">No hay notificaciones</li>
                <li>
                  <!-- inner menu: contains the actual data -->
                  <ul class="menu" id="notif-list">
                    <!-- JS will populate this -->
                  </ul>
                </li>
              </ul>
            </li>

            <!-- User Account: style can be found in dropdown.less -->
            <li class="dropdown user user-menu">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">

                <span class="hidden-xs"><?php echo $_SESSION['nombre']; ?></span>
              </a>
              <ul class="dropdown-menu">
                <!-- User image -->
                <li class="user-header">

                  <p>
                    HC MEDICA
                    <small>Evolución digital de tu consulta</small>
                  </p>
                </li>

                <!-- Menu Footer-->
                <li class="user-footer">

                  <div class="pull-right">
                    <a href="../ajax/usuario.php?op=salir" class="btn btn-default btn-flat">Cerrar</a>
                  </div>
                </li>
              </ul>
            </li>

          </ul>
        </div>

      </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
      <!-- sidebar: style can be found in sidebar.less -->
      <section class="sidebar">
        <!-- sidebar menu: : style can be found in sidebar.less -->
        <ul class="sidebar-menu">
          <li class="header"></li>
          <?php
          if (isset($_SESSION['escritorio']) && $_SESSION['escritorio'] == 1) {
            echo '<li>
              <a href="escritorio.php">
                <i class="fa fa-tasks"></i> <span>Turnos</span>
              </a>
            </li>';
          }
          if (isset($_SESSION['agenda']) && $_SESSION['agenda'] == 1) {
            echo '<li>
              <a href="agenda.php">
                <i class="fa fa-calendar"></i> <span>Agenda</span>
              </a>
            </li>';
          }
          ?>

          <?php
          if ($_SESSION['pacientes'] == 1) {
            echo '<li class="treeview">
              <a href="#">
                <i class="fa fa-laptop"></i>
                <span>Archivo</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="paciente.php"><i class="fa fa-circle-o"></i> Pacientes</a></li>
              </ul>
            </li>';
          }
          ?>

          <?php
          if (isset($_SESSION['clinica']) && $_SESSION['clinica'] == 1) {
            echo '<li class="treeview">
              <a href="#">
                <i class="fa fa-th"></i>
                <span>Mi Clínica</span>
                 <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="configuracion.php"><i class="fa fa-circle-o"></i> Configuraciones</a></li>
                <li><a href="servicio.php"><i class="fa fa-circle-o"></i> Servicios</a></li>
                <li><a href="personal.php"><i class="fa fa-circle-o"></i> Personal</a></li>
                <li><a href="permiso.php"><i class="fa fa-circle-o"></i> Permisos</a></li>
                <li><a href="diagnostico.php"><i class="fa fa-circle-o"></i> Diagnóstico</a></li>
              </ul>
            </li>';
          }

          if (isset($_SESSION['odontologia']) && $_SESSION['odontologia'] == 1) {
            echo '<li class="treeview">
              <a href="#">
                <i class="fa fa-user-md"></i>
                <span>Odontología</span>
                 <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="odont_procedimiento.php"><i class="fa fa-list-ul"></i> Procedimientos</a></li>
                <li><a href="odont_presupuesto.php"><i class="fa fa-calculator"></i> Presupuestos</a></li>
                <li><a href="odont_cobranzas.php"><i class="fa fa-circle-o"></i> Cobranzas y Deudas</a></li>
              </ul>
            </li>';
          }
          ?>

          <?php
          if ($_SESSION['atencion'] == 1) {
            echo '<li>
              <a href="atencion.php">
                <i class="fa fa-shopping-cart"></i>
                <span>Registro de Atención</span>
              </a>
            </li>';
          }
          ?>

          <?php
          if ($_SESSION['triaje'] == 1) {
            echo '<li>
              <a href="triaje.php">
                <i class="fa fa-folder"></i> <span>Triaje</span>
              </a>
            </li>';
          }
          ?>

          <?php
          if (isset($_SESSION['resultado']) && $_SESSION['resultado'] == 1) {
            echo '<li>
              <a href="plan.php">
                <i class="fa fa-heartbeat"></i> <span>Atención Med/Od</span>
              </a>
            </li>';
          if (isset($_SESSION['interconsultas']) && $_SESSION['interconsultas'] == 1) {
            echo '<li>
              <a href="interconsultas.php">
                <i class="fa fa-exchange" style="color: #673AB7;"></i> <span>Interconsultas</span>
                <span class="label label-primary pull-right" id="side-notif-count"></span>
              </a>
            </li>';
          }
          }
          if (isset($_SESSION['firma']) && $_SESSION['firma'] == 1) {
            echo '<li>
              <a href="configuracion_firma.php">
                <i class="fa fa-key"></i> <span>Firma Digital</span>
              </a>
            </li>';
          }
          if (isset($_SESSION['inventario']) && $_SESSION['inventario'] == 1) {
            echo '<li>
              <a href="inventario.php">
                <i class="fa fa-cubes"></i> <span>Inventario</span>
              </a>
            </li>';
          }
          ?>

          <?php
          if ($_SESSION['consultas'] == 1) {
            echo '<li class="treeview">
              <a href="#">
                <i class="fa fa-bar-chart"></i> <span>Registros</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="pagos.php"><i class="fa fa-circle-o"></i> Pagos</a></li>
                <li><a href="historias.php"><i class="fa fa-circle-o"></i> Historias</a></li>                
              </ul>
            </li>';
          }
          ?>


          <?php if (isset($_SESSION['certificados']) && $_SESSION['certificados'] == 1): ?>
          <li class="treeview">
            <a href="#">
              <i class="fa fa-certificate"></i> <span>Certificados</span>
              <i class="fa fa-angle-left pull-right"></i>
            </a>
            <ul class="treeview-menu">
              <li><a href="certificado_generar.php"><i class="fa fa-circle-o"></i> Generar Nuevo</a></li>
              <li><a href="certificado_historial.php"><i class="fa fa-circle-o"></i> Historial</a></li>
            </ul>
          </li>
          <?php endif; ?>

          <!-- MENÚ SOLICITUD DE EXÁMENES -->
          <?php if (isset($_SESSION['examenes']) && $_SESSION['examenes'] == 1): ?>
          <li class="treeview">
            <a href="#">
              <i class="fa fa-flask"></i> <span>Solicitud de Exámenes</span>
              <i class="fa fa-angle-left pull-right"></i>
            </a>
            <ul class="treeview-menu">
              <li><a href="examen_generar.php"><i class="fa fa-circle-o"></i> Generar Nueva</a></li>
              <li><a href="examen_avanzado_generar.php"><i class="fa fa-circle-o"></i> Generador Avanzado</a></li>
              <li><a href="examen_historial.php"><i class="fa fa-circle-o"></i> Historial</a></li>
            </ul>
          </li>
          <?php endif; ?>

          <?php if ((isset($_SESSION['facturacion']) && $_SESSION['facturacion'] == 1) || (isset($_SESSION['contabilidad']) && $_SESSION['contabilidad'] == 1)): ?>
          <li class="treeview">
            <a href="#">
              <i class="fa fa-money"></i> <span>Facturación</span>
              <i class="fa fa-angle-left pull-right"></i>
            </a>
            <ul class="treeview-menu">
              <?php if (isset($_SESSION['facturacion']) && $_SESSION['facturacion'] == 1): ?>
              <li><a href="facturacion.php"><i class="fa fa-circle-o"></i> Emitir Factura</a></li>
              <li><a href="facturas_historial.php"><i class="fa fa-circle-o"></i> Historial y RIDEs</a></li>
              <?php endif; ?>
              
              <?php if (isset($_SESSION['contabilidad']) && $_SESSION['contabilidad'] == 1): ?>
              <li><a href="contabilidad.php"><i class="fa fa-bar-chart"></i> Contabilidad</a></li>
              <?php endif; ?>
            </ul>
          </li>
          <?php endif; ?>

          <?php if (isset($_SESSION['laboratorio']) && $_SESSION['laboratorio'] == 1): ?>
          <li>
            <a href="laboratorio.php">
              <i class="fa fa-flask"></i> <span>Laboratorio</span>
            </a>
          </li>
          <?php endif; ?>

          <?php if (isset($_SESSION['rx']) && $_SESSION['rx'] == 1): ?>
          <li>
            <a href="rx.php">
              <i class="fa fa-eercast"></i> <span>RX / Imagen</span>
            </a>
          </li>
          <?php endif; ?>

          <?php if (isset($_SESSION['chat_interno']) && $_SESSION['chat_interno'] == 1): ?>
          <li>
            <a href="chat.php">
              <i class="fa fa-comments"></i> <span>Chat Interno</span>
            </a>
          </li>
          <?php endif; ?>

          <?php if (isset($_SESSION['ayuda']) && $_SESSION['ayuda'] == 1): ?>
          <li>
            <a href="javascript:void(0)" onclick="if(window.HC_TUTORIAL && window.HC_TUTORIAL.lanzar) window.HC_TUTORIAL.lanzar();">
              <i class="fa fa-question-circle"></i> <span>Ayuda</span>
              <small class="label pull-right bg-aqua">TOUR</small>
            </a>
          </li>
          <?php endif; ?>

          <?php if (isset($_SESSION['acerca_de']) && $_SESSION['acerca_de'] == 1): ?>
          <li>
            <a href="#">
              <i class="fa fa-info-circle"></i> <span>Acerca De...</span>
              <small class="label pull-right bg-yellow">HC MEDICA</small>
            </a>
          </li>
          <?php endif; ?>

        </ul>
      </section>
      <!-- /.sidebar -->
    </aside>