Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,7 +1,7 @@
# encoding: utf-8
#
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -45,35 +45,31 @@ module Redmine
pdf.SetFontStyle('',8)
pdf.RDMMultiCell(190, 5, "#{format_time(issue.created_on)} - #{issue.author}")
pdf.ln
left = []
left << [l(:field_status), issue.status]
left << [l(:field_priority), issue.priority]
left << [l(:field_assigned_to), issue.assigned_to] unless issue.disabled_core_fields.include?('assigned_to_id')
left << [l(:field_category), issue.category] unless issue.disabled_core_fields.include?('category_id')
left << [l(:field_fixed_version), issue.fixed_version] unless issue.disabled_core_fields.include?('fixed_version_id')
right = []
right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date')
right << [l(:field_due_date), format_date(issue.due_date)] unless issue.disabled_core_fields.include?('due_date')
right << [l(:field_done_ratio), "#{issue.done_ratio}%"] unless issue.disabled_core_fields.include?('done_ratio')
right << [l(:field_estimated_hours), l_hours(issue.estimated_hours)] unless issue.disabled_core_fields.include?('estimated_hours')
right << [l(:label_spent_time), l_hours(issue.total_spent_hours)] if User.current.allowed_to?(:view_time_entries, issue.project)
rows = left.size > right.size ? left.size : right.size
while left.size < rows
left << nil
end
while right.size < rows
right << nil
end
left << nil while left.size < rows
right << nil while right.size < rows
custom_field_values = issue.visible_custom_field_values.reject {|value| value.custom_field.full_width_layout?}
half = (custom_field_values.size / 2.0).ceil
custom_field_values.each_with_index do |custom_value, i|
(i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
end
if pdf.get_rtl
border_first_top = 'RT'
border_last_top = 'LT'
@ -85,7 +81,7 @@ module Redmine
border_first = 'L'
border_last = 'R'
end
rows = left.size > right.size ? left.size : right.size
rows.times do |i|
heights = []
@ -100,34 +96,36 @@ module Redmine
item = right[i]
heights << pdf.get_string_height(60, item ? item.last.to_s : "")
height = heights.max
item = left[i]
pdf.SetFontStyle('B',9)
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
pdf.SetFontStyle('',9)
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0)
item = right[i]
pdf.SetFontStyle('B',9)
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
pdf.SetFontStyle('',9)
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2)
pdf.set_x(base_x)
end
pdf.SetFontStyle('B',9)
pdf.RDMCell(35+155, 5, l(:field_description), "LRT", 1)
pdf.SetFontStyle('',9)
# Set resize image scale
pdf.set_image_scale(1.6)
text = textilizable(issue, :description,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
text =
textilizable(
issue, :description,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
custom_field_values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?}
@ -157,7 +155,7 @@ module Redmine
pdf.ln
end
end
relations = issue.relations.select { |r| r.other_issue(issue).visible? }
unless relations.empty?
truncate_length = (!is_cjk? ? 80 : 60)
@ -185,7 +183,7 @@ module Redmine
end
pdf.RDMCell(190,5, "", "T")
pdf.ln
if issue.changesets.any? &&
User.current.allowed_to?(:view_changesets, issue.project)
pdf.SetFontStyle('B',9)
@ -199,13 +197,14 @@ module Redmine
pdf.ln
unless changeset.comments.blank?
pdf.SetFontStyle('',8)
pdf.RDMwriteHTMLCell(190,5,'','',
pdf.RDMwriteHTMLCell(
190,5,'','',
changeset.comments.to_s, issue.attachments, "")
end
pdf.ln
end
end
if assoc[:journals].present?
pdf.SetFontStyle('B',9)
pdf.RDMCell(190,5, l(:label_history), "B")
@ -213,7 +212,7 @@ module Redmine
assoc[:journals].each do |journal|
pdf.SetFontStyle('B',8)
title = "##{journal.indice} - #{format_time(journal.created_on)} - #{journal.user}"
title << " (#{l(:field_private_notes)})" if journal.private_notes?
title += " (#{l(:field_private_notes)})" if journal.private_notes?
pdf.RDMCell(190,5, title)
pdf.ln
pdf.SetFontStyle('I',8)
@ -223,18 +222,20 @@ module Redmine
if journal.notes?
pdf.ln unless journal.details.empty?
pdf.SetFontStyle('',8)
text = textilizable(journal, :notes,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
text =
textilizable(
journal, :notes,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
pdf.RDMwriteFormattedCell(190,5,'','', text, issue.attachments, "")
end
pdf.ln
end
end
if issue.attachments.any?
pdf.SetFontStyle('B',9)
pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
@ -261,7 +262,7 @@ module Redmine
pdf.footer_date = format_date(User.current.today)
pdf.set_auto_page_break(false)
pdf.add_page("L")
# Landscape A4 = 210 x 297 mm
page_height = pdf.get_page_height # 210
page_width = pdf.get_page_width # 297
@ -269,7 +270,7 @@ module Redmine
right_margin = pdf.get_original_margins['right'] # 10
bottom_margin = pdf.get_footer_margin
row_height = 4
# column widths
table_width = page_width - right_margin - left_margin
col_width = []
@ -277,13 +278,13 @@ module Redmine
col_width = calc_col_width(issues, query, table_width, pdf)
table_width = col_width.inject(0, :+)
end
# use full width if the description or last_notes are displayed
if table_width > 0 && (query.has_column?(:description) || query.has_column?(:last_notes))
# use full width if the query has block columns (description, last_notes or full width custom fieds)
if table_width > 0 && query.block_columns.any?
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
table_width = col_width.inject(0, :+)
end
# title
pdf.SetFontStyle('B',11)
pdf.RDMCell(190, 8, title)
@ -303,9 +304,9 @@ module Redmine
issue_list(issues) do |issue, level|
if query.grouped? &&
(group = query.group_by_column.value(issue)) != previous_group
(group = query.group_by_column.group_value(issue)) != previous_group
pdf.SetFontStyle('B',10)
group_label = group.blank? ? 'None' : group.to_s.dup
group_label = group.blank? ? +'None' : group.to_s.dup
group_label << " (#{result_count_by_group[group]})"
pdf.bookmark group_label, 0, -1
pdf.RDMCell(table_width, row_height * 2, group_label, 'LR', 1, 'L')
@ -317,10 +318,10 @@ module Redmine
end
previous_group = group
end
# fetch row values
col_values = fetch_row_values(issue, query, level)
# make new page if it doesn't fit on the current one
base_y = pdf.get_y
max_height = get_issues_to_pdf_write_cells(pdf, col_values, col_width)
@ -330,26 +331,30 @@ module Redmine
render_table_header(pdf, query, col_width, row_height, table_width)
base_y = pdf.get_y
end
# write the cells on page
issues_to_pdf_write_cells(pdf, col_values, col_width, max_height)
pdf.set_y(base_y + max_height)
if query.has_column?(:description) && issue.description?
pdf.set_x(10)
pdf.set_auto_page_break(true, bottom_margin)
pdf.RDMwriteHTMLCell(0, 5, 10, '', issue.description.to_s, issue.attachments, "LRBT")
pdf.set_auto_page_break(false)
end
if query.has_column?(:last_notes) && issue.last_notes.present?
pdf.set_x(10)
pdf.set_auto_page_break(true, bottom_margin)
pdf.RDMwriteHTMLCell(0, 5, 10, '', issue.last_notes.to_s, [], "LRBT")
pdf.set_auto_page_break(false)
query.block_columns.each do |column|
if column.is_a?(QueryCustomFieldColumn)
cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
text = show_value(cv, false)
else
text = issue.send(column.name)
end
next if text.blank?
pdf.set_x(10)
pdf.set_auto_page_break(true, bottom_margin)
pdf.SetFontStyle('B',9)
pdf.RDMCell(0, 5, column.caption, "LRT", 1)
pdf.SetFontStyle('',9)
pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
pdf.set_auto_page_break(false)
end
end
end
if issues.size == Setting.issues_export_limit.to_i
pdf.SetFontStyle('B',10)
pdf.RDMCell(0, row_height, '...')
@ -369,25 +374,28 @@ module Redmine
# fetch row values
def fetch_row_values(issue, query, level)
query.inline_columns.collect do |column|
s = if column.is_a?(QueryCustomFieldColumn)
cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
show_value(cv, false)
else
value = issue.send(column.name)
case column.name
when :subject
value = " " * level + value
when :attachments
value = value.to_a.map {|a| a.filename}.join("\n")
end
if value.is_a?(Date)
format_date(value)
elsif value.is_a?(Time)
format_time(value)
s =
if column.is_a?(QueryCustomFieldColumn)
cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
show_value(cv, false)
else
value
value = column.value_object(issue)
case column.name
when :subject
value = " " * level + value
when :attachments
value = value.to_a.map {|a| a.filename}.join("\n")
end
if value.is_a?(Date)
format_date(value)
elsif value.is_a?(Time)
format_time(value)
elsif value.is_a?(Float)
sprintf "%.2f", value
else
value
end
end
end
s.to_s
end
end