[test] contact to setting modules

This commit is contained in:
Thanakorn S
2026-05-06 08:58:09 +07:00
parent 414f1cd81d
commit 6501d326ca
43 changed files with 4295 additions and 581 deletions
+64 -57
View File
@@ -134,10 +134,11 @@
<th>Type</th>
<th>SKU</th>
<th>Lot</th>
<th id="th_location">Location</th>
<th id="th_location">Location</th>
<th>Contact</th>
<th class="text-end">Stock In</th>
<th class="text-end">Stock Out</th>
<th>UOM</th>
<th class="text-end">Running Total</th>
</tr>
</thead>
@@ -170,54 +171,54 @@
<script>
// ── State ─────────────────────────────────────────────────────────────
var sku_queue = []; // ordered list of SKUs returned by summary call
var sku_index = 0; // next SKU to load
var is_loading = false;
var search_params = {}; // warehouse_id, from_month, to_month — fixed per search
var advanced = false;
var label_rack = 'Location';
var label_zone = 'Zone';
var label_aisle = 'Aisle';
var type_badge = {
var sku_index = 0; // next SKU to load
var is_loading = false;
var search_params = {}; // warehouse_id, from_month, to_month — fixed per search
var advanced = false;
var label_rack = 'Location';
var label_zone = 'Zone';
var label_aisle = 'Aisle';
var type_badge = {
'in': '<span class="badge bg-success">In</span>',
'out': '<span class="badge bg-danger">Out</span>',
'transfer': '<span class="badge bg-info text-dark">Transfer</span>',
};
function apply_location_labels() {
$('#th_location').text(advanced
? label_zone + ' / ' + label_aisle + ' / ' + label_rack
: label_rack
);
}
function format_location(row) {
if (advanced) {
return [row.zone, row.aisle, row.rack].filter(Boolean).join('-');
}
return row.rack || '';
}
function display_location(row) {
return format_location(row) || '<span class="text-muted">—</span>';
}
function load_company_setting() {
return ajax_request({
url: 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';
apply_location_labels();
}
});
}
};
function apply_location_labels() {
$('#th_location').text(advanced
? label_zone + ' / ' + label_aisle + ' / ' + label_rack
: label_rack
);
}
function format_location(row) {
if (advanced) {
return [row.zone, row.aisle, row.rack].filter(Boolean).join('-');
}
return row.rack || '';
}
function display_location(row) {
return format_location(row) || '<span class="text-muted">—</span>';
}
function load_company_setting() {
return ajax_request({
url: 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';
apply_location_labels();
}
});
}
// ── Default months ────────────────────────────────────────────────────
(function() {
@@ -369,6 +370,7 @@
sku: d.sku, product: d.product_name, date: 'Brought Forward', type: '',
lot: '', location: '', contact: '',
stock_in: bf.in > 0 ? bf.in : '', stock_out: bf.out > 0 ? bf.out : '',
uom: d.uom || 'pcs',
running_total: bf.balance,
});
$.each(rows, function(i, row) {
@@ -378,19 +380,21 @@
date: row.date,
type: row.type,
lot: row.lot_number || '',
location: format_location(row),
location: format_location(row),
contact: row.contact_name || '',
stock_in: row.stock_in > 0 ? row.stock_in : '',
stock_out: row.stock_out > 0 ? row.stock_out : '',
uom: d.uom || 'pcs',
running_total: row.running_total,
});
});
// SKU header row
var header = `<tr class="table-secondary">
<td colspan="9" class="py-2 fw-semibold">
<td colspan="10" class="py-2 fw-semibold">
<code>${d.sku}</code>
<span class="text-muted fw-normal ms-2">${d.product_name}</span>
<span class="badge bg-light text-secondary border ms-2 small">${d.uom || 'pcs'}</span>
</td>
</tr>`;
@@ -402,6 +406,7 @@
<td class="py-2" colspan="6">Brought Forward</td>
<td class="py-2 text-end text-success">${bf_in_val}</td>
<td class="py-2 text-end text-danger">${bf_out_val}</td>
<td class="py-2 text-muted small">${d.uom || 'pcs'}</td>
<td class="py-2 text-end fw-semibold ${bf_bal_cls}">${fmt(bf.balance)}</td>
</tr>`;
@@ -421,10 +426,11 @@
<td class="py-2">${type_badge[row.type] || row.type}</td>
<td class="py-2"><code>${row.product_sku}</code></td>
<td class="py-2">${row.lot_number || '<span class="text-muted">—</span>'}</td>
<td class="py-2">${display_location(row)}</td>
<td class="py-2">${display_location(row)}</td>
<td class="py-2">${row.contact_name || '<span class="text-muted">—</span>'}</td>
<td class="py-2 text-end text-success">${in_val}</td>
<td class="py-2 text-end text-danger">${out_val}</td>
<td class="py-2 text-muted small">${d.uom || 'pcs'}</td>
<td class="py-2 text-end fw-semibold ${rt_cls}">${fmt(row.running_total)}</td>
</tr>`;
});
@@ -482,7 +488,7 @@
doc.setFontSize(12);
doc.text('Stock Movement — ' + warehouse + ' (' + from + ' to ' + to + ')', 14, 15);
var headers = [['SKU', 'Product', 'Date', 'Type', 'Lot', 'Location', 'Contact', 'Stock In', 'Stock Out', 'Running Total']];
var headers = [['SKU', 'Product', 'Date', 'Type', 'Lot', 'Location', 'Contact', 'Stock In', 'Stock Out', 'UOM', 'Running Total']];
var rows = export_data.map(function(r) {
return [
r.sku || '',
@@ -494,6 +500,7 @@
r.contact || '',
r.stock_in || '',
r.stock_out || '',
r.uom || 'pcs',
r.running_total || '',
];
});
@@ -512,12 +519,12 @@
$(async function() {
try {
await load_company_setting();
await retrieve_warehouse();
} catch(e) { console.log(e); }
});
$(async function() {
try {
await load_company_setting();
await retrieve_warehouse();
} catch(e) { console.log(e); }
});
</script>
<!-- SheetJS — required by AlaSQL for Excel (.xlsx) export -->
@@ -528,4 +535,4 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.8.2/jspdf.plugin.autotable.min.js"></script>
</body>
</html>
</html>