add edit order item api and second display route
This commit is contained in:
@@ -67,8 +67,8 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
}
|
||||
#end extra time
|
||||
puts params[:order_items]
|
||||
puts "ITEM aaaaaaaaaaaaaaaaaaa"
|
||||
puts params[:order_items]
|
||||
puts "ORDER ITEMS"
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@@ -172,9 +172,9 @@ class Api::OrdersController < Api::ApiController
|
||||
# Update customer info, Guest Info
|
||||
# Input Params
|
||||
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
def update
|
||||
# def update
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
def order_params
|
||||
params.permits(:order_source, :booking_id,:order_type,
|
||||
@@ -199,4 +199,59 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
return status
|
||||
end
|
||||
|
||||
def update
|
||||
Rails.logger.debug "Booking ID - " + params[:booking_id].to_s
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
Rails.logger.debug "Order Item ID - " + params[:order_item_id].to_s
|
||||
|
||||
order_items_id = params[:order_item_id]
|
||||
qty_weight = params[:quantity].to_f
|
||||
remarks = params[:remark]
|
||||
|
||||
order_item = OrderItem.find(order_items_id)
|
||||
before_updated_qty = order_item.qty
|
||||
|
||||
order_item.item_order_by = current_login_employee.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
|
||||
|
||||
return return_json_status_with_code(400, "updated successfully!")
|
||||
else
|
||||
return return_json_status_with_code(406, "Checkout time is over!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user