check order reservation update and payment route fixed
This commit is contained in:
@@ -426,13 +426,13 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
|
||||
access_code = approved_code;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: post_url,
|
||||
data: {url: callback, ref_no: ref_no, status: status, waiting_time: waiting_time, min_type: type, reason: reject_reason},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status){
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: post_url,
|
||||
// data: {url: callback, ref_no: ref_no, status: status, waiting_time: waiting_time, min_type: type, reason: reject_reason},
|
||||
// dataType: "json",
|
||||
// success: function(data) {
|
||||
// if(data.status){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
@@ -466,21 +466,21 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: data.message,
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/order_reservation';
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// }else{
|
||||
// swal({
|
||||
// title: 'Oops',
|
||||
// text: data.message,
|
||||
// type: 'error',
|
||||
// html: true,
|
||||
// closeOnConfirm: false,
|
||||
// closeOnCancel: false,
|
||||
// allowOutsideClick: false
|
||||
// }, function () {
|
||||
// window.location.href = '/origami/order_reservation';
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
function showNewOrderAlert(order_reservation,shop_code){
|
||||
|
||||
@@ -463,4 +463,21 @@ function showHideNavbar(webview,page){
|
||||
|
||||
function createAccessCode(code) {
|
||||
localStorage.setItem("access_code",code);
|
||||
}
|
||||
|
||||
//get menu item cache
|
||||
function getAllMenu(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/origami/get_all_menu',
|
||||
data: {},
|
||||
success:function(result){
|
||||
localStorage.setItem("menus", JSON.stringify(result));
|
||||
|
||||
var menu = localStorage.getItem("menus");
|
||||
if (menu != null ) {
|
||||
$( "#loading_wrapper").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -31,10 +31,12 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
else
|
||||
if @status == "rejected"
|
||||
OrderReservation.update_order_reservation(@id, nil, "rejected",nil,remark,access_code,current_user)
|
||||
result = {:status=> true, :message => "rejected" }
|
||||
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"rejected")
|
||||
result = {:status=> true, :message => "rejected" }
|
||||
else
|
||||
OrderReservation.update_order_reservation(@id, nil, "accepted", expected_waiting_time)
|
||||
result = {:status=> true, :message => "accepted" }
|
||||
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"accepted")
|
||||
result = {:status=> true, :message => "accepted" }
|
||||
end
|
||||
end
|
||||
render :json => result.to_json
|
||||
|
||||
@@ -173,6 +173,7 @@ class OrderReservation < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.send_status_to_ordering(url,ref_no,status,waiting_time=nil,min_type=nil,reason=nil)
|
||||
puts "send status to ordering"
|
||||
base_url = 'https://api.doemal.com'
|
||||
token = '3T-tnlYtFJ-5Z1vY6XQqxQ'
|
||||
order_reservation = Lookup.collection_of("order_reservation")
|
||||
@@ -191,19 +192,19 @@ class OrderReservation < ApplicationRecord
|
||||
Rails.logger.debug "Doemal URL" + base_url
|
||||
post_url = base_url + url
|
||||
|
||||
if status == 'processed'
|
||||
status = 'send_to_kitchen'
|
||||
elsif status == 'delivered'
|
||||
status = 'ready_to_deliver'
|
||||
elsif status == 'completed'
|
||||
status = 'delivered'
|
||||
else
|
||||
status = status
|
||||
end
|
||||
# if status == 'processed'
|
||||
# status = 'send_to_kitchen'
|
||||
# elsif status == 'delivery'
|
||||
# status = 'ready_to_delivery'
|
||||
# elsif status == 'completed'
|
||||
# status = 'delivered'
|
||||
# else
|
||||
# status = status
|
||||
# end
|
||||
|
||||
if waiting_time != ""
|
||||
if (!min_type.nil? && !waiting_time.nil?) && (min_type != "" && waiting_time != "")
|
||||
send_params = {id: ref_no,type: min_type, waiting_time: waiting_time, status: status}
|
||||
elsif reason != ""
|
||||
elsif !reason.nil? && reason != ""
|
||||
send_params = {id: ref_no, status: status, reason: reason}
|
||||
else
|
||||
send_params = {id: ref_no, status: status}
|
||||
@@ -226,7 +227,7 @@ class OrderReservation < ApplicationRecord
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
Rails.logger.debug "Get Doemal Status "
|
||||
Rails.logger.debug "Get Doemal Status => #{send_params}"
|
||||
Rails.logger.debug response.to_json
|
||||
return response
|
||||
end
|
||||
|
||||
@@ -573,7 +573,7 @@
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
var id = menus[0]["categories"][0]["id"];
|
||||
console.log(id);
|
||||
// console.log(id);
|
||||
}else{
|
||||
var id = 1;
|
||||
}
|
||||
@@ -583,7 +583,6 @@
|
||||
$(document).ready(function () {
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
console.log("menu");
|
||||
menu_cache_append(menus);
|
||||
}else{
|
||||
$("#menu_data").removeClass("hidden");
|
||||
|
||||
@@ -211,23 +211,8 @@
|
||||
<input type="hidden" name="server_mode" value="<%=ENV["SERVER_MODE"]%>" id="server_mode">
|
||||
<script>
|
||||
$(function() {
|
||||
$( "#loading_wrapper").show();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'get_all_menu',
|
||||
data: {},
|
||||
success:function(result){
|
||||
localStorage.setItem("menus", JSON.stringify(result));
|
||||
|
||||
var menu = localStorage.getItem("menus");
|
||||
|
||||
if (menu != null ) {
|
||||
$( "#loading_wrapper").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#loading_wrapper").show();
|
||||
getAllMenu();
|
||||
|
||||
$(".cashier_view").on('click', function() {
|
||||
window.location.href = '/origami';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="<%= @webview==true ? 'col-lg-12 col-md-12 col-sm-12' : 'col-lg-10 col-md-10 col-sm-10' %>">
|
||||
@@ -144,6 +147,11 @@ $(document).ready(function(){
|
||||
var webview = <%= @webview %>;
|
||||
|
||||
showHideNavbar(webview,"index");
|
||||
if(webview){
|
||||
$("#loading_wrapper").show();
|
||||
getAllMenu();
|
||||
}
|
||||
|
||||
$(".tables").on('click', function(){
|
||||
var dining_id = $(this).attr("data-id");
|
||||
window.location.href = '/origami/table/' + dining_id;
|
||||
|
||||
@@ -218,7 +218,7 @@ $('#jcb_pay').on('click',function(){
|
||||
//end member discount
|
||||
if(bank_integration == '1'){
|
||||
$("#reference_no").val("");
|
||||
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no);
|
||||
pay_withBank("SALE", "jcb", amount, sale_id, receipt_no,cashier_type);
|
||||
}else{
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_payment_jcb_path %>",
|
||||
|
||||
@@ -1064,52 +1064,50 @@ var pdf_view = '<%=@pdf_view%>';
|
||||
var printer_name = $("#printer_name").val();
|
||||
var receipt_no = $("#sale_receipt_no").val();
|
||||
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
|
||||
data: params,
|
||||
success:function(result){
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (pdf_view ==1) {
|
||||
if (cashier_type=="cashier") {
|
||||
window.location.href = '/origami';
|
||||
}else{
|
||||
window.location.href = '/origami/quick_service';
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
}else{
|
||||
var title = "Payment Successful!";
|
||||
if($('#balance').text() < 0){
|
||||
var text = 'Changed amount ' + $('#balance').text() * (-1);
|
||||
}else{
|
||||
$('#pay').text("Pay");
|
||||
var text = 'Thank You !';
|
||||
}
|
||||
swal({
|
||||
title: "Payment Successful!",
|
||||
text: text,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
if (cashier_type=="cashier") {
|
||||
window.location.href = '/origami';
|
||||
}else{
|
||||
window.location.href = '/origami/quick_service';
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
|
||||
data: params,
|
||||
success:function(result){
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
});
|
||||
|
||||
if (pdf_view ==1) {
|
||||
if (cashier_type=="cashier") {
|
||||
window.location.href = '/origami';
|
||||
}else{
|
||||
window.location.href = '/origami/quick_service';
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
}else{
|
||||
var title = "Payment Successful!";
|
||||
if($('#balance').text() < 0){
|
||||
var text = 'Changed amount ' + $('#balance').text() * (-1);
|
||||
}else{
|
||||
$('#pay').text("Pay");
|
||||
var text = 'Thank You !';
|
||||
}
|
||||
|
||||
swal({
|
||||
title: "Payment Successful!",
|
||||
text: text,
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
if (cashier_type=="cashier") {
|
||||
window.location.href = '/origami';
|
||||
}else{
|
||||
window.location.href = '/origami/quick_service';
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user