@@ -1,168 +1,168 | |||
|
1 | 1 | <% |
|
2 | 2 | pdf=IfpdfHelper::IFPDF.new |
|
3 | 3 | pdf.AliasNbPages |
|
4 | 4 | pdf.footer_date = format_date(Date.today) |
|
5 | 5 | pdf.AddPage("L") |
|
6 | 6 | pdf.SetFont('Arial','B',12) |
|
7 | 7 | pdf.SetX(15) |
|
8 | 8 | pdf.Cell(70, 20, @project.name) |
|
9 | 9 | pdf.Ln |
|
10 | 10 | pdf.SetFont('Arial','B',9) |
|
11 | 11 | |
|
12 | 12 | subject_width = 70 |
|
13 | 13 | header_heigth = 5 |
|
14 | 14 | |
|
15 | 15 | headers_heigth = header_heigth |
|
16 | 16 | show_weeks = false |
|
17 | 17 | show_days = false |
|
18 | 18 | |
|
19 | 19 | if @months < 7 |
|
20 | 20 | show_weeks = true |
|
21 | 21 | headers_heigth = 2*header_heigth |
|
22 | 22 | if @months < 3 |
|
23 | 23 | show_days = true |
|
24 | 24 | headers_heigth = 3*header_heigth |
|
25 | 25 | end |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | g_width = 210 |
|
29 | 29 | zoom = (g_width) / (@date_to - @date_from + 1) |
|
30 | 30 | g_height = 120 |
|
31 | 31 | t_height = g_height + headers_heigth |
|
32 | 32 | |
|
33 | 33 | y_start = pdf.GetY |
|
34 | 34 | |
|
35 | 35 | |
|
36 | 36 | # |
|
37 | 37 | # Months headers |
|
38 | 38 | # |
|
39 | 39 | month_f = @date_from |
|
40 | 40 | left = subject_width |
|
41 | 41 | height = header_heigth |
|
42 | 42 | @months.times do |
|
43 | 43 | width = ((month_f >> 1) - month_f) * zoom |
|
44 | 44 | pdf.SetY(y_start) |
|
45 | 45 | pdf.SetX(left) |
|
46 | 46 | pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C") |
|
47 | 47 | left = left + width |
|
48 | 48 | month_f = month_f >> 1 |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | # |
|
52 | 52 | # Weeks headers |
|
53 | 53 | # |
|
54 | 54 | if show_weeks |
|
55 | 55 | left = subject_width |
|
56 | 56 | height = header_heigth |
|
57 | 57 | if @date_from.cwday == 1 |
|
58 | 58 | # @date_from is monday |
|
59 | 59 | week_f = @date_from |
|
60 | 60 | else |
|
61 | 61 | # find next monday after @date_from |
|
62 | 62 | week_f = @date_from + (7 - @date_from.cwday + 1) |
|
63 | 63 | width = (7 - @date_from.cwday + 1) * zoom-1 |
|
64 | 64 | pdf.SetY(y_start + header_heigth) |
|
65 | 65 | pdf.SetX(left) |
|
66 | 66 | pdf.Cell(width + 1, height, "", "LTR") |
|
67 | 67 | left = left + width+1 |
|
68 | 68 | end |
|
69 | while week_f < @date_to | |
|
69 | while week_f <= @date_to | |
|
70 | 70 | width = (week_f + 6 <= @date_to) ? 7 * zoom : (@date_to - week_f + 1) * zoom |
|
71 | 71 | pdf.SetY(y_start + header_heigth) |
|
72 | 72 | pdf.SetX(left) |
|
73 | pdf.Cell(width, height, week_f.cweek.to_s, "LTR", 0, "C") | |
|
73 | pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C") | |
|
74 | 74 | left = left + width |
|
75 | 75 | week_f = week_f+7 |
|
76 | 76 | end |
|
77 | 77 | end |
|
78 | 78 | |
|
79 | 79 | # |
|
80 | 80 | # Days headers |
|
81 | 81 | # |
|
82 | 82 | if show_days |
|
83 | 83 | left = subject_width |
|
84 | 84 | height = header_heigth |
|
85 | 85 | wday = @date_from.cwday |
|
86 | 86 | pdf.SetFont('Arial','B',7) |
|
87 | 87 | (@date_to - @date_from + 1).to_i.times do |
|
88 | 88 | width = zoom |
|
89 | 89 | pdf.SetY(y_start + 2 * header_heigth) |
|
90 | 90 | pdf.SetX(left) |
|
91 | 91 | pdf.Cell(width, height, day_name(wday)[0,1], "LTR", 0, "C") |
|
92 | 92 | left = left + width |
|
93 | 93 | wday = wday + 1 |
|
94 | 94 | wday = 1 if wday > 7 |
|
95 | 95 | end |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | pdf.SetY(y_start) |
|
99 | 99 | pdf.SetX(15) |
|
100 | 100 | pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1) |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | # |
|
104 | 104 | # Tasks |
|
105 | 105 | # |
|
106 | 106 | top = headers_heigth + y_start |
|
107 | 107 | pdf.SetFont('Arial','B',7) |
|
108 | 108 | @issues.each do |i| |
|
109 | 109 | pdf.SetY(top) |
|
110 | 110 | pdf.SetX(15) |
|
111 | 111 | pdf.Cell(subject_width-15, 5, "#{i.tracker.name} #{i.id}: #{i.subject}".sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)'), "LR") |
|
112 | 112 | |
|
113 | 113 | pdf.SetY(top) |
|
114 | 114 | pdf.SetX(subject_width) |
|
115 | 115 | pdf.Cell(g_width, 5, "", "LR") |
|
116 | 116 | |
|
117 | 117 | i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from ) |
|
118 | 118 | i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to ) |
|
119 | 119 | |
|
120 | 120 | i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor |
|
121 | 121 | i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date ) |
|
122 | 122 | i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date ) |
|
123 | 123 | |
|
124 | 124 | i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today |
|
125 | 125 | |
|
126 | 126 | i_left = ((i_start_date - @date_from)*zoom) |
|
127 | 127 | i_width = ((i_end_date - i_start_date + 1)*zoom) |
|
128 | 128 | d_width = ((i_done_date - i_start_date)*zoom) |
|
129 | 129 | l_width = ((i_late_date - i_start_date+1)*zoom) if i_late_date |
|
130 | 130 | l_width ||= 0 |
|
131 | 131 | |
|
132 | 132 | pdf.SetY(top+1.5) |
|
133 | 133 | pdf.SetX(subject_width + i_left) |
|
134 | 134 | pdf.SetFillColor(200,200,200) |
|
135 | 135 | pdf.Cell(i_width, 2, "", 0, 0, "", 1) |
|
136 | 136 | |
|
137 | 137 | if l_width > 0 |
|
138 | 138 | pdf.SetY(top+1.5) |
|
139 | 139 | pdf.SetX(subject_width + i_left) |
|
140 | 140 | pdf.SetFillColor(255,100,100) |
|
141 | 141 | pdf.Cell(l_width, 2, "", 0, 0, "", 1) |
|
142 | 142 | end |
|
143 | 143 | if d_width > 0 |
|
144 | 144 | pdf.SetY(top+1.5) |
|
145 | 145 | pdf.SetX(subject_width + i_left) |
|
146 | 146 | pdf.SetFillColor(100,100,255) |
|
147 | 147 | pdf.Cell(d_width, 2, "", 0, 0, "", 1) |
|
148 | 148 | end |
|
149 | 149 | |
|
150 | 150 | pdf.SetY(top+1.5) |
|
151 | 151 | pdf.SetX(subject_width + i_left + i_width) |
|
152 | 152 | pdf.Cell(30, 2, "#{i.status.name} #{i.done_ratio}%") |
|
153 | 153 | |
|
154 | 154 | top = top + 5 |
|
155 | 155 | pdf.SetDrawColor(200, 200, 200) |
|
156 | 156 | pdf.Line(15, top, subject_width+g_width, top) |
|
157 | 157 | if pdf.GetY() > 180 |
|
158 | 158 | pdf.AddPage("L") |
|
159 | 159 | top = 20 |
|
160 | 160 | pdf.Line(15, top, subject_width+g_width, top) |
|
161 | 161 | end |
|
162 | 162 | pdf.SetDrawColor(0, 0, 0) |
|
163 | 163 | end |
|
164 | 164 | |
|
165 | 165 | pdf.Line(15, top, subject_width+g_width, top) |
|
166 | 166 | |
|
167 | 167 | %> |
|
168 | 168 | <%= pdf.Output %> No newline at end of file |
@@ -1,241 +1,242 | |||
|
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, :output => 'pdf'}, :class => 'pic picPdf' %> |
|
4 | 4 | </div> |
|
5 | 5 | |
|
6 | 6 | <h2><%= l(:label_gantt) %></h2> |
|
7 | 7 | |
|
8 | 8 | <table width="100%"> |
|
9 | 9 | <tr> |
|
10 | 10 | <td align="left"> |
|
11 | 11 | <%= start_form_tag %> |
|
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 | <%= end_form_tag %> |
|
19 | 19 | </td> |
|
20 | 20 | <td align="right"> |
|
21 | 21 | <%= if @zoom < 4 |
|
22 | 22 | link_to image_tag('zoom_in'), {:zoom => (@zoom+1), :year => @year_from, :month => @month_from, :months => @months} |
|
23 | 23 | else |
|
24 | 24 | image_tag 'zoom_in_g' |
|
25 | 25 | end %> |
|
26 | 26 | <%= if @zoom > 1 |
|
27 | 27 | link_to image_tag('zoom_out'), :zoom => (@zoom-1), :year => @year_from, :month => @month_from, :months => @months |
|
28 | 28 | else |
|
29 | 29 | image_tag 'zoom_out_g' |
|
30 | 30 | end %> |
|
31 | 31 | </td> |
|
32 | 32 | </tr> |
|
33 | 33 | </table> |
|
34 | 34 | <br /> |
|
35 | 35 | |
|
36 | 36 | <style> |
|
37 | 37 | .m_bg { |
|
38 | 38 | position:absolute; |
|
39 | 39 | top:0; |
|
40 | 40 | height:16px; |
|
41 | 41 | border-top: 1px solid #c0c0c0; |
|
42 | 42 | border-bottom: 1px solid #c0c0c0; |
|
43 | 43 | border-right: 1px solid #c0c0c0; |
|
44 | 44 | text-align: center; |
|
45 | overflow: hidden; | |
|
45 | 46 | } |
|
46 | 47 | |
|
47 | 48 | .task { |
|
48 | 49 | position: absolute; |
|
49 | 50 | height:8px; |
|
50 | 51 | font-size:0.8em; |
|
51 | 52 | color:#888; |
|
52 | 53 | background:#aaa; |
|
53 | 54 | padding:0; |
|
54 | 55 | margin:0; |
|
55 | 56 | line-height:0.8em; |
|
56 | 57 | } |
|
57 | 58 | |
|
58 | 59 | .task_late { |
|
59 | 60 | background:#f66; |
|
60 | 61 | } |
|
61 | 62 | |
|
62 | 63 | .task_done { |
|
63 | 64 | background:#66f; |
|
64 | 65 | } |
|
65 | 66 | </style> |
|
66 | 67 | |
|
67 | 68 | <% zoom = 1 |
|
68 | 69 | @zoom.times { zoom = zoom * 2 } |
|
69 | 70 | |
|
70 | 71 | subject_width = 260 |
|
71 | 72 | header_heigth = 18 |
|
72 | 73 | |
|
73 | 74 | headers_heigth = header_heigth |
|
74 | 75 | show_weeks = false |
|
75 | 76 | show_days = false |
|
76 | 77 | |
|
77 | 78 | if @zoom >1 |
|
78 | 79 | show_weeks = true |
|
79 | 80 | headers_heigth = 2*header_heigth |
|
80 | 81 | if @zoom > 2 |
|
81 | 82 | show_days = true |
|
82 | 83 | headers_heigth = 3*header_heigth |
|
83 | 84 | end |
|
84 | 85 | end |
|
85 | 86 | |
|
86 | 87 | g_width = (@date_to - @date_from + 1)*zoom |
|
87 | 88 | g_height = [(20 * @issues.length + 6), 206].max |
|
88 | 89 | t_height = g_height + headers_heigth |
|
89 | 90 | %> |
|
90 | 91 | |
|
91 | 92 | <table width="100%" border=0 cellspacing=0 cellpading=0> |
|
92 | 93 | <tr> |
|
93 | 94 | <td width=260> |
|
94 | 95 | |
|
95 | 96 | <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> |
|
96 | 97 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_heigth %>px;" class="m_bg"></div> |
|
97 | 98 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;" class="m_bg"></div> |
|
98 | 99 | <% |
|
99 | 100 | # |
|
100 | 101 | # Tasks subjects |
|
101 | 102 | # |
|
102 | 103 | top = headers_heigth + 8 |
|
103 | 104 | @issues.each do |i| %> |
|
104 | 105 | <div style="position: absolute;line-height:1em;height:16px;top:<%= top %>px;left:4px;width:<%= subject_width - 5 %>px;overflow:hidden;"> |
|
105 | <small><%= link_to "#{i.tracker.name} ##{i.id}", :controller => 'issues', :action => 'show', :id => i %>: | |
|
106 | <small><%= link_to "#{i.tracker.name} ##{i.id}", { :controller => 'issues', :action => 'show', :id => i }, :title => "#{i.subject}" %>: | |
|
106 | 107 | <%=h i.subject.sub(/^(.{30}[^\s]*\s).*$/, '\1 (...)') %></small> |
|
107 | 108 | </div> |
|
108 | 109 | <% top = top + 20 |
|
109 | 110 | end %> |
|
110 | 111 | </div> |
|
111 | 112 | </td> |
|
112 | 113 | <td> |
|
113 | 114 | |
|
114 | 115 | <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width %>;overflow:auto;"> |
|
115 | 116 | <div style="width:<%= g_width-1 %>px;height:<%= headers_heigth %>px;" class="m_bg"> </div> |
|
116 | 117 | <% |
|
117 | 118 | # |
|
118 | 119 | # Months headers |
|
119 | 120 | # |
|
120 | 121 | month_f = @date_from |
|
121 | 122 | left = 0 |
|
122 | 123 | height = (show_weeks ? header_heigth : header_heigth + g_height) |
|
123 | 124 | @months.times do |
|
124 | 125 | width = ((month_f >> 1) - month_f) * zoom - 1 |
|
125 | 126 | %> |
|
126 | 127 | <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="m_bg"> |
|
127 | 128 | <%= link_to "#{month_f.year}-#{month_f.month}", :year => month_f.year, :month => month_f.month, :zoom => @zoom, :months => @months %> |
|
128 | 129 | </div> |
|
129 | 130 | <% |
|
130 | 131 | left = left + width + 1 |
|
131 | 132 | month_f = month_f >> 1 |
|
132 | 133 | end %> |
|
133 | 134 | |
|
134 | 135 | <% |
|
135 | 136 | # |
|
136 | 137 | # Weeks headers |
|
137 | 138 | # |
|
138 | 139 | if show_weeks |
|
139 | 140 | left = 0 |
|
140 | 141 | height = (show_days ? header_heigth-1 : header_heigth-1 + g_height) |
|
141 | 142 | if @date_from.cwday == 1 |
|
142 | 143 | # @date_from is monday |
|
143 | 144 | week_f = @date_from |
|
144 | 145 | else |
|
145 | 146 | # find next monday after @date_from |
|
146 | 147 | week_f = @date_from + (7 - @date_from.cwday + 1) |
|
147 | 148 | width = (7 - @date_from.cwday + 1) * zoom-1 |
|
148 | 149 | %> |
|
149 | 150 | <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="m_bg"> </div> |
|
150 | 151 | <% |
|
151 | 152 | left = left + width+1 |
|
152 | 153 | end %> |
|
153 | 154 | <% |
|
154 | while week_f < @date_to | |
|
155 | while week_f <= @date_to | |
|
155 | 156 | width = (week_f + 6 <= @date_to) ? 7 * zoom -1 : (@date_to - week_f + 1) * zoom-1 |
|
156 | 157 | %> |
|
157 | 158 | <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="m_bg"> |
|
158 | <small><%= week_f.cweek %></small> | |
|
159 | <small><%= week_f.cweek if width >= 16 %></small> | |
|
159 | 160 | </div> |
|
160 | 161 | <% |
|
161 | 162 | left = left + width+1 |
|
162 | 163 | week_f = week_f+7 |
|
163 | 164 | end |
|
164 | 165 | end %> |
|
165 | 166 | |
|
166 | 167 | <% |
|
167 | 168 | # |
|
168 | 169 | # Days headers |
|
169 | 170 | # |
|
170 | 171 | if show_days |
|
171 | 172 | left = 0 |
|
172 | 173 | height = g_height + header_heigth - 1 |
|
173 | 174 | wday = @date_from.cwday |
|
174 | 175 | (@date_to - @date_from + 1).to_i.times do |
|
175 | 176 | width = zoom - 1 |
|
176 | 177 | %> |
|
177 | 178 | <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="m_bg"> |
|
178 | 179 | <%= day_name(wday)[0,1] %> |
|
179 | 180 | </div> |
|
180 | 181 | <% |
|
181 | 182 | left = left + width+1 |
|
182 | 183 | wday = wday + 1 |
|
183 | 184 | wday = 1 if wday > 7 |
|
184 | 185 | end |
|
185 | 186 | end %> |
|
186 | 187 | |
|
187 | 188 | <% |
|
188 | 189 | # |
|
189 | 190 | # Today red line |
|
190 | 191 | # |
|
191 | 192 | if Date.today >= @date_from and Date.today <= @date_to %> |
|
192 | 193 | <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_heigth + 1 %>px;left:<%= ((Date.today-@date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;"> </div> |
|
193 | 194 | <% end %> |
|
194 | 195 | |
|
195 | 196 | <% |
|
196 | 197 | # |
|
197 | 198 | # Tasks |
|
198 | 199 | # |
|
199 | 200 | top = headers_heigth + 12 |
|
200 | 201 | @issues.each do |i| %> |
|
201 | 202 | <% |
|
202 | 203 | i_start_date = (i.start_date >= @date_from ? i.start_date : @date_from ) |
|
203 | 204 | i_end_date = (i.due_date <= @date_to ? i.due_date : @date_to ) |
|
204 | 205 | |
|
205 | 206 | i_done_date = i.start_date + ((i.due_date - i.start_date+1)*i.done_ratio/100).floor |
|
206 | 207 | i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date ) |
|
207 | 208 | i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date ) |
|
208 | 209 | |
|
209 | 210 | i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today |
|
210 | 211 | |
|
211 | 212 | i_left = ((i_start_date - @date_from)*zoom).floor |
|
212 | 213 | i_width = ((i_end_date - i_start_date + 1)*zoom).floor |
|
213 | 214 | d_width = ((i_done_date - i_start_date)*zoom).floor |
|
214 | 215 | l_width = ((i_late_date - i_start_date+1)*zoom).floor if i_late_date |
|
215 | 216 | l_width ||= 0 |
|
216 | 217 | %> |
|
217 | 218 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task"> </div> |
|
218 | 219 | <% if l_width > 0 %> |
|
219 | 220 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late"> </div> |
|
220 | 221 | <% end %> |
|
221 | 222 | <% if d_width > 0 %> |
|
222 | 223 | <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done"> </div> |
|
223 | 224 | <% end %> |
|
224 | 225 | <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task"> |
|
225 | 226 | <%= i.status.name %> |
|
226 | 227 | <%= (i.done_ratio).to_i %>% |
|
227 | 228 | </div> |
|
228 | 229 | <% top = top + 20 |
|
229 | 230 | end %> |
|
230 | 231 | </div> |
|
231 | 232 | </td> |
|
232 | 233 | </tr> |
|
233 | 234 | </table> |
|
234 | 235 | |
|
235 | 236 | <table width="100%"> |
|
236 | 237 | <tr> |
|
237 | 238 | <td align="left"><%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months %></td> |
|
238 | 239 | <td> |
|
239 | 240 | <td align="right"><%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months %></td> |
|
240 | 241 | </tr> |
|
241 | 242 | </table> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now