diff --git a/Dockerfile b/Dockerfile
index 69f0f58e..5c47ef29 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -8,5 +8,7 @@ COPY Gemfile /sxrestaurant/Gemfile
COPY Gemfile.lock /sxrestaurant/Gemfile.lock
RUN bundle install --without development test
RUN bundle exec rails assets:precompile
+RUN echo "Asia/Rangoon" > /etc/timezone
+RUN dpkg-reconfigure -f noninteractive tzdata
COPY . /sxrestaurant
diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js
index a4890681..a6317af6 100644
--- a/app/assets/javascripts/channels/check_new_order.js
+++ b/app/assets/javascripts/channels/check_new_order.js
@@ -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,30 +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
"+
- // "Are you accept or reject for these orders "+order_lists+"?",
- // type: 'success',
- // html: true,
- // closeOnConfirm: false,
- // closeOnCancel: false,
- // allowOutsideClick: false
- // }, function (isConfirm) {
- // if(isConfirm){
- // swal.close();
- // }
- // });
- $("#notify_new_order_lists").text(order_lists);
- $("#notify_new_order").on('show.bs.modal', function(e){
- $("#notify_order_send_to_kitchen").modal('hide');
- $("#notify_order_ready_to_delivery").modal('hide');
- }).on('shown.bs.modal', function(e){
- $("#notify_new_order").focus();
- }).on('hide.bs.modal', function (e) {
- $("#notify_new_order").modal("hide");
- }).modal({show: true, keyboard: false, backdrop: false});
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_new_order"),
+ text: "You have new orders
"+
+ "Are you accept or reject for these orders "+order_lists+"?",
+ 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").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});
}
}
});
diff --git a/app/assets/javascripts/channels/check_order_ready_to_delivery.js b/app/assets/javascripts/channels/check_order_ready_to_delivery.js
index 2e576266..319f7781 100644
--- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js
+++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js
@@ -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,30 +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
"+
- // "Could you ready these orders "+order_lists+" 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);
- $("#notify_order_ready_to_delivery").on('shown.bs.modal', function(e){
- $("#notify_new_order").modal('hide');
- $("#notify_order_send_to_kitchen").modal('hide');
- }).on('shown.bs.modal', function(e){
- $("#notify_order_ready_to_delivery").focus();
- }).on('hide.bs.modal', function (e) {
- $("#notify_order_ready_to_delivery").modal("hide");
- }).modal({show: true, keyboard: false, backdrop: false});
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_order_ready_to_delivery"),
+ text: "You have orders that are ready to deliver
"+
+ "Could you ready these orders "+order_lists+" 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").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});
}
}
});
diff --git a/app/assets/javascripts/channels/check_order_send_to_kitchen.js b/app/assets/javascripts/channels/check_order_send_to_kitchen.js
index fbb233f8..df9eb324 100644
--- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js
+++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js
@@ -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,30 +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
"+
- // "Could you send these orders "+order_lists+" 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);
- $("#notify_order_send_to_kitchen").on('show.bs.modal', function(e){
- $("#notify_new_order").modal('hide');
- $("#notify_order_ready_to_delivery").modal('hide');
- }).on('shown.bs.modal', function(e){
- $("#notify_order_send_to_kitchen").focus();
- }).on('hide.bs.modal', function (e) {
- $("#notify_order_send_to_kitchen").modal("hide");
- }).modal({show: true, keyboard: false, backdrop: false});
+ swal({
+ title: 'Information',
+ target: document.getElementById(shop_code+"_notify_order_send_to_kitchen"),
+ text: "You have to send order to kitchen
"+
+ "Could you send these orders "+order_lists+" 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").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});
}
}
});
diff --git a/app/assets/javascripts/channels/order_reservation.js b/app/assets/javascripts/channels/order_reservation.js
index 52b4cef5..468e4c31 100644
--- a/app/assets/javascripts/channels/order_reservation.js
+++ b/app/assets/javascripts/channels/order_reservation.js
@@ -3,16 +3,17 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
disconnected: function() {},
- received: function(data) {
+ received: function(data) {
+ var shop_code = data.shop_code;
var order = data.data;
if(order.length > 0){
- $('.order_reserve_cable tbody').html("");
- $(".nav-item.red > a > p.num").text(order.length);
+ $('.custom-table.'+shop_code+'_order_reserve_cable tbody').html("");
+ $("."+shop_code+" > .nav-item.red > a > p.num").text(order.length);
$.each(order, function(key,value){
var active_class = "";
if(key==0){
active_class = "tr-active";
- showNewOrder(order[key]);
+ showNewOrder(order[key],shop_code);
}
var rowCount = key+1;
var date = new Date(value.created_at);
@@ -20,9 +21,9 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate());
var delivery_type = "";
- if(value.delivery_type == "service"){
+ if(value.provider == "food2u" || value.provider == "yangondoor2door"){
delivery_type = "DELIVERY";
- }else if(value.delivery_type == "pick_up"){
+ }else if(value.provider == "pick_up"){
delivery_type = "PICK-UP";
}else{
delivery_type = "DIRECT DELIVERY";
@@ -42,7 +43,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
+''
+' ';
- $('.custom-table.order_reserve_cable tbody').append(row);
+ $('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row);
});
}
diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js
index 94f05663..ae8b727c 100644
--- a/app/assets/javascripts/custom.js
+++ b/app/assets/javascripts/custom.js
@@ -54,7 +54,17 @@ $(document).ready(function() {
});
$('#modal-set-slimscroll').slimScroll({
- height: height-$('#modal-slimscroll').attr('data-height'),
+ height: height-$('#modal-set-slimscroll').attr('data-height'),
+ size: '5px',
+ color: 'rgba(0,0,0,0.5)',
+ alwaysVisible: false,
+ borderRadius: '0',
+ railBorderRadius: '0',
+ touchScrollStep : 45
+ });
+
+ $('#customer-info-slimscroll').slimScroll({
+ height: height-$('#customer-info-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js
index 8f631284..83618770 100644
--- a/app/assets/javascripts/order_reservation.js
+++ b/app/assets/javascripts/order_reservation.js
@@ -5,6 +5,7 @@ $(function() {
$('#accepted').hide();
$('#cancel').hide();
$(".tbl_customer").hide();
+ $(".order_close_cashier").hide();
$(function() {
$('.first-1').click();
});
@@ -17,6 +18,7 @@ $(function() {
$('#accepted').hide();
$('#cancel').hide();
$(".tbl_customer").hide();
+ $(".order_close_cashier").hide();
if (type == "pending") {
$(".first-1").click();
$('#accepted').text("ACCEPT");
@@ -36,6 +38,7 @@ $(function() {
$('#accepted').attr("data-value","completed");
}else if(type == "processed"){
$(".fifth-1").click();
+ $(".order_close_cashier").show();
// $('#accepted').hide();
// $('#cancel').hide();
}
@@ -119,6 +122,12 @@ $(function() {
callback_url(callback,ref_no,order_id,status,type,minutes);
});
+ $('#order_close_cashier').on('click',function(e){
+ e.preventDefault(); // Prevent the href from redirecting directly
+ var linkURL = '/origami/shift/ordering/close';
+ warnBeforeRedirect(linkURL);
+ });
+
$(document).on('click','.access_number', function(event){
if(event.handled !== true) {
var original_value = $('#access_code').val();
@@ -147,8 +156,40 @@ $(function() {
return false;
}
});
+
+ // $('button[data-dismiss="modal"]').on('click', function(){ $(this).parent().parent().parent().parent().modal('hide'); });
+
+ // $(".new_order_close").on("click",function(){
+ // var code = $(this).attr("data-value");
+ // $("#"+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);
+ // });
});
+function warnBeforeRedirect(linkURL) {
+ swal({
+ title: "Alert!",
+ text: "Are you sure you want to close cashier?",
+ type: "warning",
+ showCancelButton: true
+ }, function() {
+ // Redirect the user
+ window.location.href = linkURL;
+ });
+}
+
function check_emp_access_code(access_code,type) {
var url = "/origami/check_emp_access_code/" + access_code ;
$.ajax({
@@ -193,6 +234,8 @@ function refreshDetailData(){
$('#discount_amount').text("0.00");
$('#total_tax').text("0.00");
$('#grand_total').text("0.00");
+ $(".tbl_customer").hide();
+ $(".order_close_cashier").hide();
}
//show order list
@@ -280,19 +323,21 @@ function show_order_detail(url,sr_no){
$('#customer_name').text(data.customer_name);
$('#phone').text(data.phone);
$('#address').text(address);
- $('#delivery_to').text(delivery.provider);
$('#ref_no').text(data.transaction_ref);
$('#callback_url').text(data.callback_url);
$('#order_id').text(data.order_reservation_id);
$("#trans_ref").text(data.transaction_ref);
- if(delivery.delivery_type == "service"){
+ if(delivery.provider == "food2u" || delivery.provider == "yangondoor2door"){
$("#delivery_info").text("(DELIVERY)");
- }else if(delivery.delivery_type == "pick_up"){
+ $("#delivery_to").text("DELIVERY");
+ }else if(delivery.provider == "pick_up"){
$("#delivery_info").text("(PICK-UP)");
+ $("#delivery_to").text("PICK-UP");
}else{
$("#delivery_info").text("(DIRECT DELIVERY)");
+ $("#delivery_to").text("DIRECT DELIVERY");
}
if(data.order_remark!=null && data.order_remark!=""){
@@ -375,6 +420,18 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
}, 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';
+ });
}
}
});
@@ -404,27 +461,47 @@ function timeFormat(date){
return time;
}
-function showNewOrder(order_reservation){
- // console.log(order_reservation);
+function showNewOrder(order_reservation,shop_code){
if((order_reservation!=undefined) && (order_reservation!=null) && (order_reservation!="")){
var date = new Date(order_reservation.requested_time);
var time = timeFormat(date);
var requested_date = date.getFullYear() + '-' + (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >= 10? date.getDate() : '0' + date.getDate()) +' '+time;
//audio play
- var audio = new Audio('/beep.wav'); // define your audio
+ var audio = new Audio('/'+shop_code+'-beep.mp3'); // define your audio
// setTimeout(function(){
// audio.loop = true;
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});
swal({
- html: true,
title: 'Information',
- text: "You have new order " + order_reservation.order_reservation_id + " at "+requested_date+"",
+ target: document.getElementById(shop_code+"_notify_new_order"),
+ text: "You have new order "+
+ ""+order_reservation.order_reservation_id+" requested for "+requested_date+"?",
type: 'success',
+ html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
+ }, function (isConfirm) {
+ if(isConfirm){
+ audio.pause();
+ swal.close();
+ }
});
}
}
diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb
index 866d3da3..1bb257de 100644
--- a/app/controllers/api/order_reserve/order_reservation_controller.rb
+++ b/app/controllers/api/order_reserve/order_reservation_controller.rb
@@ -32,31 +32,31 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
def create
status = false
if !params[:cus_info]
- render :json => { :status => false, :message => "cus_info is required!" }
+ result = { :status => false, :message => "cus_info is required!" }
elsif !params[:requested_time]
- render :json => { :status => false, :message => "requested_time is required!" }
+ result = { :status => false, :message => "requested_time is required!" }
elsif !params[:callback_url]
- render :json => { :status => false, :message => "callback_url is required!" }
+ result = { :status => false, :message => "callback_url is required!" }
elsif !params[:reference]
- render :json => { :status => false, :message => "reference is required!" }
+ result = { :status => false, :message => "reference is required!" }
elsif !params[:order_type]
- render :json => { :status => false, :message => "order_type is required!" }
+ result = { :status => false, :message => "order_type is required!" }
elsif params[:order_type] == ORDER || params[:order_type] == ORDER_RESERVATION
if !params[:order_info]
- render :json => { :status => false, :message => "order_info is required!" }
+ result = { :status => false, :message => "order_info is required!" }
else
status = true
end
elsif params[:order_type] == RESERVATION || params[:order_type] == ORDER_RESERVATION
if !params[:reservation_info]
- render :json => { :status => false, :message => "reservation_info is required!" }
+ result = { :status => false, :message => "reservation_info is required!" }
else
status = true
end
elsif !params[:payment_info]
- render :json => { :status => false, :message => "payment_info is required!" }
+ result = { :status => false, :message => "payment_info is required!" }
elsif !params[:delivery_info]
- render :json => { :status => false, :message => "delivery_info is required!" }
+ result = { :status => false, :message => "delivery_info is required!" }
end
if status == true
@@ -64,16 +64,27 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
if flag #&& ENV["SERVER_MODE"] != 'cloud'
+ shop = Shop.find_by_id(1)
+ if !shop.shop_code.nil?
+ shop_code = shop.shop_code
+ else
+ shop_code = ''
+ end
+
+ result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id)
- ActionCable.server.broadcast "order_reservation_channel",data: order_reservation
- end
-
- if flag
- render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
+ ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code
else
- render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
+ result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
end
end
+
+ puts "!!! send doemal ::"
+ puts result
+
+ Rails.logger.debug "send status to doemal"
+ Rails.logger.debug result
+ render :json => result
end
def update_status
diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb
index b49ef597..c1bce9b2 100755
--- a/app/controllers/concerns/token_verification.rb
+++ b/app/controllers/concerns/token_verification.rb
@@ -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 = "local" #request.subdomain.downcase + "." + request.domain.downcase
+ from = request.subdomain.downcase + "." + request.domain.downcase #"local"
aes = MyAesCrypt.new
return aes.checkKeyForAuth(from, token)
end
diff --git a/app/controllers/oqs/backhome_controller.rb b/app/controllers/oqs/backhome_controller.rb
index f809ef9f..4ac5f0a2 100755
--- a/app/controllers/oqs/backhome_controller.rb
+++ b/app/controllers/oqs/backhome_controller.rb
@@ -89,7 +89,6 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status
def queue_items_query(status)
- byebug
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index b7c9b1b6..63cb8736 100755
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -67,6 +67,8 @@ class Origami::AddordersController < BaseOrigamiController
end
def get_menu()
+ puts "sssssssssssssss"
+puts params[:id]
if (params[:id])
#Pull this menu
@menu = Menu.find_by_id(params[:id])
diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb
index 827cfcda..a3421fbd 100644
--- a/app/controllers/origami/order_reservation_controller.rb
+++ b/app/controllers/origami/order_reservation_controller.rb
@@ -4,6 +4,7 @@ class Origami::OrderReservationController < BaseOrigamiController
@order = OrderReservation.latest_order #.active
@count_on_order = OrderReservation.get_count_on_order
@count_on_completed = OrderReservation.get_count_on_completed
+ @shop = Shop.find_by_id(1)
end
def update
diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb
index 2cea51a4..3b2fe081 100755
--- a/app/controllers/origami/shifts_controller.rb
+++ b/app/controllers/origami/shifts_controller.rb
@@ -81,8 +81,8 @@ class Origami::ShiftsController < BaseOrigamiController
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
- byebug
- @total_waste = Sale.get_total_waste(@shift)
+ @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
+ @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
@@ -96,10 +96,9 @@ class Origami::ShiftsController < BaseOrigamiController
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
- #byebug
printer = Printer::CashierStationPrinter.new(print_settings)
-
- printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges)
+
+ printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile)
end
end
Employee.logout(session[:session_token])
diff --git a/app/models/my_aes_crypt.rb b/app/models/my_aes_crypt.rb
index 8f3cde09..4116f2a2 100644
--- a/app/models/my_aes_crypt.rb
+++ b/app/models/my_aes_crypt.rb
@@ -64,7 +64,7 @@ class MyAesCrypt
shop_json["data"].each do |j|
if j["lookup"] == from
# add [0...44] for production cloud for remove \n
- if(j["value"]["key"] == token)
+ if(j["value"]["key"].gsub(/\s+/, "") == token)
return true
end
end
diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb
index cd0b7e68..84209845 100644
--- a/app/models/order_reservation.rb
+++ b/app/models/order_reservation.rb
@@ -93,9 +93,6 @@ class OrderReservation < ApplicationRecord
count += 1
items_arr.push(items)
}
-
- puts items_arr.to_json
- puts "sssssssssssssssssssssss"
customer_id = order.customer_id
@order = Order.new
@@ -125,8 +122,11 @@ class OrderReservation < ApplicationRecord
update_order_reservation(order.id, @sale.sale_id, SEND_TO_KITCHEN)
result = {:status=> @status, :data => @sale, :message => "send to kitchen" }
- return result
+ else
+ result = {:status=> @status, :message => "No current shift open for this employee!" }
end
+
+ return result
end
def self.update_doemal_payment(order,current_user)
@@ -178,10 +178,9 @@ class OrderReservation < ApplicationRecord
end
Rails.logger.debug "Doemal URL" + base_url
post_url = base_url + url
-
- if !waiting_time.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
diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb
index 63239cdc..73813d1a 100755
--- a/app/models/printer/cashier_station_printer.rb
+++ b/app/models/printer/cashier_station_printer.rb
@@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# self.print(filename, cashier_terminal.printer_name)
# end
- def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
+ def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile)
#Use CUPS service
#Generate PDF
@@ -46,7 +46,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
- pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
+ pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile)
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty?
@@ -55,7 +55,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
if close_cashier[1] == '1'
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
else
- pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
+ pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile)
end
end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 60cf0d7a..0e19e65f 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -1092,6 +1092,14 @@ end
return sale_arr
end
+def self.get_total_waste(shift_id)
+ query = Sale.where("sale_status = 'waste' and shift_sale_id = ?", shift_id)
+end
+
+def self.get_total_spoile(shift_id)
+ query = Sale.where("sale_status = 'spoile' and shift_sale_id = ?", shift_id)
+end
+
def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
# wrong amount tax for service and commercial tax
diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb
index c2dac049..10b2de38 100755
--- a/app/models/shift_sale.rb
+++ b/app/models/shift_sale.rb
@@ -94,11 +94,6 @@ class ShiftSale < ApplicationRecord
end
end
- def self.get_total_waste(shift)
- total_waste = Sale.select(" SUM(grand_total) as total_waste")
- .where("sales.payment_status ='waste' and sale_status = 'waste'", shift.id)
- end
-
def get_closing_balance(shift)
shiftobj = ShiftSale.find(shift)
closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash
diff --git a/app/pdf/close_cashier_customise_pdf.rb b/app/pdf/close_cashier_customise_pdf.rb
index 84311caa..5a094a7b 100644
--- a/app/pdf/close_cashier_customise_pdf.rb
+++ b/app/pdf/close_cashier_customise_pdf.rb
@@ -70,7 +70,7 @@ class CloseCashierCustomisePdf < Prawn::Document
stroke_horizontal_rule
end
- def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges)
+ def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_dinein,total_takeway,total_other_charges,total_spoile)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb
index a1c92637..8f971416 100755
--- a/app/pdf/close_cashier_pdf.rb
+++ b/app/pdf/close_cashier_pdf.rb
@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
- def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
+ def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_waste,total_spoile)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -54,7 +54,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter)
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile)
end
def header (shop_details)
@@ -70,7 +70,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
- def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter)
+ def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -333,7 +333,7 @@ class CloseCashierPdf < Prawn::Document
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
- y_position = cursor
+ y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void :", :size => self.item_font_size, :align => :right
end
@@ -341,6 +341,22 @@ class CloseCashierPdf < Prawn::Document
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
end
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total Waste :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total Waste :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
+ end
+
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Grand Total :", :size => self.item_font_size, :align => :right
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 62bbf3a4..391ba83b 100644
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -650,11 +650,58 @@
$(document).on('click', '.menu_click', function(event){
var menu_id = $(this).attr("data-id");
var name = $(this).attr("data-name");
- var url = "get_menu/"+menu_id;
- show_menu_cat_list(name, url);
+ var menus = JSON.parse(localStorage.getItem("menus"));
+ if (menus != null) {
+ menu_click_cache_append(name,menus,menu_id);
+ }else{
+ var url = "get_menu/"+menu_id;
+ show_menu_cat_list(name, url);
+ }
});
//End menu category Click
+ function menu_click_cache_append(name,menus,menu_id) {
+ var menu_list = $('.menu_items_list');
+ menu_list.empty();
+
+ var menu_cat = $('.category_list');
+ menu_cat.empty();
+
+ $(".main_menu").text(name);
+ for(var i in menus) {
+ console.log(menus)
+ console.log(menus[i]["id"]);
+ console.log(menus[i]["is_active"]);
+ console.log(menu_id);
+ if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
+ // menu_list_template(menus[i]);
+ var category = menus[i]["categories"];
+
+ for(var ii in category) {
+ if (category[ii]["is_available"]== true){
+ if (category[ii]["valid_time"]== true){
+ if (category[ii]["parent_id"] == null ){
+ if(type){
+ if (category[ii]["code"].includes("SPL") != true) {
+ category_list_template(category[ii]);
+ }
+ }else{
+ if ($("#table_get_current").text()) {
+ if (category[ii]["code"].includes("SPL") != true) {
+ category_list_template(category[ii]);
+ }else {
+ category_list_template(category[ii]);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
//show menu item list when click menu category
function show_menu_cat_list(name, url_item){
var menu_list = $('.menu_items_list');
@@ -663,15 +710,18 @@
var menu_cat = $('.category_list');
menu_cat.empty();
- $(".main_menu").text(name)
- if (modify_order=="true" && type =="true") {
+ $(".main_menu").text(name);
+ cashier_type = window.location.href.indexOf("quick_service");
+ modify_order = window.location.href.indexOf("modify_order");
+ if (cashier_type != -1 && modify_order != -1) {
url_item = '../../../addorders/'+url_item;
- }if(modify_order=="false" && type =="true"){
- url_item = 'addorders/'+url_item
- }else{
- url_item = url_item;
}
-
+ if(modify_order == -1 && cashier_type != -1){
+ url_item = 'addorders/'+url_item
+ }
+ if (cashier_type ==-1 && modify_order == -1){
+ url_item = url_item;
+ }
//Start Ajax
$.ajax({
type: "GET",
@@ -679,10 +729,8 @@
data: {},
dataType: "json",
success: function(data) {
-
for(var i in data) {
if (data[i].is_available == true) {
-
row = '