haikal/templates/sales/estimates/estimate_detail.html
2024-12-29 14:49:28 +00:00

147 lines
7.5 KiB
HTML

{% extends "base.html" %}
{% load i18n %}
{% block title %}{{ _("View Estimate") }}{% endblock title %}
{% block content %}
<!-- ============================================-->
<!-- <section> begin ============================-->
<section class="pt-5 pb-9 bg-body-emphasis dark__bg-gray-1200 border-top">
<div class="container-small mt-3">
<div class="d-flex justify-content-between align-items-end mb-4">
<h2 class="mb-0">Estimate</h2>
<div>
<button class="btn btn-phoenix-primary me-2"><span class="fa-regular fa-paper-plane me-sm-2"></span><span class="d-none d-sm-inline-block">Send Estimate</span></button>
<button class="btn btn-phoenix-secondary"><span class="d-none d-sm-inline-block">Mark As Sent</span></button>
</div>
</div>
<div class="bg-body dark__bg-gray-1100 p-4 mb-4 rounded-2">
<div class="row g-4">
<div class="col-12 col-lg-3">
<div class="row g-4 g-lg-2">
<div class="col-12 col-sm-6 col-lg-12">
<div class="row align-items-center g-0">
<div class="col-auto col-lg-6 col-xl-5">
<h6 class="mb-0 me-3">Estimate No :</h6>
</div>
<div class="col-auto col-lg-6 col-xl-7">
<p class="fs-9 text-body-secondary fw-semibold mb-0">#{{estimate.estimate_number}}</p>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-12">
<div class="row align-items-center g-0">
<div class="col-auto col-lg-6 col-xl-5">
<h6 class="me-3">Estimate Date :</h6>
</div>
<div class="col-auto col-lg-6 col-xl-7">
<p class="fs-9 text-body-secondary fw-semibold mb-0">{{estimate.created}}</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-5">
<div class="row align-items-center g-0">
<div class="col-auto col-lg-6 col-xl-5">
<h6 class="mb-2 me-3">Customer :</h6>
<p class="fs-9 text-body-secondary fw-semibold mb-0">{{estimate.customer.customer_name}}</p>
</div>
<div class="col-12 col-lg-4">
<h6 class="mb-2"> Email :</h6>
<p class="fs-9 text-body-secondary fw-semibold mb-0">{{estimate.customer.email}}</p>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-lg-4">
<div class="row g-4">
<div class="col-12 col-lg-6">
<h6 class="mb-2"> Estimate Status :</h6>
<div class="fs-9 text-body-secondary fw-semibold mb-0">
{% if estimate.status == 'draft' %}
<span class="badge text-bg-warning">Draft</span>
{% elif estimate.status == 'sent' %}
<span class="badge text-bg-info">Sent</span>
{% elif estimate.status == 'approved' %}
<span class="badge text-bg-success">Approved</span>
{% elif estimate.status == 'declined' %}
<span class="badge text-bg-danger">Declined</span>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="px-0">
<div class="table-responsive scrollbar">
<table id="estimate-table" class="table fs-9 text-body mb-0">
<thead class="bg-body-secondary">
<tr>
<th scope="col" style="width: 24px;">#</th>
<th scope="col" style="min-width: 360px;">Item</th>
<th class="text-start" scope="col" style="width: 80px;">Quantity</th>
<th scope="col" style="min-width: 60px;">Unit Price</th>
<th class="ps-5" scope="col" style="min-width: 150px;">Total</th>
</tr>
</thead>
<tbody>
{% for item in estimate.get_itemtxs_data.0 %}
<tr>
<td class="">{{forloop.counter}}</td>
<td class="">{{item.item_model.name}}</td>
<td class="align-middle">{{item.ce_quantity}}</td>
<td class="align-middle ps-5">{{item.ce_unit_cost_estimate}}</td>
<td class="align-middle text-body-tertiary fw-semibold">{{item.ce_total_amount}}</td>
</tr>
{% endfor %}
<tr class="bg-body-secondary total-sum">
<td class="align-middle ps-4 fw-bold text-body-highlight" colspan="4">Grand Total</td>
<td class="align-middle text-start fw-bold">
<span id="grand-total">0.00</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- end of .container-->
</section>
<!-- <section> close ============================-->
<!-- ============================================-->
{% endblock %}
{% block extra_js %}
<script>
function calculateTotals() {
const table = document.getElementById('estimate-table');
const rows = table.getElementsByTagName('tbody')[0].rows;
let grandTotal = 0;
for (let row of rows) {
// Ensure the row has the expected number of cells
if (row.cells.length >= 5) {
const quantity = parseFloat(row.cells[2].textContent); // Quantity column
const unitPrice = parseFloat(row.cells[3].textContent); // Unit Price column
if (!isNaN(quantity) && !isNaN(unitPrice)) {
const total = quantity * unitPrice;
row.cells[4].textContent = total.toFixed(2); // Populate Total column
grandTotal += total; // Add to grand total
}
}
}
// Display the grand total
document.getElementById('grand-total').textContent = grandTotal.toFixed(2);
}
// Run the function on page load
window.onload = calculateTotals;
</script>
{% endblock %}