From 8fed8d701a15a302ae60721c653914791eca407f Mon Sep 17 00:00:00 2001 From: phyusin Date: Mon, 5 Feb 2018 11:05:58 +0630 Subject: [PATCH] add booking --- app/controllers/origami/split_bill_controller.rb | 13 +++++++++---- app/views/origami/split_bill/index.html.erb | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 59cdae1e..e9698da6 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -49,10 +49,15 @@ class Origami::SplitBillController < BaseOrigamiController end end else - puts "new booking" - puts "new order" - puts "update order_id in order" - puts "do process" + if params[:type] == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_at => Time.now.utc, :checkin_by => current_user.name, + :booking_status => "assign" }) end # Bind shift sale id to sale diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index c96e2674..e776dacf 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -15,6 +15,7 @@
+

Order No: <%=@order.order_id rescue ' '%>

@@ -167,6 +168,8 @@ /* function for split bill process */ function splitBillProcess(cnt_items){ + var dining_id = $("#table_id").text(); + var type = $("#table_type").text(); var order_items = get_selected_order_items();// Selected Order Items var json_booking = JSON.parse('<%= @booking.to_json.html_safe %>'); var booking_id = ""; @@ -179,7 +182,7 @@ function splitBillProcess(cnt_items){ type: "POST", url: ajax_url, dataType: 'JSON', - data: {'booking_id' : booking_id, 'order_items' : JSON.stringify(order_items)}, + data: {'dining_id' : dining_id, 'type': type, 'booking_id' : booking_id, 'order_items' : JSON.stringify(order_items)}, success: function (result) { if (!result.status) { swal("Information!", result.error_message);