From 916dbf2cd37f1c04691cf542047432c5407fd684 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Mon, 14 May 2018 16:00:31 +0630 Subject: [PATCH 01/13] Pull from master --- app/assets/javascripts/addorder.js | 2 +- .../javascripts/channels/check_new_order.js | 51 ++++++++-------- .../channels/check_order_ready_to_delivery.js | 51 ++++++++-------- .../channels/check_order_send_to_kitchen.js | 51 ++++++++-------- app/assets/javascripts/order_reservation.js | 57 +++++++++--------- app/assets/stylesheets/addorder.scss | 4 ++ app/models/menu.rb | 32 ++++++---- app/views/origami/addorders/detail.html.erb | 2 +- app/views/origami/dashboard/index.html.erb | 16 ++++- app/views/origami/home/show.html.erb | 8 ++- .../origami/order_reservation/index.html.erb | 18 +++--- app/views/origami/payments/show.html.erb | 18 +++--- config/environments/development.rb | 2 +- public/AC-beep.mp3 | Bin 0 -> 63528 bytes 14 files changed, 173 insertions(+), 139 deletions(-) create mode 100644 public/AC-beep.mp3 diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 344e663b..8b9c4e01 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1373,7 +1373,7 @@ $(function() { if (JSON.stringify(menu_items[field].item_sets)!='[]') { fa_plus = ''; add = ''; - menu_item_box = 'add_icon'; + menu_item_box = 'set_add_icon'; data_target = 'sx_item_set_detailModal'; data_modal = 'modal' add_icon = "set_item_box" diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js index a6317af6..92e0e715 100644 --- a/app/assets/javascripts/channels/check_new_order.js +++ b/app/assets/javascripts/channels/check_new_order.js @@ -19,33 +19,34 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', { }); // alert(order_lists); - swal({ - title: 'Information', - target: document.getElementById(shop_code+"_notify_new_order"), - text: "You have new orders
"+ - "Are you accept or reject for these orders "+order_lists+"?", - type: 'success', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function (isConfirm) { - if(isConfirm){ - swal.close(); - } - }); - // $("#notify_new_order_lists").text(order_lists); + // swal({ + // title: 'Information', + // target: document.getElementById(shop_code+"_notify_new_order"), + // text: "You have new orders
"+ + // "Are you accept or reject for these orders "+order_lists+"?", + // type: 'success', + // html: true, + // closeOnConfirm: false, + // closeOnCancel: false, + // allowOutsideClick: false + // }, function (isConfirm) { + // if(isConfirm){ + // swal.close(); + // } + // }); + $("#notify_new_order_lists").text(order_lists); // if($("#notify_new_order").hasClass("hidden")){ - // $("#notify_new_order").removeClass("hidden"); + $("#notify_new_order").removeClass("hidden"); // } - // $("#notify_new_order").on('show.bs.modal', function(e){ - // $("#notify_order_send_to_kitchen").addClass("hidden"); - // $("#notify_order_ready_to_delivery").addClass("hidden"); - // }).on('shown.bs.modal', function(e){ - // $("#notify_new_order").focus(); - // }).on('hide.bs.modal', function (e) { - // $("#notify_new_order").addClass("hidden"); - // }).modal({show: true, keyboard: false, backdrop: false}); + $("#notify_new_order").on('shown.bs.modal', function(e){ + $(document).off('focusin.modal'); + $("#notify_new_order").focus(); + $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + $("#notify_order_send_to_kitchen").addClass("hidden"); + $("#notify_order_ready_to_delivery").addClass("hidden"); + }).on('hide.bs.modal', function (e) { + $("#notify_new_order").addClass("hidden"); + }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/channels/check_order_ready_to_delivery.js b/app/assets/javascripts/channels/check_order_ready_to_delivery.js index 319f7781..05a257b3 100644 --- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js +++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js @@ -19,33 +19,34 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe }); // alert(order_lists); - swal({ - title: 'Information', - target: document.getElementById(shop_code+"_notify_order_ready_to_delivery"), - text: "You have orders that are ready to deliver
"+ - "Could you ready these orders "+order_lists+" to deliver?", - type: 'success', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function (isConfirm) { - if(isConfirm){ - swal.close(); - } - }); - // $("#notify_order_ready_to_delivery_lists").text(order_lists); + // swal({ + // title: 'Information', + // target: document.getElementById(shop_code+"_notify_order_ready_to_delivery"), + // text: "You have orders that are ready to deliver
"+ + // "Could you ready these orders "+order_lists+" to deliver?", + // type: 'success', + // html: true, + // closeOnConfirm: false, + // closeOnCancel: false, + // allowOutsideClick: false + // }, function (isConfirm) { + // if(isConfirm){ + // swal.close(); + // } + // }); + $("#notify_order_ready_to_delivery_lists").text(order_lists); // if($("#notify_order_ready_to_delivery").hasClass("hidden")){ - // $("#notify_order_ready_to_delivery").removeClass("hidden"); + $("#notify_order_ready_to_delivery").removeClass("hidden"); // } - // $("#notify_order_ready_to_delivery").on('shown.bs.modal', function(e){ - // $("#notify_new_order").addClass("hidden"); - // $("#notify_order_send_to_kitchen").addClass("hidden"); - // }).on('shown.bs.modal', function(e){ - // $("#notify_order_ready_to_delivery").focus(); - // }).on('hide.bs.modal', function (e) { - // $("#notify_order_ready_to_delivery").addClass("hidden"); - // }).modal({show: true, keyboard: false, backdrop: false}); + $("#notify_order_ready_to_delivery").on('shown.bs.modal', function(e){ + // $(document).off('focusin.modal'); + $("#notify_order_ready_to_delivery").focus(); + $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + $("#notify_new_order").addClass("hidden"); + $("#notify_order_send_to_kitchen").addClass("hidden"); + }).on('hide.bs.modal', function (e) { + $("#notify_order_ready_to_delivery").addClass("hidden"); + }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/channels/check_order_send_to_kitchen.js b/app/assets/javascripts/channels/check_order_send_to_kitchen.js index df9eb324..f9432810 100644 --- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js +++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js @@ -19,33 +19,34 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend }); // alert(order_lists); - swal({ - title: 'Information', - target: document.getElementById(shop_code+"_notify_order_send_to_kitchen"), - text: "You have to send order to kitchen
"+ - "Could you send these orders "+order_lists+" to kitchen?", - type: 'success', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function (isConfirm) { - if(isConfirm){ - swal.close(); - } - }); - // $("#notify_order_send_to_kitchen_lists").text(order_lists); + // swal({ + // title: 'Information', + // target: document.getElementById(shop_code+"_notify_order_send_to_kitchen"), + // text: "You have to send order to kitchen
"+ + // "Could you send these orders "+order_lists+" to kitchen?", + // type: 'success', + // html: true, + // closeOnConfirm: false, + // closeOnCancel: false, + // allowOutsideClick: false + // }, function (isConfirm) { + // if(isConfirm){ + // swal.close(); + // } + // }); + $("#notify_order_send_to_kitchen_lists").text(order_lists); // if($("#notify_order_send_to_kitchen").hasClass("hidden")){ - // $("#notify_order_send_to_kitchen").removeClass("hidden"); + $("#notify_order_send_to_kitchen").removeClass("hidden"); // } - // $("#notify_order_send_to_kitchen").on('show.bs.modal', function(e){ - // $("#notify_new_order").addClass("hidden"); - // $("#notify_order_ready_to_delivery").addClass("hidden"); - // }).on('shown.bs.modal', function(e){ - // $("#notify_order_send_to_kitchen").focus(); - // }).on('hide.bs.modal', function (e) { - // $("#notify_order_send_to_kitchen").addClass("hidden"); - // }).modal({show: true, keyboard: false, backdrop: false}); + $("#notify_order_send_to_kitchen").on('shown.bs.modal', function(e){ + // $(document).off('focusin.modal'); + $("#notify_order_send_to_kitchen").focus(); + $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + $("#notify_new_order").addClass("hidden"); + $("#notify_order_ready_to_delivery").addClass("hidden"); + }).on('hide.bs.modal', function (e) { + $("#notify_order_send_to_kitchen").addClass("hidden"); + }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index 83618770..d674926a 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -157,6 +157,7 @@ $(function() { } }); + // $('button[data-dismiss="modal"]').on('click', function(){ $(this).parent().parent().parent().parent().modal('hide'); }); // $(".new_order_close").on("click",function(){ @@ -473,36 +474,36 @@ function showNewOrder(order_reservation,shop_code){ audio.play(); // },10000); - // $("#new_order").text(order_reservation.order_reservation_id); - // $("#new_order_date").text(requested_date); + $("#new_order").text(order_reservation.order_reservation_id); + $("#new_order_date").text(requested_date); // if($("#"+shop_code+"_doemal_new_order").hasClass("hidden")){ - // $("#"+shop_code+"_doemal_new_order").removeClass("hidden"); + $("#"+shop_code+"_doemal_new_order").removeClass("hidden"); // } - // $("#"+shop_code+"_doemal_new_order").on('show.bs.modal', function(e){ - // $("#notify_new_order").addClass("hidden"); - // $("#notify_order_send_to_kitchen").addClass("hidden"); - // $("#notify_order_ready_to_delivery").addClass("hidden"); - // }).on('shown.bs.modal', function(e){ - // $("#"+shop_code+"_doemal_new_order").focus(); - // }).on('hide.bs.modal', function (e) { - // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); - // }).modal({show: true, keyboard: false, backdrop: false}); - swal({ - title: 'Information', - target: document.getElementById(shop_code+"_notify_new_order"), - text: "You have new order "+ - ""+order_reservation.order_reservation_id+" requested for "+requested_date+"?", - type: 'success', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function (isConfirm) { - if(isConfirm){ - audio.pause(); - swal.close(); - } - }); + $("#"+shop_code+"_doemal_new_order").on('shown.bs.modal', function(e){ + // $(document).off('focusin.modal'); + $("#"+shop_code+"_doemal_new_order").focus(); + $("#notify_new_order").addClass("hidden"); + $("#notify_order_send_to_kitchen").addClass("hidden"); + $("#notify_order_ready_to_delivery").addClass("hidden"); + }).on('hide.bs.modal', function (e) { + $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + }).modal({show: true, keyboard: false, backdrop: false}); + // swal({ + // title: 'Information', + // target: document.getElementById(shop_code+"_notify_new_order"), + // text: "You have new order "+ + // ""+order_reservation.order_reservation_id+" requested for "+requested_date+"?", + // type: 'success', + // html: true, + // closeOnConfirm: false, + // closeOnCancel: false, + // allowOutsideClick: false + // }, function (isConfirm) { + // if(isConfirm){ + // audio.pause(); + // swal.close(); + // } + // }); } } diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index ba1089d2..d9b62131 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -270,4 +270,8 @@ i.logout_icon{ .border-left{ border-left:1px solid #fff; +} + +.set_add_icon{ + display:none; } \ No newline at end of file diff --git a/app/models/menu.rb b/app/models/menu.rb index 60200aeb..a9b88a85 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -155,24 +155,28 @@ class Menu < ApplicationRecord # Menu Item Attributes item_attrs = [] - attributes = row["Attributes"].split(',') - attributes.each do |attr| - attribute = MenuItemAttribute.find_by_name(attr) - if attribute.nil? - attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase }) + if !row["Attributes"].nil? + attributes = row["Attributes"].split(',') + attributes.each do |attr| + attribute = MenuItemAttribute.find_by_name(attr) + if attribute.nil? + attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase }) + end + item_attrs.push(attribute.id) end - item_attrs.push(attribute.id) end # Menu Item Options item_opts = [] + if !row["Options"].nil? options = row["Options"].split(',') - options.each do |opt| - option = MenuItemOption.find_by_name(opt) - if option.nil? - option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase }) + options.each do |opt| + option = MenuItemOption.find_by_name(opt) + if option.nil? + option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase }) + end + item_opts.push(option.id) end - item_opts.push(option.id) end menu_itm = MenuItem.find_by_item_code(row["Item Code"]) @@ -189,7 +193,11 @@ class Menu < ApplicationRecord menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"]) if !menu_inst - imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"]) + instance_name = '' + if !row["Instance Name"].nil? + instance_name = row["Instance Name"] + end + imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: instance_name, item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"]) # else # status = status + "Instance Code already exists for " + row["Instance Name"] + "." end diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 391ba83b..65ea665b 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -17,7 +17,7 @@ <%if @menu.present? %> - <%=menu[0].name%> + <%=@menus[0].name%> <% end%> diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb index 4712a481..a0b0dc51 100644 --- a/app/views/origami/dashboard/index.html.erb +++ b/app/views/origami/dashboard/index.html.erb @@ -1,4 +1,7 @@
+

<%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %>

@@ -208,23 +211,32 @@ " id="server_mode"> \ No newline at end of file From 0d2f609b070f98719d816babe791798459a60dae Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 18 May 2018 14:38:31 +0630 Subject: [PATCH 03/13] 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 04/13] 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 05/13] 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 06/13] 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 07/13] 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 610d39847e71702062242913df85490c66be2ddf Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Fri, 18 May 2018 16:23:14 +0630 Subject: [PATCH 08/13] Add Approved By for waste & Spolie in Receive --- app/pdf/receipt_bill_pdf.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 5c1f8c01..7dc29463 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -532,7 +532,7 @@ class ReceiptBillPdf < Prawn::Document break; end end - if sale_data.payment_status == "foc" + if sale_data.payment_status == "foc" || sale_data.payment_status == "waste" || sale_data.payment_status == "spoile" y_position = cursor stroke_horizontal_rule @@ -540,12 +540,19 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 70 stroke_horizontal_rule - end + end - bounding_box([self.label_width,y_position], :width =>self.item_description_width) do - move_down 73 - text "Acknowledged By" , :size => self.item_font_size,:align => :center - end + if sale_data.payment_status == "foc" + bounding_box([self.label_width,y_position], :width =>self.item_description_width) do + move_down 73 + text "Acknowledged By" , :size => self.item_font_size,:align => :center + end + elsif sale_data.payment_status == "waste" || sale_data.payment_status == "spoile" + bounding_box([self.label_width,y_position], :width =>self.item_description_width) do + move_down 73 + text "Approved By" , :size => self.item_font_size,:align => :center + end + end end end From c1525be8260a397b08899fe14fcfc6757885901b Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Fri, 18 May 2018 16:26:03 +0630 Subject: [PATCH 09/13] Pull from master --- app/assets/javascripts/addorder.js | 12 +++++----- app/assets/javascripts/cable.js | 2 +- app/assets/javascripts/channels/bill.js | 22 +++++++++++-------- app/assets/javascripts/channels/order.js | 2 -- app/channels/application_cable/connection.rb | 20 +++++++++++++++++ app/channels/order_channel.rb | 2 +- .../origami/request_bills_controller.rb | 11 ++++++---- app/models/menu_category.rb | 2 +- app/models/menu_item.rb | 2 +- app/models/order.rb | 4 ++-- app/models/order_queue_station.rb | 1 + config/initializers/action_controller.rb | 10 ++++----- 12 files changed, 58 insertions(+), 32 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/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 55bfd46b..1668e17f 100755 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -8,7 +8,7 @@ // Temp Disable (function() { this.App || (this.App = {}); - + App.cable = ActionCable.createConsumer(); }).call(this); diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 97666e32..7fa2b77e 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -6,15 +6,19 @@ 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.trim(); + 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/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/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 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) 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) 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 d7992cd4b81edea74de5b19687769e5694725f6a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 18 May 2018 16:57:34 +0630 Subject: [PATCH 10/13] 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}" From e1bb01c029a527493933bb51ba9844ca73dd8a10 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 18 May 2018 18:01:44 +0630 Subject: [PATCH 11/13] change dashboard query and report --- .../javascripts/channels/check_new_order.js | 4 +- .../channels/check_order_ready_to_delivery.js | 4 +- .../channels/check_order_send_to_kitchen.js | 4 +- app/models/order_reservation.rb | 2 +- app/models/sale.rb | 160 +++++++++--------- app/views/home/dashboard.html.erb | 16 +- 6 files changed, 98 insertions(+), 92 deletions(-) diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js index ced5b3c2..f4d4aa9f 100644 --- a/app/assets/javascripts/channels/check_new_order.js +++ b/app/assets/javascripts/channels/check_new_order.js @@ -19,7 +19,9 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', { }); // alert(order_lists); - checkNewOrderAlert(shop_code, order_lists); + if (typeof checkNewOrderAlert !== 'undefined' && $.isFunction(checkNewOrderAlert)) { + checkNewOrderAlert(shop_code, order_lists); + } // $("#notify_new_order_lists").text(order_lists); // if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){ // $("#"+shop_code+"_notify_new_order").removeClass("hidden"); diff --git a/app/assets/javascripts/channels/check_order_ready_to_delivery.js b/app/assets/javascripts/channels/check_order_ready_to_delivery.js index 4ec3ea08..3f7f53b1 100644 --- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js +++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js @@ -19,7 +19,9 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe }); // alert(order_lists); - checkOrderReadyToKitchenAlert(shop_code, order_lists); + if (typeof checkOrderReadyToKitchenAlert !== 'undefined' && $.isFunction(checkOrderReadyToKitchenAlert)) { + checkOrderReadyToKitchenAlert(shop_code, order_lists); + } // $("#notify_order_ready_to_delivery_lists").text(order_lists); // if($("#notify_order_ready_to_delivery").hasClass("hidden")){ // $("#"+shop_code+"_notify_order_ready_to_delivery").removeClass("hidden"); diff --git a/app/assets/javascripts/channels/check_order_send_to_kitchen.js b/app/assets/javascripts/channels/check_order_send_to_kitchen.js index 5e8751b1..892e0590 100644 --- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js +++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js @@ -19,7 +19,9 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend }); // alert(order_lists); - checkOrderSendToKitchen(shop_code, order_lists); + if (typeof checkOrderSendToKitchen !== 'undefined' && $.isFunction(checkOrderSendToKitchen)) { + checkOrderSendToKitchen(shop_code, order_lists); + } // $("#notify_order_send_to_kitchen_lists").text(order_lists); // if($("#notify_order_send_to_kitchen").hasClass("hidden")){ // $("#"+shop_code+"_notify_order_send_to_kitchen").removeClass("hidden"); diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 057f6f9b..0b4ccc77 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -53,7 +53,7 @@ class OrderReservation < ApplicationRecord order_reservation = OrderReservation.new order_reservation.order_reservation_type = order_reserve[:order_type] order_reservation.customer_id = order_reserve[:cus_info] - order_reservation.requested_time = Time.parse(order_reserve[:requested_time]).utc + order_reservation.requested_time = Time.zone.parse(order_reserve[:requested_time]).utc order_reservation.callback_url = order_reserve[:callback_url] order_reservation.transaction_ref = order_reserve[:reference] if order_reserve[:order_info] diff --git a/app/models/sale.rb b/app/models/sale.rb index 6803e8f2..1441c759 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1295,7 +1295,7 @@ end query = query.group('mi.name') .order("SUM(i.qty) DESC").limit(20) else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," + " i.price as unit_price,mi.name as product_name") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") @@ -1336,7 +1336,7 @@ end .group('mi.name') .order("SUM(i.qty) DESC").limit(20) else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," + " i.price as unit_price,mi.name as product_name") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") @@ -1376,7 +1376,7 @@ end query = query.group('mi.name') .order("SUM(i.qty) ASC").limit(20) else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," + " i.price as unit_price,mi.name as product_name") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") @@ -1417,7 +1417,7 @@ end .group('mi.name') .order("SUM(i.qty) ASC").limit(20) else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," + " i.price as unit_price,mi.name as product_name") .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") @@ -1453,7 +1453,7 @@ end query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") .order('receipt_date') else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("grand_total") if !from_time.nil? && !to_time.nil? query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) @@ -1471,7 +1471,7 @@ end else query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id) end - query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") + query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") .order('receipt_date') end end @@ -1480,20 +1480,20 @@ end if current_user.nil? query = Sale.select("grand_total") .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) - .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") + .group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") .order('receipt_date') else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("grand_total") .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) - .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") + .group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") .order('receipt_date') else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("grand_total") .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id) - .group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')") + .group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')") .order('receipt_date') end end @@ -1514,7 +1514,7 @@ end query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") if !from_time.nil? && !to_time.nil? @@ -1547,7 +1547,7 @@ end .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") .where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'") @@ -1576,7 +1576,7 @@ end total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to).sum("grand_total") end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).sum("grand_total") else @@ -1597,14 +1597,14 @@ end end else if current_user.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today).sum("grand_total") else - if current_user.role == 'administrator' || current_user.role == 'manager' - total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today).sum("grand_total") else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id) + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',today,today,shift.id) .sum("grand_total") end end @@ -1621,7 +1621,7 @@ end total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',from,to).count end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).count else @@ -1640,14 +1640,14 @@ end end else if current_user.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',today,today).count else - if current_user.role == 'administrator' || current_user.role == 'manager' - total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',today,today).count else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id = ?',today,shift.id).count + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id = ?',today,today,shift.id).count end end end @@ -1667,7 +1667,7 @@ end .sum("sp.payment_amount") end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") @@ -1694,18 +1694,18 @@ end end else if current_user.nil? - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - if current_user.role == 'administrator' || current_user.role == 'manager' - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',today,shift.id) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',today,today,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") end @@ -1727,7 +1727,7 @@ end .sum("payment_amount") end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") @@ -1754,18 +1754,18 @@ end end else if current_user.nil? - query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today) + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else - if current_user.role == 'administrator' || current_user.role == 'manager' - query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today) + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? - query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ? and s.shift_sale_id=?',today,shift.id) + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and s.shift_sale_id=?',today,today,shift.id) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") end @@ -1787,7 +1787,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) @@ -1815,18 +1815,18 @@ end else if current_user.nil? query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') - .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) + .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') - .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) + .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) .first() else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') - .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id) + .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and shift_sale_id=?',today,shift.id) .first() end end @@ -1847,7 +1847,7 @@ end .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.select("distinct sp.payment_method") .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) @@ -1875,18 +1875,18 @@ end else if current_user.nil? query = Sale.select("distinct sp.payment_method") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("distinct sp.payment_method") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("distinct sp.payment_method") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") end end @@ -1919,7 +1919,7 @@ end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") if payment_method == 'card' @@ -1970,7 +1970,7 @@ end end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") if payment_method == 'card' query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) @@ -2022,7 +2022,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") @@ -2055,20 +2055,20 @@ end if current_user.nil? query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) .first() else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id) .first() end end @@ -2091,7 +2091,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") @@ -2124,20 +2124,20 @@ end if current_user.nil? query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) .first() else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',today,shift.id) .first() end end @@ -2160,7 +2160,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' if !from_time.nil? && !to_time.nil? query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") @@ -2189,20 +2189,20 @@ end if current_user.nil? query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) .first() else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null)) and sales.shift_sale_id=?',today,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null)) and sales.shift_sale_id=?',today,shift.id) .first() end end @@ -2223,7 +2223,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") if !from_time.nil? && !to_time.nil? @@ -2252,20 +2252,20 @@ end if current_user.nil? query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .first() else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',today,shift.id) .first() end end @@ -2287,7 +2287,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") @@ -2319,14 +2319,14 @@ end query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") - .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) + .where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") - .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) + .where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) .first() else shift = ShiftSale.current_open_shift(current_user.id) @@ -2334,7 +2334,7 @@ end query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") - .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id) + .where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id) .first() end end @@ -2354,7 +2354,7 @@ end query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") @@ -2382,20 +2382,20 @@ end query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today) else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") - .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id) end end end @@ -2415,7 +2415,7 @@ end .first() end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? @@ -2447,7 +2447,7 @@ end .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) @@ -2479,7 +2479,7 @@ end .order("SUM(a.qty) DESC") .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? @@ -2515,7 +2515,7 @@ end .order("SUM(a.qty) DESC") .first() else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) @@ -2549,7 +2549,7 @@ end .sum("a.qty") end else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) @@ -2578,7 +2578,7 @@ end .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .sum("a.qty") else - if current_user.role == 'administrator' || current_user.role == 'manager' + if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .sum("a.qty") diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 865202b0..6131e656 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -119,7 +119,7 @@
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
@@ -176,9 +176,9 @@
<% end %> - <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'cashier' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'cashier' %> <% if !@summ_sale.nil? %> - <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
@@ -249,12 +249,12 @@
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %> <% end %> - <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% else %> @@ -298,11 +298,11 @@
<% end %>
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %> - <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% else %> @@ -349,7 +349,7 @@
- <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + <% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% end %> <% end %> From e0a1c6c0e71bcc224d1cc1cb6dd15647d9968587 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 18 May 2018 18:15:42 +0630 Subject: [PATCH 12/13] order reservation --- app/assets/javascripts/order_reservation.js | 27 +++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index fb210f6b..1a1e6e64 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -308,13 +308,26 @@ function show_order_detail(url,sr_no){ item_price = items[i].unit_price; } var total = items[i].qty * item_price; + if(items[i].options!='[]'){ + row = '' + +''+items[i].item_name + +'
' + +' '+items[i].options+'
'+ + ''+items[i].qty+ ' X'+items[i].unit_price+'' + +'' + +''+ total +'' + +''; + }else{ row = '' - +''+items[i].item_name - +'
'+items[i].qty+ ' X'+items[i].unit_price+'' - +'' - +''+ total +'' - +''; - $('.summary-items').append(row); + +''+items[i].item_name + +'
'+ + ''+items[i].qty+ ' X'+items[i].unit_price+'' + +'' + +''+ total +'' + +''; + } + + $('.summary-items').append(row); } if(data.discount_amount > 0){ @@ -565,5 +578,5 @@ function getOrderMonth(month){ function getOrderDay(day){ var DAYS = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; - return DAYS[day]; + return DAYS[day - 1]; } \ No newline at end of file From dbfebde010f7ec7b5d2c399618e5079c0f406950 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 18 May 2018 18:16:54 +0630 Subject: [PATCH 13/13] action controller --- config/initializers/action_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index b84bca54..e0eb7455 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