From 4899e624efd2237bb7d8d63f58e13bcea00e593a Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 17 Nov 2017 09:56:40 +0630 Subject: [PATCH 1/5] change dashboard ui --- app/controllers/home_controller.rb | 2 +- app/models/sale.rb | 2 +- app/views/home/dashboard.html.erb | 74 ++++++++++++------------------ 3 files changed, 32 insertions(+), 46 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 74cc9ba9..d8592664 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -91,7 +91,7 @@ class HomeController < ApplicationController end end @summ_sale = Sale.summary_sale_receipt(today) - + p @summ_sale @total_customer = Sale.total_customer(today) @total_dinein = Sale.total_dinein(today) @total_takeaway = Sale.total_takeaway(today) diff --git a/app/models/sale.rb b/app/models/sale.rb index 696e0598..ef00fb6a 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -954,7 +954,7 @@ end end def self.summary_sale_receipt(today) - query = Sale.select('count(sale_id) as total_receipt, sum(total_amount) as total_amount, sum(grand_total) as grand_total, sum(total_discount) as total_discount, sum(total_tax) as total_tax') + 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) .first() end diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index fa0c9c72..2de6f67d 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -103,9 +103,9 @@
+ <% if !@summ_sale.nil? %>
- <% if !@summ_sale.nil? %>
Sale
@@ -157,9 +157,9 @@
- <% end %>
+ <% end %>
@@ -168,44 +168,34 @@
Customer
<% if !@total_customer.nil? %> - <% if @total_customer.total_cus > 0 %> - - - - - <% end %> + + + + <% end %> <% if !@total_dinein.nil? %> - <% if @total_dinein.total_dinein_cus > 0 %> - - - - - <% end %> + + + + <% end %> <% if !@total_takeaway.nil? %> - <% if @total_takeaway.total_take_cus > 0 %> - - - - - <% end %> + + + + <% end %> <% if !@total_other_customer.nil? %> - <% if @total_other_customer.total_cus > 0 %> - - - - - <% end %> + + + + <% end %> <% if !@total_membership.nil? %> - <% if @total_membership.total_memb_cus > 0 %> - - - - - <% end %> + + + + <% end %>
Total Customer : <%= @total_customer.total_cus %>
Total Customer : <%= @total_customer.total_cus %>
Dine in : <%= @total_dinein.total_dinein_cus %>
Dine in : <%= @total_dinein.total_dinein_cus %>
Takeaway : <%= @total_takeaway.total_take_cus %>
Takeaway : <%= @total_takeaway.total_take_cus %>
Customer : <%= @total_other_customer.total_cus %>
Customer : <%= @total_other_customer.total_cus %>
Membership : <%= @total_membership.total_memb_cus %>
Membership : <%= @total_membership.total_memb_cus %>
@@ -220,12 +210,10 @@
Order
<% if !@total_order.nil? %> - <% if @total_order.total_order > 0 %> - - - - - <% end %> + + + + <% end %> <% if !(@total_accounts.nil?) %> @@ -249,12 +237,10 @@ <% end %> <% if !@total_foc_items.nil? %> - <% if @total_foc_items > 0 %> - - - - - <% end %> + + + + <% end %>
Total Order : <%= @total_order.total_order %>
Total Order : <%= @total_order.total_order %>
Total FOC Item : <%= @total_foc_items %>
Total FOC Item : <%= @total_foc_items %>
From f333aa9a664650d3fc7f8ee2efa0cc66210bb9c1 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 17 Nov 2017 10:22:04 +0630 Subject: [PATCH 2/5] add top10 and bottom10 products in dashboard --- app/controllers/home_controller.rb | 1 + app/models/sale.rb | 12 +++++++++++- app/views/home/dashboard.html.erb | 11 ++++++++++- config/locales/en.yml | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d8592664..bc621bd7 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -68,6 +68,7 @@ class HomeController < ApplicationController @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count() @top_products = Sale.top_products(today).sum('i.qty') + @bottom_products = Sale.bottom_products(today).sum('i.qty') @hourly_sales = Sale.hourly_sales(today).sum(:grand_total) # .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p') # .sum(:grand_total) diff --git a/app/models/sale.rb b/app/models/sale.rb index ef00fb6a..7e68e771 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -907,7 +907,17 @@ end .where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+ "and payment_status='paid' and sale_status= 'completed'") .group('mi.name') - .order("SUM(i.qty) DESC").limit(5) + .order("SUM(i.qty) DESC").limit(10) + end + + def self.bottom_products(today) + 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") + .where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+ + "and payment_status='paid' and sale_status= 'completed'") + .group('mi.name') + .order("SUM(i.qty) ASC").limit(10) end def self.hourly_sales(today) diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 2de6f67d..bf4321be 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -58,7 +58,7 @@
-
+

dashboard<%= (t :top) + " " + (t :products) %>

@@ -67,6 +67,15 @@
+
+
+
+

dashboard<%= (t :bottom) + " " + (t :products) %>

+ + <%= pie_chart @bottom_products %> +
+
+
- - -
-
-
- <%= form_tag oqs_root_path, :method => :get do %> -
-
- - -
-
- -
- + +
+
+
+ <%= form_tag oqs_root_path, :method => :get do %> +
+
+ +
- <% end %> -
- - - - - - -
- - -
-
- <% - @queue_completed_item.each do |qid| - %> -
-
-
- <%= qid.type %>-<%= qid.zone %> - - <%= qid.order_id %> -
-

- - <%= qid.item_name %> - [x - - <%= qid.qty %> - ] -

- -

<%= qid.options == "[]"? "" : qid.options %>

- - - Order at - - - <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> -
- Order By - - <%= qid.item_order_by %> - -
-
- - - - -
-
- <% - end - %> -
-
- - - - -
-
- +
+ +
+
+ <% end %>
+ + + + + + +
+ + +
+
+ <% + @queue_completed_item.each do |qid| + %> +
+
+
+ <%= qid.type %>-<%= qid.zone %> + + <%= qid.order_id %> +
+

+ + <%= qid.item_name %> + [x + + <%= qid.qty %> + ] +

+ +

<%= qid.options == "[]"? "" : qid.options %>

+ + + Order at - + + <%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> +
+ Order By - + <%= qid.item_order_by %> + +
+
+ + + +
-
- - - - - - - - - - -
ItemsQTY
-
- -
-
+
+ <% + end + %>
+
- -
- - - - + + +
+
+
+ + +
+
+
+
ORDER DETAILS
+
+
+
+ + + + + + + + + + + + + + + + + + + +
Order ByOrder At
+
+
+ + + + + + + + + + +
ItemsQTY
+
+
+
+
+ + +
+ + + + + + +
- - From c56fb1b0f4103958652919da7bbd279e3fbf0cfc Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 17 Nov 2017 16:39:37 +0630 Subject: [PATCH 5/5] oqs back turbolink control --- app/assets/javascripts/OQS.js | 4 ---- app/views/oqs/edit/index.html.erb | 3 ++- app/views/oqs/home/index.html.erb | 8 ++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index d2bb42bc..2f670146 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -25,10 +25,6 @@ //= require custom.js $(document).on('turbolinks:load', function() { - $('#back').on('click', function () { - window.location.href = '/oqs/'; - }); - $(".nav-completed").on("click", function(){ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb index 4d018249..0cae40ce 100755 --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -115,8 +115,9 @@ $(document).ready(function(){ } }); }); + $('#back').on('click', function () { - window.location.href = '/oqs/'; + window.location.href = '/oqs'; }) // number key pad diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 39e84227..96074792 100755 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -177,3 +177,11 @@
+ +