<form id="form-event" method="post" data-oc-toggle="ajax" data-oc-load="{{ action }}" data-oc-target="#event">
  <div class="table-responsive">
    <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th class="text-center" style="width: 1px;"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', $(this).prop('checked'));" class="form-check-input"/></th>
          <th><a href="{{ sort_code }}"{% if sort == 'code' %} class="{{ order|lower }}"{% endif %}>{{ column_code }}</a></th>
          <th class="text-end d-none d-lg-table-cell"><a href="{{ sort_sort_order }}"{% if sort == 'sort_order' %} class="{{ order|lower }}"{% endif %}>{{ column_sort_order }}</a></th>
          <th class="text-end">{{ column_action }}</th>
        </tr>
      </thead>
      <tbody>
        {% if events %}
          {% for event in events %}
            <tr{% if not event.status %} class="table-active opacity-50"{% endif %}>
              <td class="text-center"><input type="checkbox" name="selected[]" value="{{ event.event_id }}" class="form-check-input"/></td>
              <td>{{ event.code }}</td>
              <td class="text-end d-none d-lg-table-cell">{{ event.sort_order }}</td>
              <td class="text-end text-nowrap">{% if event.description %}
                <button type="button" data-bs-toggle="modal" data-bs-target="#modal-event-{{ event.event_id }}" class="btn btn-info"><i class="fa-solid fa-info-circle"></i></button>
              {% else %}
                <button type="button" class="btn btn-info" disabled><i class="fa-solid fa-info-circle"></i></button>
              {% endif %}
              {% if not event.status %}
                <button type="button" value="{{ event.enable }}" data-bs-toggle="tooltip" title="{{ button_enable }}" class="btn btn-success"><i class="fa-solid fa-plus-circle"></i></button>
              {% else %}
                <button type="button" value="{{ event.disable }}" data-bs-toggle="tooltip" title="{{ button_disable }}" class="btn btn-danger"><i class="fa-solid fa-minus-circle"></i></button>
              {% endif %}</td>
            </tr>
          {% endfor %}
        {% else %}
          <tr>
            <td class="text-center" colspan="4">{{ text_no_results }}</td>
          </tr>
        {% endif %}
      </tbody>
    </table>
  </div>
  <div class="row">
    <div class="col-sm-6 text-start">{{ pagination }}</div>
    <div class="col-sm-6 text-end">{{ results }}</div>
  </div>
</form>
{% for event in events %}
  <div id="modal-event-{{ event.event_id }}" class="modal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title"><i class="fa-solid fa-info-circle"></i> {{ text_info }}</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
        </div>
        <div class="modal-body">
          <div class="mb-3">
            <label class="form-label">{{ entry_description }}</label>
            <textarea rows="5" class="form-control" readonly>{{ event.description }}</textarea>
          </div>
          <div class="mb-3">
            <label class="form-label">{{ entry_trigger }}</label>
            <textarea class="form-control" readonly>{{ event.trigger }}</textarea>
          </div>
          <div>
            <label class="form-label">{{ entry_action }}</label>
            <textarea class="form-control" readonly>{{ event.action }}</textarea>
          </div>
        </div>
      </div>
    </div>
  </div>
{% endfor %}