This commit is contained in:
gitea 2025-02-24 11:31:26 +00:00
commit 8ae17c9560
5 changed files with 24 additions and 94 deletions

View File

@ -1285,8 +1285,12 @@ class CustomerDetailView(LoginRequiredMixin, DetailView):
# context["estimates"] = entity.get_estimates().filter(
# customer__customer_name=name
# )
context["estimates"] = entity.get_estimates().filter(customer=self.object)
context["invoices"] = entity.get_invoices().filter(customer=self.object)
estimates = entity.get_estimates().filter(customer=self.object)
invoices = entity.get_invoices().filter(customer=self.object)
total = estimates.count() + invoices.count()
context["estimates"] = estimates
context["invoices"] = invoices
context["total"] = total
# context["notes"] = models.Notes.objects.filter(
@ -1298,8 +1302,8 @@ class CustomerDetailView(LoginRequiredMixin, DetailView):
return context
def add_note_to_customer(request, pk):
customer = get_object_or_404(CustomerModel, pk=pk)
def add_note_to_customer(request, customer_id):
customer = get_object_or_404(CustomerModel, pk=customer_id)
if request.method == "POST":
form = forms.NoteForm(request.POST)
if form.is_valid():
@ -1308,10 +1312,10 @@ def add_note_to_customer(request, pk):
note.created_by = request.user
note.save()
return redirect("customer_detail", pk=pk)
return redirect("customer_detail", pk=customer.pk)
else:
form = forms.NoteForm()
return render(request, "crm/note_form.html", {"form": form, "customer": customer})
return render(request, "customers/note_form.html", {"form": form, "customer": customer})
def add_activity_to_customer(request, pk):

View File

@ -4,40 +4,9 @@
{% block title %}{{ _("View Customer") }}{% endblock title %}
{% block content %}
<!-- Delete Modal -->
<div class="modal fade" id="deleteModal"
data-bs-backdrop="static"
data-bs-keyboard="false"
tabindex="-1"
aria-labelledby="deleteModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-sm ">
<div class="modal-content rounded">
<div class="modal-body d-flex justify-content-center">
<h1 class="text-danger me-2"><i class="bi bi-exclamation-diamond-fill"></i></h1>
<span class="text-danger">
{% trans "Are you sure you want to delete this customer?" %}
</span>
</div>
<div class="btn-group btn-group-sm">
<button type="button"
class="btn btn-sm btn-secondary"
data-bs-dismiss="modal">
{% trans 'No' %}
</button>
<a type="button"
class="btn btn-sm btn-danger"
href="{% url 'customer_delete' customer.pk %}">
{% trans 'Yes' %}
</a>
</div>
</div>
</div>
</div>
<!-- Delete Modal -->
{% include 'modal/delete_modal.html' %}
<div class="row">
<div class="mb-9">
<div class="row align-items-center justify-content-between g-3 mb-4">
<div class="col-auto">
@ -46,12 +15,16 @@
<div class="col-auto">
<div class="row g-3">
<div class="col-auto">
<a class="btn btn-phoenix-danger"
data-bs-toggle="modal"
data-bs-target="#deleteModal"><span class="fa-solid fa-trash-can me-2"></span>{{ _("Delete") }}</a>
<button class="btn btn-phoenix-danger btn-sm delete-btn"
data-url="{% url 'customer_delete' customer.pk %}"
data-message="Are you sure you want to delete this customer?"
data-bs-toggle="modal" data-bs-target="#deleteModal">
<i class="fas fa-trash me-1"> </i>{{ _("Delete") }}
</button>
</div>
<div class="col-auto">
<a href="{% url 'customer_update' customer.pk %}" class="btn btn-phoenix-warning"><span class="fa-solid fa-pen-to-square me-2"></span>{{_("Update")}}</a>
<a href="{% url 'customer_update' customer.pk %}" class="btn btn-sm btn-phoenix-warning"><span class="fa-solid fa-pen-to-square me-2"></span>{{_("Update")}}</a>
</div>
</div>
@ -68,12 +41,11 @@
<div class="avatar avatar-5xl"><img class="rounded-circle" src="{% static "images/team/15.webp" %}" alt="" /></div>
</div>
<div class="col-12 col-sm-auto flex-1">
<h3>{{ customer.first_name }} {{ customer.middle_name }} {{ customer.last_name }}</h3>
<h3>{{ customer.additional_info }}</h3>
<p class="text-body-secondary">{{ customer.created|timesince}}</p>
<div><a class="me-2" href="#!"><span class="fab fa-linkedin-in text-body-quaternary text-opacity-75 text-primary-hover"></span></a><a class="me-2" href="#!"><span class="fab fa-facebook text-body-quaternary text-opacity-75 text-primary-hover"></span></a><a href="#!"><span class="fab fa-twitter text-body-quaternary text-opacity-75 text-primary-hover"></span></a></div>
</div>
</div>
<div class="d-flex flex-between-center border-top border-dashed pt-4">
<div class="d-flex justify-content-between border-top border-dashed pt-4">
<div>
<h6>{% trans 'Invoices' %}</h6>
<p class="fs-7 text-body-secondary mb-0">{{invoices.count}}</p>
@ -133,7 +105,7 @@
</div>
<div class="col-12 col-xxl-8">
<div class="mb-6">
<h3 class="mb-4">{{ _("Cars") }} <span class="text-body-tertiary fw-normal">(4)</span></h3>
<h3 class="mb-4">{{ _("Cars") }} <span class="text-body-tertiary fw-normal">({{ total }})</span></h3>
<div class="border-top border-bottom border-translucent" id="customerOrdersTable" data-list='{"valueNames":["order","total","payment_status","fulfilment_status","delivery_type","date"],"page":6,"pagination":true}'>
<div class="table-responsive scrollbar">
<table class="table table-sm fs-9 mb-0">
@ -149,6 +121,7 @@
</tr>
</thead>
<tbody class="list" id="customer-order-table-body">
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="order align-middle white-space-nowrap ps-0"><a class="fw-semibold" href="#!">#2453</a></td>
<td class="total align-middle text-end fw-semibold pe-7 text-body-highlight">$87</td>
@ -165,54 +138,7 @@
</div>
</td>
</tr>
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="order align-middle white-space-nowrap ps-0"><a class="fw-semibold" href="#!">#2452</a></td>
<td class="total align-middle text-end fw-semibold pe-7 text-body-highlight">$7264</td>
<td class="payment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-secondary"><span class="badge-label">Cancelled</span><span class="ms-1" data-feather="x" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="fulfilment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-info"><span class="badge-label">Ready to pickup</span><span class="ms-1" data-feather="info" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="delivery_type align-middle white-space-nowrap text-body fs-9 text-start">Free shipping</td>
<td class="date align-middle white-space-nowrap text-body-tertiary fs-9 ps-4 text-end">Dec 9, 2:28PM</td>
<td class="align-middle white-space-nowrap text-end pe-0 ps-5">
<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>
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="order align-middle white-space-nowrap ps-0"><a class="fw-semibold" href="#!">#2451</a></td>
<td class="total align-middle text-end fw-semibold pe-7 text-body-highlight">$375</td>
<td class="payment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-warning"><span class="badge-label">Pending</span><span class="ms-1" data-feather="alert-octagon" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="fulfilment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-warning"><span class="badge-label">Partial FulfiLled</span><span class="ms-1" data-feather="alert-octagon" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="delivery_type align-middle white-space-nowrap text-body fs-9 text-start">Local pickup</td>
<td class="date align-middle white-space-nowrap text-body-tertiary fs-9 ps-4 text-end">Dec 4, 12:56 PM</td>
<td class="align-middle white-space-nowrap text-end pe-0 ps-5">
<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>
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="order align-middle white-space-nowrap ps-0"><a class="fw-semibold" href="#!">#2450</a></td>
<td class="total align-middle text-end fw-semibold pe-7 text-body-highlight">$657</td>
<td class="payment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-secondary"><span class="badge-label">Cancelled</span><span class="ms-1" data-feather="x" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="fulfilment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-secondary"><span class="badge-label">Order CancelLed</span><span class="ms-1" data-feather="x" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="delivery_type align-middle white-space-nowrap text-body fs-9 text-start">Standard shipping</td>
<td class="date align-middle white-space-nowrap text-body-tertiary fs-9 ps-4 text-end">Dec 1, 4:07 AM</td>
<td class="align-middle white-space-nowrap text-end pe-0 ps-5">
<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>
</tbody>
</table>