##// END OF EJS Templates
Use selected columns in the issues PDF export (#1190)....
Jean-Philippe Lang -
r2736:a49506ce5fa9
parent child
Show More
@@ -110,12 +110,20 module Redmine
110 110 # Returns a PDF string of a list of issues
111 111 def issues_to_pdf(issues, project, query)
112 112 pdf = IFPDF.new(current_language)
113 title = project ? "#{project} - #{l(:label_issue_plural)}" : "#{l(:label_issue_plural)}"
113 title = query.new_record? ? l(:label_issue_plural) : query.name
114 title = "#{project} - #{title}" if project
114 115 pdf.SetTitle(title)
115 116 pdf.AliasNbPages
116 117 pdf.footer_date = format_date(Date.today)
117 118 pdf.AddPage("L")
118 row_height = 7
119
120 row_height = 6
121 col_width = []
122 unless query.columns.empty?
123 col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
124 ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
125 col_width = col_width.collect {|w| w * ratio}
126 end
119 127
120 128 # title
121 129 pdf.SetFontStyle('B',11)
@@ -123,44 +131,47 module Redmine
123 131 pdf.Ln
124 132
125 133 # headers
126 pdf.SetFontStyle('B',10)
134 pdf.SetFontStyle('B',8)
127 135 pdf.SetFillColor(230, 230, 230)
128 pdf.Cell(15, row_height, "#", 0, 0, 'L', 1)
129 pdf.Cell(30, row_height, l(:field_tracker), 0, 0, 'L', 1)
130 pdf.Cell(30, row_height, l(:field_status), 0, 0, 'L', 1)
131 pdf.Cell(30, row_height, l(:field_priority), 0, 0, 'L', 1)
132 pdf.Cell(40, row_height, l(:field_assigned_to), 0, 0, 'L', 1)
133 pdf.Cell(25, row_height, l(:field_updated_on), 0, 0, 'L', 1)
134 pdf.Cell(0, row_height, l(:field_subject), 0, 0, 'L', 1)
135 pdf.Line(10, pdf.GetY, 287, pdf.GetY)
136 pdf.Cell(15, row_height, "#", 1, 0, 'L', 1)
137 query.columns.each_with_index do |column, i|
138 pdf.Cell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
139 end
136 140 pdf.Ln
137 pdf.Line(10, pdf.GetY, 287, pdf.GetY)
138 pdf.SetY(pdf.GetY() + 1)
139 141
140 142 # rows
141 pdf.SetFontStyle('',9)
143 pdf.SetFontStyle('',8)
142 144 pdf.SetFillColor(255, 255, 255)
143 145 group = false
144 146 issues.each do |issue|
145 147 if query.grouped? && issue.send(query.group_by) != group
146 148 group = issue.send(query.group_by)
147 pdf.SetFontStyle('B',10)
148 pdf.Cell(0, row_height, "#{group.blank? ? 'None' : group.to_s}", 0, 1, 'L')
149 pdf.Line(10, pdf.GetY, 287, pdf.GetY)
150 pdf.SetY(pdf.GetY() + 0.5)
151 pdf.Line(10, pdf.GetY, 287, pdf.GetY)
152 pdf.SetY(pdf.GetY() + 1)
153 pdf.SetFontStyle('',9)
149 pdf.SetFontStyle('B',9)
150 pdf.Cell(277, row_height, "#{group.blank? ? 'None' : group.to_s}", 1, 1, 'L')
151 pdf.SetFontStyle('',8)
154 152 end
155 pdf.Cell(15, row_height, issue.id.to_s, 0, 0, 'L', 1)
156 pdf.Cell(30, row_height, issue.tracker.name, 0, 0, 'L', 1)
157 pdf.Cell(30, row_height, issue.status.name, 0, 0, 'L', 1)
158 pdf.Cell(30, row_height, issue.priority.name, 0, 0, 'L', 1)
159 pdf.Cell(40, row_height, issue.assigned_to ? issue.assigned_to.to_s : '', 0, 0, 'L', 1)
160 pdf.Cell(25, row_height, format_date(issue.updated_on), 0, 0, 'L', 1)
161 pdf.MultiCell(0, row_height, (project == issue.project ? issue.subject : "#{issue.project} - #{issue.subject}"))
162 pdf.Line(10, pdf.GetY, 287, pdf.GetY)
163 pdf.SetY(pdf.GetY() + 1)
153 pdf.Cell(15, row_height, issue.id.to_s, 1, 0, 'L', 1)
154 query.columns.each_with_index do |column, i|
155 s = if column.is_a?(QueryCustomFieldColumn)
156 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
157 show_value(cv)
158 else
159 value = issue.send(column.name)
160 if value.is_a?(Date)
161 format_date(value)
162 elsif value.is_a?(Time)
163 format_time(value)
164 else
165 value
166 end
167 end
168 pdf.Cell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1)
169 end
170 pdf.Ln
171 end
172 if issues.size == Setting.issues_export_limit.to_i
173 pdf.SetFontStyle('B',10)
174 pdf.Cell(0, row_height, '...')
164 175 end
165 176 pdf.Output
166 177 end
General Comments 0
You need to be logged in to leave comments. Login now