diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 716816e34..d8fd95b6a 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -58,15 +58,17 @@ class IssuesController < ApplicationController end def show - @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user @custom_values = @issue.custom_values.find(:all, :include => :custom_field) @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") - end - - def export_pdf - @custom_values = @issue.custom_values.find(:all, :include => :custom_field) - @options_for_rfpdf ||= {} - @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf" + + if params[:format]=='pdf' + @options_for_rfpdf ||= {} + @options_for_rfpdf[:file_name] = "#{@project.identifier}-#{@issue.id}.pdf" + render :template => 'issues/show.rfpdf', :layout => false + else + @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user + render :template => 'issues/show.rhtml' + end end def edit diff --git a/app/views/issues/_pdf.rfpdf b/app/views/issues/_pdf.rfpdf index 485066894..558399abb 100644 --- a/app/views/issues/_pdf.rfpdf +++ b/app/views/issues/_pdf.rfpdf @@ -70,7 +70,7 @@ pdf.SetFontStyle('B',9) pdf.Cell(190,5, l(:label_history), "B") pdf.Ln - for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc") + for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") pdf.SetFontStyle('B',8) pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name) pdf.Ln @@ -86,15 +86,17 @@ pdf.Ln end - pdf.SetFontStyle('B',9) - pdf.Cell(190,5, l(:label_attachment_plural), "B") - pdf.Ln - for attachment in issue.attachments - pdf.SetFontStyle('',8) - pdf.Cell(80,5, attachment.filename) - pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") - pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R") - pdf.Cell(65,5, attachment.author.name,0,0,"R") + if issue.attachments.any? + pdf.SetFontStyle('B',9) + pdf.Cell(190,5, l(:label_attachment_plural), "B") pdf.Ln + for attachment in issue.attachments + pdf.SetFontStyle('',8) + pdf.Cell(80,5, attachment.filename) + pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") + pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R") + pdf.Cell(65,5, attachment.author.name,0,0,"R") + pdf.Ln + end end -%> \ No newline at end of file +%> diff --git a/app/views/issues/export_pdf.rfpdf b/app/views/issues/show.rfpdf similarity index 90% rename from app/views/issues/export_pdf.rfpdf rename to app/views/issues/show.rfpdf index 51a71c0c1..08f2cb92d 100644 --- a/app/views/issues/export_pdf.rfpdf +++ b/app/views/issues/show.rfpdf @@ -7,4 +7,4 @@ render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue } %> -<%= pdf.Output %> \ No newline at end of file +<%= pdf.Output %> diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index 9075df9f9..ed615c69f 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -111,7 +111,7 @@ end %> <% end %>