Chris@0
|
1 <h2><%= l(:label_gantt) %></h2>
|
Chris@0
|
2
|
Chris@0
|
3 <% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
|
Chris@0
|
4 <fieldset id="filters" class="collapsible">
|
Chris@0
|
5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
Chris@0
|
6 <div>
|
Chris@0
|
7 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
|
Chris@0
|
8 </div>
|
Chris@0
|
9 </fieldset>
|
Chris@0
|
10
|
Chris@0
|
11 <p style="float:right;">
|
Chris@0
|
12 <%= gantt_zoom_link(@gantt, :in) %>
|
Chris@0
|
13 <%= gantt_zoom_link(@gantt, :out) %>
|
Chris@0
|
14 </p>
|
Chris@0
|
15
|
Chris@0
|
16 <p class="buttons">
|
Chris@0
|
17 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
|
Chris@0
|
18 <%= l(:label_months_from) %>
|
Chris@0
|
19 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
|
Chris@0
|
20 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
|
Chris@0
|
21 <%= hidden_field_tag 'zoom', @gantt.zoom %>
|
Chris@0
|
22
|
Chris@0
|
23 <%= link_to_remote l(:button_apply),
|
Chris@0
|
24 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
|
Chris@0
|
25 :update => "content",
|
Chris@0
|
26 :with => "Form.serialize('query_form')"
|
Chris@0
|
27 }, :class => 'icon icon-checked' %>
|
Chris@0
|
28
|
Chris@0
|
29 <%= link_to_remote l(:button_clear),
|
Chris@0
|
30 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
|
Chris@0
|
31 :update => "content",
|
Chris@0
|
32 }, :class => 'icon icon-reload' if @query.new_record? %>
|
Chris@0
|
33 </p>
|
Chris@0
|
34 <% end %>
|
Chris@0
|
35
|
Chris@0
|
36 <%= error_messages_for 'query' %>
|
Chris@0
|
37 <% if @query.valid? %>
|
Chris@0
|
38 <% zoom = 1
|
Chris@0
|
39 @gantt.zoom.times { zoom = zoom * 2 }
|
Chris@0
|
40
|
Chris@0
|
41 subject_width = 330
|
Chris@0
|
42 header_heigth = 18
|
Chris@0
|
43
|
Chris@0
|
44 headers_height = header_heigth
|
Chris@0
|
45 show_weeks = false
|
Chris@0
|
46 show_days = false
|
Chris@0
|
47
|
Chris@0
|
48 if @gantt.zoom >1
|
Chris@0
|
49 show_weeks = true
|
Chris@0
|
50 headers_height = 2*header_heigth
|
Chris@0
|
51 if @gantt.zoom > 2
|
Chris@0
|
52 show_days = true
|
Chris@0
|
53 headers_height = 3*header_heigth
|
Chris@0
|
54 end
|
Chris@0
|
55 end
|
Chris@0
|
56
|
Chris@0
|
57 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
|
Chris@0
|
58 g_height = [(20 * @gantt.events.length + 6)+150, 206].max
|
Chris@0
|
59 t_height = g_height + headers_height
|
Chris@0
|
60 %>
|
Chris@0
|
61
|
Chris@0
|
62 <table width="100%" style="border:0; border-collapse: collapse;">
|
Chris@0
|
63 <tr>
|
Chris@0
|
64 <td style="width:<%= subject_width %>px; padding:0px;">
|
Chris@0
|
65
|
Chris@0
|
66 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
|
Chris@0
|
67 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
|
Chris@0
|
68 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
|
Chris@0
|
69 <%
|
Chris@0
|
70 #
|
Chris@0
|
71 # Tasks subjects
|
Chris@0
|
72 #
|
Chris@0
|
73 top = headers_height + 8
|
Chris@0
|
74 @gantt.events.each do |i|
|
Chris@0
|
75 left = 4 + (i.is_a?(Issue) ? i.level * 16 : 0)
|
Chris@0
|
76 %>
|
Chris@0
|
77 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:<%= left %>px;overflow:hidden;"><small>
|
Chris@0
|
78 <% if i.is_a? Issue %>
|
Chris@0
|
79 <%= h("#{i.project} -") unless @project && @project == i.project %>
|
Chris@0
|
80 <%= link_to_issue i %>
|
Chris@0
|
81 <% else %>
|
Chris@0
|
82 <span class="icon icon-package">
|
Chris@0
|
83 <%= link_to_version i %>
|
Chris@0
|
84 </span>
|
Chris@0
|
85 <% end %>
|
Chris@0
|
86 </small></div>
|
Chris@0
|
87 <% top = top + 20
|
Chris@0
|
88 end %>
|
Chris@0
|
89 </div>
|
Chris@0
|
90 </td>
|
Chris@0
|
91 <td>
|
Chris@0
|
92
|
Chris@0
|
93 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
|
Chris@0
|
94 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"> </div>
|
Chris@0
|
95 <%
|
Chris@0
|
96 #
|
Chris@0
|
97 # Months headers
|
Chris@0
|
98 #
|
Chris@0
|
99 month_f = @gantt.date_from
|
Chris@0
|
100 left = 0
|
Chris@0
|
101 height = (show_weeks ? header_heigth : header_heigth + g_height)
|
Chris@0
|
102 @gantt.months.times do
|
Chris@0
|
103 width = ((month_f >> 1) - month_f) * zoom - 1
|
Chris@0
|
104 %>
|
Chris@0
|
105 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
|
Chris@0
|
106 <%= link_to "#{month_f.year}-#{month_f.month}", @gantt.params.merge(:year => month_f.year, :month => month_f.month), :title => "#{month_name(month_f.month)} #{month_f.year}"%>
|
Chris@0
|
107 </div>
|
Chris@0
|
108 <%
|
Chris@0
|
109 left = left + width + 1
|
Chris@0
|
110 month_f = month_f >> 1
|
Chris@0
|
111 end %>
|
Chris@0
|
112
|
Chris@0
|
113 <%
|
Chris@0
|
114 #
|
Chris@0
|
115 # Weeks headers
|
Chris@0
|
116 #
|
Chris@0
|
117 if show_weeks
|
Chris@0
|
118 left = 0
|
Chris@0
|
119 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
|
Chris@0
|
120 if @gantt.date_from.cwday == 1
|
Chris@0
|
121 # @date_from is monday
|
Chris@0
|
122 week_f = @gantt.date_from
|
Chris@0
|
123 else
|
Chris@0
|
124 # find next monday after @date_from
|
Chris@0
|
125 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
|
Chris@0
|
126 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
|
Chris@0
|
127 %>
|
Chris@0
|
128 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> </div>
|
Chris@0
|
129 <%
|
Chris@0
|
130 left = left + width+1
|
Chris@0
|
131 end %>
|
Chris@0
|
132 <%
|
Chris@0
|
133 while week_f <= @gantt.date_to
|
Chris@0
|
134 width = (week_f + 6 <= @gantt.date_to) ? 7 * zoom -1 : (@gantt.date_to - week_f + 1) * zoom-1
|
Chris@0
|
135 %>
|
Chris@0
|
136 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
|
Chris@0
|
137 <small><%= week_f.cweek if width >= 16 %></small>
|
Chris@0
|
138 </div>
|
Chris@0
|
139 <%
|
Chris@0
|
140 left = left + width+1
|
Chris@0
|
141 week_f = week_f+7
|
Chris@0
|
142 end
|
Chris@0
|
143 end %>
|
Chris@0
|
144
|
Chris@0
|
145 <%
|
Chris@0
|
146 #
|
Chris@0
|
147 # Days headers
|
Chris@0
|
148 #
|
Chris@0
|
149 if show_days
|
Chris@0
|
150 left = 0
|
Chris@0
|
151 height = g_height + header_heigth - 1
|
Chris@0
|
152 wday = @gantt.date_from.cwday
|
Chris@0
|
153 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
|
Chris@0
|
154 width = zoom - 1
|
Chris@0
|
155 %>
|
Chris@0
|
156 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
|
Chris@0
|
157 <%= day_name(wday).first %>
|
Chris@0
|
158 </div>
|
Chris@0
|
159 <%
|
Chris@0
|
160 left = left + width+1
|
Chris@0
|
161 wday = wday + 1
|
Chris@0
|
162 wday = 1 if wday > 7
|
Chris@0
|
163 end
|
Chris@0
|
164 end %>
|
Chris@0
|
165
|
Chris@0
|
166 <%
|
Chris@0
|
167 #
|
Chris@0
|
168 # Tasks
|
Chris@0
|
169 #
|
Chris@0
|
170 top = headers_height + 10
|
Chris@0
|
171 @gantt.events.each do |i|
|
Chris@0
|
172 if i.is_a? Issue
|
Chris@0
|
173 i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
|
Chris@0
|
174 i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
|
Chris@0
|
175
|
Chris@0
|
176 i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
|
Chris@0
|
177 i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
|
Chris@0
|
178 i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
|
Chris@0
|
179
|
Chris@0
|
180 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
|
Chris@0
|
181
|
Chris@0
|
182 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
|
Chris@0
|
183 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
|
Chris@0
|
184 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
|
Chris@0
|
185 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
|
Chris@0
|
186 css = "task " + (i.leaf? ? 'leaf' : 'parent')
|
Chris@0
|
187 %>
|
Chris@0
|
188 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="<%= css %> task_todo"><div class="left"></div> <div class="right"></div></div>
|
Chris@0
|
189 <% if l_width > 0 %>
|
Chris@0
|
190 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="<%= css %> task_late"> </div>
|
Chris@0
|
191 <% end %>
|
Chris@0
|
192 <% if d_width > 0 %>
|
Chris@0
|
193 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="<%= css %> task_done"> </div>
|
Chris@0
|
194 <% end %>
|
Chris@0
|
195 <div style="top:<%= top %>px;left:<%= i_left + i_width + 8 %>px;background:#fff;" class="<%= css %>">
|
Chris@0
|
196 <%= i.status.name %>
|
Chris@0
|
197 <%= (i.done_ratio).to_i %>%
|
Chris@0
|
198 </div>
|
Chris@0
|
199 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
|
Chris@0
|
200 <span class="tip">
|
Chris@0
|
201 <%= render_issue_tooltip i %>
|
Chris@0
|
202 </span></div>
|
Chris@0
|
203 <% else
|
Chris@0
|
204 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
|
Chris@0
|
205 %>
|
Chris@0
|
206 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone"> </div>
|
Chris@0
|
207 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
|
Chris@0
|
208 <strong><%= format_version_name i %></strong>
|
Chris@0
|
209 </div>
|
Chris@0
|
210 <% end %>
|
Chris@0
|
211 <% top = top + 20
|
Chris@0
|
212 end %>
|
Chris@0
|
213
|
Chris@0
|
214 <%
|
Chris@0
|
215 #
|
Chris@0
|
216 # Today red line (excluded from cache)
|
Chris@0
|
217 #
|
Chris@0
|
218 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
|
Chris@0
|
219 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@gantt.date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;"> </div>
|
Chris@0
|
220 <% end %>
|
Chris@0
|
221
|
Chris@0
|
222 </div>
|
Chris@0
|
223 </td>
|
Chris@0
|
224 </tr>
|
Chris@0
|
225 </table>
|
Chris@0
|
226
|
Chris@0
|
227 <table width="100%">
|
Chris@0
|
228 <tr>
|
Chris@0
|
229 <td align="left"><%= link_to_remote ('« ' + l(:label_previous)), {:url => @gantt.params_previous, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td>
|
Chris@0
|
230 <td align="right"><%= link_to_remote (l(:label_next) + ' »'), {:url => @gantt.params_next, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td>
|
Chris@0
|
231 </tr>
|
Chris@0
|
232 </table>
|
Chris@0
|
233
|
Chris@0
|
234 <% other_formats_links do |f| %>
|
Chris@0
|
235 <%= f.link_to 'PDF', :url => @gantt.params %>
|
Chris@0
|
236 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
|
Chris@0
|
237 <% end %>
|
Chris@0
|
238 <% end # query.valid? %>
|
Chris@0
|
239
|
Chris@0
|
240 <% content_for :sidebar do %>
|
Chris@0
|
241 <%= render :partial => 'issues/sidebar' %>
|
Chris@0
|
242 <% end %>
|
Chris@0
|
243
|
Chris@0
|
244 <% html_title(l(:label_gantt)) -%>
|