Project

General

Profile

Feature #5125 » roadmap-pdf-updated.patch

Updated for 0.9.x - Doug Goldstein, 2010-07-02 00:19

View differences:

redmine-0.9.4-patched/app/controllers/issues_controller.rb 2010-07-01 15:12:33.948001482 -0500
respond_to do |format|
format.html { render :template => 'issues/show.rhtml' }
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
redmine-0.9.4-patched/app/controllers/projects_controller.rb 2010-07-01 15:20:44.076057803 -0500
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
......
@issues_by_version[version] = issues
end
end
@versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].empty?}
@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
redmine-0.9.4-patched/app/controllers/versions_controller.rb 2010-07-01 15:23:57.920050615 -0500
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 edit
redmine-0.9.4-patched/app/helpers/versions_helper.rb 2010-07-01 15:25:24.636323004 -0500
# 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)
redmine-0.9.4-patched/app/models/issue.rb 2010-07-01 15:41:30.140136642 -0500
named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
named_scope :for_roadmap, :include => [:status, :project, :tracker],
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id"
before_save :update_done_ratio_from_issue_status
after_save :create_journal
redmine-0.9.4-patched/app/views/projects/roadmap.rhtml 2010-07-01 15:46:02.212030406 -0500
<%= 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 %>
redmine-0.9.4-patched/app/views/versions/show.rhtml 2010-07-01 15:52:25.740023279 -0500
<%= 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 %>
redmine-0.9.4-patched/lib/redmine/export/pdf.rb 2010-07-01 16:08:33.489175239 -0500
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
(2-2/2)