Feature #5125 » roadmap_pdf_export.patch
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
format.html { render :template => 'issues/show.rhtml' }
|
||
|
format.xml { render :layout => false }
|
||
|
format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
|
||
|
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
|
||
|
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf",
|
||
|
:disposition => 'inline') }
|
||
|
end
|
||
|
end
|
||
| app/controllers/projects_controller.rb | ||
|---|---|---|
|
include CustomFieldsHelper
|
||
|
helper :issues
|
||
|
helper IssuesHelper
|
||
|
include IssuesHelper
|
||
|
helper :queries
|
||
|
include QueriesHelper
|
||
|
helper :repositories
|
||
|
include RepositoriesHelper
|
||
|
include ProjectsHelper
|
||
|
include Redmine::Export::PDF
|
||
|
|
||
|
# Lists visible projects
|
||
|
def index
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
|
||
|
respond_to do |format|
|
||
|
format.html { render :template => 'projects/roadmap.rhtml' }
|
||
|
format.pdf { send_data(versions_to_pdf(@versions, @issues_by_version),
|
||
|
:type => 'application/pdf',
|
||
|
:filename => "#{@project.identifier}-roadmap.pdf",
|
||
|
:disposition => 'inline') }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def activity
|
||
| app/controllers/versions_controller.rb | ||
|---|---|---|
|
helper :custom_fields
|
||
|
helper :projects
|
||
|
helper :issues
|
||
|
include IssuesHelper
|
||
|
include Redmine::Export::PDF
|
||
|
|
||
|
def show
|
||
|
respond_to do |format|
|
||
|
format.html { render :template => 'versions/show.rhtml' }
|
||
|
format.pdf { send_data(version_to_pdf(@version), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@version.id}.pdf",
|
||
|
:disposition => 'inline') }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def new
|
||
| app/helpers/versions_helper.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module VersionsHelper
|
||
|
include IssuesHelper
|
||
|
STATUS_BY_CRITERIAS = %w(category tracker priority author assigned_to)
|
||
|
|
||
| app/models/issue.rb | ||
|---|---|---|
|
named_scope :with_limit, lambda { |limit| { :limit => limit} }
|
||
|
named_scope :on_active_project, :include => [:status, :project, :tracker],
|
||
|
:conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
|
||
|
named_scope :for_roadmap, :include => [:status, :project, :tracker],
|
||
|
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id"
|
||
|
before_create :default_assign
|
||
|
before_save :reschedule_following_issues, :close_duplicates, :update_done_ratio_from_issue_status
|
||
| app/views/projects/roadmap.rhtml | ||
|---|---|---|
|
<%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% other_formats_links do |f| %>
|
||
|
<%= f.link_to 'PDF' %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
<% content_for :sidebar do %>
|
||
| app/views/versions/show.rhtml | ||
|---|---|---|
|
<%= render :partial => 'versions/overview', :locals => {:version => @version} %>
|
||
|
<%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
|
||
|
<% issues = @version.fixed_issues.find(:all,
|
||
|
:include => [:status, :tracker, :priority],
|
||
|
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") %>
|
||
|
<% issues = @version.fixed_issues.for_roadmap %>
|
||
|
<% if issues.size > 0 %>
|
||
|
<fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
|
||
|
<ul>
|
||
| ... | ... | |
|
<% end %>
|
||
|
</div>
|
||
|
<% other_formats_links do |f| %>
|
||
|
<%= f.link_to 'PDF' %>
|
||
|
<% end %>
|
||
|
<%= call_hook :view_versions_show_bottom, :version => @version %>
|
||
|
<% html_title @version.name %>
|
||
| lib/redmine/export/pdf.rb | ||
|---|---|---|
|
SetX(-30)
|
||
|
Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
|
||
|
end
|
||
|
# Patching the buggy page detection in FPDF that leads to only the last link
|
||
|
# being really added to the document
|
||
|
def Link(x, y, w, h, link)
|
||
|
# Put a link on the page
|
||
|
@PageLinks[@page]=Array.new unless @PageLinks.has_key?(@page)
|
||
|
@PageLinks[@page].push([x*@k,@hPt-y*@k,w*@k,h*@k,link])
|
||
|
end
|
||
|
end
|
||
|
|
||
|
# Returns a PDF string of a list of issues
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
# Returns a PDF string of a single issue
|
||
|
def issue_to_pdf(issue)
|
||
|
pdf = IFPDF.new(current_language)
|
||
|
pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
|
||
|
pdf.AliasNbPages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.AddPage
|
||
|
def issue_to_pdf(issue, pdf_document = nil)
|
||
|
# reuse existing PDF document or create a new one
|
||
|
pdf = pdf_document || IFPDF.new(current_language)
|
||
|
unless pdf_document
|
||
|
# PDF document was not given - so we initialize the new document
|
||
|
pdf.SetTitle("#{issue.project} - #{issue.tracker} ##{issue.id}")
|
||
|
pdf.AliasNbPages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.AddPage
|
||
|
end
|
||
|
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
pdf.Cell(190,10, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
pdf.Cell(190,2, "#{issue.project} - #{issue.tracker} ##{issue.id}")
|
||
|
pdf.Ln
|
||
|
pdf.SetFontStyle('',11)
|
||
|
pdf.Cell(190,7, "#{issue.subject}")
|
||
|
pdf.Ln
|
||
|
pdf.Cell(190,4, " ")
|
||
|
pdf.Ln
|
||
|
|
||
|
y0 = pdf.GetY
|
||
| ... | ... | |
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.Cell(35,5, l(:field_description) + ":")
|
||
|
pdf.SetFontStyle('',9)
|
||
|
pdf.MultiCell(155,5, @issue.description,"BR")
|
||
|
pdf.MultiCell(155,5, issue.description,"BR")
|
||
|
|
||
|
pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
|
||
|
pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
|
||
| ... | ... | |
|
pdf.Ln
|
||
|
end
|
||
|
end
|
||
|
pdf.Output
|
||
|
# Print out the pdf if we're not working on external document
|
||
|
pdf.Output unless pdf_document
|
||
|
end
|
||
|
|
||
|
# Returns a PDF string of a gantt chart
|
||
| ... | ... | |
|
pdf.Line(15, top, subject_width+g_width, top)
|
||
|
pdf.Output
|
||
|
end
|
||
|
|
||
|
# Returns a PDF string of a single version
|
||
|
def version_to_pdf(version, include_issues = true, pdf_document = nil)
|
||
|
pdf = pdf_document || IFPDF.new(current_language)
|
||
|
unless pdf_document
|
||
|
pdf.SetTitle("#{version.project} - #{version.name}")
|
||
|
pdf.AliasNbPages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.AddPage
|
||
|
end
|
||
|
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
pdf.Cell(0,10, "#{version.project} - #{version.name}")
|
||
|
pdf.Ln
|
||
|
pdf.SetFontStyle('I',7)
|
||
|
pdf.Cell(0,1,
|
||
|
l(:label_x_closed_issues_abbr, :count => version.closed_issues_count) +
|
||
|
' ('+('%0.0f' % (version.closed_issues_count.to_f / version.fixed_issues.count * 100))+'%), ' +
|
||
|
l(:label_x_open_issues_abbr, :count => version.open_issues_count) +
|
||
|
' ('+('%0.0f' % (version.open_issues_count.to_f / version.fixed_issues.count * 100))+'%)'
|
||
|
)
|
||
|
pdf.Ln
|
||
|
pdf.Cell(0,4," ")
|
||
|
pdf.Ln
|
||
|
|
||
|
issues = version.fixed_issues.for_roadmap
|
||
|
|
||
|
# Collect all created links
|
||
|
@issues_links ||= {}
|
||
|
|
||
|
# Print issues overview
|
||
|
pdf.SetFontStyle('', 8)
|
||
|
issues.each do |issue|
|
||
|
issue_id = "#{issue.tracker} ##{issue.id}:"
|
||
|
id_width = pdf.GetStringWidth(issue_id)
|
||
|
# Create new link
|
||
|
@issues_links[issue.id] = pdf.AddLink
|
||
|
if issue.closed?
|
||
|
pdf.SetTextColor(0xA0, 0xA0, 0xA0)
|
||
|
pdf.SetDrawColor(0xA0, 0xA0, 0xA0)
|
||
|
else
|
||
|
pdf.SetTextColor(0x35, 0x61, 0x8C)
|
||
|
end
|
||
|
pdf.Cell(id_width+1, 4, issue_id, 0, 0, 'L', false, @issues_links[issue.id])
|
||
|
if issue.closed?
|
||
|
curx = pdf.GetX
|
||
|
pdf.Line(curx-1, pdf.GetY+2, curx-id_width, pdf.GetY+2)
|
||
|
end
|
||
|
pdf.SetTextColor(0, 0, 0)
|
||
|
pdf.SetDrawColor(0, 0, 0)
|
||
|
pdf.Cell(0, 4, issue.subject)
|
||
|
pdf.Ln
|
||
|
end
|
||
|
|
||
|
# Print issues details
|
||
|
issues.each do |issue|
|
||
|
pdf.AddPage
|
||
|
pdf.SetLink(@issues_links[issue.id])
|
||
|
issue_to_pdf(issue, pdf)
|
||
|
end if include_issues
|
||
|
|
||
|
pdf.Output unless pdf_document
|
||
|
end
|
||
|
|
||
|
# Returns a PDF string of all versions (roadmap)
|
||
|
def versions_to_pdf(versions, issues_by_version)
|
||
|
pdf = IFPDF.new(current_language)
|
||
|
pdf.SetTitle(l(:label_roadmap))
|
||
|
pdf.AliasNbPages
|
||
|
pdf.footer_date = format_date(Date.today)
|
||
|
pdf.AddPage
|
||
|
|
||
|
# Print versions overview
|
||
|
versions.each do |version|
|
||
|
version_to_pdf(version, false, pdf)
|
||
|
pdf.Cell(0, 6, ' ')
|
||
|
pdf.Ln
|
||
|
end
|
||
|
# Print issues details
|
||
|
versions.each do |version|
|
||
|
issues_by_version[version].each do |issue|
|
||
|
pdf.AddPage
|
||
|
pdf.SetLink(@issues_links[issue.id])
|
||
|
issue_to_pdf(issue, pdf)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
pdf.Output
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||