From 55e18615e4e9341aadfd2e9e785efb4b31e21581 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 19 Jun 2015 21:41:22 +0200 Subject: [PATCH] Hook up a customer-specific time entries list in the customer form view --- stoptime.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index 930d917..41644eb 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1014,10 +1014,17 @@ module StopTime::Controllers end end + @time_entries = @customer.time_entries.order("start DESC") @invoices = @customer.invoices @invoices.each do |i| @input["paid_#{i.number}"] = true if i.paid? end + @task_list = Hash.new { |h, k| h[k] = Array.new } + @customer.tasks.reject { |t| t.billed? }.each do |t| + @task_list[t.customer.shortest_name] << [t.id, t.name] + end + @input["bill"] = true # Bill by default. + @input["task"] = @time_entries.first.task.id if @time_entries.present? @target = [CustomersN, @customer.id] @button = "update" @@ -2146,6 +2153,14 @@ module StopTime::Views end end end + + div.row do + div.span12 do + # Show registered time (ab)using the time_entries view as partial view. + h2 "Registered time" + _time_entries(@customer) unless @method == "create" + end + end end # Form for updating the properties of a task ({Models::Task}).