stock database design

This commit is contained in:
Thanakorn S
2026-03-09 17:03:18 +07:00
parent 7cb78d013b
commit 2e558a55bb
5 changed files with 66 additions and 17 deletions
+26 -7
View File
@@ -33,6 +33,10 @@ $(function () {
type: 'POST',
dataType: 'json',
data: { json: json },
// for CSRF validation
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function (res) {
@@ -80,7 +84,10 @@ $(function () {
// Replace input value with SKU
$(this)
.val(product.sku)
.attr("secondary", product.id);
.attr("secondary", product.sku);
$('input#product_name')
.val(product.product_name)
.attr("secondary", product.product_name)
console.log("Input updated with SKU:", product.sku);
@@ -90,12 +97,21 @@ $(function () {
})
// Allow HTML rendering in dropdown
.data("ui-autocomplete")._renderItem = function (ul, item) {
return $("<li>")
.append($("<div>").html(item.label))
.appendTo(ul);
};
// Allow HTML rendering in dropdown
.data("ui-autocomplete")._renderItem = function (ul, item) {
return $("<li>")
.append($("<div>").html(item.label))
.appendTo(ul);
};
// Add this ↓
$el.on('blur', function () {
var secondary = $(this).attr('secondary');
if (secondary) {
$(this).val(secondary);
$('input#product_name').val($('input#product_name').attr('secondary'));
}
});
});
@@ -147,6 +163,7 @@ function prepare_form_data(check_required, raw_data) {
if (!is_valid) {
alert("Please fill in all mandatory fields.");
isAjaxProcessing = false;
return false;
}
}
@@ -178,6 +195,7 @@ function ajax_request(options) {
let payloadJson = prepare_form_data(options.checkRequired ?? 0, true);
if (payloadJson === false) {
isAjaxProcessing = false;
return Promise.reject("validation_failed");
}
@@ -195,6 +213,7 @@ function ajax_request(options) {
// add action to JSON
payloadJson['action'] = options.action;
}else{
isAjaxProcessing = false;
return Promise.reject("please_define_action");
}