feat : redirect to sale page if MMQR is being selected

feat : add MMQR button in payment selection

fix : add create_pay params in add_order_function
This commit is contained in:
aungthetkhaing
2025-05-21 09:35:00 +06:30
parent d02da668b8
commit 67dfd6f1ce
3 changed files with 174 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ if @status == true
json.status :success
json.booking_id @booking.id
json.order_id @order.id
json.sale_id @booking.sale_id
json.order_items do
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark
end

View File

@@ -795,4 +795,92 @@ showHideNavbar(webview);
<% end %>
});
/* MMQR INTEGRATION **/
$(document).on('click','#mmqr_btn', function(event){
const paymentMethod = 'MMQR';
create_order($(this),paymentMethod);
})
function create_order(data,paymentMethod = "") {
$("#oqs_loading_wrapper").show();
var cashier_type = $("#link_type").val();
localStorage.setItem("cashier_type", cashier_type);
quick_service = window.location.href.indexOf("quick_service");
localStorage.setItem("quick_service", quick_service);
food_court = window.location.href.indexOf("food_court");
localStorage.setItem("food_court", food_court);
if (quick_service != -1 || food_court != -1) {
type = cashier_type;
var table_type = $("#table_type").text();
var table_id = $("#table_id").val();
var customer_id = $("#customer_id").val();
var booking_id = $("#booking_id").text();
var ajax_url = "addorders/create";
} else {
type = "cashier";
var table_type = $("#table_type").text();
var table_id = $("#table_id").text();
var customer_id = $("#customer_id").text();
var booking_id = $("#booking_id").text();
var ajax_url = "../addorders/create";
}
var order_items = JSON.stringify(get_order_item_rows());
if (booking_id.length > 0) {
var params = {
order_source: type,
order_type: "dine_in",
customer_id: customer_id,
guest_info: "",
booking_id: booking_id,
table_id: table_id,
order_items: order_items,
create_type: "create_pay",
};
} else {
var params = {
order_source: type,
order_type: "dine_in",
customer_id: customer_id,
guest_info: "",
table_id: table_id,
order_items: order_items,
create_type: "create_pay",
};
}
$.ajax({
type: "POST",
url: ajax_url,
data: params,
dataType: "json",
success: function (result) {
booking_id = result.booking_id;
console.log(result);
if (type == "quick_service") {
window.location.href = "/origami/quick_service";
}else if (type == "food_court" && paymentMethod == "") {
window.location.href =
"/foodcourt/app_orders?pending_id=" + booking_id;
}else if (type == "food_court" && paymentMethod == "MMQR") {
window.location.href =
`/foodcourt/sale/${result.sale_id}/${cashier_type}/payment`;
}else {
if (table_type == "Table") {
window.location.href = "/origami/table/" + table_id;
} else {
window.location.href = "/origami/room/" + table_id;
}
}
if ($("#server_mode").val() != "cloud" && second_display_lookup == 2) {
customer_display_view(null, "reload");
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#oqs_loading_wrapper").hide();
$("#create_order").prop("disabled", false);
$("#create_pay_order").prop("disabled", false);
swal("Error", "Status: " + textStatus, "error");
},
});
}
</script>