diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 30a8dba1f..317dcaff6 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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' diff --git a/app/models/project.rb b/app/models/project.rb index fe02cd829..2419e720d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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) diff --git a/app/views/projects/calendar.rhtml b/app/views/projects/calendar.rhtml index 23aba7d76..cb83a36b6 100644 --- a/app/views/projects/calendar.rhtml +++ b/app/views/projects/calendar.rhtml @@ -5,8 +5,8 @@
<%=l(:label_subproject_plural)%>
+ <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> + <% end %><%=l(:label_subproject_plural)%>
+ <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %> + <% end %><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids %> | -<%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids %> | +<%= 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] %> | +<%= 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] %> |