{% extends '@admin/index.twig' %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 mb-3 border-bottom">
  <h1 class="h2">
    <i aria-hidden="true" class="bi bi-paperclip"></i>
    {{ adminHeaderAttachments }}
  </h1>
</div>

<div class="row">
  <div class="col-12">
    <table class="table table-striped table-hover align-middle border shadow">
      <thead>
      <tr>
        <th>#</th>
        <th>{{ adminMsgAttachmentsFilename }}</th>
        <th>{{ adminMsgTransToolLanguage }}</th>
        <th>{{ adminMsgAttachmentsFilesize }}</th>
        <th colspan="4">{{ adminMsgAttachmentsMimeType }}</th>
      </tr>
      </thead>
      <tbody id="attachment-table">
      {% for item in attachments %}
        <tr id="attachment_{{ item.id }}" title="{{ item.thema }}">
          <td>{{ item.id }}</td>
          <td>{{ item.filename }}</td>
          <td>{{ item.record_lang }}</td>
          <td>{{ item.filesize | formatBytes }}</td>
          <td>{{ item.mime_type }}</td>
          <td>
            <button class="btn btn-danger btn-delete-attachment" title="{{ adminMsgButtonDelete }}"
                    data-attachment-id="{{ item.id }}" data-csrf="{{ csrfTokenDeletion }}">
              <i aria-hidden="true" class="bi bi-trash btn-delete-attachment" data-attachment-id="{{ item.id }}"
                 data-csrf="{{ csrfTokenDeletion }}"></i>
            </button>
          </td>
          <td>
            <button class="btn btn-primary btn-refresh-attachment"
                    title="{{ 'msgAdminCleanupMissingAttachment' | translate }}"
                    data-attachment-id="{{ item.id }}" data-csrf="{{ csrfTokenRefresh }}">
              <i aria-hidden="true" class="bi bi-arrow-clockwise btn-refresh-attachment"
                 title="{{ 'msgAdminCleanupMissingAttachment' | translate }}"
                 data-attachment-id="{{ item.id }}" data-csrf="{{ csrfTokenRefresh }}"></i>
            </button>
          </td>
          <td>
            <a title="{{ adminMsgFaqTitle }}" class="btn btn-info"
               href="../index.php?action=faq&id={{ item.record_id }}&lang={{ item.record_lang }}">
              <i aria-hidden="true" class="bi bi-link"></i>
            </a>
          </td>
        </tr>
      {% endfor %}
      </tbody>
      <tfoot>
      <tr>
        <td colspan="5">{{ adminAttachmentPagination | raw }}</td>
      </tr>
      </tfoot>
    </table>
  </div>
</div>
{% endblock %}
