##// END OF EJS Templates
Added versions due dates on gantt chart....
Jean-Philippe Lang -
r425:708c3c9ec6ef
parent child
Show More
@@ -592,14 +592,16 class ProjectsController < ApplicationController
592 592 @date_from = Date.civil(@year_from, @month_from, 1)
593 593 @date_to = (@date_from >> @months) - 1
594 594
595 @events = []
595 596 @project.issues_with_subprojects(params[:with_subprojects]) do
596 @issues = Issue.find(:all,
597 @events += Issue.find(:all,
597 598 :order => "start_date, due_date",
598 599 :include => [:tracker, :status, :assigned_to, :priority],
599 600 :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]
600 601 ) unless @selected_tracker_ids.empty?
601 602 end
602 @issues ||=[]
603 @events += @project.versions.find(:all, :conditions => ["effective_date BETWEEN ? AND ?", @date_from, @date_to])
604 @events.sort! {|x,y| x.start_date <=> y.start_date }
603 605
604 606 if params[:output]=='pdf'
605 607 @options_for_rfpdf ||= {}
@@ -25,6 +25,14 class Version < ActiveRecord::Base
25 25 validates_uniqueness_of :name, :scope => [:project_id]
26 26 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
27 27
28 def start_date
29 effective_date
30 end
31
32 def due_date
33 effective_date
34 end
35
28 36 private
29 37 def check_integrity
30 38 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)
106 106 #
107 107 top = headers_heigth + y_start
108 108 pdf.SetFontStyle('B',7)
109 @issues.each do |i|
109 @events.each do |i|
110 110 pdf.SetY(top)
111 111 pdf.SetX(15)
112 pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
112
113 if i.is_a? Issue
114 pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
115 else
116 pdf.Cell(subject_width-15, 5, "#{l(:label_version)}: #{i.name}", "LR")
117 end
113 118
114 119 pdf.SetY(top)
115 120 pdf.SetX(subject_width)
116 121 pdf.Cell(g_width, 5, "", "LR")
122
123 pdf.SetY(top+1.5)
117 124
118 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
119 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
120
121 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
122 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
123 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
125 if i.is_a? Issue
126 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
127 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
128
129 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
130 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
131 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
132
133 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
134
135 i_left = ((i_start_date - @date_from)*zoom)
136 i_width = ((i_end_date - i_start_date + 1)*zoom)
137 d_width = ((i_done_date - i_start_date)*zoom)
138 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
139 l_width ||= 0
124 140
125 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
141 pdf.SetX(subject_width + i_left)
142 pdf.SetFillColor(200,200,200)
143 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
126 144
127 i_left = ((i_start_date - @date_from)*zoom)
128 i_width = ((i_end_date - i_start_date + 1)*zoom)
129 d_width = ((i_done_date - i_start_date)*zoom)
130 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
131 l_width ||= 0
132
133 pdf.SetY(top+1.5)
134 pdf.SetX(subject_width + i_left)
135 pdf.SetFillColor(200,200,200)
136 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
137
138 if l_width > 0
145 if l_width > 0
146 pdf.SetY(top+1.5)
147 pdf.SetX(subject_width + i_left)
148 pdf.SetFillColor(255,100,100)
149 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
150 end
151 if d_width > 0
152 pdf.SetY(top+1.5)
153 pdf.SetX(subject_width + i_left)
154 pdf.SetFillColor(100,100,255)
155 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
156 end
157
139 158 pdf.SetY(top+1.5)
159 pdf.SetX(subject_width + i_left + i_width)
160 pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
161 else
162 i_left = ((i.start_date - @date_from)*zoom)
163
140 164 pdf.SetX(subject_width + i_left)
141 pdf.SetFillColor(255,100,100)
142 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
143 end
144 if d_width > 0
165 pdf.SetFillColor(50,200,50)
166 pdf.Cell(2, 2, "", 0, 0, "", 1)
167
145 168 pdf.SetY(top+1.5)
146 pdf.SetX(subject_width + i_left)
147 pdf.SetFillColor(100,100,255)
148 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
169 pdf.SetX(subject_width + i_left + 3)
170 pdf.Cell(30, 2, "#{i.name}")
149 171 end
150 172
151 pdf.SetY(top+1.5)
152 pdf.SetX(subject_width + i_left + i_width)
153 pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
154 173
155 174 top = top + 5
156 175 pdf.SetDrawColor(200, 200, 200)
@@ -67,7 +67,7 if @zoom >1
67 67 end
68 68
69 69 g_width = (@date_to - @date_from + 1)*zoom
70 g_height = [(20 * @issues.length + 6)+150, 206].max
70 g_height = [(20 * @events.length + 6)+150, 206].max
71 71 t_height = g_height + headers_height
72 72 %>
73 73
@@ -83,11 +83,15 t_height = g_height + headers_height
83 83 # Tasks subjects
84 84 #
85 85 top = headers_height + 8
86 @issues.each do |i| %>
87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;">
88 <small><%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
89 <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small>
90 </div>
86 @events.each do |i| %>
87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
88 <% if i.is_a? Issue %>
89 <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
90 <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %>
91 <% else %>
92 <strong><%= "#{l(:label_version)}: #{i.name}" %></strong>
93 <% end %>
94 </small></div>
91 95 <% top = top + 20
92 96 end %>
93 97 </div>
@@ -180,8 +184,8 if Date.today >= @date_from and Date.today <= @date_to %>
180 184 # Tasks
181 185 #
182 186 top = headers_height + 10
183 @issues.each do |i| %>
184 <%
187 @events.each do |i|
188 if i.is_a? Issue
185 189 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
186 190 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
187 191
@@ -212,6 +216,14 top = headers_height + 10
212 216 <span class="tip">
213 217 <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
214 218 </span></div>
219 <% else
220 i_left = ((i.start_date - @date_from)*zoom).floor
221 %>
222 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
223 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
224 <strong><%= i.name %></strong>
225 </div>
226 <% end %>
215 227 <% top = top + 20
216 228 end %>
217 229 </div>
@@ -559,6 +559,7 font-size: 1em;
559 559 .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
560 560 .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
561 561 .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
562 .milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; }
562 563
563 564 /***** Tooltips ******/
564 565 .tooltip{position:relative;z-index:24;}
General Comments 0
You need to be logged in to leave comments. Login now