<% @page_title = "#{l :daily_work_sheet} on #{@date}" + (" for #{user.login}" if user?) %>
<%=image_link_to('arrow_left.png', l(:previous_week), {:id => @date - 7}, :class => nil)%>
<%=image_link_to('arrow_left.png', l(:previous_day), {:id => @date-1}, :class => nil)%>
<%=image_link_to('arrow_right.png', l(:next_week), {:id => @date + 7}, :class => nil)%>
<%=image_link_to('arrow_right.png', l(:next_day), {:id => @date+1}, :class => nil)%>

<% day_total = 0 %> <% for @work in @works %> <% day_total += @work.hours if @work %> <%=render :partial => 'row'%> <% end %> <% last_work = @work %> <% @work = nil %> <% form_tag with_detour(:controller => 'works', :action => 'create') do %> <%=submit_tag('checkmark', :value => l(:save), :style => 'display: none')%> <%=hidden_field :work, :completed_at, :value => @date %>
<%=link_to l(:weekly_work_sheet), :action => :weekly_work_sheet_by_work_account%>
<%=l :account %> <%=l :customer %> <%=l :description %> <%=l :started_at %> <%=l :completed_at %> <%=l :done %> <%=l :invoice %>
<%=text_field_with_auto_complete :work, :work_account_name, {:value => '', :size => 16, :class => :task_description}, {:delay => "0.01"} %> <%=text_field_with_auto_complete :work, :customer_name, {:value => '', :size => 16, :class => :task_description} %> <%=text_field_with_auto_complete :work, :description, {:class => :task_description} %> <%=text_field :work, :started_at_time, :value => last_work && last_work.completed_at && last_work.completed_at.strftime('%H:%M'), :class => 'task_time' %> <%=text_field :work, :completed_at_time, :class => 'task_time', :value => @work && @work.completed_at.strftime('%H:%M'), :onchange => "update_hours(this.form);" %> <%=text_field :work, :hours_time, :value => '', :class => 'task_hours' %> <%=check_box :work, :invoice %>
<%=l :totals %> <%='%d:%02d' % [day_total.to_i, 60 * (day_total % 1)] %>
<%= submit_tag l(:save) %> <%= back_or_link_to l(:back), '' %> <% end %> <% if @period %> <%= link_to l(:back), :controller => 'periods', :action => :show, :id => @period %> <% end %>
<% if @period %> <%=render :partial => '/periods/burn_down_chart' %> <% end %>