<form id="form-product" method="post" data-oc-toggle="ajax" data-oc-load="{{ action }}" data-oc-target="#list">
  <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 class="text-center">{{ column_image }}</th>
          <th><a href="{{ sort_name }}"{% if sort == 'name' %} class="{{ order|lower }}"{% endif %}>{{ column_name }}</a></th>
          <th class="d-none d-lg-table-cell"><a href="{{ sort_model }}"{% if sort == 'model' %} class="{{ order|lower }}"{% endif %}>{{ column_model }}</a></th>
          <th class="text-end"><a href="{{ sort_price }}"{% if sort == 'price' %} class="{{ order|lower }}"{% endif %}>{{ column_price }}</a></th>
          <th class="text-end"><a href="{{ sort_quantity }}"{% if sort == 'quantity' %} class="{{ order|lower }}"{% endif %}>{{ column_quantity }}</a></th>
          <th class="text-center"><a href="{{ sort_status }}"{% if sort == 'status' %} class="{{ order|lower }}"{% endif %}>{{ column_status }}</a></th>
          <th class="text-end">{{ column_action }}</th>
        </tr>
      </thead>
      <tbody>
        {% if products %}
          {% for product in products %}
            <tr class="{% if not product.variant %}table-warning{% endif %}{% if not product.status %} table-disabled{% endif %}">
              <td class="text-center"><input type="checkbox" name="selected[]" value="{{ product.product_id }}" class="form-check-input"/></td>
              <td class="text-center"><img src="{{ product.image }}" alt="{{ product.name }}" class="img-thumbnail"/></td>
              <td>{{ product.name }}</td>
              <td class="d-none d-lg-table-cell">{{ product.model }}</td>
              <td class="text-end">
                {% if product.special %}<s>
                  <x-currency code="{{ currency }}" amount="{{ product.price }}"></x-currency></s>
                  <br/>
                  <div class="text-danger">
                    <x-currency code="{{ currency }}" amount="{{ product.special }}"></x-currency>
                  </div>
                {% else %}
                  <x-currency code="{{ currency }}" amount="{{ product.price }}"></x-currency>
                {% endif %}
              </td>
              <td class="text-end">
                {% if product.quantity <= 0 %}
                  <span class="badge bg-warning">{{ product.quantity }}</span>
                {% elseif product.quantity <= 5 %}
                  <span class="badge bg-danger">{{ product.quantity }}</span>
                {% else %}
                  <span class="badge bg-success">{{ product.quantity }}</span>
                {% endif %}</td>
              <td class="text-center">{% if product.status %}
                  <span class="badge bg-success">{{ text_enabled }}</span>
                {% else %}
                  <span class="badge bg-danger">{{ text_disabled }}</span>
                {% endif %}</td>
              <td class="text-end text-nowrap">
                {% if product.variant %}
                  <div class="btn-group">
                    <a href="{{ product.edit }}" title="{{ button_edit }}" class="btn btn-primary"><i class="fa-solid fa-pencil"></i></a>
                    <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown"><i class="fa-solid fa-caret-down"></i></button>
                    <div class="dropdown-menu dropdown-menu-end"><a href="{{ product.variant }}" class="dropdown-item"><i class="fa-solid fa-plus"></i> {{ text_variant_add }}</a></div>
                  </div>
                {% else %}
                  <a href="{{ product.edit }}" title="{{ button_edit }}" class="btn btn-warning"><i class="fa-solid fa-pencil"></i></a>
                {% endif %}</td>
            </tr>
          {% endfor %}
        {% else %}
          <tr>
            <td class="text-center" colspan="8">{{ text_no_results }}</td>
          </tr>
        {% endif %}
      </tbody>
    </table>
  </div>
  <div class="row">
    <div class="col-sm-6 text-start"><x-pagination href="{{ pagination }}" target="#list" page="{{ page }}" limit="{{ limit }}" total="{{ total }}"></x-pagination></div>
    <div class="col-sm-6 text-end">{{ results }}</div>
  </div>
</form>
