From 7485486868c49bb0c760400f45b5cd6700ff250c Mon Sep 17 00:00:00 2001 From: pyaephyoeaung Date: Fri, 3 Jun 2022 10:11:18 +0630 Subject: [PATCH] fix order update with table and room --- app/controllers/foodcourt/orders_controller.rb | 6 ++++++ app/views/foodcourt/orders/app_orders.html.erb | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 829c435a..b1d41a06 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -95,6 +95,10 @@ class Foodcourt::OrdersController < BaseFoodcourtController end def modify_order + @zone = Zone.all + @tables = Table.active.order('status desc') + @rooms = Room.active.order('status desc') + @cashier_type = "food_court" today = DateTime.now day = Date.today.wday @@ -112,6 +116,8 @@ class Foodcourt::OrdersController < BaseFoodcourtController @booking = @table.get_booking end + # byebug + @sale_id = @booking.sale_id if @booking diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb index c8e4763c..6333e39e 100644 --- a/app/views/foodcourt/orders/app_orders.html.erb +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -533,8 +533,8 @@ $('#addorder').on('click', function () { var status = "<%= @status %>" if (status == 'sale'){ - var table_id = "<%= @pending.try(:bookings).try(:first).try(:dining_facility).try(:id) %>" - var booking_id = "<%= @pending.try(:bookings).try(:first).try(:id) %>" + var table_id = "<%= @pending.try(:booking).try(:dining_facility).try(:id) %>" + var booking_id = "<%= @pending.try(:booking).try(:id) %>" } else { var table_id = "<%= @pending.try(:dining_facility).try(:id) %>"; @@ -543,11 +543,11 @@ } var sale_id = $("#sale_id").text(); - if (table_id) { - window.location.href = '/foodcourt/food_court/modify_order/' + table_id + "/"+ sale_id + '?update=true'; - }else{ - window.location.href = '/foodcourt/food_court/modify_order/' + booking_id + "/" + sale_id + '?update=true&order_id="'+order_id+'"' - } + // if (table_id) { + window.location.href = '/foodcourt/food_court/modify_order/' + booking_id + "/"+ sale_id + '?update=true'; + // }else{ + // window.location.href = '/foodcourt/food_court/modify_order/' + booking_id + "/" + sale_id + '?update=true&order_id="'+order_id+'"' + // } });