Fix: update order in mmqr

This commit is contained in:
Htoi San Aung
2025-06-30 09:58:07 +06:30
committed by DevTeam
parent 8b62d410b0
commit e322cf6c7e
2 changed files with 54 additions and 14 deletions

View File

@@ -312,8 +312,27 @@ document.addEventListener('DOMContentLoaded', function () {
create_type: "create_pay",
};
modify_order = window.location.href.indexOf("modify_order");
type = $("#link_type").val();
if (modify_order !=-1) {
var ajax_url = '/foodcourt/food_court/update_modify_order';
var table_type = $('#table_type').text();
var table_id = $('#table_id').text();
var customer_id = $('#customer_id').text();
var sale_id = $('#sale_id').text();
}else{
var ajax_url = '/foodcourt/addorders/create';
}
var booking_id = $('#booking_id').text();
if (booking_id.length > 0) {
params.booking_id = booking_id;
}
$.ajax({
url: '/foodcourt/addorders/create',
url: ajax_url,
method: 'POST',
contentType: 'application/json',
headers: {
@@ -321,8 +340,15 @@ document.addEventListener('DOMContentLoaded', function () {
},
data: JSON.stringify(params),
success: function(result) {
const booking_id = result.booking_id;
if (!result.sale_id) {
request_bill(0, function(saleId) {
window.location.href = `/foodcourt/${saleId}/qrpay/precreate`;
});
}else{
window.location.href = `/foodcourt/${result.sale_id}/qrpay/precreate`;
}
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
// customer_display_view(null, "reload");
}
@@ -338,6 +364,30 @@ document.addEventListener('DOMContentLoaded', function () {
});
}
function request_bill(customer_id, callback){
if (window.location.pathname.includes('foodcourt')) {
const order_id = $('#order_id').val() || $('#save_order_id').val();
const data = { 'customer_id': customer_id };
$.ajax({
type: "GET",
url: "/foodcourt/food_court/" + order_id + "/request_bill",
data: data,
dataType: "json",
success: function(data) {
if(data.status === true) {
callback(data.sale_id); // ✅ return via callback
} else {
swal("Alert!", "Error!", "error");
location.reload();
}
}
});
}
}
// function initDynamicQrPay() {
// const paymentMethod = 'MMQR';
// const $serverMode = $('#server_mode');