Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

report.html.erb 4.7KB

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