From 59520bf7ecf419f491d1d6a5c168c6cf14b14554 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 14:35:59 +0630 Subject: [PATCH] table status update --- app/models/sale_payment.rb | 13 ++++++++++--- app/views/origami/payments/show.html.erb | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5dff91b9..5804f602 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -215,14 +215,21 @@ class SalePayment < ApplicationRecord self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! - table_update_status() + table_update_status(sObj) rebat() end end - def table_update_status - + def table_update_status(sale_obj) + booking = Booking.find_by_sale_id(sale_obj.id) + if booking + table = DiningFacility.find(booking.dining_facility_id) + if table + table.status = "available" + table.save + end + end end def rebat diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 7eb890f4..4cff678d 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -233,7 +233,7 @@ $( document ).ready(function() { data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ alert("Thank you") - // window.location.href = '/origami'; + window.location.href = '/origami'; } }); }