Commit 708c3c9e authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Added versions due dates on gantt chart.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@428 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent c1a5c5b9
......@@ -592,14 +592,16 @@ class ProjectsController < ApplicationController
@date_from = Date.civil(@year_from, @month_from, 1)
@date_to = (@date_from >> @months) - 1
@events = []
@project.issues_with_subprojects(params[:with_subprojects]) do
@issues = Issue.find(:all,
@events += 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 ||=[]
@events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
@events.sort! {|x,y| x.start_date <=> y.start_date }
if params[:output]=='pdf'
@options_for_rfpdf ||= {}
......
......@@ -25,6 +25,14 @@ class Version < ActiveRecord::Base
validates_uniqueness_of :name, :scope => [:project_id]
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
def start_date
effective_date
end
def due_date
effective_date
end
private
def check_integrity
raise "Can't delete version" if self.fixed_issues.find(:first)
......
......@@ -106,51 +106,70 @@ pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
#
top = headers_heigth + y_start
pdf.SetFontStyle('B',7)
@issues.each do |i|
@events.each do |i|
pdf.SetY(top)
pdf.SetX(15)
pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
if i.is_a? Issue
pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
else
pdf.Cell(subject_width-15, 5, "#{l(:label_version)}: #{i.name}", "LR")
end
pdf.SetY(top)
pdf.SetX(subject_width)
pdf.Cell(g_width, 5, "", "LR")
pdf.SetY(top+1.5)
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
if i.is_a? Issue
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
i_left = ((i_start_date - @date_from)*zoom)
i_width = ((i_end_date - i_start_date + 1)*zoom)
d_width = ((i_done_date - i_start_date)*zoom)
l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
l_width ||= 0
i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
pdf.SetX(subject_width + i_left)
pdf.SetFillColor(200,200,200)
pdf.Cell(i_width, 2, "", 0, 0, "", 1)
i_left = ((i_start_date - @date_from)*zoom)
i_width = ((i_end_date - i_start_date + 1)*zoom)
d_width = ((i_done_date - i_start_date)*zoom)
l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
l_width ||= 0
pdf.SetY(top+1.5)
pdf.SetX(subject_width + i_left)
pdf.SetFillColor(200,200,200)
pdf.Cell(i_width, 2, "", 0, 0, "", 1)
if l_width > 0
if l_width > 0
pdf.SetY(top+1.5)
pdf.SetX(subject_width + i_left)
pdf.SetFillColor(255,100,100)
pdf.Cell(l_width, 2, "", 0, 0, "", 1)
end
if d_width > 0
pdf.SetY(top+1.5)
pdf.SetX(subject_width + i_left)
pdf.SetFillColor(100,100,255)
pdf.Cell(d_width, 2, "", 0, 0, "", 1)
end
pdf.SetY(top+1.5)
pdf.SetX(subject_width + i_left + i_width)
pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
else
i_left = ((i.start_date - @date_from)*zoom)
pdf.SetX(subject_width + i_left)
pdf.SetFillColor(255,100,100)
pdf.Cell(l_width, 2, "", 0, 0, "", 1)
end
if d_width > 0
pdf.SetFillColor(50,200,50)
pdf.Cell(2, 2, "", 0, 0, "", 1)
pdf.SetY(top+1.5)
pdf.SetX(subject_width + i_left)
pdf.SetFillColor(100,100,255)
pdf.Cell(d_width, 2, "", 0, 0, "", 1)
pdf.SetX(subject_width + i_left + 3)
pdf.Cell(30, 2, "#{i.name}")
end
pdf.SetY(top+1.5)
pdf.SetX(subject_width + i_left + i_width)
pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
top = top + 5
pdf.SetDrawColor(200, 200, 200)
......
......@@ -67,7 +67,7 @@ if @zoom >1
end
g_width = (@date_to - @date_from + 1)*zoom
g_height = [(20 * @issues.length + 6)+150, 206].max
g_height = [(20 * @events.length + 6)+150, 206].max
t_height = g_height + headers_height
%>
......@@ -83,11 +83,15 @@ t_height = g_height + headers_height
# Tasks subjects
#
top = headers_height + 8
@issues.each do |i| %>
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;">
<small><%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
<%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small>
</div>
@events.each do |i| %>
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
<% if i.is_a? Issue %>
<%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
<%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %>
<% else %>
<strong><%= "#{l(:label_version)}: #{i.name}" %></strong>
<% end %>
</small></div>
<% top = top + 20
end %>
</div>
......@@ -180,8 +184,8 @@ if Date.today >= @date_from and Date.today <= @date_to %>
# Tasks
#
top = headers_height + 10
@issues.each do |i| %>
<%
@events.each do |i|
if i.is_a? Issue
i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
......@@ -212,6 +216,14 @@ top = headers_height + 10
<span class="tip">
<%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
</span></div>
<% else
i_left = ((i.start_date - @date_from)*zoom).floor
%>
<div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
<div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
<strong><%= i.name %></strong>
</div>
<% end %>
<% top = top + 20
end %>
</div>
......
......@@ -559,6 +559,7 @@ font-size: 1em;
.task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
.task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
.task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
.milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; }
/***** Tooltips ******/
.tooltip{position:relative;z-index:24;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment