Chris@1296
|
1 <% @gantt.view = self %>
|
Chris@1296
|
2 <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
|
Chris@1296
|
3
|
Chris@1296
|
4 <%= form_tag({:controller => 'gantts', :action => 'show',
|
Chris@1296
|
5 :project_id => @project, :month => params[:month],
|
Chris@1296
|
6 :year => params[:year], :months => params[:months]},
|
Chris@1296
|
7 :method => :get, :id => 'query_form') do %>
|
Chris@1296
|
8 <%= hidden_field_tag 'set_filter', '1' %>
|
Chris@1296
|
9 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
|
Chris@1296
|
10 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
Chris@1296
|
11 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
|
Chris@1296
|
12 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
|
Chris@1296
|
13 </div>
|
Chris@1296
|
14 </fieldset>
|
Chris@1296
|
15
|
Chris@1296
|
16 <p class="contextual">
|
Chris@1296
|
17 <%= gantt_zoom_link(@gantt, :in) %>
|
Chris@1296
|
18 <%= gantt_zoom_link(@gantt, :out) %>
|
Chris@1296
|
19 </p>
|
Chris@1296
|
20
|
Chris@1296
|
21 <p class="buttons">
|
Chris@1296
|
22 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
|
Chris@1296
|
23 <%= l(:label_months_from) %>
|
Chris@1296
|
24 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
|
Chris@1296
|
25 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
|
Chris@1296
|
26 <%= hidden_field_tag 'zoom', @gantt.zoom %>
|
Chris@1296
|
27
|
Chris@1296
|
28 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
|
Chris@1296
|
29 :class => 'icon icon-checked' %>
|
Chris@1296
|
30 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
|
Chris@1296
|
31 :class => 'icon icon-reload' %>
|
Chris@1296
|
32 </p>
|
Chris@1296
|
33 <% end %>
|
Chris@1296
|
34
|
Chris@1296
|
35 <%= error_messages_for 'query' %>
|
Chris@1296
|
36 <% if @query.valid? %>
|
Chris@1296
|
37 <%
|
Chris@1296
|
38 zoom = 1
|
Chris@1296
|
39 @gantt.zoom.times { zoom = zoom * 2 }
|
Chris@1296
|
40
|
Chris@1296
|
41 subject_width = 330
|
Chris@1296
|
42 header_heigth = 18
|
Chris@1296
|
43
|
Chris@1296
|
44 headers_height = header_heigth
|
Chris@1296
|
45 show_weeks = false
|
Chris@1296
|
46 show_days = false
|
Chris@1296
|
47
|
Chris@1296
|
48 if @gantt.zoom > 1
|
Chris@1296
|
49 show_weeks = true
|
Chris@1296
|
50 headers_height = 2 * header_heigth
|
Chris@1296
|
51 if @gantt.zoom > 2
|
Chris@1296
|
52 show_days = true
|
Chris@1296
|
53 headers_height = 3 * header_heigth
|
Chris@1296
|
54 end
|
Chris@1296
|
55 end
|
Chris@1296
|
56
|
Chris@1296
|
57 # Width of the entire chart
|
Chris@1296
|
58 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
|
Chris@1296
|
59 @gantt.render(:top => headers_height + 8,
|
Chris@1296
|
60 :zoom => zoom,
|
Chris@1296
|
61 :g_width => g_width,
|
Chris@1296
|
62 :subject_width => subject_width)
|
Chris@1296
|
63 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
|
Chris@1296
|
64 t_height = g_height + headers_height
|
Chris@1296
|
65 %>
|
Chris@1296
|
66
|
Chris@1296
|
67 <% if @gantt.truncated %>
|
Chris@1296
|
68 <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
|
Chris@1296
|
69 <% end %>
|
Chris@1296
|
70
|
Chris@1296
|
71 <table style="width:100%; border:0; border-collapse: collapse;">
|
Chris@1296
|
72 <tr>
|
Chris@1296
|
73 <td style="width:<%= subject_width %>px; padding:0px;">
|
Chris@1296
|
74 <%
|
Chris@1296
|
75 style = ""
|
Chris@1296
|
76 style += "position:relative;"
|
Chris@1296
|
77 style += "height: #{t_height + 24}px;"
|
Chris@1296
|
78 style += "width: #{subject_width + 1}px;"
|
Chris@1296
|
79 %>
|
Chris@1296
|
80 <%= content_tag(:div, :style => style) do %>
|
Chris@1296
|
81 <%
|
Chris@1296
|
82 style = ""
|
Chris@1296
|
83 style += "right:-2px;"
|
Chris@1296
|
84 style += "width: #{subject_width}px;"
|
Chris@1296
|
85 style += "height: #{headers_height}px;"
|
Chris@1296
|
86 style += 'background: #eee;'
|
Chris@1296
|
87 %>
|
Chris@1296
|
88 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
|
Chris@1296
|
89 <%
|
Chris@1296
|
90 style = ""
|
Chris@1296
|
91 style += "right:-2px;"
|
Chris@1296
|
92 style += "width: #{subject_width}px;"
|
Chris@1296
|
93 style += "height: #{t_height}px;"
|
Chris@1296
|
94 style += 'border-left: 1px solid #c0c0c0;'
|
Chris@1296
|
95 style += 'overflow: hidden;'
|
Chris@1296
|
96 %>
|
Chris@1296
|
97 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
|
Chris@1296
|
98 <%= content_tag(:div, :class => "gantt_subjects") do %>
|
Chris@1296
|
99 <%= @gantt.subjects.html_safe %>
|
Chris@1296
|
100 <% end %>
|
Chris@1296
|
101 <% end %>
|
Chris@1296
|
102 </td>
|
Chris@1296
|
103
|
Chris@1296
|
104 <td>
|
Chris@1296
|
105 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
|
Chris@1296
|
106 <%
|
Chris@1296
|
107 style = ""
|
Chris@1296
|
108 style += "width: #{g_width - 1}px;"
|
Chris@1296
|
109 style += "height: #{headers_height}px;"
|
Chris@1296
|
110 style += 'background: #eee;'
|
Chris@1296
|
111 %>
|
Chris@1296
|
112 <%= content_tag(:div, ' '.html_safe, :style => style, :class => "gantt_hdr") %>
|
Chris@1296
|
113
|
Chris@1296
|
114 <% ###### Months headers ###### %>
|
Chris@1296
|
115 <%
|
Chris@1296
|
116 month_f = @gantt.date_from
|
Chris@1296
|
117 left = 0
|
Chris@1296
|
118 height = (show_weeks ? header_heigth : header_heigth + g_height)
|
Chris@1296
|
119 %>
|
Chris@1296
|
120 <% @gantt.months.times do %>
|
Chris@1296
|
121 <%
|
Chris@1296
|
122 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
|
Chris@1296
|
123 style = ""
|
Chris@1296
|
124 style += "left: #{left}px;"
|
Chris@1296
|
125 style += "width: #{width}px;"
|
Chris@1296
|
126 style += "height: #{height}px;"
|
Chris@1296
|
127 %>
|
Chris@1296
|
128 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
|
Chris@1296
|
129 <%= link_to h("#{month_f.year}-#{month_f.month}"),
|
Chris@1296
|
130 @gantt.params.merge(:year => month_f.year, :month => month_f.month),
|
Chris@1296
|
131 :title => "#{month_name(month_f.month)} #{month_f.year}" %>
|
Chris@1296
|
132 <% end %>
|
Chris@1296
|
133 <%
|
Chris@1296
|
134 left = left + width + 1
|
Chris@1296
|
135 month_f = month_f >> 1
|
Chris@1296
|
136 %>
|
Chris@1296
|
137 <% end %>
|
Chris@1296
|
138
|
Chris@1296
|
139 <% ###### Weeks headers ###### %>
|
Chris@1296
|
140 <% if show_weeks %>
|
Chris@1296
|
141 <%
|
Chris@1296
|
142 left = 0
|
Chris@1296
|
143 height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height)
|
Chris@1296
|
144 %>
|
Chris@1296
|
145 <% if @gantt.date_from.cwday == 1 %>
|
Chris@1296
|
146 <%
|
Chris@1296
|
147 # @date_from is monday
|
Chris@1296
|
148 week_f = @gantt.date_from
|
Chris@1296
|
149 %>
|
Chris@1296
|
150 <% else %>
|
Chris@1296
|
151 <%
|
Chris@1296
|
152 # find next monday after @date_from
|
Chris@1296
|
153 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
|
Chris@1296
|
154 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
|
Chris@1296
|
155 style = ""
|
Chris@1296
|
156 style += "left: #{left}px;"
|
Chris@1296
|
157 style += "top: 19px;"
|
Chris@1296
|
158 style += "width: #{width}px;"
|
Chris@1296
|
159 style += "height: #{height}px;"
|
Chris@1296
|
160 %>
|
Chris@1296
|
161 <%= content_tag(:div, ' '.html_safe,
|
Chris@1296
|
162 :style => style, :class => "gantt_hdr") %>
|
Chris@1296
|
163 <% left = left + width + 1 %>
|
Chris@1296
|
164 <% end %>
|
Chris@1296
|
165 <% while week_f <= @gantt.date_to %>
|
Chris@1296
|
166 <%
|
Chris@1296
|
167 width = ((week_f + 6 <= @gantt.date_to) ?
|
Chris@1296
|
168 7 * zoom - 1 :
|
Chris@1296
|
169 (@gantt.date_to - week_f + 1) * zoom - 1).to_i
|
Chris@1296
|
170 style = ""
|
Chris@1296
|
171 style += "left: #{left}px;"
|
Chris@1296
|
172 style += "top: 19px;"
|
Chris@1296
|
173 style += "width: #{width}px;"
|
Chris@1296
|
174 style += "height: #{height}px;"
|
Chris@1296
|
175 %>
|
Chris@1296
|
176 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
|
Chris@1296
|
177 <%= content_tag(:small) do %>
|
Chris@1296
|
178 <%= week_f.cweek if width >= 16 %>
|
Chris@1296
|
179 <% end %>
|
Chris@1296
|
180 <% end %>
|
Chris@1296
|
181 <%
|
Chris@1296
|
182 left = left + width + 1
|
Chris@1296
|
183 week_f = week_f + 7
|
Chris@1296
|
184 %>
|
Chris@1296
|
185 <% end %>
|
Chris@1296
|
186 <% end %>
|
Chris@1296
|
187
|
Chris@1296
|
188 <% ###### Days headers ####### %>
|
Chris@1296
|
189 <% if show_days %>
|
Chris@1296
|
190 <%
|
Chris@1296
|
191 left = 0
|
Chris@1296
|
192 height = g_height + header_heigth - 1
|
Chris@1296
|
193 wday = @gantt.date_from.cwday
|
Chris@1296
|
194 %>
|
Chris@1296
|
195 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
|
Chris@1296
|
196 <%
|
Chris@1296
|
197 width = zoom - 1
|
Chris@1296
|
198 style = ""
|
Chris@1296
|
199 style += "left: #{left}px;"
|
Chris@1296
|
200 style += "top:37px;"
|
Chris@1296
|
201 style += "width: #{width}px;"
|
Chris@1296
|
202 style += "height: #{height}px;"
|
Chris@1296
|
203 style += "font-size:0.7em;"
|
Chris@1296
|
204 clss = "gantt_hdr"
|
Chris@1296
|
205 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
|
Chris@1296
|
206 %>
|
Chris@1296
|
207 <%= content_tag(:div, :style => style, :class => clss) do %>
|
Chris@1296
|
208 <%= day_letter(wday) %>
|
Chris@1296
|
209 <% end %>
|
Chris@1296
|
210 <%
|
Chris@1296
|
211 left = left + width + 1
|
Chris@1296
|
212 wday = wday + 1
|
Chris@1296
|
213 wday = 1 if wday > 7
|
Chris@1296
|
214 %>
|
Chris@1296
|
215 <% end %>
|
Chris@1296
|
216 <% end %>
|
Chris@1296
|
217
|
Chris@1296
|
218 <%= @gantt.lines.html_safe %>
|
Chris@1296
|
219
|
Chris@1296
|
220 <% ###### Today red line (excluded from cache) ###### %>
|
Chris@1296
|
221 <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
|
Chris@1296
|
222 <%
|
Chris@1296
|
223 today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
|
Chris@1296
|
224 style = ""
|
Chris@1296
|
225 style += "position: absolute;"
|
Chris@1296
|
226 style += "height: #{g_height}px;"
|
Chris@1296
|
227 style += "top: #{headers_height + 1}px;"
|
Chris@1296
|
228 style += "left: #{today_left}px;"
|
Chris@1296
|
229 style += "width:10px;"
|
Chris@1296
|
230 style += "border-left: 1px dashed red;"
|
Chris@1296
|
231 %>
|
Chris@1296
|
232 <%= content_tag(:div, ' '.html_safe, :style => style) %>
|
Chris@1296
|
233 <% end %>
|
Chris@1296
|
234
|
Chris@1296
|
235 </div>
|
Chris@1296
|
236 </td>
|
Chris@1296
|
237 </tr>
|
Chris@1296
|
238 </table>
|
Chris@1296
|
239
|
Chris@1296
|
240 <table style="width:100%">
|
Chris@1296
|
241 <tr>
|
Chris@1296
|
242 <td align="left">
|
Chris@1296
|
243 <%= link_to_content_update("\xc2\xab " + l(:label_previous),
|
Chris@1296
|
244 params.merge(@gantt.params_previous)) %>
|
Chris@1296
|
245 </td>
|
Chris@1296
|
246 <td align="right">
|
Chris@1296
|
247 <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
|
Chris@1296
|
248 params.merge(@gantt.params_next)) %>
|
Chris@1296
|
249 </td>
|
Chris@1296
|
250 </tr>
|
Chris@1296
|
251 </table>
|
Chris@1296
|
252
|
Chris@1296
|
253 <% other_formats_links do |f| %>
|
Chris@1296
|
254 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
|
Chris@1296
|
255 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
|
Chris@1296
|
256 <% end %>
|
Chris@1296
|
257 <% end # query.valid? %>
|
Chris@1296
|
258
|
Chris@1296
|
259 <% content_for :sidebar do %>
|
Chris@1296
|
260 <%= render :partial => 'issues/sidebar' %>
|
Chris@1296
|
261 <% end %>
|
Chris@1296
|
262
|
Chris@1296
|
263 <% html_title(l(:label_gantt)) -%>
|