From 26433c9020e436e13a3101217cd67365c597b4da Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 14 Jan 2023 06:38:48 -0500 Subject: [PATCH] Added hour totals to customer job history --- app/controllers/customers_controller.rb | 4 ++++ app/views/customers/show.html.erb | 4 ++-- config/locales/en.yml | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index 353e266..e8b8ec4 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -93,6 +93,10 @@ class CustomersController < ApplicationController @billing_address = address_to_s(@customer.billing_address) @shipping_address = address_to_s(@customer.shipping_address) @closed_issues = (@issues - @issues.open) + @hours = 0 + @closed_hours = 0 + @issues.open.each { |i| @hours+= i.total_spent_hours } + @closed_issues.each { |i| @closed_hours+= i.total_spent_hours } rescue render_404 end diff --git a/app/views/customers/show.html.erb b/app/views/customers/show.html.erb index 2a7689f..af5d5b7 100644 --- a/app/views/customers/show.html.erb +++ b/app/views/customers/show.html.erb @@ -35,8 +35,8 @@
-

<%=@issues.open.count%> <%=t(:label_open_issues)%>:

+

<%=@issues.open.count%> <%=t(:label_open_issues)%> - <%=@hours.round(1)%> <%=t(:label_hours)%>

<%= render :partial => 'issues/list_simple', locals: {issues: @issues.open} %> -

<%=@closed_issues.count%> <%=t(:label_closed_issues)%>:

+

<%=@closed_issues.count%> <%=t(:label_closed_issues)%> - <%= @closed_hours.round(1)%> <%=t(:label_hours)%>

<%= render :partial => 'issues/list_simple', locals: {issues: @closed_issues} %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 48768cb..c93d22c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -87,4 +87,5 @@ en: label_billed_success: "Successfully Billed " label_billing_error: "Cannot bill without a customer assigned" label_qbo_sync_success: "Successfully synced to Quickbooks" + label_hours: "Hours" \ No newline at end of file