From 1e38ebcd51a5c704a9d6672eb176d963f421a243 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 11:15:25 +0630 Subject: [PATCH 1/9] update cable --- app/assets/javascripts/cable.js | 6 ++++++ app/assets/javascripts/channels/order.js | 2 -- app/channels/application_cable/connection.rb | 20 ++++++++++++++++++++ config/initializers/action_controller.rb | 10 +++++----- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 55bfd46b..033f521b 100755 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -9,6 +9,12 @@ (function() { this.App || (this.App = {}); + // var hostname = location.hostname; + // var port = location.port; + // var host = hostname + ":" + port + "/cable" + // console.log(host); + // App.cable = ActionCable.createConsumer(); + // console.log(App.cable); App.cable = ActionCable.createConsumer(); }).call(this); diff --git a/app/assets/javascripts/channels/order.js b/app/assets/javascripts/channels/order.js index 9598ed6f..26c7897e 100755 --- a/app/assets/javascripts/channels/order.js +++ b/app/assets/javascripts/channels/order.js @@ -1,6 +1,4 @@ App.order = App.cable.subscriptions.create('OrderChannel', { -// App.messages = App.cable.subscriptions.create('MessagesChannel', { - connected: function() {}, disconnected: function() {}, diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 4efdb70d..14561a4e 100755 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,7 +1,27 @@ module ApplicationCable class Connection < ActionCable::Connection::Base + identified_by :current_subdomain def connect + if ENV["server_mode"] == "cloud" + self.current_subdomain = verified_subdomain + end logger.add_tags "SX-ActionCable" end + + private + def verified_subdomain + from = request.subdomain.downcase + "." + request.domain.downcase + file_path = "config/shops.json" + shop_data = File.read(file_path) + + shop_json = JSON.parse(shop_data) + shop_json["data"].each do |j| + if j["lookup"] == from + verified_subdomain = from + else + reject_unauthorized_connection + end + end + end end end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index e0eb7455..b84bca54 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class ActionController::Base end else #check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end From 9c26e63110494e1b8a8418f3e1b9ba6c06e26b35 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 18 May 2018 11:57:20 +0630 Subject: [PATCH 2/9] update menu asc with name --- app/assets/javascripts/addorder.js | 12 ++++++------ app/models/menu_category.rb | 2 +- app/models/menu_item.rb | 2 +- app/models/order.rb | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 8b9c4e01..611ffb17 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -58,8 +58,8 @@ $(function() { row = '
' +'
' - +'
'+ product[field].name +'
' - +"' + +"' +'
' @@ -1430,8 +1430,8 @@ $(function() { row = '
' +'
' - +'
'+ menu_items[field].name +'
' - +"
'+ menu_items[field].name +'
' + +"
" - +"" + +"" +add+ '' +'
' +'
' diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 218bacb8..21d95770 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -9,7 +9,7 @@ class MenuCategory < ApplicationRecord validates_presence_of :code, :name, :menu, :order_by validates_uniqueness_of :code - default_scope { order('order_by asc') } + default_scope { order('name asc') } scope :active, -> {where("is_available = 1")} def self.destroyCategory(menu_category) diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 03e90011..e184cd51 100755 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -16,7 +16,7 @@ class MenuItem < ApplicationRecord validates_presence_of :item_code, :name, :type, :min_qty,:account_id validates_uniqueness_of :item_code - default_scope { order('item_code asc') } + default_scope { order('name asc') } scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') } scope :set_menu_item, -> { where(type: 'SetMenuItem') } diff --git a/app/models/order.rb b/app/models/order.rb index 66ac883f..8a0e52b3 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -71,9 +71,9 @@ class Order < ApplicationRecord BookingOrder.create({:booking_id => booking.booking_id, :order => self}) #Send order to queue one it done! - # if self.source != "quick_service" + if self.source != "quick_service" process_order_queue - # end + end #send order to broadcast job send_order_broadcast(booking) From 0b7834ff29582558291876ab0d24b2dea7305376 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 18 May 2018 12:25:47 +0630 Subject: [PATCH 3/9] update pay process order --- app/models/order_queue_station.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 1541828c..70b28c1f 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -116,6 +116,7 @@ class OrderQueueStation < ApplicationRecord order = Order.find(order_id) order_items = order.order_items + Order.pay_process_order_queue(order_id,table_id) if table_id.to_i > 0 # get dining dining = DiningFacility.find(table_id) From 0d2f609b070f98719d816babe791798459a60dae Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 14:38:31 +0630 Subject: [PATCH 4/9] ac test --- app/assets/javascripts/cable.js | 8 +------ app/assets/javascripts/channels/bill.js | 23 +++++++++++-------- app/channels/order_channel.rb | 2 +- .../origami/request_bills_controller.rb | 11 +++++---- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 033f521b..1668e17f 100755 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -8,13 +8,7 @@ // Temp Disable (function() { this.App || (this.App = {}); - - // var hostname = location.hostname; - // var port = location.port; - // var host = hostname + ":" + port + "/cable" - // console.log(host); - // App.cable = ActionCable.createConsumer(); - // console.log(App.cable); + App.cable = ActionCable.createConsumer(); }).call(this); diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 97666e32..b6915b53 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -6,15 +6,20 @@ App.order = App.cable.subscriptions.create('BillChannel', { disconnected: function() {}, received: function(data) { - if($('.table_'+data.table.id).hasClass('blue')){ - $('.table_'+data.table.id).removeClass('blue'); - $('.table_'+data.table.id).addClass('red'); - }else{ - $('.table_'+data.table.id).removeClass('orange'); - $('.table_'+data.table.id).addClass('red'); - } - $('.new_text_'+data.table.id).removeClass('hide'); - $('.new_text_'+data.table.id).text('billed'); + var hostname = location.hostname; + console.log(hostname + "\n" + data.from); + if(data.from == "" || hostname == data.from) + { + if($('.table_'+data.table.id).hasClass('blue')){ + $('.table_'+data.table.id).removeClass('blue'); + $('.table_'+data.table.id).addClass('red'); + }else{ + $('.table_'+data.table.id).removeClass('orange'); + $('.table_'+data.table.id).addClass('red'); + } + $('.new_text_'+data.table.id).removeClass('hide'); + $('.new_text_'+data.table.id).text('billed'); + } } }); diff --git a/app/channels/order_channel.rb b/app/channels/order_channel.rb index d261e48b..6f899707 100755 --- a/app/channels/order_channel.rb +++ b/app/channels/order_channel.rb @@ -1,5 +1,5 @@ class OrderChannel < ApplicationCable::Channel - def subscribed + def subscribed stream_from "order_channel" end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 0c50a5da..3d2c90aa 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -38,10 +38,13 @@ class Origami::RequestBillsController < ApplicationController # Promotion Activation Promotion.promo_activate(@sale) - #bill channel - #if ENV["SERVER_MODE"] != 'cloud' - ActionCable.server.broadcast "bill_channel",table: table - #end + #bill channel + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + ActionCable.server.broadcast "bill_channel",table: table, from: from if order.source == "quick_service" result = {:status=> @status, :data => @sale.sale_id } render :json => result.to_json From ba1ad69181c1415c835e335292d6be8161a4a647 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 14:58:51 +0630 Subject: [PATCH 5/9] acable test --- app/assets/javascripts/channels/bill.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index b6915b53..ad500d4a 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -6,8 +6,8 @@ App.order = App.cable.subscriptions.create('BillChannel', { disconnected: function() {}, received: function(data) { - var hostname = location.hostname; - console.log(hostname + "\n" + data.from); + var hostname = location.hostname.strip; + console.log(hostname==data.from); if(data.from == "" || hostname == data.from) { if($('.table_'+data.table.id).hasClass('blue')){ From 881593ce2cda12c1363c9f28d04a4390ac549749 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 15:12:58 +0630 Subject: [PATCH 6/9] acable test --- app/assets/javascripts/channels/bill.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index ad500d4a..174f14aa 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -7,6 +7,7 @@ App.order = App.cable.subscriptions.create('BillChannel', { received: function(data) { var hostname = location.hostname.strip; + console.log(hostname + data.from); console.log(hostname==data.from); if(data.from == "" || hostname == data.from) { From 0e4d3211422a5f5e7f7432a6e375f544fa39f85a Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 15:32:29 +0630 Subject: [PATCH 7/9] actioncable test --- app/assets/javascripts/channels/bill.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 174f14aa..6cf35810 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -6,9 +6,9 @@ App.order = App.cable.subscriptions.create('BillChannel', { disconnected: function() {}, received: function(data) { - var hostname = location.hostname.strip; + var hostname = location.hostname.trim(); console.log(hostname + data.from); - console.log(hostname==data.from); + console.log(hostname==data.from.trim()); if(data.from == "" || hostname == data.from) { if($('.table_'+data.table.id).hasClass('blue')){ From 5e4b727d527da678cce5f0371a307c9163c28241 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 16:00:45 +0630 Subject: [PATCH 8/9] remove console.log --- app/assets/javascripts/channels/bill.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 6cf35810..7fa2b77e 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -7,8 +7,6 @@ App.order = App.cable.subscriptions.create('BillChannel', { received: function(data) { var hostname = location.hostname.trim(); - console.log(hostname + data.from); - console.log(hostname==data.from.trim()); if(data.from == "" || hostname == data.from) { if($('.table_'+data.table.id).hasClass('blue')){ From d7992cd4b81edea74de5b19687769e5694725f6a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 18 May 2018 16:57:34 +0630 Subject: [PATCH 9/9] update access code for void foc and edit --- app/controllers/origami/sale_edit_controller.rb | 8 ++++---- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/waste_spoile_controller.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 0f27567a..b9b2c5d4 100755 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -52,7 +52,7 @@ class Origami::SaleEditController < BaseOrigamiController end # FOr Sale Audit action_by = current_user.name - if access_code != "null" + if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}" @@ -88,7 +88,7 @@ class Origami::SaleEditController < BaseOrigamiController order = Order.find(order_id) action_by = current_user.name - if access_code != "null" + if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}" @@ -132,7 +132,7 @@ class Origami::SaleEditController < BaseOrigamiController saleitemObj.taxable_price = update_qty.to_f * update_price.to_f action_by = current_user.name - if access_code != "null" + if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end remark = "Update Qty #{update_qty} Price [#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}" @@ -185,7 +185,7 @@ class Origami::SaleEditController < BaseOrigamiController order = Order.find(order_id) action_by = current_user.name - if access_code != "null" + if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}" diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 45676492..891cd398 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -73,7 +73,7 @@ class Origami::VoidController < BaseOrigamiController # FOr Sale Audit action_by = current_user.name - if access_code != "null" + if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 9cfde698..d008a54d 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -55,7 +55,7 @@ class Origami::WasteSpoileController < BaseOrigamiController # FOr Sale Audit action_by = current_user.name - if access_code != "null" + if access_code != "null" && current_user.role == "cashier" action_by = Employee.find_by_emp_id(access_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"