annotate app/views/timelog/report.rhtml @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
rev   line source
Chris@0 1 <div class="contextual">
Chris@0 2 <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %>
Chris@0 3 </div>
Chris@0 4
Chris@0 5 <%= render_timelog_breadcrumb %>
Chris@0 6
Chris@0 7 <h2><%= l(:label_spent_time) %></h2>
Chris@0 8
Chris@0 9 <% form_remote_tag(:url => {}, :html => {:method => :get, :id => 'query_form'}, :method => :get, :update => 'content') do %>
Chris@0 10 <% @criterias.each do |criteria| %>
Chris@0 11 <%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
Chris@0 12 <% end %>
Chris@0 13 <%# TODO: get rid of the project_id field, that should already be in the URL %>
Chris@0 14 <%= hidden_field_tag('project_id', params[:project_id]) if @project %>
Chris@0 15 <%= hidden_field_tag('issue_id', params[:issue_id]) if @issue %>
Chris@0 16 <%= render :partial => 'date_range' %>
Chris@0 17
Chris@0 18 <p><%= l(:label_details) %>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'],
Chris@0 19 [l(:label_month), 'month'],
Chris@0 20 [l(:label_week), 'week'],
Chris@0 21 [l(:label_day_plural).titleize, 'day']], @columns),
Chris@0 22 :onchange => "this.form.onsubmit();" %>
Chris@0 23
Chris@0 24 <%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l_or_humanize(@available_criterias[k][:label]), k]}),
Chris@0 25 :onchange => "this.form.onsubmit();",
Chris@0 26 :style => 'width: 200px',
Chris@0 27 :id => nil,
Chris@0 28 :disabled => (@criterias.length >= 3)) %>
Chris@0 29 <%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @columns},
Chris@0 30 :method => :get,
Chris@0 31 :update => 'content'
Chris@0 32 }, :class => 'icon icon-reload' %></p>
Chris@0 33 <% end %>
Chris@0 34
Chris@0 35 <% unless @criterias.empty? %>
Chris@0 36 <div class="total-hours">
Chris@0 37 <p><%= l(:label_total) %>: <%= html_hours(l_hours(@total_hours)) %></p>
Chris@0 38 </div>
Chris@0 39
Chris@0 40 <% unless @hours.empty? %>
Chris@0 41 <table class="list" id="time-report">
Chris@0 42 <thead>
Chris@0 43 <tr>
Chris@0 44 <% @criterias.each do |criteria| %>
Chris@0 45 <th><%= l_or_humanize(@available_criterias[criteria][:label]) %></th>
Chris@0 46 <% end %>
Chris@0 47 <% columns_width = (40 / (@periods.length+1)).to_i %>
Chris@0 48 <% @periods.each do |period| %>
Chris@0 49 <th class="period" width="<%= columns_width %>%"><%= period %></th>
Chris@0 50 <% end %>
Chris@0 51 <th class="total" width="<%= columns_width %>%"><%= l(:label_total) %></th>
Chris@0 52 </tr>
Chris@0 53 </thead>
Chris@0 54 <tbody>
Chris@0 55 <%= render :partial => 'report_criteria', :locals => {:criterias => @criterias, :hours => @hours, :level => 0} %>
Chris@0 56 <tr class="total">
Chris@0 57 <td><%= l(:label_total) %></td>
Chris@0 58 <%= '<td></td>' * (@criterias.size - 1) %>
Chris@0 59 <% total = 0 -%>
Chris@0 60 <% @periods.each do |period| -%>
Chris@0 61 <% sum = sum_hours(select_hours(@hours, @columns, period.to_s)); total += sum -%>
Chris@0 62 <td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
Chris@0 63 <% end -%>
Chris@0 64 <td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
Chris@0 65 </tr>
Chris@0 66 </tbody>
Chris@0 67 </table>
Chris@0 68
Chris@0 69 <% other_formats_links do |f| %>
Chris@0 70 <%= f.link_to 'CSV', :url => params %>
Chris@0 71 <% end %>
Chris@0 72 <% end %>
Chris@0 73 <% end %>
Chris@0 74
Chris@0 75 <% html_title l(:label_spent_time), l(:label_report) %>
Chris@0 76