From 5b30f90912be8fe434f1c1f51ef0b242606cfd74 Mon Sep 17 00:00:00 2001 From: Bernhard Furtmueller Date: Fri, 28 Jan 2011 19:48:36 +0000 Subject: [PATCH] Forward port of: Export issue to PDF does not include Subtaks and Related Issues 409798c61eb6d30c3c18daabc2211908b1c1c694 5fdef11fa74aea36ba3bbfff916cbe6f95b76d4f --- lib/redmine/export/pdf.rb | 71 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 64 insertions(+), 7 deletions(-) diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index c98b25f..dd973cc 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -193,8 +193,19 @@ module Redmine pdf.footer_date = format_date(Date.today) pdf.AddPage - pdf.SetFontStyle('B',11) - pdf.Cell(190,10, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}") + i = 0 + pdf.SetFontStyle('',9) + issue.ancestors.each do |ancestor| + if i == 0 + pdf.MultiCell(190,5,(i>=1?" " * i + ">":"") + "#{ancestor.project} - #{ancestor.tracker} # #{ancestor.id}: #{ancestor.subject} (#{ancestor.status.to_s})", "0", 1 ) + else + pdf.MultiCell(190,5,(i>=1?" " * i + ">":"") + "#{ancestor.project} - #{ancestor.tracker} # #{ancestor.id}: #{ancestor.subject} (#{ancestor.status.to_s})", "0", 1 ) + end + i += 1 + end + + pdf.SetFontStyle('B',11) + pdf.Cell(190,10,(i>=1?" " * (i+1) + ">":"") + "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}") pdf.Ln y0 = pdf.GetY @@ -253,12 +264,58 @@ module Redmine pdf.Ln pdf.SetFontStyle('B',9) - pdf.Cell(35,5, l(:field_description) + ":") + y = pdf.GetY + x = pdf.GetX + pdf.Cell(35,5, l(:field_description) + ":","") pdf.SetFontStyle('',9) - pdf.MultiCell(155,5, issue.description.to_s,"BR") - - pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY) - pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY) + pdf.MultiCell(155,5, issue.description,"R") + pdf.Line(x,y,x,pdf.GetY) + + i = 0 + issue_list(issue.descendants.sort_by(&:lft)) do |child, level| + if i == 0 + pdf.SetFontStyle('B',9) + pdf.Cell(35,5, l(:label_subtask_plural) + ":", "LT") + pdf.SetFontStyle('', 9) + pdf.Cell(125,5,(level>=1?" " * level + ">":"") + "#{child.project} - #{child.tracker} # #{child.id}: #{child.subject}".first(80)+"...", "T") + pdf.SetFontStyle('B',9) + pdf.Cell(30,5, "#{child.status.to_s}", "RT",0,"L",true) + pdf.Ln + else + pdf.SetFontStyle('B',9) + pdf.Cell(35,5, "", "L") + pdf.SetFontStyle('', 9) + pdf.Cell(125,5,(level>=1?" " * level + ">":"") + "#{child.project} - #{child.tracker} # #{child.id}: #{child.subject}".first(80)+"...", "0") + pdf.SetFontStyle('B',9) + pdf.Cell(30,5, "#{child.status.to_s}", "R",0,"L",true) + pdf.Ln + end + i += 1 + end + + i = 0 + issue.relations.select { |r| r.other_issue(issue).visible? }.each do |relation| + if i == 0 + pdf.SetFontStyle('B',9) + pdf.Cell(35,5, l(relation.label_for(issue)) + ":", "LT") + pdf.SetFontStyle('', 9) + pdf.Cell(125,5, "#{relation.other_issue(issue).project} - #{relation.other_issue(issue).tracker} # #{relation.other_issue(issue).id}: #{relation.other_issue(issue).subject}".first(80) + "...", "T") + pdf.SetFontStyle('B',9) + pdf.Cell(30,5, "#{relation.other_issue(issue).status.to_s}", "RT",0,"L",true) + pdf.Ln + else + pdf.SetFontStyle('B',9) + pdf.Cell(35,5, l(relation.label_for(issue)) + ":", "L") + pdf.SetFontStyle('', 9) + pdf.Cell(125,5, "#{relation.other_issue(issue).project} - #{relation.other_issue(issue).tracker} # #{relation.other_issue(issue).id}: #{relation.other_issue(issue).subject}".first(80) + "...", "0") + pdf.SetFontStyle('B',9) + pdf.Cell(30,5, "#{relation.other_issue(issue).status.to_s}", "R",0,"L",true) + pdf.Ln + end + i += 1 + end + + pdf.Cell(190,5, "", "T",0) pdf.Ln if issue.changesets.any? && User.current.allowed_to?(:view_changesets, issue.project) -- 1.6.5.2