<!-- ============================================================== -->
<!-- Left Sidebar - style you can find in sidebar.scss  -->
<!-- ============================================================== -->
<aside class="left-sidebar">
  <!-- Sidebar scroll-->
  <div class="scroll-sidebar">
    <!-- Sidebar navigation-->
    <nav class="sidebar-nav">
      <ul id="sidebarnav">

        <!-- Home --
        <li <?php /*if( $Seccion == 'Home' ){ echo "class='active'"; }*/ ?>>
          <a class="waves-effect waves-dark" href="#" aria-expanded="false">
            <i class="fa fa-home mar-r-10"></i><span class="hide-menu">Home</span>
          </a>
        </li>
        <li class="nav-devider"></li>
        <!-- / Home -->

        <?php if( !$Are[Id] ){ ?>
          <?php
            //Areas
            $Query = "
              SELECT
                are.Id,
                are.Clave, are.Nombre
              FROM Areas are
              WHERE
                are.Activo = '1'
              ORDER BY are.Nombre ASC
            ";
            $Ares = $mysqli->query($Query);
            mysqli_data_seek($Ares, 0);
            while($Area = mysqli_fetch_array($Ares)) {
          ?>
            <!-- Areas -->
            <li>
              <a
                class="waves-effect waves-dark"
                href="?a=<?php echo $Area[Clave]; ?>"
                aria-expanded="false"
              >
                <span class="hide-menu">
                  <i class="fa fa-file"></i>
                  <?php echo $Area[Nombre]; ?>
                </span>
              </a>
            </li>
            <!-- End Areas -->
          <?php } ?>
        <?php } ?>

        <?php
          //Temas
          $Query = "
            SELECT
              tem.Id,
              tem.Clave, tem.NombreMenu,
              tem.Linked
            FROM Temas tem
            WHERE
              tem.Activo = '1'
              AND tem.Posicion = '1'
              AND tem.Fk_Area = '$Are[Id]'
            ORDER BY tem.Orden ASC
          ";
          $MenuTemas = $mysqli->query($Query);
          mysqli_data_seek($MenuTemas, 0);
          while($MenuTema = mysqli_fetch_array($MenuTemas)) {

            //CountSubmenus
            $Query = "
              SELECT
                COUNT(tem.Id) AS Total
              FROM Temas tem
              WHERE
                tem.Posicion = '2'
                AND tem.Fk_Tema = '$MenuTema[Id]'
            ";
            $Result = mysqli_query($mysqli, $Query);
            $TemCount = mysqli_fetch_assoc($Result);

        ?>
          <!-- Temas -->
          <li <?php /*if( $_GET['t'] == $MenuTema[Clave] ){ echo "class='active'"; }*/ ?>>
            <?php
              //If SubTemas
              if( $TemCount[Total] == 0 ){
            ?>
              <a
                class="waves-effect waves-dark"
                href="?a=<?php echo $Are[Clave]; ?>&t=<?php echo $MenuTema[Clave]; ?>"
                aria-expanded="false"
              >
                <span class="hide-menu">
                  <?php echo $MenuTema[NombreMenu]; ?>
                </span>
              </a>
            <?php }else{ ?>
              <a class="has-arrow waves-effect waves-dark" href="#" aria-expanded="false">
                <span class="hide-menu">
                  <?php echo $MenuTema[NombreMenu]; ?>
                </span>
              </a>
              <ul aria-expanded="false" class="collapse">
                <?php
                  //End SubTemas
                  $Query = "
                    SELECT
                      tem.Id,
                      tem.Clave, tem.NombreMenu
                    FROM Temas tem
                    WHERE
                      tem.Posicion = '2'
                      AND tem.Fk_Tema = '$MenuTema[Id]'
                    ORDER BY tem.Orden ASC
                  ";
                  $MenuTemas2 = $mysqli->query($Query);
                  mysqli_data_seek($MenuTemas2, 0);
                  while($MenuTema2 = mysqli_fetch_array($MenuTemas2)) {
                ?>
                  <li>
                    <a href="?a=<?php echo $Are[Clave]; ?>&t=<?php echo $MenuTema2[Clave]; ?>">
                      <?php echo $MenuTema2[NombreMenu]; ?>
                    </a>
                  </li>
                <?php }//End SubTemas ?>
              </ul>
            <?php }//End If SubTemas ?>

          </li>
          <!-- / Temas -->
        <?php } ?>

        <li>
          <hr>
        </li>

        <!-- Postaman -->
        <li>
          <a
            class="waves-effect waves-dark"
            href="<?php echo $Position; ?>download/SwitchPoint-App-Api.zip"
            target="_blank"
            aria-expanded="false"
          >
            <span class="hide-menu">
              <i class="fa fa-download"></i>
              Postman Api
            </span>
          </a>
        </li>
        <!-- End Postman -->

      </ul>
    </nav>
    <!-- / Sidebar navigation -->
  </div>
  <!-- / Sidebar scroll-->
</aside>
<!-- ============================================================== -->
<!-- / Left Sidebar - style you can find in sidebar.scss  -->
<!-- ============================================================== -->
