From a531ef4f8766339f94e1f8b0deb08af1e7d27b6a Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 14 Jan 2023 06:20:41 -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 c497ce0..febee86 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -86,6 +86,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 558f560..19f1aa0 100644 --- a/app/views/customers/show.html.erb +++ b/app/views/customers/show.html.erb @@ -31,8 +31,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 cc6e49c..888ffdf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,4 +79,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