report.html.erb 3.5 KB
Newer Older
1
<div class="contextual">
2 3 4
<%= link_to l(:button_log_time), 
            _new_time_entry_path(@project, @issue),
            :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
5 6
</div>

7
<h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2>
jplang's avatar
jplang committed
8

9
<%= form_tag(_report_time_entries_path(@project, nil), :method => :get, :id => 'query_form') do %>
10 11
  <% @report.criteria.each do |criterion| %>
    <%= hidden_field_tag 'criteria[]', criterion, :id => nil %>
jplang's avatar
jplang committed
12
  <% end %>
13
  <%= render :partial => 'timelog/date_range' %>
14

15
  <p><label for='columns'><%= l(:label_details) %></label>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'],
16
                                                                            [l(:label_month), 'month'],
17
                                                                            [l(:label_week), 'week'],
18
                                                                            [l(:label_day_plural).titleize, 'day']], @report.columns),
19
                                                        :onchange => "this.form.submit();" %>
jplang's avatar
jplang committed
20

21
  <label for='criterias'><%= l(:button_add) %></label>: <%= select_tag('criteria[]', options_for_select([[]] + (@report.available_criteria.keys - @report.criteria).collect{|k| [l_or_humanize(@report.available_criteria[k][:label]), k]}),
22
                                                          :onchange => "this.form.submit();",
23
                                                          :style => 'width: 200px',
24 25
                                                          :disabled => (@report.criteria.length >= 3),
                                                          :id => "criterias") %>
26
     <%= link_to l(:button_clear), {:project_id => @project, :issue_id => @issue, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @report.columns}, :class => 'icon icon-reload' %></p>
27 28
<% end %>

29
<% unless @report.criteria.empty? %>
30
<div class="total-hours">
31
<p><%= l(:label_total_time) %>: <%= html_hours(l_hours(@report.total_hours)) %></p>
32
</div>
jplang's avatar
jplang committed
33

34
<% unless @report.hours.empty? %>
35
<div class="autoscroll">
36
<table class="list" id="time-report">
jplang's avatar
jplang committed
37 38
<thead>
<tr>
39 40
<% @report.criteria.each do |criteria| %>
  <th><%= l_or_humanize(@report.available_criteria[criteria][:label]) %></th>
jplang's avatar
jplang committed
41
<% end %>
42 43
<% columns_width = (40 / (@report.periods.length+1)).to_i %>
<% @report.periods.each do |period| %>
44
  <th class="period" style="width:<%= columns_width %>%;"><%= period %></th>
jplang's avatar
jplang committed
45
<% end %>
46
  <th class="total" style="width:<%= columns_width %>%;"><%= l(:label_total_time) %></th>
jplang's avatar
jplang committed
47 48 49
</tr>
</thead>
<tbody>
50
<%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0} %>
51
  <tr class="total">
52
  <td><%= l(:label_total_time) %></td>
53
  <%= ('<td></td>' * (@report.criteria.size - 1)).html_safe %>
54
  <% total = 0 -%>
55 56
  <% @report.periods.each do |period| -%>
    <% sum = sum_hours(select_hours(@report.hours, @report.columns, period.to_s)); total += sum -%>
57 58
    <td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
  <% end -%>
59
  <td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
60
  </tr>
jplang's avatar
jplang committed
61 62
</tbody>
</table>
63
</div>
64

65
<% other_formats_links do |f| %>
66
  <%= f.link_to 'CSV', :url => params %>
67
<% end %>
jplang's avatar
jplang committed
68 69
<% end %>
<% end %>
70

71 72 73 74
<% content_for :sidebar do %>
  <%= render_sidebar_queries(TimeEntryQuery, @project) %>
<% end %>

75
<% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_report)) %>
76