From 2e5985b32b0ca9f112ff1b0aae2f02ae096d53a6 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 8 Nov 2014 12:06:19 +0100 Subject: [PATCH 1/2] Discern customer tasks and active tasks --- stoptime.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 3324fc2..c51a9c1 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -895,18 +895,22 @@ module StopTime::Controllers # {Views#overview}. def get @tasks = {} - @tasks_summary = {} @task_count = 0 + @active_tasks = {} + @active_tasks_summary = {} Customer.all.each do |customer| - tasks = customer.active_tasks + tasks = customer.unbilled_tasks @tasks[customer] = tasks - @tasks_summary[customer] = tasks.inject([0.0, 0.0]) do |summ, task| - task_summ = task.summary - summ[0] += task_summ[0] - summ[1] += task_summ[2] - summ - end @task_count += tasks.count + active_tasks = customer.active_tasks + @active_tasks[customer] = active_tasks + @active_tasks_summary[customer] = + active_tasks.inject([0.0, 0.0]) do |summ, task| + task_summ = task.summary + summ[0] += task_summ[0] + summ[1] += task_summ[2] + summ + end end render :overview end @@ -1789,7 +1793,7 @@ module StopTime::Views col.task col.hours col.amount - @tasks[customer].each do |task| + @active_tasks[customer].each do |task| tr do summary = task.summary td do @@ -1803,8 +1807,8 @@ module StopTime::Views end tr do td { b "Total" } - td.text_right { "%.2fh" % @tasks_summary[customer][0] } - td.text_right { "€ %.2f" % @tasks_summary[customer][1] } + td.text_right { "%.2fh" % @active_tasks_summary[customer][0] } + td.text_right { "€ %.2f" % @active_tasks_summary[customer][1] } end end end From 4cf1517b438f16ed0344ef09a72b703d33c25fda Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 8 Nov 2014 12:06:33 +0100 Subject: [PATCH 2/2] Show message if there are tasks but no active tasks Show links to the task form of each of these tasks so that time can be registered there. --- stoptime.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index c51a9c1..332b961 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1788,6 +1788,16 @@ module StopTime::Views text! "No projects/tasks found! Create one " + "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." end + elsif @active_tasks[customer].empty? + p do + text! "No active projects/tasks found! " + + "Register time on one of these tasks: " + br + @tasks[customer].each do |task| + a task.name, :href => R(CustomersNTasksN, customer.id, task.id) + text! "·" unless task == @tasks[customer].last + end + end else table.table.table_condensed do col.task