warehouse capacity and occupancy

This commit is contained in:
Thanakorn S
2026-04-23 08:24:30 +07:00
parent 35dd1a9fce
commit ed23c269ea
15 changed files with 429 additions and 85 deletions
+17 -8
View File
@@ -53,9 +53,10 @@
<div class=" p-6 flex-grow-1 d-flex justify-content-between" id="total_capacity">
<div class="d-flex flex-column">
<span class="fs-2 fw-bold mb-3 d-block">41,000</span>
<!-- Total Capacity card -->
<span class="fs-5">Total Capacity</span>
<small class="text-warning">
Storage units available</small>
<small class="text-warning">Rack positions available</small>
<!-- was "Storage units available" -->
</div>
<div class="">
<span class="text-warning">
@@ -81,9 +82,10 @@
<div class=" p-6 flex-grow-1 d-flex justify-content-between" id="total_space_used">
<div class="d-flex flex-column">
<span class="fs-2 fw-bold mb-3 d-block">25,500</span>
<!-- Space Used card -->
<span class="fs-5">Space Used</span>
<small class="text-success">
Storage units available</small>
<small class="text-success">Racks occupied</small>
<!-- was "Storage units available" (which was wrong!) -->
</div>
<div class="">
<span class="text-success">
@@ -252,7 +254,6 @@
<script>
function retrieve_stats() {
return ajax_request({
url: "<?php echo $server_url?>inventory/api/engine/warehouse_stats.php",
autoPrepare: true,
@@ -263,13 +264,21 @@
$("#total_warehouse span.fs-2").text(res.total_warehouse);
$("#total_warehouse small.text-info").text(`Across ${res.total_location} locations`);
$("#total_capacity span.fs-2").text(format_number(res.total_capacity,2));
// Capacity = rack count (integer, no decimals)
$("#total_capacity span.fs-2").text(format_number(res.total_capacity, 0));
// NEW: Space Used wiring
$("#total_space_used span.fs-2").text(format_number(res.space_used, 0));
// Optional: show % utilization in the small text
var pct = res.total_capacity > 0
? Math.round(res.space_used / res.total_capacity * 100)
: 0;
$("#total_space_used small").text(`${pct}% utilized`);
$("#total_product span.fs-2").text(res.total_product);
}
});
}