mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Added PDF hooks
This commit is contained in:
@@ -55,16 +55,10 @@ module IssuesPdfHelperPatch
|
||||
left << [l(:field_priority), issue.priority]
|
||||
left << [l(:field_customer), customer]
|
||||
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')
|
||||
|
||||
v = Vehicle.find_by_id(issue.vehicles_id)
|
||||
vehicle = v ? v.to_s : nil
|
||||
vin = v ? v.vin : nil
|
||||
notes = v ? v.notes : nil
|
||||
left << [l(:field_vehicles), vehicle]
|
||||
left << [l(:field_vin), vin ? vin.gsub(/(.{9})/, '\1 ') : nil]
|
||||
#left << [l(:field_notes), notes]
|
||||
|
||||
logger.debug "Calling :pdf_left hook"
|
||||
context = Redmine::Hook.call_hook :pdf_left, { array: left, issue: issue }
|
||||
left = left + context.first unless context.nil?
|
||||
|
||||
right = []
|
||||
right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date')
|
||||
@@ -72,7 +66,10 @@ module IssuesPdfHelperPatch
|
||||
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)
|
||||
right << [l(:field_notes), notes]
|
||||
|
||||
logger.debug "Calling :pdf_right hook"
|
||||
context = Redmine::Hook.call_hook :pdf_right, { array: right, issue: issue }
|
||||
right = right + context.first unless context.nil?
|
||||
|
||||
rows = left.size > right.size ? left.size : right.size
|
||||
while left.size < rows
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# TODO move this into seperate plugin
|
||||
class QboHookListener < Redmine::Hook::Listener
|
||||
|
||||
# Load the javascript to support the autocomplete forms
|
||||
# Check to see if the Invoice custom field VIN matches
|
||||
def process_invoice_custom_fields(context = {})
|
||||
Rails.logger.debug "QboHookListener.process_invoice_custom_fields"
|
||||
issue = context[:issue]
|
||||
@@ -46,4 +46,27 @@ class QboHookListener < Redmine::Hook::Listener
|
||||
return { issue: issue, invoice: invoice, is_changed: is_changed }
|
||||
end
|
||||
|
||||
# Add vehicle information to the left side of the pdf attribute block
|
||||
def pdf_left(context = {})
|
||||
left = []
|
||||
issue = context[:issue]
|
||||
v = Vehicle.find_by_id(issue.vehicles_id)
|
||||
vehicle = v.to_s unless v.nil?
|
||||
vin = v.vin.gsub(/(.{9})/, '\1 ') unless v.nil?
|
||||
|
||||
left << [l(:field_vehicles), vehicle]
|
||||
left << [l(:field_vin), vin]
|
||||
return left
|
||||
end
|
||||
|
||||
# Add vehicle information to the right side of the pdf attribute block
|
||||
def pdf_right(context = {})
|
||||
right = []
|
||||
issue = context[:issue]
|
||||
v = Vehicle.find_by_id(issue.vehicles_id)
|
||||
notes = v unless v.nil?
|
||||
right << [l(:field_notes), notes]
|
||||
return right
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user