##// END OF EJS Templates
Fixed an unicode problem on gantt (first letter of the day name)...
Jean-Philippe Lang -
r498:78b5e57a4ad8
parent child
Show More
@@ -1,188 +1,188
1 1 <%
2 2 pdf=IfpdfHelper::IFPDF.new(current_language)
3 3 pdf.SetTitle("#{@project.name} - #{l(:label_gantt)}")
4 4 pdf.AliasNbPages
5 5 pdf.footer_date = format_date(Date.today)
6 6 pdf.AddPage("L")
7 7 pdf.SetFontStyle('B',12)
8 8 pdf.SetX(15)
9 9 pdf.Cell(70, 20, @project.name)
10 10 pdf.Ln
11 11 pdf.SetFontStyle('B',9)
12 12
13 13 subject_width = 70
14 14 header_heigth = 5
15 15
16 16 headers_heigth = header_heigth
17 17 show_weeks = false
18 18 show_days = false
19 19
20 20 if @months < 7
21 21 show_weeks = true
22 22 headers_heigth = 2*header_heigth
23 23 if @months < 3
24 24 show_days = true
25 25 headers_heigth = 3*header_heigth
26 26 end
27 27 end
28 28
29 29 g_width = 210
30 30 zoom = (g_width) / (@date_to - @date_from + 1)
31 31 g_height = 120
32 32 t_height = g_height + headers_heigth
33 33
34 34 y_start = pdf.GetY
35 35
36 36
37 37 #
38 38 # Months headers
39 39 #
40 40 month_f = @date_from
41 41 left = subject_width
42 42 height = header_heigth
43 43 @months.times do
44 44 width = ((month_f >> 1) - month_f) * zoom
45 45 pdf.SetY(y_start)
46 46 pdf.SetX(left)
47 47 pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
48 48 left = left + width
49 49 month_f = month_f >> 1
50 50 end
51 51
52 52 #
53 53 # Weeks headers
54 54 #
55 55 if show_weeks
56 56 left = subject_width
57 57 height = header_heigth
58 58 if @date_from.cwday == 1
59 59 # @date_from is monday
60 60 week_f = @date_from
61 61 else
62 62 # find next monday after @date_from
63 63 week_f = @date_from + (7 - @date_from.cwday + 1)
64 64 width = (7 - @date_from.cwday + 1) * zoom-1
65 65 pdf.SetY(y_start + header_heigth)
66 66 pdf.SetX(left)
67 67 pdf.Cell(width + 1, height, "", "LTR")
68 68 left = left + width+1
69 69 end
70 70 while week_f <= @date_to
71 71 width = (week_f + 6 <= @date_to) ? 7 * zoom : (@date_to - week_f + 1) * zoom
72 72 pdf.SetY(y_start + header_heigth)
73 73 pdf.SetX(left)
74 74 pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
75 75 left = left + width
76 76 week_f = week_f+7
77 77 end
78 78 end
79 79
80 80 #
81 81 # Days headers
82 82 #
83 83 if show_days
84 84 left = subject_width
85 85 height = header_heigth
86 86 wday = @date_from.cwday
87 87 pdf.SetFontStyle('B',7)
88 88 (@date_to - @date_from + 1).to_i.times do
89 89 width = zoom
90 90 pdf.SetY(y_start + 2 * header_heigth)
91 91 pdf.SetX(left)
92 pdf.Cell(width, height, day_name(wday)[0,1], "LTR", 0, "C")
92 pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C")
93 93 left = left + width
94 94 wday = wday + 1
95 95 wday = 1 if wday > 7
96 96 end
97 97 end
98 98
99 99 pdf.SetY(y_start)
100 100 pdf.SetX(15)
101 101 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
102 102
103 103
104 104 #
105 105 # Tasks
106 106 #
107 107 top = headers_heigth + y_start
108 108 pdf.SetFontStyle('B',7)
109 109 @events.each do |i|
110 110 pdf.SetY(top)
111 111 pdf.SetX(15)
112 112
113 113 if i.is_a? Issue
114 114 pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR")
115 115 else
116 116 pdf.Cell(subject_width-15, 5, "#{l(:label_version)}: #{i.name}", "LR")
117 117 end
118 118
119 119 pdf.SetY(top)
120 120 pdf.SetX(subject_width)
121 121 pdf.Cell(g_width, 5, "", "LR")
122 122
123 123 pdf.SetY(top+1.5)
124 124
125 125 if i.is_a? Issue
126 126 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
127 127 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
128 128
129 129 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
130 130 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
131 131 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
132 132
133 133 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
134 134
135 135 i_left = ((i_start_date - @date_from)*zoom)
136 136 i_width = ((i_end_date - i_start_date + 1)*zoom)
137 137 d_width = ((i_done_date - i_start_date)*zoom)
138 138 l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date
139 139 l_width ||= 0
140 140
141 141 pdf.SetX(subject_width + i_left)
142 142 pdf.SetFillColor(200,200,200)
143 143 pdf.Cell(i_width, 2, "", 0, 0, "", 1)
144 144
145 145 if l_width > 0
146 146 pdf.SetY(top+1.5)
147 147 pdf.SetX(subject_width + i_left)
148 148 pdf.SetFillColor(255,100,100)
149 149 pdf.Cell(l_width, 2, "", 0, 0, "", 1)
150 150 end
151 151 if d_width > 0
152 152 pdf.SetY(top+1.5)
153 153 pdf.SetX(subject_width + i_left)
154 154 pdf.SetFillColor(100,100,255)
155 155 pdf.Cell(d_width, 2, "", 0, 0, "", 1)
156 156 end
157 157
158 158 pdf.SetY(top+1.5)
159 159 pdf.SetX(subject_width + i_left + i_width)
160 160 pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%")
161 161 else
162 162 i_left = ((i.start_date - @date_from)*zoom)
163 163
164 164 pdf.SetX(subject_width + i_left)
165 165 pdf.SetFillColor(50,200,50)
166 166 pdf.Cell(2, 2, "", 0, 0, "", 1)
167 167
168 168 pdf.SetY(top+1.5)
169 169 pdf.SetX(subject_width + i_left + 3)
170 170 pdf.Cell(30, 2, "#{i.name}")
171 171 end
172 172
173 173
174 174 top = top + 5
175 175 pdf.SetDrawColor(200, 200, 200)
176 176 pdf.Line(15, top, subject_width+g_width, top)
177 177 if pdf.GetY() > 180
178 178 pdf.AddPage("L")
179 179 top = 20
180 180 pdf.Line(15, top, subject_width+g_width, top)
181 181 end
182 182 pdf.SetDrawColor(0, 0, 0)
183 183 end
184 184
185 185 pdf.Line(15, top, subject_width+g_width, top)
186 186
187 187 %>
188 188 <%= pdf.Output %> No newline at end of file
@@ -1,239 +1,239
1 1 <div class="contextual">
2 2 <%= l(:label_export_to) %>
3 3 <%= link_to 'PDF', {:zoom => @zoom, :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects], :output => 'pdf'}, :class => 'icon icon-pdf' %>
4 4 </div>
5 5
6 6 <h2><%= l(:label_gantt) %></h2>
7 7
8 8 <% form_tag do %>
9 9 <table width="100%">
10 10 <tr>
11 11 <td align="left">
12 12 <input type="text" name="months" size="2" value="<%= @months %>" />
13 13 <%= l(:label_months_from) %>
14 14 <%= select_month(@month_from, :prefix => "month", :discard_type => true) %>
15 15 <%= select_year(@year_from, :prefix => "year", :discard_type => true) %>
16 16 <%= hidden_field_tag 'zoom', @zoom %>
17 17 <%= submit_tag l(:button_submit), :class => "button-small" %>
18 18 </td>
19 19 <td>
20 20 <%= toggle_link l(:label_options), "trackerselect" %>
21 21 <div id="trackerselect" class="rightbox overlay" style="width:140px; display: none;">
22 22 <p><strong><%=l(:label_tracker_plural)%></strong></p>
23 23 <% @trackers.each do |tracker| %>
24 24 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
25 25 <%= tracker.name %><br />
26 26 <% end %>
27 27 <% if @project.children.any? %>
28 28 <p><strong><%=l(:label_subproject_plural)%></strong></p>
29 29 <%= check_box_tag "with_subprojects", 1, params[:with_subprojects] %> <%= l(:general_text_Yes) %>
30 30 <% end %>
31 31 <p><center><%= submit_tag l(:button_apply), :class => 'button-small' %></center></p>
32 32 </div>
33 33 </td>
34 34 <td align="right">
35 35 <%= if @zoom < 4
36 36 link_to image_tag('zoom_in.png'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
37 37 else
38 38 image_tag 'zoom_in_g.png'
39 39 end %>
40 40 <%= if @zoom > 1
41 41 link_to image_tag('zoom_out.png'),{:zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects]}
42 42 else
43 43 image_tag 'zoom_out_g.png'
44 44 end %>
45 45 </td>
46 46 </tr>
47 47 </table>
48 48 <% end %>
49 49
50 50 <% zoom = 1
51 51 @zoom.times { zoom = zoom * 2 }
52 52
53 53 subject_width = 330
54 54 header_heigth = 18
55 55
56 56 headers_height = header_heigth
57 57 show_weeks = false
58 58 show_days = false
59 59
60 60 if @zoom >1
61 61 show_weeks = true
62 62 headers_height = 2*header_heigth
63 63 if @zoom > 2
64 64 show_days = true
65 65 headers_height = 3*header_heigth
66 66 end
67 67 end
68 68
69 69 g_width = (@date_to - @date_from + 1)*zoom
70 70 g_height = [(20 * @events.length + 6)+150, 206].max
71 71 t_height = g_height + headers_height
72 72 %>
73 73
74 74 <table width="100%" style="border:0; border-collapse: collapse;">
75 75 <tr>
76 76 <td style="width:<%= subject_width %>px;">
77 77
78 78 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
79 79 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
80 80 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
81 81 <%
82 82 #
83 83 # Tasks subjects
84 84 #
85 85 top = headers_height + 8
86 86 @events.each do |i| %>
87 87 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
88 88 <% if i.is_a? Issue %>
89 89 <%= link_to_issue i %><%= " (#{i.project.name})" unless @project && @project == i.project %>:
90 90 <%=h i.subject %>
91 91 <% else %>
92 92 <strong><%= "#{l(:label_version)}: #{i.name}" %></strong>
93 93 <% end %>
94 94 </small></div>
95 95 <% top = top + 20
96 96 end %>
97 97 </div>
98 98 </td>
99 99 <td>
100 100
101 101 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
102 102 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
103 103 <%
104 104 #
105 105 # Months headers
106 106 #
107 107 month_f = @date_from
108 108 left = 0
109 109 height = (show_weeks ? header_heigth : header_heigth + g_height)
110 110 @months.times do
111 111 width = ((month_f >> 1) - month_f) * zoom - 1
112 112 %>
113 113 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
114 114 <%= link_to "#{month_f.year}-#{month_f.month}", { :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] }, :title => "#{month_name(month_f.month)} #{month_f.year}"%>
115 115 </div>
116 116 <%
117 117 left = left + width + 1
118 118 month_f = month_f >> 1
119 119 end %>
120 120
121 121 <%
122 122 #
123 123 # Weeks headers
124 124 #
125 125 if show_weeks
126 126 left = 0
127 127 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
128 128 if @date_from.cwday == 1
129 129 # @date_from is monday
130 130 week_f = @date_from
131 131 else
132 132 # find next monday after @date_from
133 133 week_f = @date_from + (7 - @date_from.cwday + 1)
134 134 width = (7 - @date_from.cwday + 1) * zoom-1
135 135 %>
136 136 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
137 137 <%
138 138 left = left + width+1
139 139 end %>
140 140 <%
141 141 while week_f <= @date_to
142 142 width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1
143 143 %>
144 144 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
145 145 <small><%= week_f.cweek if width >= 16 %></small>
146 146 </div>
147 147 <%
148 148 left = left + width+1
149 149 week_f = week_f+7
150 150 end
151 151 end %>
152 152
153 153 <%
154 154 #
155 155 # Days headers
156 156 #
157 157 if show_days
158 158 left = 0
159 159 height = g_height + header_heigth - 1
160 160 wday = @date_from.cwday
161 161 (@date_to - @date_from + 1).to_i.times do
162 162 width = zoom - 1
163 163 %>
164 164 <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">
165 <%= day_name(wday)[0,1] %>
165 <%= day_name(wday).first %>
166 166 </div>
167 167 <%
168 168 left = left + width+1
169 169 wday = wday + 1
170 170 wday = 1 if wday > 7
171 171 end
172 172 end %>
173 173
174 174 <%
175 175 #
176 176 # Today red line
177 177 #
178 178 if Date.today >= @date_from and Date.today <= @date_to %>
179 179 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
180 180 <% end %>
181 181
182 182 <%
183 183 #
184 184 # Tasks
185 185 #
186 186 top = headers_height + 10
187 187 @events.each do |i|
188 188 if i.is_a? Issue
189 189 i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from )
190 190 i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to )
191 191
192 192 i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor
193 193 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
194 194 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
195 195
196 196 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
197 197
198 198 i_left = ((i_start_date - @date_from)*zoom).floor
199 199 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
200 200 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
201 201 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
202 202 %>
203 203 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div>
204 204 <% if l_width > 0 %>
205 205 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div>
206 206 <% end %>
207 207 <% if d_width > 0 %>
208 208 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div>
209 209 <% end %>
210 210 <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
211 211 <%= i.status.name %>
212 212 <%= (i.done_ratio).to_i %>%
213 213 </div>
214 214 <% # === tooltip === %>
215 215 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
216 216 <span class="tip">
217 217 <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
218 218 </span></div>
219 219 <% else
220 220 i_left = ((i.start_date - @date_from)*zoom).floor
221 221 %>
222 222 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
223 223 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
224 224 <strong><%= i.name %></strong>
225 225 </div>
226 226 <% end %>
227 227 <% top = top + 20
228 228 end %>
229 229 </div>
230 230 </td>
231 231 </tr>
232 232 </table>
233 233
234 234 <table width="100%">
235 235 <tr>
236 236 <td align="left"><%= link_to ('&#171; ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
237 237 <td align="right"><%= link_to (l(:label_next) + ' &#187;'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %></td>
238 238 </tr>
239 239 </table> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now