{% extends "base.html" %}
{% block page_title %}{{ page_title }}{% endblock %}
{% block body %}
<!-- ======= Header ======= -->
<header id="header" class="header fixed-top d-flex align-items-center">
  <div class="d-flex align-items-center justify-content-between">
    <i class="bi bi-list toggle-sidebar-btn"></i>
  </div><!-- End Logo -->

  <div class="search-bar">
    <form class="search-form d-flex align-items-center" method="get" action="/inventory/search/">
      <input class="" type="text" name="q" placeholder="Search" title="Enter search keyword">
      <button type="submit" title="Search"><i class="bi bi-search"></i></button>
    </form>
  </div><!-- End Search Bar -->
  <div class="search-bar d-none">
    <form class="search-form d-flex align-items-center" method="" id="SearchForm" action="#">
      <input class="dropdown-toggle" type="text" name="query" placeholder="Search" title="Enter search keyword"
        autocomplete="off" id="dropdownSearch" data-bs-toggle="dropdown" aria-expanded="false">
      <button type="submit" title="Search"><i class="bi bi-search"></i></button>

      <ul class="dropdown-menu" autoClose="outside" aria-labelledby="dropdownSearch" id="dropdown-search-list"
        style="min-width: 100px;">
        <li class="dropdown-header">
          <h6 class="dropdown-header">You can search:</h6>
        </li>
        <li class="dropdown-item"><i class="bi bi-laptop"></i> Devices <span class="badge bg-secondary"
            style="float: right;">DHID</span></li>
        <li class="dropdown-item"><i class="bi bi-folder2"></i> lots <span class="badge bg-secondary"
            style="float: right;">Name</span></li>
        <li class="dropdown-item">
          <small class="text-muted">
            <a href="{# url_for('inventory.advanced_search') #}">Advanced Search</a>
          </small>
        </li>
      </ul>
    </form>
  </div><!-- End Search Bar -->

  <nav class="header-nav ms-auto">
    <ul class="d-flex align-items-center">

      <li class="nav-item d-block d-lg-none">
        <a class="nav-link nav-icon search-bar-toggle " href="#">
          <i class="bi bi-search"></i>
        </a>
      </li><!-- End Search Icon-->
      <li class="nav-item dropdown pe-3">
        <a class="nav-link nav-profile d-flex align-items-center pe-0" href="{# url_for('labels.label_list') #}">
          <span class="d-none d-md-block ps-2 pb-3 pt-3">Identifiers</span>
        </a>
      </li>

      <li class="nav-item dropdown pe-3">

        <a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown">
          <span class="d-none d-md-block dropdown-toggle ps-2 pb-3 pt-3">Reports</span>
        </a><!-- End Profile Iamge Icon -->

        <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile">
          <li class="dropdown-header">
            <h6>Exports</h6>
          </li>
          <li>
            <hr class="dropdown-divider">
          </li>

          <li>
            <a class="dropdown-item d-flex align-items-center" href="{# url_for('inventory.export', export_id='lots') #}">
              <i class="bi bi-file-spreadsheet"></i>
              <span>Lots Spreadsheet</span>
            </a>
          </li>
          <li>
            <a class="dropdown-item d-flex align-items-center" href="{# url_for('inventory.device_erasure_list') #}">
              <i class="bi bi-eraser-fill"></i><span>Drives Sanitization</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="nav-item dropdown pe-3">

        <a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown">
          <i class="bi bi-person-circle" style="font-size: 36px;"></i>
          <span class="d-none d-md-block dropdown-toggle ps-2">{{ current_user.email }}</span>
        </a><!-- End Profile Iamge Icon -->

        <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile">
          <li class="dropdown-header">
            <h6>{{ current_user.get_full_name }}</h6>
          </li>
          <li>
            <hr class="dropdown-divider">
          </li>

          <li>
            <a class="dropdown-item d-flex align-items-center" href="{# url_for('core.user-profile') #}">
              <i class="bi bi-person"></i>
              <span>My Profile</span>
            </a>
          </li>
          <li>
            <hr class="dropdown-divider">
          </li>

          <li>
            <a class="dropdown-item d-flex align-items-center" href="{# url_for('workbench.settings') #}">
              <i class="bi bi-tools"></i>
              <span>Setup</span>
            </a>
          </li>
          <li>
            <hr class="dropdown-divider">
          </li>

          <li>
            <a class="dropdown-item d-flex align-items-center" href="https://help.usody.com/" target="_blank">
              <i class="bi bi-question-circle"></i>
              <span>Need Help?</span>
            </a>
          </li>
          <li>
            <hr class="dropdown-divider">
          </li>

          <li>
            <a class="dropdown-item d-flex align-items-center" href="{# url_for('core.logout') #}">
              <i class="bi bi-box-arrow-right"></i>
              <span>Sign Out</span>
            </a>
          </li>

        </ul><!-- End Profile Dropdown Items -->
      </li><!-- End Profile Nav -->

    </ul>
  </nav><!-- End Icons Navigation -->

</header><!-- End Header -->

<!-- ======= Sidebar ======= -->
<aside id="sidebar" class="sidebar">

  <ul class="sidebar-nav" id="sidebar-nav">
    <!-- We need defined before the Dashboard
    <li class="nav-item">
      <a class="nav-link collapsed" href="index.html">
        <i class="bi bi-grid"></i>
        <span>Dashboard</span>
      </a>
    </li><!-- End Dashboard Nav -->

    <li class="nav-heading">evidences</li>

    <li class="nav-item">
      <a class="nav-link collapsed" href="{# url_for('inventory.evidenceslist') #}">
        <i class="bi-menu-button-wide"></i>
        <span>Uploaded evidences</span>
      </a>
    </li>

    <li class="nav-heading">Placeholders</li>

    <li class="nav-item">
      <a class="nav-link collapsed" href="{# url_for('inventory.placeholder_logs') #}">
        <i class="bi-menu-button-wide"></i>
        <span>Uploaded Placeholders</span>
      </a>
    </li>

    <li class="nav-heading">Devices</li>

    <li class="nav-item">
      <a class="nav-link collapsed" href="{# url_for('inventory.alldevicelist') #}">
        <i class="bi bi-laptop"></i>
        <span>All devices</span>
      </a>
    </li>

    <li class="nav-item">
      <a class="nav-link collapsed" href="{# url_for('inventory.devicelist') #}">
        <i class="bi-menu-button-wide"></i>
        <span>Unassigned devices</span>
      </a>
    </li>

    <li class="nav-heading">Lots</li>

    <li class="nav-item">
      {% if lot and lot.is_incoming %}
      <a class="nav-link" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#">
        {% else %}
        <a class="nav-link collapsed" data-bs-target="#incoming-lots-nav" data-bs-toggle="collapse" href="#">
          {% endif %}
          <i class="bi bi-arrow-down-right"></i><span>Incoming</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        {% if lot and lot.is_incoming %}
        <ul id="incoming-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
          {% else %}
          <ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
            {% endif %}
            <li>
              <a href="{# url_for('inventory.new_transfer', type_id='incoming') #}">
                <i class="bi bi-plus" style="font-size: larger;"></i><span>New Incoming lot</span>
              </a>
            </li>
            {% for lot in lots %}
            {% if lot.is_incoming %}
            <li>
              <a href="{# url_for('inventory.lotdevicelist', lot_id=lot.id) #}">
                <i class="bi bi-circle"></i><span>{{ lot.name }}</span>
              </a>
            </li>
            {% endif %}
            {% endfor %}
          </ul>
    </li><!-- End Incoming Lots Nav -->

    <li class="nav-item">
      {% if lot and lot.is_outgoing %}
      <a class="nav-link" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#">
        {% else %}
        <a class="nav-link collapsed" data-bs-target="#outgoing-lots-nav" data-bs-toggle="collapse" href="#">
          {% endif %}
          <i class="bi bi-arrow-up-right"></i><span>Outgoing</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        {% if lot and lot.is_outgoing %}
        <ul id="outgoing-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
          {% else %}
          <ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
            {% endif %}
            <li>
              <a href="{# url_for('inventory.new_transfer', type_id='outgoing') #}">
                <i class="bi bi-plus" style="font-size: larger;"></i><span>New Outgoing lot</span>
              </a>
            </li>
            {% for lot in lots %}
            {% if lot.is_outgoing %}
            <li>
              <a href="{# url_for('inventory.lotdevicelist', lot_id=lot.id) #}">
                <i class="bi bi-circle"></i><span>{{ lot.name }}</span>
              </a>
            </li>
            {% endif %}
            {% endfor %}
          </ul>
    </li><!-- End Outgoing Lots Nav -->

    <li class="nav-item">
      {% if lot and lot.is_temporary %}
      <a class="nav-link" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#">
        {% else %}
        <a class="nav-link collapsed" data-bs-target="#temporal-lots-nav" data-bs-toggle="collapse" href="#">
          {% endif %}
          <i class="bi bi-layout-text-window-reverse"></i><span>Temporary</span><i
            class="bi bi-chevron-down ms-auto"></i>
        </a>
        {% if lot and lot.is_temporary %}
        <ul id="temporal-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
          {% else %}
          <ul id="temporal-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
            {% endif %}
            <li>
              <a href="{# url_for('inventory.lot_add')#}">
                <i class="bi bi-plus" style="font-size: larger;"></i><span>New temporary lot</span>
              </a>
            </li>
            {% for lot in lots %}
            {% if lot.is_temporary %}
            <li>
              <a href="{# url_for('inventory.lotdevicelist', lot_id=lot.id) #}">
                <i class="bi bi-circle"></i><span>{{ lot.name }}</span>
              </a>
            </li>
            {% endif %}
            {% endfor %}
          </ul>
    </li>
    {% if share_lots.all() %}
    <li class="nav-item">
      <a class="nav-link collapsed" data-bs-target="#share-lots-nav" data-bs-toggle="collapse" href="javascript:void()">
      <i class="bi bi-share-fill"></i><span>Shared with me</span><i
            class="bi bi-chevron-down ms-auto"></i>
      </a>
      {% if lot and lot.is_shared %}
      <ul id="share-lots-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
      {% else %}
      <ul id="share-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
      {% endif %}
      {% for lot in share_lots %}
      <li>
        <a href="{# url_for('inventory.lotdevicelist', lot_id=lot.lot_id) #}">
          <i class="bi bi-circle"></i><span>{{ lot.lot.name }}</span>
        </a>
       </li>
      {% endfor %}
      </ul>
    </li><!-- End Temporal Lots Nav -->
    {% endif %}

  </ul>

</aside><!-- End Sidebar-->

<main id="main" class="main">
  {% block messages %}
  {% for level, message in get_flashed_messages(with_categories=true) %}
  <div class="alert alert-{{ level}} alert-dismissible fade show" role="alert">
    {% if '_message_icon' in session %}
    <i class="bi bi-{{ session['_message_icon'][level]}} me-1"></i>
    {% else %}
    <!-- fallback if 3rd party libraries (e.g. flask_login.login_required) -->
    <i class="bi bi-info-circle me-1"></i>
    {% endif %}
    {{ message }}
    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  </div>
  {% endfor %}
  {% endblock %}
  {% block main %}

  {% endblock main %}
</main><!-- End #main -->

<!-- ======= Footer ======= -->
<footer id="footer" class="footer">
  <div class="copyright">
    &copy; Copyright <strong><span>Usody</span></strong>. All Rights Reserved
  </div>
  <div class="credits">
    <a href="https://help.usody.com/en/" target="_blank">Help</a> | 
    <a href="https://www.usody.com/legal/privacy-policy" target="_blank">Privacy</a> | 
    <a href="https://www.usody.com/legal/terms" target="_blank">Terms</a>
  </div>
  <div class="credits">
    DeviceHub {{ version }}
  </div>
</footer><!-- End Footer -->

{% endblock body %}
