Files
sx-fc/app/controllers/oqs/edit_controller.rb
2018-03-19 09:17:12 +06:30

74 lines
2.7 KiB
Ruby

class Oqs::EditController < BaseOqsController
def index
assigned_item_id = params[:id]
@link_type = params[:type]
@dining_type = nil
if params[:type] == 'oqs'
assigned_item = AssignedOrderItem.find(assigned_item_id)
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'")
elsif
assigned_item = OrderItem.find(assigned_item_id)
@booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id")
.where("bko.order_id = '#{assigned_item.order_id}'").first()
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
else
assigned_item = OrderItem.find(assigned_item_id)
dining = DiningFacility.find_by_id(params[:type])
@dining_type = dining.type
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
end
end
def update
order_items_id = params[:order_items_id]
qty_weight = params[:qty_weight]
remarks = params[:remarks]
order_item = OrderItem.find(order_items_id)
before_updated_qty = order_item.qty
order_item.item_order_by = current_user.name
order_item.qty = qty_weight
order_item.remark = remarks
order_item.save
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# print
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
# order queue stations
oqs = assigned_item.order_queue_station
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
order_slim_pdf.each do |order_item_slim|
if order_item_slim[0] == 'OrderSlimPdf'
if order_item_slim[1] == '1'
unique_code="OrderItemSlimPdf"
else
unique_code="OrderItemPdf"
end
elsif order_item_slim[0] == 'OrderSetPdf'
if order_item_slim[1] == '1'
unique_code="OrderSetItemPdf"
else
unique_code="OrderItemPdf"
end
end
end
end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end