OpenProject is the leading open source project management software.
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.
 
 
 
 
 
 
openproject/app/views/cost_reports/index.rhtml

103 lines
3.6 KiB

<%# things above this line should be deleted or go into the controller %>
<% @query = CostQuery.example %>
<% if @custom_error %>
<div class="flash error"><%= @custom_error %></div>
<% end %>
<h2><%= l(:label_cost_report) %></h2>
<% html_title( l(:label_cost_report) ) %>
<% form_for @query, :url => {:controller => 'cost_report', :action => 'new' }, :html => {:id => 'query_form', :method => :post} do |query_form| %>
<div id="query_from_content">
<fieldset id="filters" class="collapsible <%= "collapsed" unless @query.new_record? %>">
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
<div <%#= 'style="display:none;"' unless @query.new_record? %>><%#= render :partial => 'filters', :locals => {:query_form => query_form} %></div>
</fieldset>
<fieldset id="group-by" class="collapsible">
<legend onclick="toggleFieldset(this);"><%= l(:label_group_by) %></legend>
<div><%#= render :partial => 'group_by', :locals => {:query_form => query_form} %></div>
</fieldset>
<p class="buttons">
<%= link_to_remote l(:button_apply),
{ :url => { :set_filter => 1 },
:update => "content",
:with => "Form.serialize('query_form')"
}, :class => 'icon icon-checked' %>
<%= link_to_remote l(:button_clear),
{ :url => { :set_filter => 1 },
:update => "content",
}, :class => 'icon icon-reload' %>
<% if User.current.allowed_to?(:save_queries, @project, :global => true) %>
<%
#link_to l(:button_save), {}, :onclick => "$('query_form').submit(); return false;", :class => 'icon icon-save'
%>
<% end %>
</p>
</div>
<% end %>
<h1>Die sch&ouml;ne Tabelle:</h1>
<%
def show_row(row)
row.render do |key, value|
case key.to_sym
when :project_id then "Project ##{value}: #{Project.find(value.to_i).name}"
when :user_id then link_to_user User.find(value)
when :tyear then value
when :tweek then "Week ##{value}"
else "#{key}: #{value}"
end
end
end
@walker = CostQuery::Walker.new @query
@walker.for_final_row do |row, cells|
"<td>#{show_row row}</td>" << cells.join << "<td>#{row.real_costs} €</td>"
end
@walker.for_row do |row, subrows|
subrows.flatten!
unless row.fields.empty?
subrows[0] = "<td rowspan='#{subrows.size}'>#{show_row row}</td>" \
"#{subrows[0]}<td rowspan='#{subrows.size}'>#{row.real_costs} €</td>"
end
subrows
end
@walker.for_empty_cell { "<td></td>" }
@walker.for_cell do |result|
"<td>#{result.real_costs} €</td>"
end
%>
<table style='text-align: center' border='1'>
<% @walker.headers do |list, first| %>
<tr>
<%= "<td rowspan='#{@query.depth_of(:column)}' colspan='#{@query.depth_of(:row) - 1}'></td>" if first %>
<% list.each do |column| %>
<td colspan="<%= column.final_number(:column) %>"><%= show_row column %></td>
<% end %>
<%= "<td rowspan='#{@query.depth_of(:column)}' colspan='#{@query.depth_of(:row) - 1}'></td>" if first %>
</tr>
<% end %>
<% @walker.body do |line| %>
<tr><%= line %></tr>
<% end %>
<% @walker.headers(:reverse) do |list, final| %>
<% first = list.first.final_column? %>
<tr>
<%= "<td rowspan='#{@query.depth_of(:column) - 1}' colspan='#{@query.depth_of(:row) - 1}'></td>" if first %>
<% if !final then list.each do |column| %>
<td colspan="<%= column.final_number(:column) %>"><%= column.real_costs %> €</td>
<% end end %>
<%= "<td rowspan='#{@query.depth_of(:column) - 1}' colspan='#{@query.depth_of(:row) - 1}'>#{@query.real_costs} €</td>" if first %>
</tr>
<% end %>
</table>