<% @page_title = l(:weekly_work_sheet) + (@period ? " for #{@period}" : '') + (user? ? " for #{user.login}" : '')%>
<% track_times = @rows.find {|r| r.find {|w| w && w.task.track_times?}} %> <% invoicing = @rows.find {|r| r.find {|w| w && w.task.enable_invoicing?}} %> <% columns = 2 + (track_times ? 2 : 0) + (invoicing ? 1 : 0) %>
<%=link_to(image_tag('arrow_left.png'), :id => (@week - 1))%>
<%=link_to(image_tag('arrow_right.png'), :id => (@week + 1))%>

Work for week <%=@week%><%=user? ? " for #{user.login}" : ''%>

[<%=detour_to l(:new_work), :controller => 'works', :action => :new %>] [<%=link_to 'Timeliste', :action => :timeliste %>] [<%= if params[:with_empty] link_to 'Hide empty work records' else link_to 'Show empty work records', :with_empty => 'yes' end %>]
<% (1..7).each do %> <% if invoicing %> <% end %> <% if track_times %> <% end %> <% end %> <% week_total = 0 %> <% day_totals = Array.new(7, 0) %> <% for row in @rows %> <% row.each_with_index do |@work, day| %> <% if @work %> <% day_totals[day] += @work.hours %> <% week_total += @work.hours %> <% if track_times %> <% end %> <% else %> <% end %> <% (0..6).each do |day| %> <% end %>
<%=l :monday %> <%=l :tuesday %> <%=l :wednesday %> <%=l :thursday %> <%=l :friday %> <%=l :saturday %> <%=l :sunday %> <%=l :week %>
<%=l :task %><%=l :invoice_short %><%=l :started_at if track_times %> <%=l(:completed_at) if track_times %><%=l :done %><%=l :totals %>
<%=link_to(h(@work.task.period.to_s), :controller => 'periods', :action => :show, :id => @work.task.period) %> <%=link_to(h(@work.task.description), :controller => 'periods', :action => :show, :id => @work.task.period, :task_id => @work.task.id) %> <%=check_box(:work, :invoice, :onchange => "new Ajax.Updater('invoice_#{@work}', '#{url_for(:action => :set_work_invoice, :id => @work)}' + '?value=' + this.checked);") if @work.task.period.invoice? %> <%=in_place_editor_field(:work, :started_at_time, :class => :task_time) %> <%=in_place_editor_field(:work, :completed_at_time, :class => :task_time) %><%=in_place_editor_field(:work, :hours, {}, :value => '%.2f' % @work.hours) %> <% if track_times %> <% end %> <% end %> <% end %>
<%='%.2f' % day_totals[day] if day_totals[day] > 0%><%= '%.2f' % week_total %>