45 |
45 |
pdf.SetFontStyle('',8)
|
46 |
46 |
pdf.RDMMultiCell(190, 5, "#{format_time(issue.created_on)} - #{issue.author}")
|
47 |
47 |
pdf.ln
|
48 |
|
|
|
48 |
|
49 |
49 |
left = []
|
50 |
50 |
left << [l(:field_status), issue.status]
|
51 |
51 |
left << [l(:field_priority), issue.priority]
|
52 |
52 |
left << [l(:field_assigned_to), issue.assigned_to] unless issue.disabled_core_fields.include?('assigned_to_id')
|
53 |
53 |
left << [l(:field_category), issue.category] unless issue.disabled_core_fields.include?('category_id')
|
54 |
54 |
left << [l(:field_fixed_version), issue.fixed_version] unless issue.disabled_core_fields.include?('fixed_version_id')
|
55 |
|
|
|
55 |
|
56 |
56 |
right = []
|
57 |
57 |
right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date')
|
58 |
58 |
right << [l(:field_due_date), format_date(issue.due_date)] unless issue.disabled_core_fields.include?('due_date')
|
59 |
59 |
right << [l(:field_done_ratio), "#{issue.done_ratio}%"] unless issue.disabled_core_fields.include?('done_ratio')
|
60 |
60 |
right << [l(:field_estimated_hours), l_hours(issue.estimated_hours)] unless issue.disabled_core_fields.include?('estimated_hours')
|
61 |
61 |
right << [l(:label_spent_time), l_hours(issue.total_spent_hours)] if User.current.allowed_to?(:view_time_entries, issue.project)
|
62 |
|
|
|
62 |
|
63 |
63 |
rows = left.size > right.size ? left.size : right.size
|
64 |
64 |
while left.size < rows
|
65 |
65 |
left << nil
|
... | ... | |
68 |
68 |
right << nil
|
69 |
69 |
end
|
70 |
70 |
|
71 |
|
custom_field_values = issue.visible_custom_field_values.reject {|value| value.custom_field.full_width_layout?}
|
72 |
|
half = (custom_field_values.size / 2.0).ceil
|
73 |
|
custom_field_values.each_with_index do |custom_value, i|
|
74 |
|
(i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
|
75 |
|
end
|
76 |
|
|
77 |
71 |
if pdf.get_rtl
|
78 |
72 |
border_first_top = 'RT'
|
79 |
73 |
border_last_top = 'LT'
|
... | ... | |
85 |
79 |
border_first = 'L'
|
86 |
80 |
border_last = 'R'
|
87 |
81 |
end
|
88 |
|
|
|
82 |
border_middle_top = 'T'
|
|
83 |
|
89 |
84 |
rows = left.size > right.size ? left.size : right.size
|
90 |
85 |
rows.times do |i|
|
91 |
86 |
heights = []
|
... | ... | |
100 |
95 |
item = right[i]
|
101 |
96 |
heights << pdf.get_string_height(60, item ? item.last.to_s : "")
|
102 |
97 |
height = heights.max
|
103 |
|
|
|
98 |
|
104 |
99 |
item = left[i]
|
105 |
100 |
pdf.SetFontStyle('B',9)
|
106 |
101 |
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
|
107 |
102 |
pdf.SetFontStyle('',9)
|
108 |
|
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0)
|
109 |
|
|
|
103 |
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_middle_top : ""), '', 0, 0)
|
|
104 |
|
110 |
105 |
item = right[i]
|
111 |
106 |
pdf.SetFontStyle('B',9)
|
112 |
|
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
|
|
107 |
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_middle_top : ""), '', 0, 0)
|
113 |
108 |
pdf.SetFontStyle('',9)
|
114 |
109 |
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2)
|
115 |
|
|
|
110 |
|
116 |
111 |
pdf.set_x(base_x)
|
117 |
112 |
end
|
118 |
|
|
|
113 |
|
|
114 |
group_by_keys(issue.project_id, issue.tracker_id, issue.visible_custom_field_values).each do |title, values|
|
|
115 |
if values.present?
|
|
116 |
unless title.nil?
|
|
117 |
pdf.RDMCell(35+155, 5, title, "LRT", 1)
|
|
118 |
end
|
|
119 |
|
|
120 |
while values.present?
|
|
121 |
if values[0].custom_field.full_width_layout?
|
|
122 |
while values.present? && values[0].custom_field.full_width_layout?
|
|
123 |
value = values.shift
|
|
124 |
pdf.SetFontStyle('B',9)
|
|
125 |
pdf.RDMCell(35, 5, "#{value.custom_field.name}:", 'L', 0)
|
|
126 |
pdf.SetFontStyle('',9)
|
|
127 |
pdf.RDMCell(155, 5, show_value(value, false).to_s, 'R', 1)
|
|
128 |
end
|
|
129 |
else
|
|
130 |
lr_values = []
|
|
131 |
while values.present? && ! values[0].custom_field.full_width_layout?
|
|
132 |
lr_values += [ values.shift ]
|
|
133 |
end
|
|
134 |
|
|
135 |
half = (lr_values.size / 2.0).ceil
|
|
136 |
left = []
|
|
137 |
right = []
|
|
138 |
lr_values.each_with_index do |custom_value, i|
|
|
139 |
(i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
|
|
140 |
end
|
|
141 |
|
|
142 |
rows = left.size > right.size ? left.size : right.size
|
|
143 |
rows.times do |i|
|
|
144 |
heights = []
|
|
145 |
pdf.SetFontStyle('B',9)
|
|
146 |
item = left[i]
|
|
147 |
heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
|
|
148 |
item = right[i]
|
|
149 |
heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
|
|
150 |
pdf.SetFontStyle('',9)
|
|
151 |
item = left[i]
|
|
152 |
heights << pdf.get_string_height(60, item ? item.last.to_s : "")
|
|
153 |
item = right[i]
|
|
154 |
heights << pdf.get_string_height(60, item ? item.last.to_s : "")
|
|
155 |
height = heights.max
|
|
156 |
|
|
157 |
item = left[i]
|
|
158 |
pdf.SetFontStyle('B',9)
|
|
159 |
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", border_first, '', 0, 0)
|
|
160 |
pdf.SetFontStyle('',9)
|
|
161 |
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", "", '', 0, 0)
|
|
162 |
|
|
163 |
item = right[i]
|
|
164 |
pdf.SetFontStyle('B',9)
|
|
165 |
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", "", '', 0, 0)
|
|
166 |
pdf.SetFontStyle('',9)
|
|
167 |
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", border_last, '', 0, 2)
|
|
168 |
|
|
169 |
pdf.set_x(base_x)
|
|
170 |
end
|
|
171 |
end
|
|
172 |
end
|
|
173 |
end
|
|
174 |
end
|
|
175 |
|
119 |
176 |
pdf.SetFontStyle('B',9)
|
120 |
177 |
pdf.RDMCell(35+155, 5, l(:field_description), "LRT", 1)
|
121 |
178 |
pdf.SetFontStyle('',9)
|
122 |
|
|
|
179 |
|
123 |
180 |
# Set resize image scale
|
124 |
181 |
pdf.set_image_scale(1.6)
|
125 |
182 |
text = textilizable(issue, :description,
|
... | ... | |
130 |
187 |
)
|
131 |
188 |
pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
|
132 |
189 |
|
133 |
|
custom_field_values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?}
|
134 |
|
custom_field_values.each do |value|
|
135 |
|
text = show_value(value, false)
|
136 |
|
next if text.blank?
|
137 |
|
|
138 |
|
pdf.SetFontStyle('B',9)
|
139 |
|
pdf.RDMCell(35+155, 5, value.custom_field.name, "LRT", 1)
|
140 |
|
pdf.SetFontStyle('',9)
|
141 |
|
pdf.RDMwriteHTMLCell(35+155, 5, '', '', text, issue.attachments, "LRB")
|
142 |
|
end
|
143 |
|
|
144 |
190 |
unless issue.leaf?
|
145 |
191 |
truncate_length = (!is_cjk? ? 90 : 65)
|
146 |
192 |
pdf.SetFontStyle('B',9)
|
... | ... | |
157 |
203 |
pdf.ln
|
158 |
204 |
end
|
159 |
205 |
end
|
160 |
|
|
|
206 |
|
161 |
207 |
relations = issue.relations.select { |r| r.other_issue(issue).visible? }
|
162 |
208 |
unless relations.empty?
|
163 |
209 |
truncate_length = (!is_cjk? ? 80 : 60)
|
... | ... | |
185 |
231 |
end
|
186 |
232 |
pdf.RDMCell(190,5, "", "T")
|
187 |
233 |
pdf.ln
|
188 |
|
|
|
234 |
|
189 |
235 |
if issue.changesets.any? &&
|
190 |
236 |
User.current.allowed_to?(:view_changesets, issue.project)
|
191 |
237 |
pdf.SetFontStyle('B',9)
|
... | ... | |
205 |
251 |
pdf.ln
|
206 |
252 |
end
|
207 |
253 |
end
|
208 |
|
|
|
254 |
|
209 |
255 |
if assoc[:journals].present?
|
210 |
256 |
pdf.SetFontStyle('B',9)
|
211 |
257 |
pdf.RDMCell(190,5, l(:label_history), "B")
|
... | ... | |
234 |
280 |
pdf.ln
|
235 |
281 |
end
|
236 |
282 |
end
|
237 |
|
|
|
283 |
|
238 |
284 |
if issue.attachments.any?
|
239 |
285 |
pdf.SetFontStyle('B',9)
|
240 |
286 |
pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
|
... | ... | |
261 |
307 |
pdf.footer_date = format_date(User.current.today)
|
262 |
308 |
pdf.set_auto_page_break(false)
|
263 |
309 |
pdf.add_page("L")
|
264 |
|
|
|
310 |
|
265 |
311 |
# Landscape A4 = 210 x 297 mm
|
266 |
312 |
page_height = pdf.get_page_height # 210
|
267 |
313 |
page_width = pdf.get_page_width # 297
|
... | ... | |
269 |
315 |
right_margin = pdf.get_original_margins['right'] # 10
|
270 |
316 |
bottom_margin = pdf.get_footer_margin
|
271 |
317 |
row_height = 4
|
272 |
|
|
|
318 |
|
273 |
319 |
# column widths
|
274 |
320 |
table_width = page_width - right_margin - left_margin
|
275 |
321 |
col_width = []
|
... | ... | |
277 |
323 |
col_width = calc_col_width(issues, query, table_width, pdf)
|
278 |
324 |
table_width = col_width.inject(0, :+)
|
279 |
325 |
end
|
280 |
|
|
|
326 |
|
281 |
327 |
# use full width if the description or last_notes are displayed
|
282 |
328 |
if table_width > 0 && (query.has_column?(:description) || query.has_column?(:last_notes))
|
283 |
329 |
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
|
284 |
330 |
table_width = col_width.inject(0, :+)
|
285 |
331 |
end
|
286 |
|
|
|
332 |
|
287 |
333 |
# title
|
288 |
334 |
pdf.SetFontStyle('B',11)
|
289 |
335 |
pdf.RDMCell(190, 8, title)
|
... | ... | |
317 |
363 |
end
|
318 |
364 |
previous_group = group
|
319 |
365 |
end
|
320 |
|
|
|
366 |
|
321 |
367 |
# fetch row values
|
322 |
368 |
col_values = fetch_row_values(issue, query, level)
|
323 |
|
|
|
369 |
|
324 |
370 |
# make new page if it doesn't fit on the current one
|
325 |
371 |
base_y = pdf.get_y
|
326 |
372 |
max_height = get_issues_to_pdf_write_cells(pdf, col_values, col_width)
|
... | ... | |
330 |
376 |
render_table_header(pdf, query, col_width, row_height, table_width)
|
331 |
377 |
base_y = pdf.get_y
|
332 |
378 |
end
|
333 |
|
|
|
379 |
|
334 |
380 |
# write the cells on page
|
335 |
381 |
issues_to_pdf_write_cells(pdf, col_values, col_width, max_height)
|
336 |
382 |
pdf.set_y(base_y + max_height)
|
337 |
|
|
|
383 |
|
338 |
384 |
if query.has_column?(:description) && issue.description?
|
339 |
385 |
pdf.set_x(10)
|
340 |
386 |
pdf.set_auto_page_break(true, bottom_margin)
|
... | ... | |
349 |
395 |
pdf.set_auto_page_break(false)
|
350 |
396 |
end
|
351 |
397 |
end
|
352 |
|
|
|
398 |
|
353 |
399 |
if issues.size == Setting.issues_export_limit.to_i
|
354 |
400 |
pdf.SetFontStyle('B',10)
|
355 |
401 |
pdf.RDMCell(0, row_height, '...')
|