comparison app/controllers/gantts_controller.rb @ 22:40f7cfd4df19

* Update to SVN trunk rev 4173
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 24 Sep 2010 14:06:04 +0100
parents 1d32c0a0efbf
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
14:1d32c0a0efbf 22:40f7cfd4df19
2 menu_item :gantt 2 menu_item :gantt
3 before_filter :find_optional_project 3 before_filter :find_optional_project
4 4
5 rescue_from Query::StatementInvalid, :with => :query_statement_invalid 5 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
6 6
7 helper :gantt
7 helper :issues 8 helper :issues
8 helper :projects 9 helper :projects
9 helper :queries 10 helper :queries
10 include QueriesHelper 11 include QueriesHelper
11 helper :sort 12 helper :sort
12 include SortHelper 13 include SortHelper
13 include Redmine::Export::PDF 14 include Redmine::Export::PDF
14 15
15 def show 16 def show
16 @gantt = Redmine::Helpers::Gantt.new(params) 17 @gantt = Redmine::Helpers::Gantt.new(params)
18 @gantt.project = @project
17 retrieve_query 19 retrieve_query
18 @query.group_by = nil 20 @query.group_by = nil
19 if @query.valid? 21 @gantt.query = @query if @query.valid?
20 events = []
21 # Issues that have start and due dates
22 events += @query.issues(:include => [:tracker, :assigned_to, :priority],
23 :order => "start_date, due_date",
24 :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)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
25 )
26 # Issues that don't have a due date but that are assigned to a version with a date
27 events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
28 :order => "start_date, effective_date",
29 :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
30 )
31 # Versions
32 events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
33
34 @gantt.events = events
35 end
36 22
37 basename = (@project ? "#{@project.identifier}-" : '') + 'gantt' 23 basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
38 24
39 respond_to do |format| 25 respond_to do |format|
40 format.html { render :action => "show", :layout => !request.xhr? } 26 format.html { render :action => "show", :layout => !request.xhr? }
41 format.png { send_data(@gantt.to_image(@project), :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') 27 format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
42 format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") } 28 format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") }
43 end 29 end
44 end 30 end
45 31
32 def update
33 show
34 end
35
46 end 36 end