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