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

121 lines
3.5 KiB

<% @query = CostQuery.new
@query.filter :project_id, :value => [1,2]
@query.group_by :tweek
@query.column :tweek
@query.row :user_id
@query.row :project_id
@walker = @query.walker
@row = @walker.row_first
@column = @walker.column_first
%>
<%# things above this line should be deleted or go into the controler %>
<% 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>
<%
data = @query.walk(:row_first) do |current, sub|
if current.column?
if @was_column
next sub.join
else
@was_column = true
next sub
end
end
field = "<td rowspan='%d'>#{current.type}, #{@was_column.inspect}: #{current.fields.inspect}</td>"
if sub.blank?
[field % 1]
else
if @was_column
@was_column = false
[(field % 1) << sub.join]
else
first, *rest = sub.flatten
size = rest.size + 1
first = (field % size) << first
[first, *rest]
end
end
end
%>
<table border='1'>
<% data.flatten.each do |line| %>
<tr><%= line %></tr>
<% end %>
</table>
<div style="border-width: 1; background-color: #BBB; padding: 5px">
query chain: <br />
<ul>
<% chain = @query.chain
while chain %>
<li><%= chain.class.to_s %></li>
<% chain = chain.child
end %>
</ul>
<% max = 20 %>
Result (row):
<pre><% @row.recursive_each_with_level do |l, r| %>
<%= "#{'| '*l}#{r.class} (#{r.fields}) # size:#{r.size}" %><% max -=1; break if max <= 0; end %>
...
</pre>
<% max = 20 %>
Result (column):
<pre><% @column.recursive_each_with_level do |l, r| %>
<%= "#{'| '*l}#{r.class} (#{r.fields}) # size:#{r.size}" %><% max -=1; break if max <= 0; end %>
...
</pre>
SQL statement: <br />
<pre><%= @query.sql_statement.to_s %></pre>
</div>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<%= stylesheet_link_tag 'costs', :plugin => 'redmine_costs' %>
<% end %>