{#
The Mia! Accounting Project
toolbar-buttons.html: The toolbar buttons on the report

 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/3/8
#}
{% if accounting_can_edit() %}
  <div class="btn-group d-none d-md-flex" role="group">
    <button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
      <i class="fa-solid fa-plus"></i>
      <span class="d-none d-md-inline">{{ A_("New") }}</span>
    </button>
    <ul class="dropdown-menu">
      <li>
        <a class="dropdown-item" href="{{ url_for("accounting.journal-entry.create", journal_entry_type=report.journal_entry_types.CASH_DISBURSEMENT)|accounting_append_next }}">
          {{ A_("Cash Disbursement") }}
        </a>
      </li>
      <li>
        <a class="dropdown-item" href="{{ url_for("accounting.journal-entry.create", journal_entry_type=report.journal_entry_types.CASH_RECEIPT)|accounting_append_next }}">
          {{ A_("Cash Receipt") }}
        </a>
      </li>
      <li>
        <a class="dropdown-item" href="{{ url_for("accounting.journal-entry.create", journal_entry_type=report.journal_entry_types.TRANSFER)|accounting_append_next }}">
          {{ A_("Transfer") }}
        </a>
      </li>
    </ul>
  </div>
{% endif %}
<div class="btn-group" role="group">
  <button id="accounting-choose-report" class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
    <i class="fa-solid fa-book"></i>
    <span class="d-none d-md-inline">{{ A_("Report") }}</span>
  </button>
  <ul class="dropdown-menu" aria-labelledby="accounting-choose-report">
    {% for report in report.report_chooser %}
      <li>
        <a class="dropdown-item {% if report.is_active %} active {% endif %}" href="{{ report.url }}">
          <i class="{{ report.fa_icon }}"></i>
          {{ report.title }}
        </a>
      </li>
    {% endfor %}
    <li>
      <span class="dropdown-item {% if report.report_chooser.is_search %} active {% endif %} accounting-clickable" data-bs-toggle="modal" data-bs-target="#accounting-search-modal">
        <i class="fa-solid fa-magnifying-glass"></i>
        {{ A_("Search") }}
      </span>
    </li>
  </ul>
</div>
{% if use_currency_chooser %}
  <div class="btn-group" role="group">
    <button id="accounting-choose-currency" class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
      <i class="fa-solid fa-money-bill-wave"></i>
      <span class="d-none d-md-inline">{{ A_("Currency") }}</span>
    </button>
    <ul class="dropdown-menu" aria-labelledby="accounting-choose-currency">
      {% for currency in report.currency_options %}
        <li>
          <a class="dropdown-item {% if currency.is_active %} active {% endif %}" href="{{ currency.url }}">
            {{ currency.title }}
          </a>
        </li>
      {% endfor %}
    </ul>
  </div>
{% endif %}
{% if use_account_chooser %}
  <div class="btn-group" role="group">
    <button id="accounting-choose-account" class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
      <i class="fa-solid fa-clipboard"></i>
      <span class="d-none d-md-inline">{{ A_("Account") }}</span>
    </button>
    <ul class="dropdown-menu accounting-toolbar-accounts" aria-labelledby="accounting-choose-account">
      {% for account in report.account_options %}
        <li>
          <a class="dropdown-item {% if account.is_active %} active {% endif %}" href="{{ account.url }}">
            {{ account.title }}
          </a>
        </li>
      {% endfor %}
    </ul>
  </div>
{% endif %}
{% if use_period_chooser %}
  <button class="btn btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#accounting-period-chooser-modal">
    <i class="fa-solid fa-calendar-day"></i>
    <span class="d-none d-md-inline">{{ A_("Period") }}</span>
  </button>
{% endif %}
{% if report.has_data %}
  <a class="btn btn-primary" role="button" href="{{ report.csv_uri }}">
    <i class="fa-solid fa-download"></i>
    <span class="d-none d-md-inline">{{ A_("Download") }}</span>
  </a>
{% else %}
  <button class="btn btn-secondary" type="button" disabled="disabled">
    <i class="fa-solid fa-download"></i>
    <span class="d-none d-md-inline">{{ A_("Download") }}</span>
  </button>
{% endif %}
{% if use_search %}
  <form class="btn btn-primary d-flex input-group" name="accounting-search-form" action="{{ url_for("accounting-report.search") }}" method="get" role="search" aria-labelledby="accounting-toolbar-search-label">
    <input id="accounting-toolbar-search" class="form-control form-control-sm" type="search" name="q" value="{{ request.args.q }}" placeholder=" " required="required">
    <label id="accounting-toolbar-search-label" for="accounting-toolbar-search" class="input-group-text">
      <button type="submit">
        <i class="fa-solid fa-magnifying-glass"></i>
        <span class="d-none d-md-inline">{{ A_("Search") }}</span>
      </button>
    </label>
  </form>
{% endif %}
