annotate app/controllers/gantts_controller.rb @ 905:a97ce6b60fde yuya

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