From a744a4f0d1b817361c91b069f72982faa9e484ef Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 19 Jun 2015 22:02:13 +0200 Subject: [PATCH] Add a grand total of unbilled hours and amount to the overview view --- stoptime.rb | 17 +++++++++++++++++ templates/sass/style.sass | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index 41644eb..817b911 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -898,6 +898,7 @@ module StopTime::Controllers @task_count = 0 @active_tasks = {} @active_tasks_summary = {} + @totals = [0.0, 0,0] Customer.all.each do |customer| tasks = customer.unbilled_tasks @tasks[customer] = tasks @@ -908,7 +909,9 @@ module StopTime::Controllers active_tasks.inject([0.0, 0.0]) do |summ, task| task_summ = task.summary summ[0] += task_summ[0] + @totals[0] += task_summ[0] summ[1] += task_summ[2] + @totals[1] += task_summ[2] summ end end @@ -1861,6 +1864,20 @@ module StopTime::Views end end end + div.row do + div.span12 do + table.table.table_condensed.grand_total do + col + col.total_hours + col.total_amount + tr do + td { big { b "Grand total" } } + td.text_right { big { b("%.2fh" % @totals[0]) } } + td.text_right { big { b("€ %.2f" % @totals[1]) } } + end + end + end + end end end diff --git a/templates/sass/style.sass b/templates/sass/style.sass index a6752eb..6c7c4d8 100644 --- a/templates/sass/style.sass +++ b/templates/sass/style.sass @@ -48,6 +48,8 @@ table col.amount, col.hours, col.hourly_rate width: 85px + col.total_hours, col.total_amount + width: 130px col.reg_hours width: 90px col.flag @@ -93,6 +95,9 @@ table td.indent padding-left: 20px +table.grand-total + margin-top: 30px + /* Form layout */ .form-condensed padding-top: 0px