first push

This commit is contained in:
2025-05-23 14:44:12 +08:00
commit abefd1b19b
817 changed files with 580289 additions and 0 deletions
@@ -0,0 +1,127 @@
<div class="modal-content">
<div class="modal-header bg-dark text-center">
<h5 class="modal-title white w-100" id="myModalLabel160">添加位置
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close">
</button>
</div>
<form hx-post="{{request.path}}" novalidate>
{% csrf_token %}
<div class="modal-body">
<div class="row">
<div class="col-md-6 col-12">
<div class="form-group">
<label>办公室名称</label>
{{location_form.office_name}}
{% for error in location_form.office_name.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>联系人姓名</label>
{{location_form.contact_person_name}}
{% for error in location_form.contact_person_name.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>联系人邮箱</label>
{{location_form.contact_person_email}}
{% for error in location_form.contact_person_email.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>联系人电话</label>
{{location_form.contact_person_phone}}
{% for error in location_form.contact_person_phone.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>地址行 1</label>
{{address_form.address_line_one}}
{% for error in address_form.address_line_one.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>地址行 2</label>
{{address_form.address_line_two}}
{% for error in address_form.address_line_two.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>国家</label>
{{address_form.country}}
{% for error in address_form.country.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>省份</label>
{{address_form.state}}
{% for error in address_form.state.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>城市</label>
{{address_form.city}}
{% for error in address_form.city.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>邮编</label>
{{address_form.pin_code}}
{% for error in address_form.pin_code.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light-secondary"
data-bs-dismiss="modal">
<i class="bx bx-x d-block d-sm-none"></i>
<span class="d-none d-sm-block">关闭</span>
</button>
<button type="submit" class="btn btn-info ml-1"
onclick="this.innerHTML = `<span class='spinner-grow spinner-grow-sm' role='status' aria-hidden='true'></span> Saving...`;"
>
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">保存</span>
</button>
</div>
</form>
</div>
<script>
htmx.on("htmx:beforeSwap", (e) => {
if (
e.detail.target.id == "add-location-modal-content" && !e.detail.xhr.response){
location.reload();
}
});
</script>
+73
View File
@@ -0,0 +1,73 @@
{% 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>Location Details</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" aria-current="page">Locations</li>
<li class="breadcrumb-item active" aria-current="page">Location Details</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div>
<a href="{% url 'dashboard:locations' %}" class="btn btn-sm btn-outline-info my-3">Back to Location List</a>
</div>
<div class="card">
<div class="card-body">
<h6 class="my-3">
<i class="bi bi-geo-alt-fill"></i>
<span>Location Information</span>
</h6>
<div class="table-responsive">
<table class="table table-borderless">
<tbody>
<tr>
<th scope="row">Office Name</th>
<td>{{location.office_name}}</td>
<th scope="row">Contact Person Name</th>
<td>{{location.contact_person_name}}</td>
</tr>
<tr>
<th scope="row">Contact Person Email</th>
<td>{{location.contact_person_email}}</td>
<th scope="row">Contact Person Number</th>
<td>{{location.contact_person_phone}}</td>
</tr>
<tr>
<th scope="row">Country</th>
<td>{{location.address.country}}</td>
<th scope="row">State</th>
<td>{{location.address.state}}</td>
</tr>
<tr>
<th scope="row">City</th>
<td>{{location.address.city}}</td>
<th scope="row">Zip Code</th>
<td>{{location.address.pin_code}}</td>
</tr>
<tr>
<th scope="row">Address Line 1</th>
<td colspan="3">{{location.address.address_line_one}}</td>
</tr>
<tr>
<th scope="row">Address Line 2</th>
<td colspan="3">{{location.address.address_line_two}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{% include 'commons/history.html' %}
</section>
</div>
{% endblock content%}
+113
View File
@@ -0,0 +1,113 @@
{% 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">Locations</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
{% if perms.authentication.add_location %}
<div>
<button type="button" class="btn btn-sm btn-outline-info my-3"
hx-get="{% url 'dashboard:add_location' %}" hx-target="#add-location-modal-content"
data-bs-toggle="modal" data-bs-target="#add-location-modal"
>添加位置</i></button>
</div>
{% endif %}
<!-- add modal -->
<div class="modal fade text-left" id="add-location-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-location-modal-content" class="modal-content" hx-target="this"></div>
</div>
</div>
<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='Search here...'
hx-get="{% url 'dashboard:search_location' page_object.number %}" hx-trigger="keyup changed delay:500ms, search" hx-target="#search_result">
</div>
{% endif %}
<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.view_location or perms.authentication.delete_location or perms.authentication.edit_location %}
<th>操作</th>
{% endif %}
</tr>
</thead>
{% if page_object %}
<tbody id="search_result">
{% for location in page_object %}
<tr>
<td>{{page_object.start_index|add:forloop.counter0}}</td>
<td>{{location.office_name}}</td>
<td>{{location.contact_person_name}}</td>
<td>{{location.address.state}}</td>
<td>{{location.address.city}}</td>
<td>{{location.address.pin_code}}</td>
<td>
{% if request.user.is_superuser %}
<div class="form-check form-switch">
<input
class="form-check-input"
hx-post="{% url 'dashboard:location_status' location.id %}"
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
type="checkbox" {% if location.status %} checked {% endif %}
style="cursor: pointer;"
>
</div>
{% else %}
{% if location.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_location %}
<a href="{% url 'dashboard:location_details' location.id %}" class="btn btn-success"><i class="bi bi-eye-fill"></i></a>
{% endif %}
{% if perms.authentication.edit_location %}
<a href="{% url 'dashboard:update_location' location.id %}" class="btn btn-info"><i class="bi bi-pencil-square"></i></a>
{% endif %}
{% if perms.authentication.delete_location %}
<form action="{% url 'dashboard:delete_location' location.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">
No record available!
</div>
{% endif %}
</table>
{% include 'commons/pagination.html' %}
</div>
</div>
</section>
</div>
{% endblock content%}
@@ -0,0 +1,51 @@
{% if page_object %}
{% for location in page_object %}
<tr>
<td>
{% if page_object.start_index %}
{{page_object.start_index|add:forloop.counter0}}
{% else %}
{{forloop.counter}}
{% endif %}
</td>
<td>{{location.office_name}}</td>
<td>{{location.contact_person_name}}</td>
<td>{{location.address.state}}</td>
<td>{{location.address.city}}</td>
<td>{{location.address.pin_code}}</td>
<td>
{% if request.user.is_superuser %}
<div class="form-check form-switch">
<input
class="form-check-input"
hx-post="{% url 'dashboard:location_status' location.id %}"
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
type="checkbox" {% if location.status %} checked {% endif %}
style="cursor: pointer;"
>
</div>
{% else %}
{% if location.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_location %}
<a href="{% url 'dashboard:location_details' location.id %}" class="btn btn-success"><i class="bi bi-eye-fill"></i></a>
{% endif %}
{% if perms.authentication.edit_location %}
<a href="{% url 'dashboard:update_location' location.id %}" class="btn btn-info"><i class="bi bi-pencil-square"></i></a>
{% endif %}
{% if perms.authentication.delete_location %}
<form action="{% url 'dashboard:delete_location' location.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 %}
{% else %}
<td colspan="8" class="text-center"> No record found related to your search keyword</td>
{% endif %}
@@ -0,0 +1,128 @@
{% 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>Update Location</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">Locations</li>
<li class="breadcrumb-item active" aria-current="page">Update Location</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div>
<a href="{% url 'dashboard:locations' %}" class="btn btn-sm btn-outline-info my-3">Back to Location List</a>
</div>
<form class="form row" action="{% url 'dashboard:update_location' location.id %}" method="POST" novalidate>
{% csrf_token %}
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6 col-12">
<div class="form-group">
<label>Office Name</label>
{{location_form.office_name}}
{% for error in location_form.office_name.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Contact Person Name</label>
{{location_form.contact_person_name}}
{% for error in location_form.contact_person_name.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Contact Person Email</label>
{{location_form.contact_person_email}}
{% for error in location_form.contact_person_email.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Contact Person Phone</label>
{{location_form.contact_person_phone}}
{% for error in location_form.contact_person_phone.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Address Line 1</label>
{{address_form.address_line_one}}
{% for error in address_form.address_line_one.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Address Line 2</label>
{{address_form.address_line_two}}
{% for error in address_form.address_line_two.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Country</label>
{{address_form.country}}
{% for error in address_form.country.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>State</label>
{{address_form.state}}
{% for error in address_form.state.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>City</label>
{{address_form.city}}
{% for error in address_form.city.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
<div class="col-md-6 col-12">
<div class="form-group">
<label>Zip Code</label>
{{address_form.pin_code}}
{% for error in address_form.pin_code.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="card-header">
<button type="submit" class="btn btn-sm btn-info float-end">Save</button>
</div>
</div>
</form>
</section>
</div>
{% endblock content%}