class Oqs::EditController < BaseOqsController
  def index
  	assigned_item_id = params[:id]
    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 }'");    
  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);
    order_item.item_order_by = current_user.name
    order_item.qty = qty_weight
    order_item.remark = remarks
    order_item.save

    # print
    assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)    
    # order queue stations
    oqs = assigned_item.order_queue_station
    
    unique_code="OrderItemPdf"    

    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=" (Updated)" )
  end
end
