haikal/templates/vendors/vendors_list.html
2024-12-17 14:08:40 +00:00

111 lines
4.5 KiB
HTML

{% extends 'base.html' %}
{% load i18n %}
{% load static %}
{% block title %}{{ _('Vendors')|capfirst }}{% endblock title %}
{% block vendors %}<a class="nav-link active">{{ _("Vendors")|capfirst }}</a>{% endblock %}
{% block content %}
<div class="container-fluid p-3">
<div class="card shadow rounded">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0">{{ _("Vendors")|capfirst }}</h6>
<form method="get" class="d-inline-block">
<div class="input-group input-group-sm">
<button class="btn btn-secondary" type="submit">
{{ _("Search")|capfirst }}
</button>
<input type="text"
name="q"
class="form-control"
placeholder="{{ _('Enter vendor name') }}"
value="{{ request.GET.q }}">
{% if request.GET.q %}
<a href="{% url request.resolver_match.view_name %}" class="btn btn-outline-danger ms-1">
<i class="bi bi-x-lg"></i>
</a>
{% endif %}
</div>
</form>
</div>
<div class="card-body p-0">
<table class="table table-hover table-striped mb-0">
<thead class="table-light">
<tr>
<th>{{ _("Name")|capfirst }}</th>
<th>{{ _("Logo")|capfirst }}</th>
<th>{{ _("Address")|capfirst }}</th>
<th>{{ _("Actions")|capfirst }}</th>
</tr>
</thead>
<tbody>
{% if page_obj.object_list %}
{% for vendor in vendors %}
<tr>
<td>{{ vendor.get_local_name }}</td>
<td>
{% if vendor.logo %}
<img src="{{ vendor.logo.url }}"
alt="{{ vendor.get_local_name }}"
class="img-thumbnail"
style="max-width: 100px;">
{% endif %}
</td>
<td>{{ vendor.address }}</td>
<td>
<a href="{% url 'vendor_detail' vendor.id %}" class="btn btn-success btn-sm">
{{ _("view")|capfirst }}
</a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="4" class="text-center">{{ _("No vendors found")|capfirst }}</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<!-- Optional: Pagination -->
{% if is_paginated %}
<nav aria-label="Page navigation">
<ul class="pagination pagination-sm justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item py-0">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
<li class="page-item active"><a class="page-link" href="?page={{ num }}">{{ num }}</a></li>
{% else %}
<li class="page-item"><a class="page-link" href="?page={{ num }}">{{ num }}</a></li>
{% endif %}
{% endfor %} {% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% else %}
<li class="page-item disabled">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
{% endblock %}