diff --git a/app/views/foodcourt/qrpay/precreate.html.erb b/app/views/foodcourt/qrpay/precreate.html.erb
index d087e94f..e7d4eb67 100644
--- a/app/views/foodcourt/qrpay/precreate.html.erb
+++ b/app/views/foodcourt/qrpay/precreate.html.erb
@@ -89,17 +89,7 @@
-
+
Checkin Time : <%if !@checkin_time.nil?%><%= @checkin_time.strftime("%I:%M %p") %>
<%end%>
@@ -1353,4 +1343,4 @@ function initDynamicQrPay() {
}
});
});
-
\ No newline at end of file
+
diff --git a/app/views/layouts/_read_modal.html.erb b/app/views/layouts/_read_modal.html.erb
index 7e74c141..e909f94b 100644
--- a/app/views/layouts/_read_modal.html.erb
+++ b/app/views/layouts/_read_modal.html.erb
@@ -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');