From 4899e624efd2237bb7d8d63f58e13bcea00e593a Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 17 Nov 2017 09:56:40 +0630 Subject: [PATCH] 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 %>