change action cable issue for quick service

This commit is contained in:
phyusin
2018-05-31 10:29:38 +06:30
parent 6472dbeacb
commit c1961720c8
7 changed files with 73 additions and 33 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -33,7 +33,10 @@
</div>
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Customer :</strong> <span id="customer_name"> <%= @sale_data.customer.name%></span> <span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<div class="col-lg-6 col-md-6 col-sm-6">
<strong>Customer :</strong>
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale_data.customer.name%></button>
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
<%end%></div>
@@ -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});
// }
}
});
</script>

View File

@@ -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';
}
}
});