diff --git a/app/assets/javascripts/channels/order_reservation.js b/app/assets/javascripts/channels/order_reservation.js
new file mode 100644
index 00000000..605afe16
--- /dev/null
+++ b/app/assets/javascripts/channels/order_reservation.js
@@ -0,0 +1,38 @@
+App.checkin = App.cable.subscriptions.create('OrderReservationChannel', {
+// App.messages = App.cable.subscriptions.create('MessagesChannel', {
+
+ connected: function() {},
+
+ disconnected: function() {},
+
+ received: function(data) {
+ var order = data.data;
+ var rowCount = $('.order_reserve_cable tbody tr').length+1;
+
+ var date = new Date(order.requested_time);
+ var requested_time = date.getHours()+ ':' + date.getMinutes()+ '-' + date.getMinutes();
+
+ var isPM = date.getHours() >= 12;
+ var isMidday = date.getHours() == 12;
+ var result = document.querySelector('#result');
+ var time = [date.getHours() - (isPM && !isMidday ? 12 : 0),
+ date.getMinutes() || '00'].join(':') +
+ (isPM ? ' PM' : 'AM');
+
+ row = '
'
+ +'| '+rowCount
+ +' | '
+ +''+time
+ +' | '
+ +''+order.grand_total
+ +' | '
+ +''
+ +''+ order.status +''
+ +' | '
+ +'
'
+
+ $('.order_reserve_cable tbody').append(row);
+
+ }
+});
+
diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js
index 63760798..9b7c3fbb 100644
--- a/app/assets/javascripts/order_reservation.js
+++ b/app/assets/javascripts/order_reservation.js
@@ -62,7 +62,6 @@ $(function() {
// console.log(data);
var delivery = data["delivery"];
var items = data["order_items"];
-console.log(data)
var item_list = $('.summary-items');
item_list.empty();
@@ -158,7 +157,6 @@ console.log(data)
data: {'order_id': order_id, 'status': status},
dataType: "json",
success: function(data) {
- console.log(data);
if (data.status) {
swal({
title: 'Information',
diff --git a/app/channels/order_reservation_channel.rb b/app/channels/order_reservation_channel.rb
new file mode 100644
index 00000000..a461615e
--- /dev/null
+++ b/app/channels/order_reservation_channel.rb
@@ -0,0 +1,10 @@
+class OrderReservationChannel < ApplicationCable::Channel
+ def subscribed
+ stream_from "order_reservation_channel"
+ end
+
+ def unsubscribed
+ stop_all_streams
+ # Any cleanup needed when channel is unsubscribed
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb
index 2dfc29aa..42768d58 100644
--- a/app/controllers/api/order_reserve/order_reservation_controller.rb
+++ b/app/controllers/api/order_reserve/order_reservation_controller.rb
@@ -57,6 +57,10 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
if status == true
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(params)
+
+ order_reservation = OrderReservation.find(order_reservation_id)
+ ActionCable.server.broadcast "order_reservation_channel",data: order_reservation
+
if flag
render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
else
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 0e090073..cc3ab4bb 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -128,6 +128,9 @@ class Sale < ApplicationRecord
self.save!
#compute sales summary
+ if order_source.nil?
+ order_source = order.order_source
+ end
compute(order_source)
#Update the order items that is billed
diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb
index f693946e..15f173ce 100644
--- a/app/views/origami/order_reservation/index.html.erb
+++ b/app/views/origami/order_reservation/index.html.erb
@@ -22,7 +22,7 @@