Chris@0: class GanttsController < ApplicationController Chris@14: menu_item :gantt Chris@0: before_filter :find_optional_project Chris@0: Chris@0: rescue_from Query::StatementInvalid, :with => :query_statement_invalid Chris@0: Chris@0: helper :issues Chris@0: helper :projects Chris@0: helper :queries Chris@0: include QueriesHelper Chris@0: helper :sort Chris@0: include SortHelper Chris@0: include Redmine::Export::PDF Chris@0: Chris@0: def show Chris@0: @gantt = Redmine::Helpers::Gantt.new(params) Chris@0: retrieve_query Chris@0: @query.group_by = nil Chris@0: if @query.valid? Chris@0: events = [] Chris@0: # Issues that have start and due dates Chris@0: events += @query.issues(:include => [:tracker, :assigned_to, :priority], Chris@0: :order => "start_date, due_date", Chris@0: :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_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: ) Chris@0: # Issues that don't have a due date but that are assigned to a version with a date Chris@0: events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version], Chris@0: :order => "start_date, effective_date", Chris@0: :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_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: ) Chris@0: # Versions Chris@0: events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to]) Chris@0: Chris@0: @gantt.events = events Chris@0: end Chris@0: Chris@0: basename = (@project ? "#{@project.identifier}-" : '') + 'gantt' Chris@0: Chris@0: respond_to do |format| Chris@0: format.html { render :action => "show", :layout => !request.xhr? } Chris@1: format.png { send_data(@gantt.to_image(@project), :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') Chris@0: format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") } Chris@0: end Chris@0: end Chris@0: Chris@0: end