<!DOCTYPE html>
<html lang="en">

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  {% if title %}
  <title>Gestión del Transporte Público del Gran Concepción - {{title}}</title>
  {% else %}
  <title>Gestión del Transporte Público del Gran Concepción</title>
  {% endif %}
  <link href="/static/googlefonts.css" rel="stylesheet">
  <link href="/static/fa-all.min.css" rel="stylesheet" type="text/css">
  <link href="/static/sb-admin-2.min.css" rel="stylesheet">
  {% block css %}{% endblock %}
</head>

<body id="page-top">

  <!-- Page Wrapper -->
  <div id="wrapper">

    <!-- Sidebar -->
    <ul class="navbar-nav bg-gradient-dark sidebar sidebar-dark accordion" id="accordionSidebar">

      <!-- Sidebar - Brand -->
      <a class="sidebar-brand d-flex align-items-center justify-content-center" href="{{ url_for('main.dashboard') }}">
        <div class="sidebar-brand-icon">
          <i class="fas fa-bus"></i>
        </div>
        <div class="sidebar-brand-text mx-1">TPMC</div>
      </a>

      <!-- Divider -->
      <hr class="sidebar-divider my-0">

        {% for  id, name, icon, tgrupo, links in current_user.sidebar_menu %}

            {%  if tgrupo|length %}
        <!-- Divider -->
        <hr class="sidebar-divider">

        <!-- Heading -->
        <div class="sidebar-heading">
            {{ tgrupo }}
        </div>
            {% endif %}
        <!-- Nav Item - Pages Collapse Menu -->
        <li class="nav-item">
          <a class="nav-link{% if grupo!=name %} collapsed{% endif %}" href="#" data-toggle="collapse" data-target="#collapse{{ id }}" aria-expanded="true" aria-controls="collapse{{ id }}">
            <i class="fas fa-fw fa-{{icon}}"></i>
            <span>{{name}}</span>
          </a>
          <div id="collapse{{ id }}" class="collapse{% if grupo==name %} show{% endif %}" aria-labelledby="heading{{ id }}" data-parent="#accordionSidebar">
            <div class="bg-white py-2 collapse-inner rounded">
               {% for link in links -%}
               {% if link[1]|length -%}
              <a class="collapse-item{% if tag==link[2] %} active{% endif %}" href="{{ link[3] }}"><i class="mr-2 fas fa-fw fa-{{ link[1] }}"></i>{{ link[0] }}</a>
              {%- else -%}
              <a class="collapse-item{% if tag==link[2] %} active{% endif %}" href="{{ link[3] }}">{{ link[0] }}</a>
              {%- endif %}
              {%- endfor %}
            </div>
          </div>
        </li>

        {% endfor %}
      <!-- Divider -->
      <hr class="sidebar-divider d-none d-md-block">

      <!-- Sidebar Toggler (Sidebar) -->
      <div class="text-center d-none d-md-inline">
        <button class="rounded-circle border-0" id="sidebarToggle"></button>
      </div>

    </ul>
    <!-- Menu lateral -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

      <!-- Main Content -->
      <div id="content">

        <!-- Topbar -->
        <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

          <!-- Sidebar Toggle (Topbar) -->
          <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
            <i class="fa fa-bars"></i>
          </button>
          <div class="d-sm-flex align-items-center justify-content-between my-2 text-truncate">
            <h1 class="h2 text-gray-900">{{title}}</h1>
          </div>
          <!-- Topbar Navbar -->
          <ul class="navbar-nav ml-auto">

            <div class="topbar-divider d-none d-sm-block"></div>

            <!-- Nav Item - User Information -->
            <li class="nav-item dropdown no-arrow">
              <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="mr-2 d-none d-lg-inline text-gray-600 small">{{ current_user.nombrecompleto }}</span>
                <img class="img-profile rounded-circle" src="https://app.ilab.cl/static/profile_pics/{{ current_user.foto }}">
              </a>
              <!-- Dropdown - User Information -->
              <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
                <a class="dropdown-item" href="https://tpmc.ilab.cl/system/me">
                  <i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400"></i>
                  Mis Datos
                </a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                  <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
                  Salir
                </a>
              </div>
            </li>

          </ul>

        </nav>
        <!-- End of Topbar -->

        <!-- Begin Page Content -->
<!--        <div class="container-fluid px-0" >   -->
        <div class="row" >

          <!-- Page Heading -->
          {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
              {% for category, message in messages %}
                <div class="col-12 mx-2 alert alert-{{ category }}">
                  {{  message }}
                </div>
              {% endfor %}
            {% endif %}
          {% endwith %}
          {% block content %}{% endblock %}

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

      </div>
      <!-- End of Main Content -->

      <!-- Footer -->
      <footer class="sticky-footer bg-white">
        <div class="container my-auto">
          <div class="copyright text-center my-auto">
            <span>Copyright &copy; iLab 2020 <br> Israel Figueroa Pedreros (ifiguero@ilab.cl) </span>
          </div>
        </div>
      </footer>
      <!-- End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">¿Quieres salir?</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
        <div class="modal-body">Confirme que desea cerrar sesión.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancelar</button>
          <a class="btn btn-primary" href="{{ url_for('main.logout') }}">Cerrar sesión</a>
        </div>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="/static/jquery-3.6.0.min.js"></script>
  <script src="/static/bootstrap.bundle.min.js"></script>
  <script src="/static/jquery.easing.min.js"></script>
  <script src="/static/sb-admin-2.min.js"></script>
  {% block js %}{% endblock %}

</body>
</html>
