From c1961720c843252e83b1cb7a466dd804ea6b09a2 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 31 May 2018 10:29:38 +0630 Subject: [PATCH] change action cable issue for quick service --- .../origami/addorders_controller.rb | 31 +++++++++++++------ .../origami/payments_controller.rb | 22 +++++++++++++ app/models/order.rb | 2 +- app/models/order_queue_station.rb | 14 ++++----- app/models/sale_payment.rb | 14 ++++----- app/views/origami/payments/show.html.erb | 21 ++++++++----- app/views/origami/pending_order/show.html.erb | 2 +- 7 files changed, 73 insertions(+), 33 deletions(-) diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 3fc11693..84c5ee6a 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -182,6 +182,15 @@ puts params[:id] @status, @booking = @order.generate if @status && @booking + #send order broadcast to order_channel + if @order.table_id.to_i > 0 + table = DiningFacility.find(@booking.dining_facility_id) + type = 'order' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + + end + if params[:order_source] != "quick_service" process_order_queue(@order.order_id,@order.table_id,@order.source) end @@ -194,11 +203,7 @@ puts params[:id] @status, @sale = Sale.request_bill(@order,current_user,current_login_employee) # for second display - if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain - else - from = "" - end + from = getCloudDomain #get sub domain in cloud mode ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from #end result = {:status=> @status, :data => @sale } @@ -307,11 +312,7 @@ puts params[:id] oqs.process_order(order, table_id, order_source) end - if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain - else - from = "" - end + from = getCloudDomain #get sub domain in cloud mode assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from end @@ -325,6 +326,16 @@ puts params[:id] end return false end + + #get cloud domain + def getCloudDomain + from = "" + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + end + + return from + end private diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 284656d2..2ef01ea1 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -120,6 +120,10 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") + type = 'payment' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + rebate_amount = nil # For Cashier by Zone @@ -184,6 +188,10 @@ class Origami::PaymentsController < BaseOrigamiController # Order.pay_process_order_queue(order.order_id, table_id) oqs = OrderQueueStation.new oqs.pay_process_order_queue(order.order_id, table_id) + + assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id) + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from end end @@ -468,6 +476,10 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark) + type = 'payment' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") # if bookings.count > 1 @@ -595,4 +607,14 @@ class Origami::PaymentsController < BaseOrigamiController render json: JSON.generate({:status => true}) end + + #get cloud domain + def getCloudDomain + from = "" + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + end + + return from + end end \ No newline at end of file diff --git a/app/models/order.rb b/app/models/order.rb index 5edc778a..571c549c 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -76,7 +76,7 @@ class Order < ApplicationRecord # end #send order to broadcast job - send_order_broadcast(booking) + # send_order_broadcast(booking) return true, booking end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 3a69fe62..9ecd54c0 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -121,13 +121,13 @@ class OrderQueueStation < ApplicationRecord # oqs = OrderQueueStation.new # oqs.process_order(order, table_id) # end - assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) - if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain - else - from = "" - end - ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from + # assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) + # if ENV["SERVER_MODE"] == 'cloud' + # from = request.subdomain + "." + request.domain + # else + # from = "" + # end + # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from if table_id.to_i > 0 # get dining diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 3933aa2c..0e17ee26 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -619,16 +619,16 @@ class SalePayment < ApplicationRecord table.save end - type = 'payment' + # type = 'payment' #Send to background job for processing # OrderBroadcastJob.perform_later(table,type) #if ENV["SERVER_MODE"] != 'cloud' - if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain - else - from = "" - end - ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + # if ENV["SERVER_MODE"] == 'cloud' + # from = request.subdomain + "." + request.domain + # else + # from = "" + # end + # ActionCable.server.broadcast "order_channel",table: table,type:type,from:from #end end end diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index f16fc42d..a7e6ce07 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -33,7 +33,10 @@
-
Customer : <%= @sale_data.customer.name%> +
+ Customer : + +
Checkin Time : <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %> <%end%>
@@ -624,12 +627,6 @@ var customer_id = "<%= @customer.id %>"; var customer_name = "<%= @customer.name %>"; $(document).ready(function(){ setHeaderBreadCrumb(_PAYMENTS_); - //start customer modal popup - if((cashier_type=='quick_service') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){ - // if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){ - $("#is_memberModal").modal({show : true, backdrop: false, keyboard : false}); - // } - } /* start check first bill or not*/ var member_id = $('#membership_id').text(); @@ -1489,4 +1486,14 @@ var customer_name = "<%= @customer.name %>"; $(".change_tax").hide(); } } + + /* customer light-box */ + $("#customer_name").on("click",function(){ + //start customer modal popup + if((cashier_type=='quick_service') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){ + // if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){ + $("#is_memberModal").modal({show : true, backdrop: false, keyboard : false}); + // } + } + }); diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index e979d6d5..2559c179 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -237,7 +237,7 @@ $(document).ready(function(){ swal("Information!", result.error_message); } else { - window.location.href = '/origami/quick_service/pending_order'; + window.location.href = '/origami/sale/'+result.data+'/quick_service/payment'; } } });