update print pay in qs

This commit is contained in:
Aung Myo
2018-02-21 12:34:03 +06:30
parent 4ebe353182
commit 4455b03e8a
6 changed files with 73 additions and 54 deletions

View File

@@ -225,10 +225,13 @@ i.logout_icon{
background-color: #eee;
border-bottom: 1px solid #fff;
}
.list-menu > a:focus{
background-color:initial;
}
.menu_list{
display: block;
background-color: #eeeeee;
border-bottom: .214rem solid #fff;
border-bottom: .014rem solid #fff;
border-left: 1px solid #54A5AF;
border-right: 1px solid #54A5AF;
margin-bottom: -1px;

View File

@@ -157,8 +157,14 @@ class Origami::PaymentsController < BaseOrigamiController
if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,booking.dining_facility_id)
Order.pay_process_order_queue(order.order_id,table_id,sale_id)
end
end
end

View File

@@ -1,7 +1,7 @@
class OrderQueueProcessorJob < ApplicationJob
queue_as :default
def perform(order_id, table_id)
def perform(order_id, table_id,sale_id=nil)
# Do something later
#Order ID
order = Order.find(order_id)
@@ -9,7 +9,7 @@ class OrderQueueProcessorJob < ApplicationJob
#Execute orders and send to order stations
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
oqs.process_order(order, table_id,sale_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)

View File

@@ -309,9 +309,9 @@ class Order < ApplicationRecord
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
def self.pay_process_order_queue(id,table_id,sale_id=nil)
#Send to background job for processing
OrderQueueProcessorJob.perform_later(id, table_id)
OrderQueueProcessorJob.perform_later(id, table_id,sale_id)
end
def check_cup_status(status)

View File

@@ -13,46 +13,22 @@ class OrderQueueStation < ApplicationRecord
# validations
validates_presence_of :station_name, :printer_name
def process_order (order, table_id)
def process_order (order, table_id,sale_id=nil)
oqs_stations = OrderQueueStation.active
dining=DiningFacility.find(table_id)
# oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
order_items = order.order_items
# get dining
booking = Booking.find_by_dining_facility_id(dining.id)
#Assign OQS id to order Items
# oqs_stations.each do |oqs|
# is_auto_printed = false
# oqs_order_items = []
# #Get List of items -
# pq_items = JSON.parse(oqs.processing_items)
# #Loop through the processing items
# pq_items.each do |pq_item|
# #Processing through the looping items
# order_items.each do |order_item|
# if (pq_item == order_item.item_code)
# # if oqs.id == oqpbz.order_queue_station_id
# # #Same Order_items can appear in two location.
# # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# # else
# if (order_item.price != 0)
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# oqs_order_items.push(order_item)
# end
# # end
# end
# end
# end
if table_id > 0
# get dining
dining=DiningFacility.find(table_id)
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
booking = Booking.find_by_dining_facility_id(dining.id)
# ToDo per item per printer
OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").find_each do |oqpbz|
oqs_by_zones.each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
@@ -86,17 +62,51 @@ class OrderQueueStation < ApplicationRecord
end
end
end
# if oqs.id == oqpbz.order_queue_station_id
# # Auto Printing
# if oqs.auto_print
# if oqs_order_items.length > 0
# print_slip(oqs, order, oqs_order_items)
# is_auto_printed = true
# end
# end
# end
end
# end
end
else
# get dining
sale = Sale.find(sale_id).shift_sale_id
terminal_by_zones = CashierTerminalByZones.where("cashier_terminal_id=#{shift.cashier_terminal_id}")
# ToDo per item per printer
terminal_by_zones.each do |tbz|
OrderQueueProcessByZone.where("zone_id=#{tbz.zone_id}").find_each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
# if oqs.id == oqpbz.order_queue_station_id
# #Same Order_items can appear in two location.
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
# end
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
end
end #end else
end
private

View File

@@ -28,7 +28,7 @@
<span class="main_menu" id="main_menu" ><%= @menus[0].name %></span>
<!-- <i class="material-icons material-icons m-l-50 p-r-30">arrow_drop_down</i> -->
</a>
<ul class="ml-menu menu_list aria-hidden " style="">
<ul class="ml-menu menu_list aria-hidden " style="border-top: 1px solid #fff">
<% @menus.each do |menu| %>
<li class="nav-item menu_click" data-name="<%=menu.name%>" data-id="<%=menu.id%>" style="">
<a class="nav-link" data-toggle="tab" href="" role="tab" style="text-transform: lowercase;"><%=menu.name%></a>
@@ -213,14 +213,14 @@
<% if type && modify_order%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary btn-lg create col-md-10" id="create_pay_order" disabled="disabled">Update Order & Pay</button>
<button type="button" class="btn btn-primary action-btn create col-md-10" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<%elsif !modify_order && type%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary btn-lg create col-md-6" id="create_pay_order" disabled="disabled">Create & Pay</button>
<button type="button" class="btn btn-primary btn-lg create col-md-5" id="create_order" disabled="disabled">Create Order</button>
<button type="button" class="btn btn-primary action-btn create col-md-6" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create & Pay</button>
<button type="button" class="btn btn-primary action-btn create col-md-5" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<%else%>
<button type="button" class="btn btn-primary btn-lg create col-md-10" id="create_order" disabled="disabled">Create Order</button>
<button type="button" class="btn btn-primary action-btn create col-md-10" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<%end%>