haikal/templates/sales/sales_list.html
Marwan Alwali 692fa3f0ed update
2025-02-16 11:48:12 +03:00

286 lines
20 KiB
HTML

{% extends "base.html" %}
{% load i18n %}
{% load custom_filters %}
{% block customCSS %}
<style>
.htmx-indicator{
opacity:0;
transition: opacity 500ms ease-in;
}
.htmx-request .htmx-indicator{
opacity:1;
}
.htmx-request.htmx-indicator{
opacity:1;
}
.on-before-request{
opacity: 0.5;
pointer-events: none;
}
.transition {
transition: all ease-in 1s ;
}
</style>
{% endblock customCSS %}
{% block content %}
<div class="mb-9">
<div id="projectSummary">
<div class="row g-3 justify-content-between align-items-end mb-4">
<div class="col-12 col-sm-auto">
{% comment %} <ul class="nav nav-links mx-n2" hx-boost="true" hx-push-url='false' hx-target=".table-responsive" hx-select=".table-responsive" hx-swap="innerHTML show:window:top" hx-indicator=".htmx-indicator"
hx-on::before-request="on_before_request()"
hx-on::after-request="on_after_request()"
>
<li class="nav-item"><a class="nav-link px-2 py-1 active" aria-current="page" href="{% url 'car_list' %}"><span>All</span><span class="text-body-tertiary fw-semibold">({{stats.all}})</span></a></li>
<li class="nav-item"><a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=available"><span>Available</span><span class="text-body-tertiary fw-semibold">({{stats.available}})</span></a></li>
<li class="nav-item"><a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=reserved"><span>Reserved</span><span class="text-body-tertiary fw-semibold">({{stats.reserved}})</span></a></li>
<li class="nav-item"><a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=transfer"><span>Transfer</span><span class="text-body-tertiary fw-semibold">({{stats.transfer}})</span></a></li>
<li class="nav-item"><a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=sold"><span>Sold</span><span class="text-body-tertiary fw-semibold">({{stats.sold}})</span></a></li>
<li class="nav-item"><button hx-on:click="toggle_filter()" class="nav-link px-2 py-1"><span>Filter</span><span class="text-body-tertiary fw-semibold"></span></button></li>
</ul> {% endcomment %}
</div>
<div class="col-12 col-sm-auto">
<div class="d-flex align-items-center">
<div class="spinner-border mx-3 htmx-indicator" role="status"><span class="visually-hidden">Loading...</span></div>
<div class="search-box me-3">
<form class="position-relative">
<input class="form-control search-input search" name='search' type="search" placeholder="{{ _("Search") }}" aria-label="Search" hx-get="{% url 'car_list' %}" hx-trigger='keyup changed delay:500ms' hx-target='.table-responsive' hx-select='.table-responsive' hx-swap="innerHTML show:window:top" hx-indicator=".htmx-indicator"
hx-on::before-request="on_before_request()"
hx-on::after-request="on_after_request()"
/>
<span class="fas fa-search search-box-icon"></span>
</form>
</div><a class="btn btn-phoenix-primary px-3 me-1 border-0 text-body" href="#" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="List view"><span class="fa-solid fa-list fs-10"></span></a><a class="btn btn-phoenix-primary px-3 me-1" href="#" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Board view">
<svg width="9" height="9" viewbox="0 0 9 9" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0.5C0 0.223857 0.223858 0 0.5 0H1.83333C2.10948 0 2.33333 0.223858 2.33333 0.5V1.83333C2.33333 2.10948 2.10948 2.33333 1.83333 2.33333H0.5C0.223857 2.33333 0 2.10948 0 1.83333V0.5Z" fill="currentColor"></path>
<path d="M3.33333 0.5C3.33333 0.223857 3.55719 0 3.83333 0H5.16667C5.44281 0 5.66667 0.223858 5.66667 0.5V1.83333C5.66667 2.10948 5.44281 2.33333 5.16667 2.33333H3.83333C3.55719 2.33333 3.33333 2.10948 3.33333 1.83333V0.5Z" fill="currentColor"></path>
<path d="M6.66667 0.5C6.66667 0.223857 6.89052 0 7.16667 0H8.5C8.77614 0 9 0.223858 9 0.5V1.83333C9 2.10948 8.77614 2.33333 8.5 2.33333H7.16667C6.89052 2.33333 6.66667 2.10948 6.66667 1.83333V0.5Z" fill="currentColor"></path>
<path d="M0 3.83333C0 3.55719 0.223858 3.33333 0.5 3.33333H1.83333C2.10948 3.33333 2.33333 3.55719 2.33333 3.83333V5.16667C2.33333 5.44281 2.10948 5.66667 1.83333 5.66667H0.5C0.223857 5.66667 0 5.44281 0 5.16667V3.83333Z" fill="currentColor"></path>
<path d="M3.33333 3.83333C3.33333 3.55719 3.55719 3.33333 3.83333 3.33333H5.16667C5.44281 3.33333 5.66667 3.55719 5.66667 3.83333V5.16667C5.66667 5.44281 5.44281 5.66667 5.16667 5.66667H3.83333C3.55719 5.66667 3.33333 5.44281 3.33333 5.16667V3.83333Z" fill="currentColor"></path>
<path d="M6.66667 3.83333C6.66667 3.55719 6.89052 3.33333 7.16667 3.33333H8.5C8.77614 3.33333 9 3.55719 9 3.83333V5.16667C9 5.44281 8.77614 5.66667 8.5 5.66667H7.16667C6.89052 5.66667 6.66667 5.44281 6.66667 5.16667V3.83333Z" fill="currentColor"></path>
<path d="M0 7.16667C0 6.89052 0.223858 6.66667 0.5 6.66667H1.83333C2.10948 6.66667 2.33333 6.89052 2.33333 7.16667V8.5C2.33333 8.77614 2.10948 9 1.83333 9H0.5C0.223857 9 0 8.77614 0 8.5V7.16667Z" fill="currentColor"></path>
<path d="M3.33333 7.16667C3.33333 6.89052 3.55719 6.66667 3.83333 6.66667H5.16667C5.44281 6.66667 5.66667 6.89052 5.66667 7.16667V8.5C5.66667 8.77614 5.44281 9 5.16667 9H3.83333C3.55719 9 3.33333 8.77614 3.33333 8.5V7.16667Z" fill="currentColor"></path>
<path d="M6.66667 7.16667C6.66667 6.89052 6.89052 6.66667 7.16667 6.66667H8.5C8.77614 6.66667 9 6.89052 9 7.16667V8.5C9 8.77614 8.77614 9 8.5 9H7.16667C6.89052 9 6.66667 8.77614 6.66667 8.5V7.16667Z" fill="currentColor"></path>
</svg></a><a class="btn btn-phoenix-primary px-3" href="#" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Card view">
<svg width="9" height="9" viewBox="0 0 9 9" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0.5C0 0.223858 0.223858 0 0.5 0H3.5C3.77614 0 4 0.223858 4 0.5V3.5C4 3.77614 3.77614 4 3.5 4H0.5C0.223858 4 0 3.77614 0 3.5V0.5Z" fill="currentColor"></path>
<path d="M0 5.5C0 5.22386 0.223858 5 0.5 5H3.5C3.77614 5 4 5.22386 4 5.5V8.5C4 8.77614 3.77614 9 3.5 9H0.5C0.223858 9 0 8.77614 0 8.5V5.5Z" fill="currentColor"></path>
<path d="M5 0.5C5 0.223858 5.22386 0 5.5 0H8.5C8.77614 0 9 0.223858 9 0.5V3.5C9 3.77614 8.77614 4 8.5 4H5.5C5.22386 4 5 3.77614 5 3.5V0.5Z" fill="currentColor"></path>
<path d="M5 5.5C5 5.22386 5.22386 5 5.5 5H8.5C8.77614 5 9 5.22386 9 5.5V8.5C9 8.77614 8.77614 9 8.5 9H5.5C5.22386 9 5 8.77614 5 8.5V5.5Z" fill="currentColor"></path>
</svg></a>
</div>
</div>
</div>
<div class="d-flex align-items-center d-none filter">
<select hx-get="{% url 'car_list' %}" name="make" hx-target='.model-select' hx-select='.model-select' hx-swap="outerHTML show:window:top" hx-indicator=".htmx-indicator" class="form-select make" aria-label="Default select example"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()"
>
<option selected="" value="" disabled>Select Make</option>
{% for m in make %}
<option value="{{ m.pk }}">{{ m.name }}</option>
{% endfor %}
</select>
<select hx-get="{% url 'car_list' %}" hx-include=".make" name="model" hx-target='.year' hx-select='.year' hx-swap="outerHTML show:window:top" hx-indicator=".htmx-indicator" class="form-select model-select" aria-label="Default select example"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()"
>
<option selected="" value="" disabled>Select Model</option>
{% for m in model %}
<option value="{{ m.pk }}">{{ m.name }}</option>
{% endfor %}
</select>
<select class="form-select year" name="year" aria-label="Default select example">
<option selected="" value="" disabled>Select Year</option>
{% for y in year %}
<option value="{{ y.0 }}">{{ y.0 }}</option>
{% endfor %}
</select>
<select class="form-select car_status" name="car_status" aria-label="Default select example">
<option selected="" value="">All</option>
<option value="available">Available</option>
<option value="reserved">Reserved</option>
<option value="sold">Sold</option>
<option value="transfer">Transfer</option>
</select>
<button id="search" hx-get="{% url 'car_list' %}" hx-include=".make,.model,.year,.car_status" hx-indicator=".htmx-indicator" hx-target='.table-responsive' hx-select='.table-responsive' hx-swap="outerHTML show:window:top" class="btn btn-sm btn-phoenix-primary"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">Search</button>
</div>
<div class="table-responsive scrollbar transition">
<div class="d-flex flex-wrap align-items-center justify-content-between py-3 pe-0 fs-9 border-bottom border-translucent">
<div class="d-flex">
</div>
<div class="d-flex" hx-boost="true" hx-push-url='false' hx-include=".make,.model,.year,.car_status" hx-target=".table-responsive" hx-select=".table-responsive" hx-swap="innerHTML show:window:top" hx-indicator=".htmx-indicator"
hx-on::before-request="on_before_request()"
hx-on::after-request="on_after_request()">
{% if page_obj.has_previous %}
<a href="{% url 'sales_list' %}?page={{page_obj.previous_page_number}}" class="page-link" data-list-pagination="prev"><span class="fas fa-chevron-left"></span></a>
{% endif %}
<ul class="mb-0 pagination">Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</ul>
{% if page_obj.has_next %}
<a href="{% url 'sales_list' %}?page={{page_obj.next_page_number}}" class="page-link pe-0" data-list-pagination="next"><span class="fas fa-chevron-right"></span></a>
{% endif %}
</div>
</div>
<table class="table fs-9 mb-0 border-top border-translucent">
<thead>
<tr>
<th class="sort white-space-nowrap align-middle ps-0" scope="col" data-sort="projectName" style="width:10%;">
{{ _("Customer Name")}}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="assignees" style="width:5%;">{{ _("Customer Address")}}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="start" style="width:5%;">{{ _("Customer Phone")}}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="deadline" style="width:5%;">{{ _("Make") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">{{ _("Model") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">{{ _("VIN") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">{{ _("Trim") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">{{ _("Price") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:7%;">{{ _("Quotation") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:7%;">{{ _("Invoice") }}</th>
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:7%;">{{ _("Staff Member") }}</th>
<th class="sort align-middle text-end" scope="col" style="width:10%;"></th>
</tr>
</thead>
<tbody class="list" id="project-list-table-body">
{% for tx in txs %}
<tr class="position-static">
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
<p class="mb-0 fs-9 text-body">{{tx.customer.customer_name}}</p>
</td>
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
<p class="mb-0 fs-9 text-body">{{tx.customer.address_1}}</p>
</td>
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
<p class="mb-0 fs-9 text-body">{{tx.customer.phone}}</p>
</td>
<td class="align-middle time white-space-nowrap ps-0 projectName py-4">{{tx.info.make}}</td>
<td class="align-middle white-space-nowrap start ps-3 py-4">
<p class="mb-0 fs-9 text-body">{{tx.info.model}}</p>
</td>
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
<p class="mb-0 fs-9 text-body">{{tx.info.vin}}</p>
</td>
<td class="align-middle white-space-nowrap task ps-3 py-4">
<p class="fw-bo text-body fs-9 mb-0">{{tx.info.trim}}</p>
</td>
<td class="align-middle white-space-nowrap task ps-3 py-4">
<p class="fw-bo text-body fs-9 mb-0">{{tx.finance.total}}</p>
</td>
<td class="align-middle white-space-nowrap task ps-3 py-4">
{% if tx.has_estimate %}
<p class="fw-bo text-body fs-9 mb-0">
<a href="{% url 'estimate_detail' tx.estimate.uuid %}">
{{tx.estimate.estimate_number}}
</a><br>
{% if tx.estimate.status == "draft" %}
<span class="badge badge-phoenix badge-phoenix-warning">{{tx.estimate.status}}</span>
{% elif tx.estimate.status == "in_review" %}
<span class="badge badge-phoenix badge-phoenix-info">{{tx.estimate.status}}</span>
{% elif tx.estimate.status == "approved" %}
<span class="badge badge-phoenix badge-phoenix-success">{{tx.estimate.status}}</span>
{% elif tx.estimate.status == "completed" %}
<span class="badge badge-phoenix badge-phoenix-success">{{tx.estimate.status}}</span>
{% endif %}
</p>
{% endif %}
</td>
<td class="align-middle white-space-nowrap task ps-3 py-4">
{% if tx.has_invoice %}
<p class="fw-bo text-body fs-9 mb-0">
<a href="{% url 'invoice_detail' tx.invoice.uuid %}">
{{tx.invoice.invoice_number}}
</a><br>
{% if tx.invoice.is_draft %}
<span class="badge badge-phoenix badge-phoenix-warning">{{tx.invoice.invoice_status}}</span>
{% elif tx.invoice.is_review %}
<span class="badge badge-phoenix badge-phoenix-info">{{tx.invoice.invoice_status}}</span>
{% elif tx.invoice.is_approved %}
<span class="badge badge-phoenix badge-phoenix-info">{{tx.invoice.invoice_status}}</span>
{% elif tx.invoice.is_completed %}
<span class="badge badge-phoenix badge-phoenix-success">{{tx.invoice.invoice_status}}</span>
{% elif tx.invoice.is_paid %}
<span class="badge badge-phoenix badge-phoenix-success">{{tx.invoice.invoice_status}}</span>
{% elif tx.invoice.is_canceled %}
<span class="badge badge-phoenix badge-phoenix-danger">{{tx.invoice.invoice_status}}</span>
{% elif tx.invoice.is_past_due %}
<span class="badge badge-phoenix badge-phoenix-danger">{{ _("Past Due")}}</span>
{% endif %}
</p>
{% endif %}
</td>
<td class="align-middle white-space-nowrap text-end statuses">
{% if car.status == "available" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-success">{{car.status}}</span>
{% elif car.status == "reserved" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-danger">{{car.status}}</span>
{% elif car.status == "sold" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-info">{{car.status}}</span>
{% elif car.status == "transfer" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-warning">{{car.status}}</span>
{% endif %}
</td>
<td class="align-middle text-end white-space-nowrap pe-0 action">
<div class="btn-reveal-trigger position-static">
<button class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10" type="button" data-bs-toggle="dropdown" data-boundary="window" aria-haspopup="true" aria-expanded="false" data-bs-reference="parent"><span class="fas fa-ellipsis-h fs-10"></span></button>
<div class="dropdown-menu dropdown-menu-end py-2"><a class="dropdown-item" href="">{{ _("View") }}</a><a class="dropdown-item" href="">{{ _("Export") }}</a>
<div class="dropdown-divider"></div><a class="dropdown-item text-danger" href="">{{ _("Remove") }}</a>
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="d-flex flex-wrap align-items-center justify-content-between py-3 pe-0 fs-9 border-bottom border-translucent">
<div class="d-flex">
{% if is_paginated %}
{% include 'partials/pagination.html' %}
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block customJS %}
<script>
links = document.querySelectorAll('.nav-link')
links.forEach(link => {
link.addEventListener('click', () => {
links.forEach(link => {
link.classList.remove('active')
})
link.classList.add('active')
})
})
function on_before_request() {
document.querySelector('.table').classList.toggle('on-before-request')
document.querySelector('.model-select').classList.add('on-after-request')
}
function on_after_request() {
document.querySelector('.table').classList.remove('on-before-request')
document.querySelector('.model-select').classList.remove('on-after-request')
}
function toggle_filter(){
document.querySelector('.filter').classList.toggle('d-none')
}
function filter_before_request(){
document.querySelector('.model-select').setAttribute('disabled', true)
document.querySelector('.year').setAttribute('disabled', true)
document.querySelector('.car_status').setAttribute('disabled', true)
}
function filter_after_request(){
document.querySelector('.model-select').removeAttribute('disabled')
document.querySelector('.year').removeAttribute('disabled')
document.querySelector('.car_status').removeAttribute('disabled')
}
</script>
{% endblock customJS %}