car list filter fix

This commit is contained in:
Faheedkhan 2025-08-27 14:11:33 +03:00
parent ac01d944dd
commit e9f301ee20
3 changed files with 211 additions and 260 deletions

View File

@ -77,15 +77,182 @@
<div class="row-fluid {% if car.status == 'sold' %}disabled{% endif %}">
<div class="row g-3 justify-content-between">
<div class="col-md-6">
<div class="row mb-2">
<div class="col-md-4">
<div class="card mb-3 rounded shadow d-flex justify-content-center align-item-center{% if car.get_transfer %}disabled{% endif %}">
<p class="card-header rounded-top fw-bold">{% trans 'Car Details' %}</p>
<div class="col-md-4 ms-4 mt-2">
<div class="avatar avatar-6xl mb-3">
<img class="rounded"
src="{% static 'images/car_images/' %}{{ car.get_hash }}.png"
alt="{{ car.vin }}" />
</div>
</div>
<div class="col-md-8">
<div class="card-body">
<div class="table-responsive scrollbar mb-3">
<table class="table table-sm fs-9 mb-0 overflow-hidden">
<tr>
<th>{% trans "VIN" %}</th>
<td>{{ car.vin }}</td>
</tr>
<tr>
<th>{% trans "year"|capfirst %}</th>
<td>{{ car.year }}</td>
</tr>
<tr>
<th>{% trans "make"|capfirst %}</th>
<td>{{ car.id_car_make.get_local_name }}</td>
</tr>
<tr>
<th>{% trans "model"|capfirst %}</th>
<td>{{ car.id_car_model.get_local_name }}</td>
</tr>
<tr>
<th>{% trans "series"|capfirst %}</th>
<td>{{ car.id_car_serie.name }}</td>
</tr>
<tr>
<th>{% trans "trim"|capfirst %}</th>
<td>{{ car.id_car_trim.name }}</td>
</tr>
<tr>
<th>{% trans "Status"|capfirst %}</th>
<td>{{ car.get_status_display }}</td>
</tr>
<tr>
<th>{% trans "Stock Type"|capfirst %}</th>
<td>{{ car.get_stock_type_display }}</td>
</tr>
<tr>
<th>{% trans "Mileage"|capfirst %}</th>
<td>{{ car.mileage }}</td>
</tr>
<tr>
<th>{% trans "Receiving Date"|capfirst %}</th>
<td>{{ car.receiving_date|timesince }}</td>
</tr>
{% if car.vendor %}
<tr>
<th>{% trans "Vendor"|capfirst %}</th>
<td>{{ car.vendor.name }}</td>
</tr>
{% endif %}
<tr>
<th>{% trans "Remarks"|capfirst %}</th>
<td>{{ car.remarks }}</td>
</tr>
<tr>
<th>{% trans 'specifications'|capfirst %}</th>
<td>
<button type="button"
class="btn btn-phoenix-primary btn-sm"
id="specification-btn"
data-bs-toggle="modal"
data-bs-target="#specificationsModal">
{% trans 'view'|capfirst %}
</button>
</td>
</tr>
{% if car.custom_cards %}
<tr>
<th>{% trans "Custom Number"|capfirst %}</th>
<td>{{ car.custom_cards.custom_number }}</td>
</tr>
<tr>
<th>{% trans "Custom Date"|capfirst %}</th>
<td>{{ car.custom_cards.custom_date|date }}</td>
</tr>
{% else %}
<tr>
<th>{% trans "Custom Card" %}</th>
<td>
{% if perms.inventory.add_customcard %}
<button type="button"
class="btn btn-sm btn-phoenix-success"
data-bs-toggle="modal"
data-bs-target="#mainModal"
hx-get="{% url 'add_custom_card' request.dealer.slug car.slug %}"
hx-target=".main-modal-body"
hx-swap="innerHTML">{% trans 'Add' %}</button>
{% endif %}
</td>
</tr>
{% endif %}
{% if car.registrations %}
<tr>
<th>{% trans "Registration"|capfirst %}</th>
<td>
{{ car.registrations.plate_number }} | {{ car.registrations.text1 }} {{ car.registrations.text2 }} {{ car.registrations.text3 }}
</td>
</tr>
<tr>
<th>{% trans "Registration Date"|capfirst %}</th>
<td>{{ car.registrations.registration_date|date }}</td>
</tr>
{% else %}
<tr>
<th>{% trans "Registration" %}</th>
<td>
{% if perms.inventory.add_carregistration %}
<button type="button"
class="btn btn-sm btn-phoenix-success"
data-bs-toggle="modal"
data-bs-target="#mainModal"
hx-get="{% url 'add_registration' request.dealer.slug car.slug %}"
hx-target=".main-modal-body"
hx-swap="innerHTML">{% trans 'Add' %}</button>
{% endif %}
</td>
</tr>
{% endif %}
<tr>
<th>{% trans 'Location'|capfirst %}</th>
<td>
{% if car.marked_price and not car.get_transfer %}
{% if car.location %}
{% if car.location.is_owner_showroom %}
{% trans 'Our Showroom' %}
{% else %}
{{ car.location.showroom.get_local_name }}
{% endif %}
{% if perms.inventory.add_cartransfer %}
<a href="{% url 'update_car_location' car.slug car.location.pk %}"
class="btn btn-phoenix-danger btn-sm">
{% trans "transfer"|capfirst %}
</a>
{% endif %}
{% else %}
{% trans "No location available." %}
{% if perms.inventory.add_carlocation %}
<a href="{% url 'add_car_location' car.slug %}"
class="btn btn-phoenix-success btn-sm ms-2">{% trans "Add" %}</a>
{% endif %}
{% endif %}
{% endif %}
</td>
</tr>
</table>
</div>
<div>
{% if not car.get_transfer %}
{% if perms.inventory.change_car %}
<a href="{% url 'car_update' request.dealer.slug car.slug %}"
class="btn btn-phoenix-primary btn-sm mt-1 me-3 mb-3">{% trans "Edit" %}
<span class="fas fa-solid fa-pencil ms-1"></span>
</a>
<a href="{% url 'transfer' car.slug %}"
class="btn btn-phoenix-danger btn-sm">
{% trans "Sell to another dealer"|capfirst %}
</a>
{% endif %}
{% else %}
<span class="badge bg-danger">{% trans "Cannot Edit, Car in Transfer." %}</span>
{% endif %}
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row mb-2">
<div class="col-md-12">
<div class="card rounded shadow d-flex align-content-center {% if car.get_transfer %}transfer{% endif %}">
<p class="card-header rounded-top fw-bold">{% trans 'Financial Details' %}</p>
<div class="card-body">
@ -100,34 +267,7 @@
<th>{% trans "Marked Price"|capfirst %}</th>
<td>{{ car.marked_price|floatformat:2 }}</td>
</tr>
{% comment %} <tr>
<th>{% trans "Selling Price"|capfirst %}</th>
<td>{{ car.finances.selling_price|floatformat:2 }}</td>
</tr>
<tr>
<th>{% trans "Discount Amount"|capfirst %}</th>
<td>{{ car.finances.discount_amount|floatformat:2 }}</td>
</tr>
<tr>
<th>{% trans "Additional Fee"|capfirst %}</th>
<td></td>
</tr>
{% if car.finances.additional_services.first.pk %}
{% for service in car.finances.additional_services.all %}
<tr>
<td>{{ service.name }}</td>
<td>{{ service.price_|floatformat:2 }}</td>
</tr>
{% endfor %}
{% endif %}
<tr>
<th>{% trans "VAT Amount"|capfirst %}</th>
<td>{{ car.finances.vat_amount|floatformat:2 }}</td>
</tr>
<tr>
<th>{% trans "Total"|capfirst %}</th>
<td>{{ car.finances.total_vat|floatformat:2 }}</td>
</tr> {% endcomment %}
<tr>
<td colspan="2">
{% if not car.get_transfer %}
@ -327,173 +467,7 @@
</div>
{% endif %}
</div>
<div class="col-md-6">
<div class="card mb-3 rounded shadow d-flex align-content-center {% if car.get_transfer %}disabled{% endif %}">
<p class="card-header rounded-top fw-bold">{% trans 'Car Details' %}</p>
<div class="card-body">
<div class="table-responsive scrollbar mb-3">
<table class="table table-sm fs-9 mb-0 overflow-hidden">
<tr>
<th>{% trans "VIN" %}</th>
<td>{{ car.vin }}</td>
</tr>
<tr>
<th>{% trans "year"|capfirst %}</th>
<td>{{ car.year }}</td>
</tr>
<tr>
<th>{% trans "make"|capfirst %}</th>
<td>{{ car.id_car_make.get_local_name }}</td>
</tr>
<tr>
<th>{% trans "model"|capfirst %}</th>
<td>{{ car.id_car_model.get_local_name }}</td>
</tr>
<tr>
<th>{% trans "series"|capfirst %}</th>
<td>{{ car.id_car_serie.name }}</td>
</tr>
<tr>
<th>{% trans "trim"|capfirst %}</th>
<td>{{ car.id_car_trim.name }}</td>
</tr>
<tr>
<th>{% trans "Status"|capfirst %}</th>
<td>{{ car.get_status_display }}</td>
</tr>
<tr>
<th>{% trans "Stock Type"|capfirst %}</th>
<td>{{ car.get_stock_type_display }}</td>
</tr>
<tr>
<th>{% trans "Mileage"|capfirst %}</th>
<td>{{ car.mileage }}</td>
</tr>
<tr>
<th>{% trans "Receiving Date"|capfirst %}</th>
<td>{{ car.receiving_date|timesince }}</td>
</tr>
{% if car.vendor %}
<tr>
<th>{% trans "Vendor"|capfirst %}</th>
<td>{{ car.vendor.name }}</td>
</tr>
{% endif %}
<tr>
<th>{% trans "Remarks"|capfirst %}</th>
<td>{{ car.remarks }}</td>
</tr>
<tr>
<th>{% trans 'specifications'|capfirst %}</th>
<td>
<button type="button"
class="btn btn-phoenix-primary btn-sm"
id="specification-btn"
data-bs-toggle="modal"
data-bs-target="#specificationsModal">
{% trans 'view'|capfirst %}
</button>
</td>
</tr>
{% if car.custom_cards %}
<tr>
<th>{% trans "Custom Number"|capfirst %}</th>
<td>{{ car.custom_cards.custom_number }}</td>
</tr>
<tr>
<th>{% trans "Custom Date"|capfirst %}</th>
<td>{{ car.custom_cards.custom_date|date }}</td>
</tr>
{% else %}
<tr>
<th>{% trans "Custom Card" %}</th>
<td>
{% if perms.inventory.add_customcard %}
<button type="button"
class="btn btn-sm btn-phoenix-success"
data-bs-toggle="modal"
data-bs-target="#mainModal"
hx-get="{% url 'add_custom_card' request.dealer.slug car.slug %}"
hx-target=".main-modal-body"
hx-swap="innerHTML">{% trans 'Add' %}</button>
{% endif %}
</td>
</tr>
{% endif %}
{% if car.registrations %}
<tr>
<th>{% trans "Registration"|capfirst %}</th>
<td>
{{ car.registrations.plate_number }} | {{ car.registrations.text1 }} {{ car.registrations.text2 }} {{ car.registrations.text3 }}
</td>
</tr>
<tr>
<th>{% trans "Registration Date"|capfirst %}</th>
<td>{{ car.registrations.registration_date|date }}</td>
</tr>
{% else %}
<tr>
<th>{% trans "Registration" %}</th>
<td>
{% if perms.inventory.add_carregistration %}
<button type="button"
class="btn btn-sm btn-phoenix-success"
data-bs-toggle="modal"
data-bs-target="#mainModal"
hx-get="{% url 'add_registration' request.dealer.slug car.slug %}"
hx-target=".main-modal-body"
hx-swap="innerHTML">{% trans 'Add' %}</button>
{% endif %}
</td>
</tr>
{% endif %}
<tr>
<th>{% trans 'Location'|capfirst %}</th>
<td>
{% if car.marked_price and not car.get_transfer %}
{% if car.location %}
{% if car.location.is_owner_showroom %}
{% trans 'Our Showroom' %}
{% else %}
{{ car.location.showroom.get_local_name }}
{% endif %}
{% if perms.inventory.add_cartransfer %}
<a href="{% url 'update_car_location' car.slug car.location.pk %}"
class="btn btn-phoenix-danger btn-sm">
{% trans "transfer"|capfirst %}
</a>
{% endif %}
{% else %}
{% trans "No location available." %}
{% if perms.inventory.add_carlocation %}
<a href="{% url 'add_car_location' car.slug %}"
class="btn btn-phoenix-success btn-sm ms-2">{% trans "Add" %}</a>
{% endif %}
{% endif %}
{% endif %}
</td>
</tr>
</table>
</div>
<div>
{% if not car.get_transfer %}
{% if perms.inventory.change_car %}
<a href="{% url 'car_update' request.dealer.slug car.slug %}"
class="btn btn-phoenix-primary btn-sm mt-1 me-3 mb-3">{% trans "Edit" %}
<span class="fas fa-solid fa-pencil ms-1"></span>
</a>
<a href="{% url 'transfer' car.slug %}"
class="btn btn-phoenix-danger btn-sm">
{% trans "Sell to another dealer"|capfirst %}
</a>
{% endif %}
{% else %}
<span class="badge bg-danger">{% trans "Cannot Edit, Car in Transfer." %}</span>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% if car.status == 'sold' %}
<img class="car_status"

View File

@ -239,12 +239,12 @@
<span class="fs-10 fw-light me-2">{{ _("Inventory Ready") }}</span>
{% if car.ready %}
<span class="badge bg-success rounded-circle p-1 me-2">
<span class="visually-hidden">Ready</span>
<span class="visually-hidden">{% trans "Ready" %}</span>
</span>
<span class="text-success fw-bold">{{ _("Yes") }}</span>
{% else %}
<span class="badge bg-danger rounded-circle p-1 me-2">
<span class="visually-hidden">Not Ready</span>
<span class="visually-hidden">{% trans "Not Ready" %}</span>
</span>
<span class="text-danger fw-bold">{{ _("No") }}</span>
{% endif %}
@ -306,3 +306,11 @@
{% include "empty-illustration-page.html" with value="car" url=create_car_url %}
{% endif %}
{% endblock %}
{% block customJS%}
<script>
function toggle_filter() {
const filterContainer = document.querySelector('.filter');
filterContainer.classList.toggle('d-none');
}
</script>
{% endblock %}

View File

@ -1,68 +1,37 @@
{% extends 'base.html' %}
{% load i18n crispy_forms_filters %}
{% block title %}
{% trans 'Billing Information' %}
{% trans 'Billing Information' %}
{% endblock %}
{% block content %}
{% comment %} <div class="row mb-3">
<div class="col-sm-6">
<form action="{% url 'billing_info' %}{% if request.GET.next %}?next={{ request.GET.next }}{% endif %}" method="post" class="form">
<h3>{% trans "Provide billing data"|upper %}</h3>
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-sm btn-phoenix-success me-2">
<i class="fa fa-save me-1"></i>{{ _("Save") }}
</button>
{% if object %}
<a class="btn btn-sm btn-phoenix-danger " href="{% url 'billing_info_delete' %}"><i class="fa-solid fa-trash me-1"></i> {{ _("Delete") }}</a>
{% endif %}
</form>
</div>
</div> {% endcomment %}
<!---->
<div class="row justify-content-center mt-5 mb-3">
<div class="col-lg-8 col-md-10">
<div class="card shadow-sm border-0 rounded-3">
<div class="card-header bg-gray-200 py-3 border-0 rounded-top-3">
<h3 class="mb-0 fs-4 text-center">
{% trans "Provide billing data"|upper %}<span class="fas fa-file-invoice-dollar ms-2 text-primary"></span>
</h3>
{% trans 'Billing Information' %}
{% endblock %}
{% block content %}
<main class="d-flex align-items-center justify-content-center min-vh-80 py-5">
<div class="col-md-8">
<div class="card shadow-lg border-0 rounded-4 overflow-hidden animate__animated animate__fadeInUp">
<div class="card-header bg-gradient py-4 border-0 rounded-top-4">
<h3 class="mb-0 fs-4 fw-bold text-center">
{% trans "Provide billing data"|upper %}
<i class="fas fa-file-invoice-dollar ms-2"></i>
</h3>
</div>
<div class="card-body p-4 p-md-5">
<form action="{% url 'billing_info' %}{% if request.GET.next %}?next={{ request.GET.next }}{% endif %}"
method="post"
class="needs-validation"
novalidate>
{% csrf_token %}
{{ form|crispy }}
<hr class="my-4">
<div class="d-grid gap-2 d-md-flex justify-content-md-center mt-3">
<button class="btn btn-phoenix-primary btn-lg me-md-2" type="submit">
<i class="fa-solid fa-floppy-disk me-1"></i>
{{ _("Save") }}
</button>
<a href="{% url 'dealer_detail' request.dealer.slug %}"
<main class="d-flex align-items-center justify-content-center min-vh-80 py-5">
<div class="col-md-8">
<div class="card shadow-lg border-0 rounded-4 overflow-hidden animate__animated animate__fadeInUp">
<div class="card-header bg-gradient py-4 border-0 rounded-top-4">
<h3 class="mb-0 fs-4 fw-bold text-center">
{% trans "Provide billing data"|upper %}
<i class="fas fa-file-invoice-dollar ms-2"></i>
</h3>
</div>
<div class="card-body p-4 p-md-5">
<form action="{% url 'billing_info' %}{% if request.GET.next %}?next={{ request.GET.next }}{% endif %}"
method="post" class="needs-validation" novalidate>
{% csrf_token %}
{{ form|crispy }}
<hr class="my-4">
<div class="d-grid gap-2 d-md-flex justify-content-md-center mt-3">
<button class="btn btn-phoenix-primary btn-lg me-md-2" type="submit">
<i class="fa-solid fa-floppy-disk me-1"></i>
{{ _("Save") }}
</button>
<a href="{% url 'dealer_detail' request.dealer.slug %}"
class="btn btn-lg btn-phoenix-secondary md-me-2"
type="submit"><i class="fa-solid fa-ban me-1"></i>{{ _("Cancel") }}</a>
</div>
</form>
</div>
</div>
</div>
</main>
{% endblock %}
</div>
</form>
</div>
</div>
</div>
</main>
{% endblock %}