Added a main task overview for the index.

This commit is contained in:
Paul van Tilburg 2011-11-09 16:02:43 +01:00
parent c4e3161b87
commit f420cb58dd
1 changed files with 46 additions and 1 deletions

View File

@ -267,7 +267,11 @@ module StopTime::Controllers
class Index
def get
redirect R(Timeline)
@tasks = {}
Customer.all.each do |customer|
@tasks[customer] = customer.unbilled_tasks
end
render :overview
end
end
@ -682,6 +686,47 @@ module StopTime::Views
end
end
def overview
h2 "Overview"
if @tasks.empty?
p do
text "No customers found! Create one "
a "here", :href => R(CustomersNew)
end
else
@tasks.keys.sort_by { |c| c.name }.each do |customer|
h3 { a customer.name, :href => R(CustomersN, customer.id) }
if @tasks[customer].empty?
p do
text "No projects/tasks found! Create one "
a "here", :href => R(CustomersNTasksNew, customer.id)
end
else
table do
@tasks[customer].each do |task|
tr do
td do
a task.name,
:href => R(CustomersNTasksN, customer.id, task.id)
end
summary = task.summary
case task.type
when "fixed_rate"
td ""
td { "€ %.2f" % summary[2] }
when "hourly_rate"
td { "%.2fh" % summary[0] }
td { "€ %.2f" % summary[2] }
end
end
end
end
end
end
end
end
def time_entries
h2 "Timeline"
table do