@@ -29,6 +29,58 module Redmine | |||||
29 | include ActionView::Helpers::TextHelper |
|
29 | include ActionView::Helpers::TextHelper | |
30 | include ActionView::Helpers::NumberHelper |
|
30 | include ActionView::Helpers::NumberHelper | |
31 |
|
31 | |||
|
32 | class ITCPDF < TCPDF | |||
|
33 | include Redmine::I18n | |||
|
34 | attr_accessor :footer_date | |||
|
35 | ||||
|
36 | def initialize(lang) | |||
|
37 | super() | |||
|
38 | set_language_if_valid lang | |||
|
39 | @font_for_content = 'FreeSans' | |||
|
40 | @font_for_footer = 'FreeSans' | |||
|
41 | SetCreator(Redmine::Info.app_name) | |||
|
42 | SetFont(@font_for_content) | |||
|
43 | end | |||
|
44 | ||||
|
45 | def SetFontStyle(style, size) | |||
|
46 | SetFont(@font_for_content, style, size) | |||
|
47 | end | |||
|
48 | ||||
|
49 | def SetTitle(txt) | |||
|
50 | txt = begin | |||
|
51 | utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt) | |||
|
52 | hextxt = "<FEFF" # FEFF is BOM | |||
|
53 | hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join | |||
|
54 | hextxt << ">" | |||
|
55 | rescue | |||
|
56 | txt | |||
|
57 | end || '' | |||
|
58 | super(txt) | |||
|
59 | end | |||
|
60 | ||||
|
61 | def textstring(s) | |||
|
62 | # Format a text string | |||
|
63 | if s =~ /^</ # This means the string is hex-dumped. | |||
|
64 | return s | |||
|
65 | else | |||
|
66 | return '('+escape(s)+')' | |||
|
67 | end | |||
|
68 | end | |||
|
69 | ||||
|
70 | alias RDMCell Cell | |||
|
71 | alias RDMMultiCell MultiCell | |||
|
72 | ||||
|
73 | def Footer | |||
|
74 | SetFont(@font_for_footer, 'I', 8) | |||
|
75 | SetY(-15) | |||
|
76 | SetX(15) | |||
|
77 | RDMCell(0, 5, @footer_date, 0, 0, 'L') | |||
|
78 | SetY(-15) | |||
|
79 | SetX(-30) | |||
|
80 | RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') | |||
|
81 | end | |||
|
82 | end | |||
|
83 | ||||
32 | class IFPDF < FPDF |
|
84 | class IFPDF < FPDF | |
33 | include Redmine::I18n |
|
85 | include Redmine::I18n | |
34 | attr_accessor :footer_date |
|
86 | attr_accessor :footer_date | |
@@ -90,7 +142,7 module Redmine | |||||
90 | end |
|
142 | end | |
91 | end |
|
143 | end | |
92 |
|
144 | |||
93 | def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='') |
|
145 | def fix_text_encoding(txt) | |
94 | @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8') |
|
146 | @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8') | |
95 | # these quotation marks are not correctly rendered in the pdf |
|
147 | # these quotation marks are not correctly rendered in the pdf | |
96 | txt = txt.gsub(/[Γ’β¬ΕΓ’β¬οΏ½]/, '"') if txt |
|
148 | txt = txt.gsub(/[Γ’β¬ΕΓ’β¬οΏ½]/, '"') if txt | |
@@ -102,27 +154,37 module Redmine | |||||
102 | rescue |
|
154 | rescue | |
103 | txt |
|
155 | txt | |
104 | end || '' |
|
156 | end || '' | |
105 | super w,h,txt,border,ln,align,fill,link |
|
157 | return txt | |
|
158 | end | |||
|
159 | ||||
|
160 | def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='') | |||
|
161 | Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link) | |||
|
162 | end | |||
|
163 | ||||
|
164 | def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0) | |||
|
165 | MultiCell(w,h,fix_text_encoding(txt),border,align,fill) | |||
106 | end |
|
166 | end | |
107 |
|
167 | |||
108 | def Footer |
|
168 | def Footer | |
109 | SetFont(@font_for_footer, 'I', 8) |
|
169 | SetFont(@font_for_footer, 'I', 8) | |
110 | SetY(-15) |
|
170 | SetY(-15) | |
111 | SetX(15) |
|
171 | SetX(15) | |
112 | Cell(0, 5, @footer_date, 0, 0, 'L') |
|
172 | RDMCell(0, 5, @footer_date, 0, 0, 'L') | |
113 | SetY(-15) |
|
173 | SetY(-15) | |
114 | SetX(-30) |
|
174 | SetX(-30) | |
115 | Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') |
|
175 | RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') | |
116 | end |
|
176 | end | |
|
177 | alias alias_nb_pages AliasNbPages | |||
117 | end |
|
178 | end | |
118 |
|
179 | |||
119 | # Returns a PDF string of a list of issues |
|
180 | # Returns a PDF string of a list of issues | |
120 | def issues_to_pdf(issues, project, query) |
|
181 | def issues_to_pdf(issues, project, query) | |
121 | pdf = IFPDF.new(current_language) |
|
182 | pdf = IFPDF.new(current_language) | |
|
183 | ||||
122 | title = query.new_record? ? l(:label_issue_plural) : query.name |
|
184 | title = query.new_record? ? l(:label_issue_plural) : query.name | |
123 | title = "#{project} - #{title}" if project |
|
185 | title = "#{project} - #{title}" if project | |
124 | pdf.SetTitle(title) |
|
186 | pdf.SetTitle(title) | |
125 |
pdf. |
|
187 | pdf.alias_nb_pages | |
126 | pdf.footer_date = format_date(Date.today) |
|
188 | pdf.footer_date = format_date(Date.today) | |
127 | pdf.AddPage("L") |
|
189 | pdf.AddPage("L") | |
128 |
|
190 | |||
@@ -136,15 +198,15 module Redmine | |||||
136 |
|
198 | |||
137 | # title |
|
199 | # title | |
138 | pdf.SetFontStyle('B',11) |
|
200 | pdf.SetFontStyle('B',11) | |
139 | pdf.Cell(190,10, title) |
|
201 | pdf.RDMCell(190,10, title) | |
140 | pdf.Ln |
|
202 | pdf.Ln | |
141 |
|
203 | |||
142 | # headers |
|
204 | # headers | |
143 | pdf.SetFontStyle('B',8) |
|
205 | pdf.SetFontStyle('B',8) | |
144 | pdf.SetFillColor(230, 230, 230) |
|
206 | pdf.SetFillColor(230, 230, 230) | |
145 | pdf.Cell(15, row_height, "#", 1, 0, 'L', 1) |
|
207 | pdf.RDMCell(15, row_height, "#", 1, 0, 'L', 1) | |
146 | query.columns.each_with_index do |column, i| |
|
208 | query.columns.each_with_index do |column, i| | |
147 | pdf.Cell(col_width[i], row_height, column.caption, 1, 0, 'L', 1) |
|
209 | pdf.RDMCell(col_width[i], row_height, column.caption, 1, 0, 'L', 1) | |
148 | end |
|
210 | end | |
149 | pdf.Ln |
|
211 | pdf.Ln | |
150 |
|
212 | |||
@@ -155,13 +217,13 module Redmine | |||||
155 | issues.each do |issue| |
|
217 | issues.each do |issue| | |
156 | if query.grouped? && (group = query.group_by_column.value(issue)) != previous_group |
|
218 | if query.grouped? && (group = query.group_by_column.value(issue)) != previous_group | |
157 | pdf.SetFontStyle('B',9) |
|
219 | pdf.SetFontStyle('B',9) | |
158 | pdf.Cell(277, row_height, |
|
220 | pdf.RDMCell(277, row_height, | |
159 | (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})", |
|
221 | (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})", | |
160 | 1, 1, 'L') |
|
222 | 1, 1, 'L') | |
161 | pdf.SetFontStyle('',8) |
|
223 | pdf.SetFontStyle('',8) | |
162 | previous_group = group |
|
224 | previous_group = group | |
163 | end |
|
225 | end | |
164 | pdf.Cell(15, row_height, issue.id.to_s, 1, 0, 'L', 1) |
|
226 | pdf.RDMCell(15, row_height, issue.id.to_s, 1, 0, 'L', 1) | |
165 | query.columns.each_with_index do |column, i| |
|
227 | query.columns.each_with_index do |column, i| | |
166 | s = if column.is_a?(QueryCustomFieldColumn) |
|
228 | s = if column.is_a?(QueryCustomFieldColumn) | |
167 | cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id} |
|
229 | cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id} | |
@@ -176,13 +238,13 module Redmine | |||||
176 | value |
|
238 | value | |
177 | end |
|
239 | end | |
178 | end |
|
240 | end | |
179 | pdf.Cell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1) |
|
241 | pdf.RDMCell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1) | |
180 | end |
|
242 | end | |
181 | pdf.Ln |
|
243 | pdf.Ln | |
182 | end |
|
244 | end | |
183 | if issues.size == Setting.issues_export_limit.to_i |
|
245 | if issues.size == Setting.issues_export_limit.to_i | |
184 | pdf.SetFontStyle('B',10) |
|
246 | pdf.SetFontStyle('B',10) | |
185 | pdf.Cell(0, row_height, '...') |
|
247 | pdf.RDMCell(0, row_height, '...') | |
186 | end |
|
248 | end | |
187 | pdf.Output |
|
249 | pdf.Output | |
188 | end |
|
250 | end | |
@@ -191,73 +253,73 module Redmine | |||||
191 | def issue_to_pdf(issue) |
|
253 | def issue_to_pdf(issue) | |
192 | pdf = IFPDF.new(current_language) |
|
254 | pdf = IFPDF.new(current_language) | |
193 | pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}") |
|
255 | pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}") | |
194 |
pdf. |
|
256 | pdf.alias_nb_pages | |
195 | pdf.footer_date = format_date(Date.today) |
|
257 | pdf.footer_date = format_date(Date.today) | |
196 | pdf.AddPage |
|
258 | pdf.AddPage | |
197 |
|
259 | |||
198 | pdf.SetFontStyle('B',11) |
|
260 | pdf.SetFontStyle('B',11) | |
199 | pdf.Cell(190,10, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}") |
|
261 | pdf.RDMCell(190,10, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}") | |
200 | pdf.Ln |
|
262 | pdf.Ln | |
201 |
|
263 | |||
202 | y0 = pdf.GetY |
|
264 | y0 = pdf.GetY | |
203 |
|
265 | |||
204 | pdf.SetFontStyle('B',9) |
|
266 | pdf.SetFontStyle('B',9) | |
205 | pdf.Cell(35,5, l(:field_status) + ":","LT") |
|
267 | pdf.RDMCell(35,5, l(:field_status) + ":","LT") | |
206 | pdf.SetFontStyle('',9) |
|
268 | pdf.SetFontStyle('',9) | |
207 | pdf.Cell(60,5, issue.status.to_s,"RT") |
|
269 | pdf.RDMCell(60,5, issue.status.to_s,"RT") | |
208 | pdf.SetFontStyle('B',9) |
|
270 | pdf.SetFontStyle('B',9) | |
209 | pdf.Cell(35,5, l(:field_priority) + ":","LT") |
|
271 | pdf.RDMCell(35,5, l(:field_priority) + ":","LT") | |
210 | pdf.SetFontStyle('',9) |
|
272 | pdf.SetFontStyle('',9) | |
211 | pdf.Cell(60,5, issue.priority.to_s,"RT") |
|
273 | pdf.RDMCell(60,5, issue.priority.to_s,"RT") | |
212 | pdf.Ln |
|
274 | pdf.Ln | |
213 |
|
275 | |||
214 | pdf.SetFontStyle('B',9) |
|
276 | pdf.SetFontStyle('B',9) | |
215 | pdf.Cell(35,5, l(:field_author) + ":","L") |
|
277 | pdf.RDMCell(35,5, l(:field_author) + ":","L") | |
216 | pdf.SetFontStyle('',9) |
|
278 | pdf.SetFontStyle('',9) | |
217 | pdf.Cell(60,5, issue.author.to_s,"R") |
|
279 | pdf.RDMCell(60,5, issue.author.to_s,"R") | |
218 | pdf.SetFontStyle('B',9) |
|
280 | pdf.SetFontStyle('B',9) | |
219 | pdf.Cell(35,5, l(:field_category) + ":","L") |
|
281 | pdf.RDMCell(35,5, l(:field_category) + ":","L") | |
220 | pdf.SetFontStyle('',9) |
|
282 | pdf.SetFontStyle('',9) | |
221 | pdf.Cell(60,5, issue.category.to_s,"R") |
|
283 | pdf.RDMCell(60,5, issue.category.to_s,"R") | |
222 | pdf.Ln |
|
284 | pdf.Ln | |
223 |
|
285 | |||
224 | pdf.SetFontStyle('B',9) |
|
286 | pdf.SetFontStyle('B',9) | |
225 | pdf.Cell(35,5, l(:field_created_on) + ":","L") |
|
287 | pdf.RDMCell(35,5, l(:field_created_on) + ":","L") | |
226 | pdf.SetFontStyle('',9) |
|
288 | pdf.SetFontStyle('',9) | |
227 | pdf.Cell(60,5, format_date(issue.created_on),"R") |
|
289 | pdf.RDMCell(60,5, format_date(issue.created_on),"R") | |
228 | pdf.SetFontStyle('B',9) |
|
290 | pdf.SetFontStyle('B',9) | |
229 | pdf.Cell(35,5, l(:field_assigned_to) + ":","L") |
|
291 | pdf.RDMCell(35,5, l(:field_assigned_to) + ":","L") | |
230 | pdf.SetFontStyle('',9) |
|
292 | pdf.SetFontStyle('',9) | |
231 | pdf.Cell(60,5, issue.assigned_to.to_s,"R") |
|
293 | pdf.RDMCell(60,5, issue.assigned_to.to_s,"R") | |
232 | pdf.Ln |
|
294 | pdf.Ln | |
233 |
|
295 | |||
234 | pdf.SetFontStyle('B',9) |
|
296 | pdf.SetFontStyle('B',9) | |
235 | pdf.Cell(35,5, l(:field_updated_on) + ":","LB") |
|
297 | pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB") | |
236 | pdf.SetFontStyle('',9) |
|
298 | pdf.SetFontStyle('',9) | |
237 | pdf.Cell(60,5, format_date(issue.updated_on),"RB") |
|
299 | pdf.RDMCell(60,5, format_date(issue.updated_on),"RB") | |
238 | pdf.SetFontStyle('B',9) |
|
300 | pdf.SetFontStyle('B',9) | |
239 | pdf.Cell(35,5, l(:field_due_date) + ":","LB") |
|
301 | pdf.RDMCell(35,5, l(:field_due_date) + ":","LB") | |
240 | pdf.SetFontStyle('',9) |
|
302 | pdf.SetFontStyle('',9) | |
241 | pdf.Cell(60,5, format_date(issue.due_date),"RB") |
|
303 | pdf.RDMCell(60,5, format_date(issue.due_date),"RB") | |
242 | pdf.Ln |
|
304 | pdf.Ln | |
243 |
|
305 | |||
244 | for custom_value in issue.custom_field_values |
|
306 | for custom_value in issue.custom_field_values | |
245 | pdf.SetFontStyle('B',9) |
|
307 | pdf.SetFontStyle('B',9) | |
246 | pdf.Cell(35,5, custom_value.custom_field.name + ":","L") |
|
308 | pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L") | |
247 | pdf.SetFontStyle('',9) |
|
309 | pdf.SetFontStyle('',9) | |
248 | pdf.MultiCell(155,5, (show_value custom_value),"R") |
|
310 | pdf.RDMMultiCell(155,5, (show_value custom_value),"R") | |
249 | end |
|
311 | end | |
250 |
|
312 | |||
251 | pdf.SetFontStyle('B',9) |
|
313 | pdf.SetFontStyle('B',9) | |
252 | pdf.Cell(35,5, l(:field_subject) + ":","LTB") |
|
314 | pdf.RDMCell(35,5, l(:field_subject) + ":","LTB") | |
253 | pdf.SetFontStyle('',9) |
|
315 | pdf.SetFontStyle('',9) | |
254 | pdf.Cell(155,5, issue.subject,"RTB") |
|
316 | pdf.RDMCell(155,5, issue.subject,"RTB") | |
255 | pdf.Ln |
|
317 | pdf.Ln | |
256 |
|
318 | |||
257 | pdf.SetFontStyle('B',9) |
|
319 | pdf.SetFontStyle('B',9) | |
258 | pdf.Cell(35,5, l(:field_description) + ":") |
|
320 | pdf.RDMCell(35,5, l(:field_description) + ":") | |
259 | pdf.SetFontStyle('',9) |
|
321 | pdf.SetFontStyle('',9) | |
260 | pdf.MultiCell(155,5, issue.description.to_s,"BR") |
|
322 | pdf.RDMMultiCell(155,5, issue.description.to_s,"BR") | |
261 |
|
323 | |||
262 | pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY) |
|
324 | pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY) | |
263 | pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY) |
|
325 | pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY) | |
@@ -265,49 +327,49 module Redmine | |||||
265 |
|
327 | |||
266 | if issue.changesets.any? && User.current.allowed_to?(:view_changesets, issue.project) |
|
328 | if issue.changesets.any? && User.current.allowed_to?(:view_changesets, issue.project) | |
267 | pdf.SetFontStyle('B',9) |
|
329 | pdf.SetFontStyle('B',9) | |
268 | pdf.Cell(190,5, l(:label_associated_revisions), "B") |
|
330 | pdf.RDMCell(190,5, l(:label_associated_revisions), "B") | |
269 | pdf.Ln |
|
331 | pdf.Ln | |
270 | for changeset in issue.changesets |
|
332 | for changeset in issue.changesets | |
271 | pdf.SetFontStyle('B',8) |
|
333 | pdf.SetFontStyle('B',8) | |
272 | pdf.Cell(190,5, format_time(changeset.committed_on) + " - " + changeset.author.to_s) |
|
334 | pdf.RDMCell(190,5, format_time(changeset.committed_on) + " - " + changeset.author.to_s) | |
273 | pdf.Ln |
|
335 | pdf.Ln | |
274 | unless changeset.comments.blank? |
|
336 | unless changeset.comments.blank? | |
275 | pdf.SetFontStyle('',8) |
|
337 | pdf.SetFontStyle('',8) | |
276 | pdf.MultiCell(190,5, changeset.comments.to_s) |
|
338 | pdf.RDMMultiCell(190,5, changeset.comments.to_s) | |
277 | end |
|
339 | end | |
278 | pdf.Ln |
|
340 | pdf.Ln | |
279 | end |
|
341 | end | |
280 | end |
|
342 | end | |
281 |
|
343 | |||
282 | pdf.SetFontStyle('B',9) |
|
344 | pdf.SetFontStyle('B',9) | |
283 | pdf.Cell(190,5, l(:label_history), "B") |
|
345 | pdf.RDMCell(190,5, l(:label_history), "B") | |
284 | pdf.Ln |
|
346 | pdf.Ln | |
285 | for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") |
|
347 | for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") | |
286 | pdf.SetFontStyle('B',8) |
|
348 | pdf.SetFontStyle('B',8) | |
287 | pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name) |
|
349 | pdf.RDMCell(190,5, format_time(journal.created_on) + " - " + journal.user.name) | |
288 | pdf.Ln |
|
350 | pdf.Ln | |
289 | pdf.SetFontStyle('I',8) |
|
351 | pdf.SetFontStyle('I',8) | |
290 | for detail in journal.details |
|
352 | for detail in journal.details | |
291 | pdf.Cell(190,5, "- " + show_detail(detail, true)) |
|
353 | pdf.RDMCell(190,5, "- " + show_detail(detail, true)) | |
292 | pdf.Ln |
|
354 | pdf.Ln | |
293 | end |
|
355 | end | |
294 | if journal.notes? |
|
356 | if journal.notes? | |
295 | pdf.SetFontStyle('',8) |
|
357 | pdf.SetFontStyle('',8) | |
296 | pdf.MultiCell(190,5, journal.notes.to_s) |
|
358 | pdf.RDMMultiCell(190,5, journal.notes.to_s) | |
297 | end |
|
359 | end | |
298 | pdf.Ln |
|
360 | pdf.Ln | |
299 | end |
|
361 | end | |
300 |
|
362 | |||
301 | if issue.attachments.any? |
|
363 | if issue.attachments.any? | |
302 | pdf.SetFontStyle('B',9) |
|
364 | pdf.SetFontStyle('B',9) | |
303 | pdf.Cell(190,5, l(:label_attachment_plural), "B") |
|
365 | pdf.RDMCell(190,5, l(:label_attachment_plural), "B") | |
304 | pdf.Ln |
|
366 | pdf.Ln | |
305 | for attachment in issue.attachments |
|
367 | for attachment in issue.attachments | |
306 | pdf.SetFontStyle('',8) |
|
368 | pdf.SetFontStyle('',8) | |
307 | pdf.Cell(80,5, attachment.filename) |
|
369 | pdf.RDMCell(80,5, attachment.filename) | |
308 | pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") |
|
370 | pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R") | |
309 | pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R") |
|
371 | pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R") | |
310 | pdf.Cell(65,5, attachment.author.name,0,0,"R") |
|
372 | pdf.RDMCell(65,5, attachment.author.name,0,0,"R") | |
311 | pdf.Ln |
|
373 | pdf.Ln | |
312 | end |
|
374 | end | |
313 | end |
|
375 | end |
@@ -509,12 +509,12 module Redmine | |||||
509 | def to_pdf |
|
509 | def to_pdf | |
510 | pdf = ::Redmine::Export::PDF::IFPDF.new(current_language) |
|
510 | pdf = ::Redmine::Export::PDF::IFPDF.new(current_language) | |
511 | pdf.SetTitle("#{l(:label_gantt)} #{project}") |
|
511 | pdf.SetTitle("#{l(:label_gantt)} #{project}") | |
512 |
pdf. |
|
512 | pdf.alias_nb_pages | |
513 | pdf.footer_date = format_date(Date.today) |
|
513 | pdf.footer_date = format_date(Date.today) | |
514 | pdf.AddPage("L") |
|
514 | pdf.AddPage("L") | |
515 | pdf.SetFontStyle('B',12) |
|
515 | pdf.SetFontStyle('B',12) | |
516 | pdf.SetX(15) |
|
516 | pdf.SetX(15) | |
517 | pdf.Cell(PDF::LeftPaneWidth, 20, project.to_s) |
|
517 | pdf.RDMCell(PDF::LeftPaneWidth, 20, project.to_s) | |
518 | pdf.Ln |
|
518 | pdf.Ln | |
519 | pdf.SetFontStyle('B',9) |
|
519 | pdf.SetFontStyle('B',9) | |
520 |
|
520 | |||
@@ -549,7 +549,7 module Redmine | |||||
549 | width = ((month_f >> 1) - month_f) * zoom |
|
549 | width = ((month_f >> 1) - month_f) * zoom | |
550 | pdf.SetY(y_start) |
|
550 | pdf.SetY(y_start) | |
551 | pdf.SetX(left) |
|
551 | pdf.SetX(left) | |
552 | pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C") |
|
552 | pdf.RDMCell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C") | |
553 | left = left + width |
|
553 | left = left + width | |
554 | month_f = month_f >> 1 |
|
554 | month_f = month_f >> 1 | |
555 | end |
|
555 | end | |
@@ -567,14 +567,14 module Redmine | |||||
567 | width = (7 - self.date_from.cwday + 1) * zoom-1 |
|
567 | width = (7 - self.date_from.cwday + 1) * zoom-1 | |
568 | pdf.SetY(y_start + header_heigth) |
|
568 | pdf.SetY(y_start + header_heigth) | |
569 | pdf.SetX(left) |
|
569 | pdf.SetX(left) | |
570 | pdf.Cell(width + 1, height, "", "LTR") |
|
570 | pdf.RDMCell(width + 1, height, "", "LTR") | |
571 | left = left + width+1 |
|
571 | left = left + width+1 | |
572 | end |
|
572 | end | |
573 | while week_f <= self.date_to |
|
573 | while week_f <= self.date_to | |
574 | width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom |
|
574 | width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom | |
575 | pdf.SetY(y_start + header_heigth) |
|
575 | pdf.SetY(y_start + header_heigth) | |
576 | pdf.SetX(left) |
|
576 | pdf.SetX(left) | |
577 | pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C") |
|
577 | pdf.RDMCell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C") | |
578 | left = left + width |
|
578 | left = left + width | |
579 | week_f = week_f+7 |
|
579 | week_f = week_f+7 | |
580 | end |
|
580 | end | |
@@ -590,7 +590,7 module Redmine | |||||
590 | width = zoom |
|
590 | width = zoom | |
591 | pdf.SetY(y_start + 2 * header_heigth) |
|
591 | pdf.SetY(y_start + 2 * header_heigth) | |
592 | pdf.SetX(left) |
|
592 | pdf.SetX(left) | |
593 | pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C") |
|
593 | pdf.RDMCell(width, height, day_name(wday).first, "LTR", 0, "C") | |
594 | left = left + width |
|
594 | left = left + width | |
595 | wday = wday + 1 |
|
595 | wday = wday + 1 | |
596 | wday = 1 if wday > 7 |
|
596 | wday = 1 if wday > 7 | |
@@ -599,7 +599,7 module Redmine | |||||
599 |
|
599 | |||
600 | pdf.SetY(y_start) |
|
600 | pdf.SetY(y_start) | |
601 | pdf.SetX(15) |
|
601 | pdf.SetX(15) | |
602 | pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1) |
|
602 | pdf.RDMCell(subject_width+g_width-15, headers_heigth, "", 1) | |
603 |
|
603 | |||
604 | # Tasks |
|
604 | # Tasks | |
605 | top = headers_heigth + y_start |
|
605 | top = headers_heigth + y_start | |
@@ -719,11 +719,11 module Redmine | |||||
719 | params[:pdf].SetX(15) |
|
719 | params[:pdf].SetX(15) | |
720 |
|
720 | |||
721 | char_limit = PDF::MaxCharactorsForSubject - params[:indent] |
|
721 | char_limit = PDF::MaxCharactorsForSubject - params[:indent] | |
722 | params[:pdf].Cell(params[:subject_width]-15, 5, (" " * params[:indent]) + subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR") |
|
722 | params[:pdf].RDMCell(params[:subject_width]-15, 5, (" " * params[:indent]) + subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR") | |
723 |
|
723 | |||
724 | params[:pdf].SetY(params[:top]) |
|
724 | params[:pdf].SetY(params[:top]) | |
725 | params[:pdf].SetX(params[:subject_width]) |
|
725 | params[:pdf].SetX(params[:subject_width]) | |
726 | params[:pdf].Cell(params[:g_width], 5, "", "LR") |
|
726 | params[:pdf].RDMCell(params[:g_width], 5, "", "LR") | |
727 | end |
|
727 | end | |
728 |
|
728 | |||
729 | def image_subject(params, subject, options={}) |
|
729 | def image_subject(params, subject, options={}) | |
@@ -780,19 +780,19 module Redmine | |||||
780 | params[:pdf].SetY(params[:top]+1.5) |
|
780 | params[:pdf].SetY(params[:top]+1.5) | |
781 | params[:pdf].SetX(params[:subject_width] + coords[:bar_start]) |
|
781 | params[:pdf].SetX(params[:subject_width] + coords[:bar_start]) | |
782 | params[:pdf].SetFillColor(200,200,200) |
|
782 | params[:pdf].SetFillColor(200,200,200) | |
783 | params[:pdf].Cell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1) |
|
783 | params[:pdf].RDMCell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1) | |
784 |
|
784 | |||
785 | if coords[:bar_late_end] |
|
785 | if coords[:bar_late_end] | |
786 | params[:pdf].SetY(params[:top]+1.5) |
|
786 | params[:pdf].SetY(params[:top]+1.5) | |
787 | params[:pdf].SetX(params[:subject_width] + coords[:bar_start]) |
|
787 | params[:pdf].SetX(params[:subject_width] + coords[:bar_start]) | |
788 | params[:pdf].SetFillColor(255,100,100) |
|
788 | params[:pdf].SetFillColor(255,100,100) | |
789 | params[:pdf].Cell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1) |
|
789 | params[:pdf].RDMCell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1) | |
790 | end |
|
790 | end | |
791 | if coords[:bar_progress_end] |
|
791 | if coords[:bar_progress_end] | |
792 | params[:pdf].SetY(params[:top]+1.5) |
|
792 | params[:pdf].SetY(params[:top]+1.5) | |
793 | params[:pdf].SetX(params[:subject_width] + coords[:bar_start]) |
|
793 | params[:pdf].SetX(params[:subject_width] + coords[:bar_start]) | |
794 | params[:pdf].SetFillColor(90,200,90) |
|
794 | params[:pdf].SetFillColor(90,200,90) | |
795 | params[:pdf].Cell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1) |
|
795 | params[:pdf].RDMCell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1) | |
796 | end |
|
796 | end | |
797 | end |
|
797 | end | |
798 | # Renders the markers |
|
798 | # Renders the markers | |
@@ -801,19 +801,19 module Redmine | |||||
801 | params[:pdf].SetY(params[:top] + 1) |
|
801 | params[:pdf].SetY(params[:top] + 1) | |
802 | params[:pdf].SetX(params[:subject_width] + coords[:start] - 1) |
|
802 | params[:pdf].SetX(params[:subject_width] + coords[:start] - 1) | |
803 | params[:pdf].SetFillColor(50,50,200) |
|
803 | params[:pdf].SetFillColor(50,50,200) | |
804 | params[:pdf].Cell(2, 2, "", 0, 0, "", 1) |
|
804 | params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1) | |
805 | end |
|
805 | end | |
806 | if coords[:end] |
|
806 | if coords[:end] | |
807 | params[:pdf].SetY(params[:top] + 1) |
|
807 | params[:pdf].SetY(params[:top] + 1) | |
808 | params[:pdf].SetX(params[:subject_width] + coords[:end] - 1) |
|
808 | params[:pdf].SetX(params[:subject_width] + coords[:end] - 1) | |
809 | params[:pdf].SetFillColor(50,50,200) |
|
809 | params[:pdf].SetFillColor(50,50,200) | |
810 | params[:pdf].Cell(2, 2, "", 0, 0, "", 1) |
|
810 | params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1) | |
811 | end |
|
811 | end | |
812 | end |
|
812 | end | |
813 | # Renders the label on the right |
|
813 | # Renders the label on the right | |
814 | if options[:label] |
|
814 | if options[:label] | |
815 | params[:pdf].SetX(params[:subject_width] + (coords[:bar_end] || 0) + 5) |
|
815 | params[:pdf].SetX(params[:subject_width] + (coords[:bar_end] || 0) + 5) | |
816 | params[:pdf].Cell(30, 2, options[:label]) |
|
816 | params[:pdf].RDMCell(30, 2, options[:label]) | |
817 | end |
|
817 | end | |
818 | end |
|
818 | end | |
819 |
|
819 |
General Comments 0
You need to be logged in to leave comments.
Login now