Files
2025-05-23 14:44:12 +08:00

128 lines
7.2 KiB
HTML

{% extends 'layouts/main-layout.html' %}
{% block content %}
<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>供应商</h3>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page">Vendors</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
{% if perms.authentication.add_vendor %}
<div>
<button type="button" class="btn btn-sm btn-outline-info my-3"
hx-get="{% url 'vendors:add' %}" hx-target="#add-vendor-modal-content"
data-bs-toggle="modal" data-bs-target="#add-vendor-modal">添加供应商</button>
<div class="modal fade text-left" id="add-vendor-modal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel160" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div id="add-vendor-modal-content" class="modal-content" hx-target="this"></div>
</div>
</div>
</div>
{% endif %}
<div class="card">
<div class="card-body">
{% if page_object %}
<div class="d-flex justify-content-end my-2 gap-2">
<input name="search_text" type="search" class='dataTable-input' autocomplete="off" placeholder='搜索'
hx-get="{% url 'vendors:search' page_object.number %}" hx-trigger="keyup changed delay:500ms, search" hx-target="#search_result">
{% if request.user.is_superuser %}
<button
type="button"
class="btn btn-secondary rounded"
data-bs-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
><i class="bi bi-download"></i></button>
<div class="dropdown-menu">
<a class="dropdown-item" href="{% url 'vendors:export_vendors_csv' %}"><i class="bi bi-filetype-csv"></i> CSV Format</a>
<a class="dropdown-item" href="{% url 'vendors:export_vendors_pdf' %}"><i class="bi bi-filetype-pdf"></i> PDF Format</a>
</div>
{% endif %}
</div>
{% endif %}
<div class="table-responsive">
<table class="table table-hover" id="table1">
<thead>
<tr>
<th>序号</th>
<th>供应商名称</th>
<th>联系人</th>
<th>邮箱</th>
<th>税号</th>
<th>电话号码</th>
<th>状态</th>
{% if perms.authentication.edit_vendor or perms.authentication.view_vendor or perms.authentication.delete_vendor %}
<th>操作</th>
{% endif %}
</tr>
</thead>
{% if page_object %}
<tbody id="search_result">
{% for vendors in page_object %}
<tr>
<td>{{forloop.counter}}</td>
<td>{{vendors.name}}</td>
<td>{{vendors.contact_person}}</td>
<td>{{vendors.email}}</td>
<td>{{vendors.gstin_number}}</td>
<td>{{vendors.phone}}</td>
<td>
{% if request.user.is_superuser %}
<div class="form-check form-switch">
<input
class="form-check-input"
hx-post="{% url 'vendors:status' vendors.id %}"
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
type="checkbox" {% if vendors.status %} checked {% endif %}
style="cursor: pointer;"
>
</div>
{% else %}
{% if vendors.status %} Active {% else %} Inactive {% endif %}
{% endif %}
</td>
<td>
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
{% if perms.authentication.view_vendor %}
<a href="{% url 'vendors:details' vendors.id %}" class="btn btn-success"><i class="bi bi-eye-fill"></i></a>
{% endif %}
{% if perms.authentication.edit_vendor %}
<a href="{% url 'vendors:update_vendor' vendors.id %}" class="btn btn-info"><i class="bi bi-pencil-square"></i></a>
{% endif %}
{% if perms.authentication.delete_vendor %}
<form action="{% url 'vendors:delete_vendor' vendors.id %}" method="post" onsubmit="return confirm('Are you sure you want to delete this?')">
{% csrf_token %}
<button type="submit" value="Delete" class="btn btn-sm btn-danger"><i class="bi bi-trash3-fill"></i></button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
{% else %}
<div class="alert alert-info" role="alert">
暂无记录
</div>
{% endif %}
</table>
</div>
{% include 'commons/pagination.html' %}
</div>
</div>
</section>
</div>
{% endblock content%}