warehouse layers [switchable]

This commit is contained in:
Thanakorn S
2026-05-04 13:43:32 +07:00
parent a90975d9f1
commit 414f1cd81d
26 changed files with 2022 additions and 584 deletions
+78 -21
View File
@@ -129,9 +129,9 @@
<thead class="table-primary border-light">
<tr>
<th>Warehouse</th>
<th>Zone</th>
<th>Aisle</th>
<th>Rack</th>
<th class="th_loc_zone">Zone</th>
<th class="th_loc_aisle">Aisle</th>
<th class="th_loc_rack">Rack</th>
<th>SKU</th>
<th>Product</th>
<th>Status</th>
@@ -172,9 +172,9 @@
<thead class="table-danger border-light">
<tr>
<th>Warehouse</th>
<th>Zone</th>
<th>Aisle</th>
<th>Rack</th>
<th class="th_loc_zone">Zone</th>
<th class="th_loc_aisle">Aisle</th>
<th class="th_loc_rack">Rack</th>
<th>SKU</th>
<th>Product</th>
<th>Action</th>
@@ -214,9 +214,9 @@
<thead class="table-success border-light">
<tr>
<th>Warehouse</th>
<th>Zone</th>
<th>Aisle</th>
<th>Rack</th>
<th class="th_loc_zone">Zone</th>
<th class="th_loc_aisle">Aisle</th>
<th class="th_loc_rack">Rack</th>
<th>Action</th>
</tr>
</thead>
@@ -263,6 +263,68 @@
<?php require "../include_ending.php";?>
<script>
// ── Location config ───────────────────────────────────────────────────────
var advanced = false;
var label_rack = 'Location';
var label_zone = 'Zone';
var label_aisle = 'Aisle';
function load_location_config(callback) {
return ajax_request({
url: '<?php echo $server_url?>setting/api/engine/company_setting.php',
autoPrepare: true,
checkRequired: 0,
action: 'read',
onSuccess: function(res) {
var s = res.output;
advanced = s.advanced_location == 1;
label_rack = s.location_label_rack || (advanced ? 'Rack' : 'Location');
label_zone = s.location_label_zone || 'Zone';
label_aisle = s.location_label_aisle || 'Aisle';
if (callback) callback();
}
});
}
function apply_location_labels() {
if (advanced) {
$('.th_loc_zone').text(label_zone).show();
$('.th_loc_aisle').text(label_aisle).show();
$('.th_loc_rack').text(label_rack);
} else {
$('.th_loc_zone').hide();
$('.th_loc_aisle').hide();
$('.th_loc_rack').text(label_rack);
}
var loc_hint = advanced
? label_zone.toLowerCase() + ', ' + label_aisle.toLowerCase() + ', ' + label_rack.toLowerCase()
: label_rack.toLowerCase();
$('#search_all, #search_occupied').attr('placeholder',
'Search by warehouse, ' + loc_hint + ', or SKU…');
$('#search_empty').attr('placeholder',
'Search by warehouse or ' + loc_hint + '…');
$('#rackLogModalLabel').text(label_rack + ' Log');
$('#stat_label_racks').text('Total ' + label_rack + 's');
}
// Returns 1 or 3 <td> cells depending on mode
function location_cells(item) {
if (advanced) {
return '<td class="py-3">' + (item.zone || '—') + '</td>'
+ '<td class="py-3">' + (item.aisle || '—') + '</td>'
+ '<td class="py-3">' + (item.rack || '—') + '</td>';
}
return '<td class="py-3">' + (item.rack || '—') + '</td>';
}
// Rack log modal label
function rack_label(item) {
return advanced
? item.warehouse_name + ' ' + item.zone + '-' + item.aisle + '-' + item.rack
: item.warehouse_name + ' ' + item.rack;
}
var search_all = '';
var search_occupied = '';
var search_empty = '';
@@ -334,13 +396,11 @@
: '<span class="badge bg-success">Available</span>';
body += `<tr>
<td class="py-3">${item.warehouse_name}</td>
<td class="py-3">${item.zone}</td>
<td class="py-3">${item.aisle}</td>
<td class="py-3">${item.rack}</td>
` + location_cells(item) + `
<td class="py-3">${item.product_sku || '<span class="text-muted">—</span>'}</td>
<td class="py-3">${item.product_name || '<span class="text-muted">—</span>'}</td>
<td class="py-3">${badge}</td>
<td class="py-3"><a href="javascript:;" onclick="view_rack_log(${item.id}, '${item.warehouse_name} ${item.zone}-${item.aisle}-${item.rack}')"><i class="ti ti-history fs-5"></i></a></td>
<td class="py-3"><a href="javascript:;" onclick="view_rack_log(${item.id}, '${rack_label(item)}')"><i class="ti ti-history fs-5"></i></a></td>
</tr>`;
});
$('table#tbl_all > tbody').html(body);
@@ -377,12 +437,10 @@
$.each(filtered.slice(offset, offset + prop_limit), function(i, item) {
body += `<tr>
<td class="py-3">${item.warehouse_name}</td>
<td class="py-3">${item.zone}</td>
<td class="py-3">${item.aisle}</td>
<td class="py-3">${item.rack}</td>
` + location_cells(item) + `
<td class="py-3">${item.product_sku}</td>
<td class="py-3">${item.product_name || '<span class="text-muted">—</span>'}</td>
<td class="py-3"><a href="javascript:;" onclick="view_rack_log(${item.id}, '${item.warehouse_name} ${item.zone}-${item.aisle}-${item.rack}')"><i class="ti ti-history fs-5"></i></a></td>
<td class="py-3"><a href="javascript:;" onclick="view_rack_log(${item.id}, '${rack_label(item)}')"><i class="ti ti-history fs-5"></i></a></td>
</tr>`;
});
$('table#tbl_occupied > tbody').html(body);
@@ -417,10 +475,8 @@
$.each(filtered.slice(offset, offset + prop_limit), function(i, item) {
body += `<tr>
<td class="py-3">${item.warehouse_name}</td>
<td class="py-3">${item.zone}</td>
<td class="py-3">${item.aisle}</td>
<td class="py-3">${item.rack}</td>
<td class="py-3"><a href="javascript:;" onclick="view_rack_log(${item.id}, '${item.warehouse_name} ${item.zone}-${item.aisle}-${item.rack}')"><i class="ti ti-history fs-5"></i></a></td>
` + location_cells(item) + `
<td class="py-3"><a href="javascript:;" onclick="view_rack_log(${item.id}, '${rack_label(item)}')"><i class="ti ti-history fs-5"></i></a></td>
</tr>`;
});
$('table#tbl_empty > tbody').html(body);
@@ -512,6 +568,7 @@
// ── Boot ─────────────────────────────────────────────────────────────
$(async function() {
try {
await load_location_config(apply_location_labels);
await retrieve_rack_occupancy();
} catch(e) {
console.log(e);