git-svn-id: http://redmine.rubyforge.org/svn/trunk@398 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.5.0
@@ -545,10 +545,12 @@ class ProjectsController < ApplicationController | |||
# finish on sunday | |||
@date_to = @date_to + (7-@date_to.cwday) | |||
@issues = @project.issues.find(:all, | |||
:include => [:tracker, :status, :assigned_to, :priority], | |||
:conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to] | |||
) unless @selected_tracker_ids.empty? | |||
@project.issues_with_subprojects(params[:with_subprojects]) do | |||
@issues = Issue.find(:all, | |||
:include => [:tracker, :status, :assigned_to, :priority], | |||
:conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')})", @date_from, @date_to, @date_from, @date_to] | |||
) unless @selected_tracker_ids.empty? | |||
end | |||
@issues ||=[] | |||
@ending_issues_by_days = @issues.group_by {|issue| issue.due_date} | |||
@@ -579,11 +581,13 @@ class ProjectsController < ApplicationController | |||
@date_from = Date.civil(@year_from, @month_from, 1) | |||
@date_to = (@date_from >> @months) - 1 | |||
@issues = @project.issues.find(:all, | |||
:order => "start_date, due_date", | |||
:include => [:tracker, :status, :assigned_to, :priority], | |||
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] | |||
) unless @selected_tracker_ids.empty? | |||
@project.issues_with_subprojects(params[:with_subprojects]) do | |||
@issues = Issue.find(:all, | |||
:order => "start_date, due_date", | |||
:include => [:tracker, :status, :assigned_to, :priority], | |||
:conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null and #{Issue.table_name}.tracker_id in (#{@selected_tracker_ids.join(',')}))", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to] | |||
) unless @selected_tracker_ids.empty? | |||
end | |||
@issues ||=[] | |||
if params[:output]=='pdf' |
@@ -47,6 +47,19 @@ class Project < ActiveRecord::Base | |||
errors[:identifier].nil? && !(new_record? || identifier.blank?) | |||
end | |||
def issues_with_subprojects(include_subprojects=false) | |||
conditions = nil | |||
if include_subprojects && children.size > 0 | |||
ids = [id] + children.collect {|c| c.id} | |||
conditions = ["#{Issue.table_name}.project_id IN (#{ids.join(',')})"] | |||
else | |||
conditions = ["#{Issue.table_name}.project_id = ?", id] | |||
end | |||
Issue.with_scope :find => { :conditions => conditions } do | |||
yield | |||
end | |||
end | |||
# returns latest created projects | |||
# non public projects will be returned only if user is a member of those | |||
def self.latest(user=nil, count=5) |
@@ -5,8 +5,8 @@ | |||
<tr> | |||
<td align="left" style="width:15%"> | |||
<%= link_to_remote ('« ' + (@month==1 ? "#{month_name(12)} #{@year-1}" : "#{month_name(@month-1)}")), | |||
{:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids }}, | |||
{:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids)} | |||
{:update => "content", :url => { :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }}, | |||
{:href => url_for(:action => 'calendar', :year => (@month==1 ? @year-1 : @year), :month =>(@month==1 ? 12 : @month-1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])} | |||
%> | |||
</td> | |||
<td align="center" style="width:55%"> | |||
@@ -22,13 +22,17 @@ | |||
<%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> | |||
<%= tracker.name %><br /> | |||
<% end %> | |||
<% if @project.children.any? %> | |||
<p><strong><%=l(:label_subproject_plural)%></strong></p> | |||
<%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> | |||
<% end %> | |||
<p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p> | |||
</div> | |||
</td> | |||
<td align="right" style="width:15%"> | |||
<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' »'), | |||
{:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids }}, | |||
{:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids)} | |||
{:update => "content", :url => { :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }}, | |||
{:href => url_for(:action => 'calendar', :year => (@month==12 ? @year+1 : @year), :month =>(@month==12 ? 1 : @month+1), :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects])} | |||
%> | |||
</td> | |||
</tr> |
@@ -1,6 +1,6 @@ | |||
<div class="contextual"> | |||
<%= l(:label_export_to) %> | |||
<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :output => 'pdf'}, :class => 'icon icon-pdf' %> | |||
<%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %> | |||
</div> | |||
<h2><%= l(:label_gantt) %></h2> | |||
@@ -24,17 +24,21 @@ | |||
<%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %> | |||
<%= tracker.name %><br /> | |||
<% end %> | |||
<% if @project.children.any? %> | |||
<p><strong><%=l(:label_subproject_plural)%></strong></p> | |||
<%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> | |||
<% end %> | |||
<p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p> | |||
</div> | |||
</td> | |||
<td align="right"> | |||
<%= if @zoom < 4 | |||
link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids} | |||
link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]} | |||
else | |||
image_tag 'zoom_in_g.png' | |||
end %> | |||
<%= if @zoom > 1 | |||
link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids} | |||
link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]} | |||
else | |||
image_tag 'zoom_out_g.png' | |||
end %> | |||
@@ -103,7 +107,7 @@ height = (show_weeks ? header_heigth : header_heigth + g_height) | |||
width = ((month_f >> 1) - month_f) * zoom - 1 | |||
%> | |||
<div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> | |||
<%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months }, :title => "#{month_name(month_f.month)} #{month_f.year}"%> | |||
<%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%> | |||
</div> | |||
<% | |||
left = left + width + 1 | |||
@@ -217,7 +221,7 @@ end %> | |||
<table width="100%"> | |||
<tr> | |||
<td align="left"><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids %></td> | |||
<td align="right"><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids %></td> | |||
<td align="left"><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td> | |||
<td align="right"><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td> | |||
</tr> | |||
</table> |