check api issue

This commit is contained in:
phyusin
2018-05-12 15:20:57 +06:30
parent 8457ebc08e
commit 050d3379c0
8 changed files with 150 additions and 114 deletions

View File

@@ -5,6 +5,7 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', {
received: function(data) {
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
@@ -18,33 +19,33 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', {
});
// alert(order_lists);
// swal({
// title: 'Information',
// target: document.getElementById("notify_new_order"),
// text: "You have new orders <br/>"+
// "Are you accept or reject for these orders <b>"+order_lists+"</b>?",
// type: 'success',
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function (isConfirm) {
// if(isConfirm){
// swal.close();
// }
// });
$("#notify_new_order_lists").text(order_lists);
swal({
title: 'Information',
target: document.getElementById(shop_code+"_notify_new_order"),
text: "You have new orders <br/>"+
"Are you accept or reject for these orders <b>"+order_lists+"</b>?",
type: 'success',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
swal.close();
}
});
// $("#notify_new_order_lists").text(order_lists);
// if($("#notify_new_order").hasClass("hidden")){
$("#notify_new_order").removeClass("hidden");
// $("#notify_new_order").removeClass("hidden");
// }
$("#notify_new_order").on('show.bs.modal', function(e){
$("#notify_order_send_to_kitchen").addClass("hidden");
$("#notify_order_ready_to_delivery").addClass("hidden");
}).on('shown.bs.modal', function(e){
$("#notify_new_order").focus();
}).on('hide.bs.modal', function (e) {
$("#notify_new_order").addClass("hidden");
}).modal({show: true, keyboard: false, backdrop: false});
// $("#notify_new_order").on('show.bs.modal', function(e){
// $("#notify_order_send_to_kitchen").addClass("hidden");
// $("#notify_order_ready_to_delivery").addClass("hidden");
// }).on('shown.bs.modal', function(e){
// $("#notify_new_order").focus();
// }).on('hide.bs.modal', function (e) {
// $("#notify_new_order").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
}
}
});

View File

@@ -5,6 +5,7 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe
received: function(data) {
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
@@ -18,33 +19,33 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe
});
// alert(order_lists);
// swal({
// title: 'Information',
// target: document.getElementById("notify_order_ready_to_delivery"),
// text: "You have orders that are ready to deliver <br/>"+
// "Could you ready these orders <b>"+order_lists+"</b> to deliver?",
// type: 'success',
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function (isConfirm) {
// if(isConfirm){
// swal.close();
// }
// });
$("#notify_order_ready_to_delivery_lists").text(order_lists);
swal({
title: 'Information',
target: document.getElementById(shop_code+"_notify_order_ready_to_delivery"),
text: "You have orders that are ready to deliver <br/>"+
"Could you ready these orders <b>"+order_lists+"</b> to deliver?",
type: 'success',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
swal.close();
}
});
// $("#notify_order_ready_to_delivery_lists").text(order_lists);
// if($("#notify_order_ready_to_delivery").hasClass("hidden")){
$("#notify_order_ready_to_delivery").removeClass("hidden");
// $("#notify_order_ready_to_delivery").removeClass("hidden");
// }
$("#notify_order_ready_to_delivery").on('shown.bs.modal', function(e){
$("#notify_new_order").addClass("hidden");
$("#notify_order_send_to_kitchen").addClass("hidden");
}).on('shown.bs.modal', function(e){
$("#notify_order_ready_to_delivery").focus();
}).on('hide.bs.modal', function (e) {
$("#notify_order_ready_to_delivery").addClass("hidden");
}).modal({show: true, keyboard: false, backdrop: false});
// $("#notify_order_ready_to_delivery").on('shown.bs.modal', function(e){
// $("#notify_new_order").addClass("hidden");
// $("#notify_order_send_to_kitchen").addClass("hidden");
// }).on('shown.bs.modal', function(e){
// $("#notify_order_ready_to_delivery").focus();
// }).on('hide.bs.modal', function (e) {
// $("#notify_order_ready_to_delivery").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
}
}
});

View File

@@ -5,6 +5,7 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend
received: function(data) {
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
@@ -18,33 +19,33 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend
});
// alert(order_lists);
// swal({
// title: 'Information',
// target: document.getElementById("notify_order_send_to_kitchen"),
// text: "You have to send order to kitchen <br/>"+
// "Could you send these orders <b>"+order_lists+"</b> to kitchen?",
// type: 'success',
// html: true,
// closeOnConfirm: false,
// closeOnCancel: false,
// allowOutsideClick: false
// }, function (isConfirm) {
// if(isConfirm){
// swal.close();
// }
// });
$("#notify_order_send_to_kitchen_lists").text(order_lists);
swal({
title: 'Information',
target: document.getElementById(shop_code+"_notify_order_send_to_kitchen"),
text: "You have to send order to kitchen <br/>"+
"Could you send these orders <b>"+order_lists+"</b> to kitchen?",
type: 'success',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
swal.close();
}
});
// $("#notify_order_send_to_kitchen_lists").text(order_lists);
// if($("#notify_order_send_to_kitchen").hasClass("hidden")){
$("#notify_order_send_to_kitchen").removeClass("hidden");
// $("#notify_order_send_to_kitchen").removeClass("hidden");
// }
$("#notify_order_send_to_kitchen").on('show.bs.modal', function(e){
$("#notify_new_order").addClass("hidden");
$("#notify_order_ready_to_delivery").addClass("hidden");
}).on('shown.bs.modal', function(e){
$("#notify_order_send_to_kitchen").focus();
}).on('hide.bs.modal', function (e) {
$("#notify_order_send_to_kitchen").addClass("hidden");
}).modal({show: true, keyboard: false, backdrop: false});
// $("#notify_order_send_to_kitchen").on('show.bs.modal', function(e){
// $("#notify_new_order").addClass("hidden");
// $("#notify_order_ready_to_delivery").addClass("hidden");
// }).on('shown.bs.modal', function(e){
// $("#notify_order_send_to_kitchen").focus();
// }).on('hide.bs.modal', function (e) {
// $("#notify_order_send_to_kitchen").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
}
}
});

View File

@@ -164,18 +164,18 @@ $(function() {
// $("#"+code+"_doemal_new_order").modal("hide");
// });
$("[data-dismiss='modal']").on('click', function() {
$('body').addClass('modal-open-fix');
if($('body').css("padding-right") == '15px') {
$('body').addClass('modal-open-fix-pad');
}
setTimeout(function() {
if($('body').hasClass('modal-open-fix-pad')) {
$('body').css('padding-right', '15px');
}
$('body').addClass('modal-open').removeClass('modal-open-fix, modal-open-fix-pad');
}, 1000);
});
// $("[data-dismiss='modal']").on('click', function() {
// $('body').addClass('modal-open-fix');
// if($('body').css("padding-right") == '15px') {
// $('body').addClass('modal-open-fix-pad');
// }
// setTimeout(function() {
// if($('body').hasClass('modal-open-fix-pad')) {
// $('body').css('padding-right', '15px');
// }
// $('body').addClass('modal-open').removeClass('modal-open-fix, modal-open-fix-pad');
// }, 1000);
// });
});
function warnBeforeRedirect(linkURL) {
@@ -473,20 +473,36 @@ function showNewOrder(order_reservation,shop_code){
audio.play();
// },10000);
$("#new_order").text(order_reservation.order_reservation_id);
$("#new_order_date").text(requested_date);
if($("#"+shop_code+"_doemal_new_order").hasClass("hidden")){
$("#"+shop_code+"_doemal_new_order").removeClass("hidden");
}
$("#"+shop_code+"_doemal_new_order").on('show.bs.modal', function(e){
$("#notify_new_order").addClass("hidden");
$("#notify_order_send_to_kitchen").addClass("hidden");
$("#notify_order_ready_to_delivery").addClass("hidden");
}).on('shown.bs.modal', function(e){
$("#"+shop_code+"_doemal_new_order").focus();
}).on('hide.bs.modal', function (e) {
$("#"+shop_code+"_doemal_new_order").addClass("hidden");
}).modal({show: true, keyboard: false, backdrop: false});
// $("#new_order").text(order_reservation.order_reservation_id);
// $("#new_order_date").text(requested_date);
// if($("#"+shop_code+"_doemal_new_order").hasClass("hidden")){
// $("#"+shop_code+"_doemal_new_order").removeClass("hidden");
// }
// $("#"+shop_code+"_doemal_new_order").on('show.bs.modal', function(e){
// $("#notify_new_order").addClass("hidden");
// $("#notify_order_send_to_kitchen").addClass("hidden");
// $("#notify_order_ready_to_delivery").addClass("hidden");
// }).on('shown.bs.modal', function(e){
// $("#"+shop_code+"_doemal_new_order").focus();
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
swal({
title: 'Information',
target: document.getElementById(shop_code+"_notify_new_order"),
text: "You have new order "+
"<b>"+order_reservation.order_reservation_id+"</b> requested for "+requested_date+"?",
type: 'success',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
audio.pause();
swal.close();
}
});
}
}

View File

@@ -18,7 +18,7 @@ module TokenVerification
# Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL")
if(ENV["SERVER_MODE"] === "cloud")
from = request.subdomain.downcase + "." + request.domain.downcase #"local"
from = request.subdomain.downcase + "." + request.domain.downcase #"local"
aes = MyAesCrypt.new
return aes.checkKeyForAuth(from, token)
end

View File

@@ -65,7 +65,6 @@ class MyAesCrypt
if j["lookup"] == from
# add [0...44] for production cloud for remove \n
if(j["value"]["key"].gsub(/\s+/, "") == token)
puts token
return true
end
end

View File

@@ -178,10 +178,9 @@ class OrderReservation < ApplicationRecord
end
Rails.logger.debug "Doemal URL" + base_url
post_url = base_url + url
if !waiting_time.nil? && !min_type.nil? && reason.nil?
if waiting_time != ""
send_params = {id: ref_no,type: min_type, waiting_time: waiting_time, status: status}
elsif !reason.nil?
elsif reason != ""
send_params = {id: ref_no, status: status, reason: reason}
else
send_params = {id: ref_no, status: status}
@@ -290,28 +289,46 @@ class OrderReservation < ApplicationRecord
end
def self.check_new_order
shop = Shop.find_by_id(1)
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
shop_code = ''
end
order_reservation = OrderReservation.where("status='new'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code
end
end
end
def self.check_order_send_to_kitchen
shop = Shop.find_by_id(1)
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
shop_code = ''
end
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.now.utc}'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code
end
end
end
def self.check_order_ready_to_delivery
shop = Shop.find_by_id(1)
if !shop.shop_code.nil?
shop_code = shop.shop_code
else
shop_code = ''
end
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.now.utc}'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code
end
end
end

View File

@@ -464,9 +464,10 @@
</div>
</div>
<!-- <div id="notify_new_order"></div>
<div id="notify_order_send_to_kitchen"></div>
<div id="notify_order_ready_to_delivery"></div> -->
<div id="<%= @shop.shop_code ? @shop.shop_code : '' %>_doemal_new_order"></div>
<div id="<%= @shop.shop_code ? @shop.shop_code : '' %>_notify_new_order"></div>
<div id="<%= @shop.shop_code ? @shop.shop_code : '' %>_notify_order_send_to_kitchen"></div>
<div id="<%= @shop.shop_code ? @shop.shop_code : '' %>_notify_order_ready_to_delivery"></div>
</div>
<p id="ref_no" class="hidden"></p>
@@ -583,7 +584,7 @@
</div>
</div>
<div class="modal fade text-center" id="<%= @shop.shop_code ? @shop.shop_code : '' %>_doemal_new_order" tabindex="-1" role="dialog">
<!-- <div class="modal fade text-center" id="<%= @shop.shop_code ? @shop.shop_code : '' %>_doemal_new_order" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
@@ -670,4 +671,4 @@
</div>
</div>
</div>
</div>
</div> -->