added the implemetation for the detail of expense and service and opportunity list search fix
This commit is contained in:
parent
dbd2153b18
commit
490723c3f4
@ -938,7 +938,12 @@ urlpatterns = [
|
||||
views.ItemServiceUpdateView.as_view(),
|
||||
name="item_service_update",
|
||||
),
|
||||
|
||||
|
||||
path(
|
||||
"<slug:dealer_slug>/items/services/<int:pk>/detail/",
|
||||
views.ItemServiceDetailView.as_view(),
|
||||
name="item_service_detail",
|
||||
),
|
||||
# Expanese
|
||||
path(
|
||||
"<slug:dealer_slug>/items/expeneses/",
|
||||
@ -955,6 +960,11 @@ urlpatterns = [
|
||||
views.ItemExpenseUpdateView.as_view(),
|
||||
name="item_expense_update",
|
||||
),
|
||||
path(
|
||||
"<slug:dealer_slug>/items/expeneses/<uuid:pk>/detail/",
|
||||
views.ItemExpenseDetailView.as_view(),
|
||||
name="item_expense_detail",
|
||||
),
|
||||
# Bills
|
||||
path(
|
||||
"<slug:dealer_slug>/items/bills/",
|
||||
|
||||
@ -7762,7 +7762,17 @@ class ItemServiceListView(LoginRequiredMixin, PermissionRequiredMixin, ListView)
|
||||
)
|
||||
return qs
|
||||
|
||||
class ItemServiceDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
|
||||
model = models.AdditionalServices
|
||||
template_name = "items/service/service_detail.html"
|
||||
context_object_name = "service"
|
||||
permission_required = ["inventory.view_additionalservices"]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context=super().get_context_data(**kwargs)
|
||||
sold_cars=models.Car.objects.filter(status='sold',)
|
||||
context['total_services_price']=self.object.price*self.object.additionals.filter(status='sold').count()
|
||||
return context
|
||||
|
||||
|
||||
class ItemExpenseCreateView(LoginRequiredMixin, PermissionRequiredMixin,SuccessMessageMixin, CreateView):
|
||||
@ -7896,6 +7906,32 @@ class ItemExpenseListView(LoginRequiredMixin, PermissionRequiredMixin, ListView)
|
||||
return qs
|
||||
|
||||
|
||||
class ItemExpenseDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
|
||||
queryset=ItemModel.objects.filter(item_role='expense')
|
||||
template_name = "items/expenses/expense_detail.html"
|
||||
context_object_name = "expense"
|
||||
permission_required = ["django_ledger.view_itemmodel"]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
# Get the related bills queryset
|
||||
bills_list = self.object.billmodel_set.all().order_by('-created')
|
||||
|
||||
# Paginate the bills
|
||||
paginator = Paginator(bills_list, 10) # Show 10 bills per page
|
||||
page_number = self.request.GET.get('page')
|
||||
page_obj = paginator.get_page(page_number)
|
||||
|
||||
# Add the paginated bills to the context
|
||||
context['page_obj'] = page_obj
|
||||
context["entity"] = get_user_type(self.request).entity
|
||||
return context
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BillListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
|
||||
"""
|
||||
Provides a view for listing bills.
|
||||
|
||||
@ -72,6 +72,7 @@
|
||||
{% endif %}
|
||||
<div class="d-flex align-items-center mb-4">
|
||||
{% if opportunity.car.marked_price %}
|
||||
<span class="">{% trans "Marked Price: " %}</span>
|
||||
<h5 class="mb-0 me-4">
|
||||
{{ opportunity.car.marked_price }} <span class="fw-light"><span class="icon-saudi_riyal"></span></span>
|
||||
</h5>
|
||||
@ -370,7 +371,7 @@
|
||||
{% if request.user.email == opportunity.staff.email %}
|
||||
<div class="ps-6 ps-sm-0 fw-semibold mb-0">{% trans "You" %}</div>
|
||||
{% else %}
|
||||
<div class="ps-6 ps-sm-0 fw-semibold mb-0">{{ opportunity.staff.get_local_name }}</div>
|
||||
<div class="ps-6 ps-sm-0 fw-semibold mb-0">{{ opportunity.staff.fullname }}</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -29,17 +29,22 @@
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-3 mb-4">
|
||||
<!-- Filter Controls -->
|
||||
<div class="d-flex flex-column flex-lg-row align-items-start align-items-lg-center gap-3 w-100"
|
||||
id="filter-container">
|
||||
<!-- Search Input - Wider and properly aligned -->
|
||||
id="filter-container"
|
||||
hx-get="{% url 'opportunity_list' request.dealer.slug %}"
|
||||
hx-target="#opportunities-grid"
|
||||
hx-select="#opportunities-grid"
|
||||
hx-swap="outerHTML">
|
||||
<div class="search-box position-relative flex-grow-1 me-2"
|
||||
style="min-width: 200px">
|
||||
<form class="position-relative show"
|
||||
id="search-form"
|
||||
hx-get=""
|
||||
hx-boost="false"
|
||||
hx-trigger="keyup changed delay:500ms, search">
|
||||
hx-get="."
|
||||
hx-boost="true"
|
||||
hx-trigger="keyup changed delay:500ms, search"
|
||||
hx-target="#opportunities-grid"
|
||||
hx-select="#opportunities-grid"
|
||||
hx-swap="outerHTML">
|
||||
<input name="q"
|
||||
id="search-input"
|
||||
class="form-control form-control-sm search-input search"
|
||||
@ -56,11 +61,8 @@
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
<!-- Filter Dropdowns - Aligned in a row -->
|
||||
<div class="d-flex flex-column flex-sm-row gap-3 w-100"
|
||||
style="max-width: 400px">
|
||||
<!-- Stage Filter -->
|
||||
<!-- Stage Filter -->
|
||||
<div class="flex-grow-1">
|
||||
<select class="form-select"
|
||||
name="stage"
|
||||
@ -69,7 +71,7 @@
|
||||
hx-target="#opportunities-grid"
|
||||
hx-select="#opportunities-grid"
|
||||
hx-swap="outerHTML"
|
||||
hx-include="#filter-container input, #filter-container select">
|
||||
hx-include="#search-form input, select[name='sort']">
|
||||
<option value="">{% trans "All Stages" %}</option>
|
||||
{% for value, label in stage_choices %}
|
||||
<option value="{{ value }}"
|
||||
@ -79,7 +81,6 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<!-- Sort Filter -->
|
||||
<div class="flex-grow-1">
|
||||
<select class="form-select"
|
||||
name="sort"
|
||||
@ -88,7 +89,7 @@
|
||||
hx-target="#opportunities-grid"
|
||||
hx-select="#opportunities-grid"
|
||||
hx-swap="outerHTML"
|
||||
hx-include="#filter-container input, #filter-container select">
|
||||
hx-include="#search-form input, select[name='stage']">
|
||||
<option value="newest"
|
||||
{% if request.GET.sort == 'newest' %}selected{% endif %}>
|
||||
{% trans "Newest First" %}
|
||||
@ -112,8 +113,10 @@
|
||||
{% include 'crm/opportunities/partials/opportunity_grid.html' %}
|
||||
</div>
|
||||
{% if page_obj.paginator.num_pages > 1 %}
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<div class="d-flex">{% include 'partials/pagination.html' %}</div>
|
||||
<div id="pagination-container" class="d-flex justify-content-end mt-3">
|
||||
<div class="d-flex">
|
||||
{% include 'partials/pagination.html' %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
@ -125,17 +128,19 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const searchInput = document.getElementById("search-input");
|
||||
const clearButton = document.getElementById("clear-search");
|
||||
const searchForm = document.getElementById("search-form");
|
||||
|
||||
|
||||
if (clearButton) {
|
||||
clearButton.addEventListener("click", function() {
|
||||
// Clear the input field
|
||||
searchInput.value = "";
|
||||
// This clears the search and triggers the htmx search
|
||||
// by submitting the form with an empty query.
|
||||
searchForm.submit();
|
||||
|
||||
// Trigger HTMX search with a 'search' event
|
||||
// This uses the hx-trigger="search" on the form
|
||||
// and prevents a full page reload.
|
||||
searchInput.dispatchEvent(new Event('search', { bubbles: true }));
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
@ -67,7 +67,7 @@
|
||||
{% else %}
|
||||
{{ opportunity.staff.fullname }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<table class="mb-3 w-100">
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<div class="row align-items-center justify-content-between g-3 mb-4">
|
||||
<div class="col-auto">
|
||||
<h3 class="mb-0">
|
||||
{% trans 'Customer details' %}<i class="fas fa-user ms-2 text-primary"></i>
|
||||
{% trans 'Customer details' %}<i class="fas fa-user ms-2 "></i>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="col-auto d-flex gap-2">
|
||||
|
||||
97
templates/items/expenses/expense_detail.html
Normal file
97
templates/items/expenses/expense_detail.html
Normal file
@ -0,0 +1,97 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load tenhal_tag %}
|
||||
|
||||
{% block title %}{% trans "Expense Detail" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<section class="hero-section text-center py-5">
|
||||
<div class="container">
|
||||
<h1 class="display-4 fw-bold text-primary">{{ expense.name|title }}</h1>
|
||||
<p class="lead text-muted">{% trans "Comprehensive details for your expense." %}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="container my-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-11">
|
||||
<div class="card shadow-lg border-0 rounded-4">
|
||||
<div class="card-body p-4 p-md-5">
|
||||
|
||||
<h2 class="h4 fw-bold mb-4">{% trans "Expense Information" %} <span class="fs-7 ms-3"><a class="btn btn-phoenix-secondary" href="{% url 'item_expense_list' request.dealer.slug %}">Back To List</a></span></h2>
|
||||
|
||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 g-4 text-center text-md-start mb-5">
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted small mb-1">SKU</h6>
|
||||
<p class="fw-bold ">{{ expense.sku|default:"N/A" }}</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted small mb-1">UPC</h6>
|
||||
<p class="fw-bold ">{{ expense.upc|default:"N/A" }}</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted small mb-1">{% trans "Default Amount" %}</h6>
|
||||
<p class="fw-bold">{{ expense.default_amount }}<span class="icon-saudi_riyal ms-1"></span></p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted small mb-1">{% trans "Expense Account" %}</h6>
|
||||
<p class="fw-boldBI">{{ expense.expense_account }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-5">
|
||||
|
||||
<h2 class="h4 fw-bold mb-4">{% trans "Associated Bills" %}</h2>
|
||||
|
||||
|
||||
{% if page_obj %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th scope="col">{% trans "Bill Number" %}</th>
|
||||
<th scope="col" class="text-center">{% trans "Status" %}</th>
|
||||
<th scope="col" class="text-center">{% trans "Vendor" %}</th>
|
||||
<th scope="col" class="text-center">{% trans "Terms" %}</th>
|
||||
<th scope="col" class="text-center">{% trans "Created On" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for bill in page_obj%}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'bill-detail' dealer_slug=request.dealer.slug entity_slug=entity.slug bill_pk=bill.pk %}" class="fw-bold text-decoration-none">
|
||||
{{ bill.bill_number }}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<span class="">{{ bill.get_bill_status_display }}</span>
|
||||
</td>
|
||||
<td class="text-center">{{ bill.vendor }}</td>
|
||||
<td class="text-center">{{ bill.get_terms_display }}</td>
|
||||
<td class="text-center">{{ bill.created|date:"M j, Y" }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
{% if page_obj.paginator.num_pages > 1 %}
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<div class="d-flex">{% include 'partials/pagination.html' %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="alert alert-info text-center py-4">
|
||||
{% trans "No bills are associated with this expense yet." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -51,9 +51,12 @@
|
||||
href="{% url 'item_expense_update' request.dealer.slug expense.pk %}">
|
||||
<i class="fa fa-edit me-2"></i>{% trans "Update" %}
|
||||
</a>
|
||||
<a class="text-info dropdown-item" href="{% url 'bill-create' request.dealer.slug request.entity.slug %}">
|
||||
<a class="text-primary dropdown-item" href="{% url 'bill-create' request.dealer.slug request.entity.slug %}">
|
||||
<i class="fa fa-plus me-2"></i>{% trans "Create Expense Bill" %}
|
||||
</a>
|
||||
<a class="text-info dropdown-item" href="{% url 'item_expense_detail' request.dealer.slug expense.pk %}">
|
||||
<i class="fa fa-eye me-2"></i>{% trans "Expense Detail" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
66
templates/items/service/service_detail.html
Normal file
66
templates/items/service/service_detail.html
Normal file
@ -0,0 +1,66 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load tenhal_tag %}
|
||||
|
||||
{% block title %}{{ service.name|title }} - {% trans "My Company" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<section class="hero-section text-center py-5">
|
||||
<div class="container">
|
||||
<h1 class="display-5 fw-bold">{{ service.name|title }}</h1>
|
||||
<p class=" mt-3">{{ service.description|default:"No description provided." }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="py-5">
|
||||
<div class="container">
|
||||
|
||||
<div class="card mb-5 p-4 p-lg-5">
|
||||
<div class="card-body">
|
||||
|
||||
<h2 class="card-title fw-bold mb-4">{% trans "Service Details" %}</h2>
|
||||
|
||||
|
||||
<div class="row g-4 mb-3">
|
||||
<div class="col-lg-8"><a class="btn btn-phoenix-primary me-1" href="{% url 'item_service_update' request.dealer.slug service.pk %}"> Edit</a></div>
|
||||
<div class="col-lg-4"><a class="btn btn-phoenix-secondary mb-2" href="{% url 'item_service_list' request.dealer.slug %}">Back To List</a></div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4 text-center text-md-start">
|
||||
|
||||
<div class="col-md-4">
|
||||
<h6 class="text-uppercase text-muted small mb-1">{% trans 'Service Name' %}</h6>
|
||||
<p class="fw-bold fs-7 mb-0">{{ service.name|capfirst }}</p>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<h6 class="text-uppercase text-muted small mb-1">{% trans 'Price' %}</h6>
|
||||
<p class="fw-bold fs-7 mb-0">{{ service.price }}<span class="icon-saudi_riyal ms-1"></span></p>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<h6 class="text-uppercase text-muted small mb-1">{% trans 'Unit of Measure' %}</h6>
|
||||
<p class="fw-bold fs-7 mb-0">{{ service.get_uom_display }}</p>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<h6 class="text-uppercase text-muted small mb-1">{% trans 'Tax Status' %}</h6>
|
||||
<p class="fw-bold fs-7 mb-0">{% if service.taxable %}{% trans 'Taxable' %}{% else %}{% trans 'Non Taxable' %}{% endif %}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center my-5 py-5 border rounded-3 p-4">
|
||||
<h2 class="fw-bold text-muted mb-4">{% trans "Total Revenue from this service" %}</h2>
|
||||
<p class="display-5 fw-bold mb-0 text-primary">{{ total_services_price }}<span class="icon-saudi_riyal ms-4"></span></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
@ -52,9 +52,9 @@
|
||||
href="{% url 'item_service_update' request.dealer.slug service.pk %}">
|
||||
<i class="fa fa-edit me-2"></i>{% trans "Update" %}
|
||||
</a>
|
||||
{% comment %} <a class="text-danger dropdown-item" href="#">
|
||||
<i class="fa fa-trash me-2"></i>{% trans "Delete" %}
|
||||
</a> {% endcomment %}
|
||||
<a class="text-info dropdown-item" href="{% url 'item_service_detail' request.dealer.slug service.pk %}">
|
||||
<i class="fa fa-eye me-2"></i>{% trans "service detail" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
<div class="col-md-6">
|
||||
<label for="end_date" class="form-label">{% trans 'End Date' %}</label>
|
||||
<input type="date" class="form-control" id="end_date" name="end_date" value="{{ end_date }}">
|
||||
</div> 65000.00
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="make-select" class="form-label">{% trans 'Make' %}</label>
|
||||
<select id="make-select" name="make" class="form-select">
|
||||
|
||||
@ -252,8 +252,8 @@
|
||||
<td class="align-middle">{{ data.car.year }}</td>
|
||||
<td class="align-middle">{{ data.car.vin }}</td>
|
||||
<td class="align-middle">1</td>
|
||||
<td class="align-middle ps-5">{{ data.car.marked_price }}</td>
|
||||
<td class="align-middle text-body-tertiary fw-semibold">{{ data.car.marked_price }}</td>
|
||||
<td class="align-middle ps-5">{{ data.car.marked_price|floatformat:'g' }}<span class="icon-saudi_riyal"></span></td>
|
||||
<td class="align-middle text-body-tertiary fw-semibold">{{ data.car.marked_price|floatformat:'g'}}<span class="icon-saudi_riyal"></span></td>
|
||||
</tr>
|
||||
<tr class="bg-body-secondary total-sum">
|
||||
<td class="align-middle ps-4 fw-semibold text-body-highlight" colspan="7">{% trans "Discount Amount" %}</td>
|
||||
|
||||
@ -334,8 +334,8 @@
|
||||
<td class="align-middle">{{ data.car.year }}</td>
|
||||
<td class="align-middle">{{ data.car.vin }}</td>
|
||||
<td class="align-middle">1</td>
|
||||
<td class="align-middle ps-5">{{ data.car.marked_price }}</td>
|
||||
<td class="align-middle text-body-tertiary fw-semibold">{{ data.car.marked_price }}</td>
|
||||
<td class="align-middle ps-5">{{ data.car.marked_price|floatformat:'g' }}<span class='icon-saudi_riyal'></span></td>
|
||||
<td class="align-middle text-body-tertiary fw-semibold">{{ data.car.marked_price |floatformat:'g'}}<span class='icon-saudi_riyal'></span></td>
|
||||
</tr>
|
||||
<tr class="bg-body-secondary total-sum">
|
||||
<td class="align-middle ps-4 fw-semibold text-body-highlight" colspan="7">{% trans "Discount Amount" %}</td>
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<a class="fw-bold text-decoration-none text-dark"
|
||||
<a class="fw-bold text-decoration-none"
|
||||
href="{% url 'user_detail' request.dealer.slug user.slug %}">
|
||||
{{ user.fullname }}
|
||||
</a>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user