Fix timestamps, delete requests, invoice dates and GR quantities
Apply the configured timezone to PHP and both DB connections, wrap unwrapped ajax payloads so delete buttons reach their engines, normalise and validate invoice due dates, reject stock quantities below the stored 4dp scale, and list stock movements across all warehouses.
This commit is contained in:
+16
-9
@@ -32,7 +32,7 @@
|
||||
<input class="form-control" value='Warehouse' disabled>
|
||||
</div>
|
||||
<div class="mb-3 col-lg-2">
|
||||
<select name="warehouse" id="warehouse" class="form-select" required></select>
|
||||
<select name="warehouse" id="warehouse" class="form-select"></select>
|
||||
</div>
|
||||
<div class="mb-3 col-lg-2">
|
||||
<input class="form-control" value='Source' disabled>
|
||||
@@ -56,6 +56,7 @@
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Reference</th>
|
||||
<th>Warehouse</th>
|
||||
<th>Product</th>
|
||||
<th>Lot Number</th>
|
||||
<th>Serial Number</th>
|
||||
@@ -151,7 +152,7 @@
|
||||
}
|
||||
|
||||
var delete_btn = (!source)
|
||||
? `<a href="javascript:void(0);" class="link-danger" onclick="delete_stock_out($(this),${item['id']})">
|
||||
? `<a href="javascript:void(0);" class="link-danger" onclick="delete_stock_out($(this),${item['id']},${warehouse})">
|
||||
<i class="ti ti-trash ms-2 fs-5"></i>
|
||||
</a>`
|
||||
: '';
|
||||
@@ -237,18 +238,21 @@
|
||||
|
||||
var body = ``;
|
||||
|
||||
var warehouse = $(`select#warehouse`).val();
|
||||
|
||||
$.each(page_data, function(key, item) {
|
||||
// The row's own warehouse, not the filter — with "All Warehouses" the
|
||||
// filter has no value, and each row lives in its own td_stock_<id> table.
|
||||
var warehouse = item['warehouse_id'];
|
||||
|
||||
body += `<tr>
|
||||
<td class="py-3">${format_date(item["date"])}</td>
|
||||
<td class="py-3 fw-semibold">${item["stock_reference"] || "—"}</td>
|
||||
<td class="py-3">${escape_html(item['warehouse_name'] || '—')}</td>
|
||||
<td class="py-3">${item["product_sku"]}: ${item['product_name']}</td>
|
||||
<td class="py-3">${item['lot_number'] || '<span class="text-muted">—</span>'}</td>
|
||||
<td class="py-3">${item['serial_number'] || '<span class="text-muted">—</span>'}</td>
|
||||
<td class="py-3">
|
||||
<div class="d-flex justify-content-end align-items-baseline gap-1">
|
||||
<span>${format_number(item['quantity'], 2)}</span>
|
||||
<span>${format_quantity(item['quantity'])}</span>
|
||||
<span class="text-muted small" style="min-width:28px;">${item['uom'] || ''}</span>
|
||||
</div>
|
||||
</td>
|
||||
@@ -275,9 +279,12 @@
|
||||
checkRequired: 0,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
var option = ``;
|
||||
// Default to every warehouse — stock is stored one table per
|
||||
// warehouse, so a single-warehouse default hides movements that went
|
||||
// elsewhere and makes a document look only partly processed.
|
||||
var option = `<option value=''>All Warehouses</option>`;
|
||||
$.each(res.output, function(key, item) {
|
||||
option += `<option value='${item.id}'>${item.warehouse_name}</option>`;
|
||||
option += `<option value='${item.id}'>${escape_html(item.warehouse_name)}</option>`;
|
||||
})
|
||||
$(`select#warehouse`).html(option);
|
||||
}
|
||||
@@ -285,7 +292,7 @@
|
||||
|
||||
}
|
||||
|
||||
function delete_stock_out(element, id) {
|
||||
function delete_stock_out(element, id, warehouse_id) {
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>ics/api/engine/delete_stock_out.php",
|
||||
@@ -294,7 +301,7 @@
|
||||
action: 'delete',
|
||||
data : {
|
||||
id: id,
|
||||
wh: $(`select#warehouse`).val()
|
||||
wh: warehouse_id
|
||||
},
|
||||
onSuccess: function(res) {
|
||||
element.closest('tr').remove();
|
||||
|
||||
Reference in New Issue
Block a user