{#
The Mia! Accounting Demonstration Website
base.html: The side-wide layout template

 Copyright (c) 2023 imacat.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2023/1/27
#}
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ _("en") }}">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="author" content="{{ "imacat" }}" />
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css" integrity="sha384-iw3OoTErCYJJB9mCa8LNS2hbsQ7M3C0EpIsO/H5+EGAkPGc6rk+V8i04oW/K5xq0" crossorigin="anonymous">
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.7/dist/css/tempus-dominus.min.css" integrity="sha384-l66rSL7gUubrdJxFRbXUo/tO7eNPAcCiZXFs/Xl147146xNqQ1qt4oPW6jlVezsS" crossorigin="anonymous">
  {% block styles %}{% endblock %}
  <script src="{{ url_for("babel_catalog") }}"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/decimal.js-light@2.5.1/decimal.min.js" integrity="sha384-QdsxGEq4Y0erX8WUIsZJDtfoSSyBF6dmNCnzRNYCa2AOM/xzNsyhHu0RbdFBAm+l" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.7/dist/js/tempus-dominus.min.js" integrity="sha384-MxHp+/TqTjbku1jSTIe1e/4l6CZTLhACLDbWyxYaFRgD3AM4oh99AY8bxsGhIoRc" crossorigin="anonymous"></script>
  {% block scripts %}{% endblock %}
  <link rel="shortcut icon" href="{{ url_for("static", filename="favicon.svg") }}">
  <title>{% block title %}{% endblock %}</title>
</head>
<body>

<nav class="navbar navbar-expand-lg bg-body-tertiary bg-dark navbar-dark">
  <div class="container-fluid">
    <a class="navbar-brand" href="{{ url_for("home.home") }}">
      <i class="fa-solid fa-house"></i>
      {{ _("Home") }}
    </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#accounting-collapsible-navbar" aria-controls="accounting-collapsible-navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="accounting-collapsible-navbar" class="collapse navbar-collapse">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        {% include "accounting/include/nav.html" %}
      </ul>

      <!-- The right side -->
      <ul class="navbar-nav d-flex">
        {% if current_user() is not none %}
          <li class="nav-item dropdown">
            <span class="nav-link dropdown-toggle" data-bs-toggle="dropdown">
              <i class="fa-solid fa-user"></i>
              {{ current_user().username }}
            </span>
            <ul class="dropdown-menu dropdown-menu-end">
              <li>
                <form action="{{ url_for("auth.logout") }}" method="post">
                  <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                  <button class="btn dropdown-item" type="submit">
                    <i class="fa-solid fa-right-from-bracket"></i>
                    {{ _("Log Out") }}
                  </button>
                </form>
              </li>
              {% if current_user().username == "admin" %}
                <li>
                  <a class="dropdown-item {% if request.endpoint and request.endpoint.startswith("reset.") %} active {% endif %}" href="{{ url_for("reset.reset-page") }}">
                    <i class="fa-solid fa-rotate-right"></i>
                    {{ _("Reset") }}
                  </a>
                </li>
              {% endif %}
            </ul>
          </li>
        {% else %}
          <li class="nav-item">
            <a class="nav-link" href="{{ url_for("auth.login") }}">
              <i class="fa-solid fa-right-to-bracket"></i>
              {{ _("Log In") }}
            </a>
          </li>
        {% endif %}
        <li class="nav-item dropdown">
          <span class="nav-link dropdown-toggle" data-bs-toggle="dropdown">
            <i class="fa-solid fa-language"></i>
          </span>
          <form action="{{ url_for("locale.set-locale") }}" method="post">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <input type="hidden" name="next" value="{{ accounting_as_next() }}">
            <ul class="dropdown-menu dropdown-menu-end">
              {% for locale_code, locale_name in get_all_linguas().items() %}
                <li>
                  <button class="dropdown-item {% if locale_code == get_locale() %} active {% endif %}" type="submit" name="locale" value="{{ locale_code }}">
                    {{ locale_name }}
                  </button>
                </li>
              {% endfor %}
            </ul>
          </form>
        </li>
      </ul>
    </div>
  </div>
</nav>

<div class="container">

<h1>{% block header %}{% endblock %}</h1>

{% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
    {% for category, message in messages %}
      {% if category == "success" %}
        <div class="alert alert-success alert-dismissible fade show" role="alert">
          {{ message }}
          <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
      {% elif category == "error" %}
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
          <strong>{{ _("Error:") }}</strong> {{ message }}
          <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
      {% endif %}
    {% endfor %}
  {% endif %}
{% endwith %}

<main class="pb-5">
  {% block content %}{% endblock %}
</main>

</div>

</body>
</html>
