You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

report.html.erb 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <div class="contextual">
  2. <%= link_to l(:button_log_time),
  3. _new_time_entry_path(@project, @issue),
  4. :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
  5. </div>
  6. <h2><%= @query.new_record? ? l(:label_spent_time) : @query.name %></h2>
  7. <%= form_tag(_report_time_entries_path(@project, nil), :method => :get, :id => 'query_form') do %>
  8. <% @report.criteria.each do |criterion| %>
  9. <%= hidden_field_tag 'criteria[]', criterion, :id => nil %>
  10. <% end %>
  11. <%= render :partial => 'timelog/date_range' %>
  12. <p><label for='columns'><%= l(:label_details) %></label>: <%= select_tag 'columns', options_for_select([[l(:label_year), 'year'],
  13. [l(:label_month), 'month'],
  14. [l(:label_week), 'week'],
  15. [l(:label_day_plural).titleize, 'day']], @report.columns),
  16. :onchange => "this.form.submit();" %>
  17. <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]}),
  18. :onchange => "this.form.submit();",
  19. :style => 'width: 200px',
  20. :disabled => (@report.criteria.length >= 3),
  21. :id => "criterias") %>
  22. <%= link_to l(:button_clear), {:params => request.query_parameters.merge(:criteria => nil)}, :class => 'icon icon-reload' %></p>
  23. <%= hidden_field_tag 'encoding', l(:general_csv_encoding) unless l(:general_csv_encoding).casecmp('UTF-8') == 0 %>
  24. <% end %>
  25. <% if @query.valid? %>
  26. <% unless @report.criteria.empty? %>
  27. <% if @report.hours.empty? %>
  28. <p class="nodata"><%= l(:label_no_data) %></p>
  29. <% else %>
  30. <div class="autoscroll">
  31. <table class="list" id="time-report">
  32. <thead>
  33. <tr>
  34. <% @report.criteria.each do |criteria| %>
  35. <th><%= l_or_humanize(@report.available_criteria[criteria][:label]) %></th>
  36. <% end %>
  37. <% columns_width = (40 / (@report.periods.length+1)).to_i %>
  38. <% @report.periods.each do |period| %>
  39. <th class="period" style="width:<%= columns_width %>%;"><%= period %></th>
  40. <% end %>
  41. <th class="total" style="width:<%= columns_width %>%;"><%= l(:label_total_time) %></th>
  42. </tr>
  43. </thead>
  44. <tbody>
  45. <%= render :partial => 'report_criteria', :locals => {:criterias => @report.criteria, :hours => @report.hours, :level => 0} %>
  46. <tr class="total">
  47. <td><%= l(:label_total_time) %></td>
  48. <%= ('<td></td>' * (@report.criteria.size - 1)).html_safe %>
  49. <% total = 0 -%>
  50. <% @report.periods.each do |period| -%>
  51. <% sum = sum_hours(select_hours(@report.hours, @report.columns, period.to_s)); total += sum -%>
  52. <td class="hours"><%= html_hours(format_hours(sum)) if sum > 0 %></td>
  53. <% end -%>
  54. <td class="hours"><%= html_hours(format_hours(total)) if total > 0 %></td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </div>
  59. <% other_formats_links do |f| %>
  60. <%= f.link_to_with_query_parameters 'CSV', {}, :onclick => "showModal('csv-export-options', '330px'); return false;" %>
  61. <% end %>
  62. <% end %>
  63. <div id="csv-export-options" style="display: none;">
  64. <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
  65. <%= export_csv_encoding_select_tag %>
  66. <p class="buttons">
  67. <%= submit_tag l(:button_export), :name => nil, :id => 'csv-export-button' %>
  68. <%= submit_tag l(:button_cancel), :name => nil, :onclick => 'hideModal(this);', :type => 'button' %>
  69. </p>
  70. </div>
  71. <% end %>
  72. <% end %>
  73. <% content_for :sidebar do %>
  74. <%= render_sidebar_queries(TimeEntryQuery, @project) %>
  75. <% end %>
  76. <% html_title(@query.new_record? ? l(:label_spent_time) : @query.name, l(:label_report)) %>
  77. <%= javascript_tag do %>
  78. $(document).ready(function(){
  79. $('input#csv-export-button').click(function(){
  80. $('form input#encoding').val($('select#encoding option:selected').val());
  81. $('form#query_form').attr('action', '<%= report_time_entries_path(:format => 'csv') %>').submit();
  82. $('form#query_form').attr('action', '<%= report_time_entries_path %>');
  83. hideModal(this);
  84. });
  85. });
  86. <% end %>