##// 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 @date_from = Date.civil(@year_from, @month_from, 1)
592 @date_from = Date.civil(@year_from, @month_from, 1)
593 @date_to = (@date_from >> @months) - 1
593 @date_to = (@date_from >> @months) - 1
594
594
595 @events = []
595 @project.issues_with_subprojects(params[:with_subprojects]) do
596 @project.issues_with_subprojects(params[:with_subprojects]) do
596 @issues = Issue.find(:all,
597 @events += Issue.find(:all,
597 :order => "start_date, due_date",
598 :order => "start_date, due_date",
598 :include => [:tracker, :status, :assigned_to, :priority],
599 :include => [:tracker, :status, :assigned_to, :priority],
599 :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 :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 ) unless @selected_tracker_ids.empty?
601 ) unless @selected_tracker_ids.empty?
601 end
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 if params[:output]=='pdf'
606 if params[:output]=='pdf'
605 @options_for_rfpdf ||= {}
607 @options_for_rfpdf ||= {}
@@ -25,6 +25,14 class Version < ActiveRecord::Base
25 validates_uniqueness_of :name, :scope => [:project_id]
25 validates_uniqueness_of :name, :scope => [:project_id]
26 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date
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 private
36 private
29 def check_integrity
37 def check_integrity
30 raise "Can't delete version" if self.fixed_issues.find(:first)
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 top = headers_heigth + y_start
107 top = headers_heigth + y_start
108 pdf.SetFontStyle('B',7)
108 pdf.SetFontStyle('B',7)
109 @issues.each do |i|
109 @events.each do |i|
110 pdf.SetY(top)
110 pdf.SetY(top)
111 pdf.SetX(15)
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 pdf.SetY(top)
119 pdf.SetY(top)
115 pdf.SetX(subject_width)
120 pdf.SetX(subject_width)
116 pdf.Cell(g_width, 5, "", "LR")
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 )
125 if i.is_a? Issue
119 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
126 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
120
127 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
121 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
128
122 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
129 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
123 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
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)
145 if l_width > 0
128 i_width = ((i_end_date - i_start_date + 1)*zoom)
146 pdf.SetY(top+1.5)
129 d_width = ((i_done_date - i_start_date)*zoom)
147 pdf.SetX(subject_width + i_left)
130 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
148 pdf.SetFillColor(255,100,100)
131 l_width ||= 0
149 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
132
150 end
133 pdf.SetY(top+1.5)
151 if d_width > 0
134 pdf.SetX(subject_width + i_left)
152 pdf.SetY(top+1.5)
135 pdf.SetFillColor(200,200,200)
153 pdf.SetX(subject_width + i_left)
136 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
154 pdf.SetFillColor(100,100,255)
137
155 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
138 if l_width > 0
156 end
157
139 pdf.SetY(top+1.5)
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 pdf.SetX(subject_width + i_left)
164 pdf.SetX(subject_width + i_left)
141 pdf.SetFillColor(255,100,100)
165 pdf.SetFillColor(50,200,50)
142 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
166 pdf.Cell(2, 2, "", 0, 0, "", 1)
143 end
167
144 if d_width > 0
145 pdf.SetY(top+1.5)
168 pdf.SetY(top+1.5)
146 pdf.SetX(subject_width + i_left)
169 pdf.SetX(subject_width + i_left + 3)
147 pdf.SetFillColor(100,100,255)
170 pdf.Cell(30, 2, "#{i.name}")
148 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
149 end
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 top = top + 5
174 top = top + 5
156 pdf.SetDrawColor(200, 200, 200)
175 pdf.SetDrawColor(200, 200, 200)
@@ -67,7 +67,7 if @zoom >1
67 end
67 end
68
68
69 g_width = (@date_to - @date_from + 1)*zoom
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 t_height = g_height + headers_height
71 t_height = g_height + headers_height
72 %>
72 %>
73
73
@@ -83,11 +83,15 t_height = g_height + headers_height
83 # Tasks subjects
83 # Tasks subjects
84 #
84 #
85 top = headers_height + 8
85 top = headers_height + 8
86 @issues.each do |i| %>
86 @events.each do |i| %>
87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;">
87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
88 <small><%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
88 <% if i.is_a? Issue %>
89 <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small>
89 <%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>:
90 </div>
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 <% top = top + 20
95 <% top = top + 20
92 end %>
96 end %>
93 </div>
97 </div>
@@ -180,8 +184,8 if Date.today >= @date_from and Date.today <= @date_to %>
180 # Tasks
184 # Tasks
181 #
185 #
182 top = headers_height + 10
186 top = headers_height + 10
183 @issues.each do |i| %>
187 @events.each do |i|
184 <%
188 if i.is_a? Issue
185 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
189 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
186 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
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 <span class="tip">
216 <span class="tip">
213 <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
217 <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
214 </span></div>
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 <% top = top + 20
227 <% top = top + 20
216 end %>
228 end %>
217 </div>
229 </div>
@@ -559,6 +559,7 font-size: 1em;
559 .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
559 .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
560 .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
560 .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
561 .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
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 /***** Tooltips ******/
564 /***** Tooltips ******/
564 .tooltip{position:relative;z-index:24;}
565 .tooltip{position:relative;z-index:24;}
General Comments 0
You need to be logged in to leave comments. Login now