generic API response + ICS: warehouse_balance md_rack update

This commit is contained in:
Thanakorn S
2026-04-23 16:06:19 +07:00
parent ed23c269ea
commit a75e180686
25 changed files with 934 additions and 342 deletions
+40 -9
View File
@@ -25,7 +25,7 @@
<div class="col-lg-8 col-12">
<div class="card">
<div class="card-body p-5">
<h2 class="fs-5 mb-4">Add Stock</h2>
<h2 class="fs-5 mb-4">Move Stock</h2>
<form class="row gx-5">
<!-- Product Name -->
<div class="mb-3 col-lg-3">
@@ -40,8 +40,7 @@
<!-- SKU or Product Code -->
<div class="mb-3 col-lg-6">
<label for="quantity" class="form-label">Quantity</label>
<input type="number" class="form-control" id="quantity" placeholder="Enter quantity" required>
</div>
@@ -49,7 +48,9 @@
<!-- Warehouse -->
<div class="mb-3 col-lg-3">
<label for="warehouse" class="form-label">From Warehouse</label>
<select name="warehouse" id="warehouse_from" role="from" class="form-select" required></select>
<select name="warehouse" id="warehouse_from" role="from" class="form-select" required>
<option value="">Please select warehouse</option>
</select>
</div>
<div class="mb-3 col-lg-3">
@@ -77,7 +78,9 @@
<!-- Warehouse -->
<div class="mb-3 col-lg-3">
<label for="warehouse" class="form-label">To Warehouse</label>
<select name="warehouse" id="warehouse_to" role="to" class="form-select" required></select>
<select name="warehouse" id="warehouse_to" role="to" class="form-select" required>
<option value="">Please select warehouse</option>
</select>
</div>
<div class="mb-3 col-lg-3">
@@ -156,19 +159,23 @@
function retrieve_warehouse(type) {
return ajax_request({
url: "<?php echo $server_url?>inventory/api/engine/warehouse.php",
url: "<?php echo $server_url?>ics/api/engine/retrieve_warehouse.php",
autoPrepare: true,
checkRequired: 0,
data: {
"type": type
},
action: 'read',
debugMode: 0,
onSuccess: function(res) {
var option = `<option value="">Please select warehouse</option>`;
$.each(res.output, function(key, item) {
option += `<option value='${item.id}'>${item.warehouse_name}</option>`;
})
$(`select[name='warehouse'][role='${type}']`).html(option);
if(!type) {
$(`select[name='warehouse']`).html(option);
}
}
});
@@ -195,6 +202,10 @@
})
$(`select[name='zone'][role='${type}']`).html(option);
if(!type) {
$(`select[name='zone']`).html(option);
}
if (callback) callback(); // ← add this
}
});
@@ -214,6 +225,7 @@
},
noLoading: true,
action: 'read',
debugMode: 0,
onSuccess: function(res) {
var option = `<option value="">Please select aisle</option>`;
$.each(res.output, function(key, item) {
@@ -221,6 +233,10 @@
})
$(`select[name='aisle'][role='${type}']`).html(option);
if(!type) {
$(`select[name='aisle']`).html(option);
}
if (callback) callback(); // ← add this
}
});
@@ -247,6 +263,10 @@
})
$(`select[name='rack'][role='${type}']`).html(option);
if(!type) {
$(`select[name='rack']`).html(option);
}
if (callback) callback(); // ← add this
}
});
@@ -324,7 +344,7 @@
$('#contact').val(data.contact_name)
.attr('secondary', data.contact_name)
.attr('data-id', data.contact_id);
console.log(data);
$('#product_name').val(data.product_name);
$('#product_sku').attr('secondary', data.product_sku);
@@ -340,13 +360,24 @@
$(async function() {
try {
await retrieve_warehouse("from");
await retrieve_warehouse("to");
await retrieve_warehouse('from');
await retrieve_warehouse('to');
await retrieve_for_edit();
} catch (e) {
console.log(e);
}
});
$(`#product_sku`).on('blur', function() {
$(async function() {
try {
await retrieve_warehouse('from');
await retrieve_warehouse('to');
} catch (e) {
console.log(e);
}
})
});
<?php if(empty($_GET["id"])){ ?>
$("select[name='warehouse']").change(function() {