class Origami::MoveroomController < BaseOrigamiController
  
  authorize_resource :class => false
  
  def move_dining
    @tables = Table.all.active.order('status desc')
    @rooms = Room.all.active.order('status desc')
    @complete = Sale.all
    @orders = Order.all.order('date desc')

    @status_order = ""
    @dining = DiningFacility.find(params[:dining_id])
    @dining.bookings.each do |booking|
         if booking.sale_id.nil?
           @order_items = Array.new
           booking.booking_orders.each do |booking_order|
              order = Order.find(booking_order.order_id)
              @obj_order = order
              @date = order.created_at
              order.order_items.each do |item|
                @order_items.push(item)
              end
           end
           @status_order = 'order'
         else
          sale = Sale.find(booking.sale_id)
           if sale.sale_status != "completed"
             if @status_order == 'order'
               @status_order = 'sale'
             end
             @date = sale.created_at
             @status_sale = 'sale'
             @obj_sale = sale
           end
         end
    end
  end
  
end
