mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-02-13 09:34:00 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f960c65f0 | |||
| db3c8be03d | |||
| 8eecdc0ddd | |||
| c477f7a37e | |||
| 2f49a21fed | |||
| 896d5a64ba |
@@ -12,7 +12,6 @@ class Vehicle < ActiveRecord::Base
|
|||||||
|
|
||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
has_many :issues
|
has_many :issues
|
||||||
has_many :projects
|
|
||||||
validates_presence_of :customer
|
validates_presence_of :customer
|
||||||
validates :vin, uniqueness: true
|
validates :vin, uniqueness: true
|
||||||
before_save :decode_vin
|
before_save :decode_vin
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ en:
|
|||||||
label_make: " Make"
|
label_make: " Make"
|
||||||
label_model: "Model"
|
label_model: "Model"
|
||||||
label_no_vehicles: "There are no vehicles containing the term(s)"
|
label_no_vehicles: "There are no vehicles containing the term(s)"
|
||||||
label_no_customers: "There are no customers containing the term(s)"
|
|
||||||
label_search_vin: "Search Vehicles by VIN"
|
label_search_vin: "Search Vehicles by VIN"
|
||||||
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
||||||
label_cusomer_vehicles: "Customer Vehicles"
|
label_cusomer_vehicles: "Customer Vehicles"
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ class CreateVehicles < ActiveRecord::Migration[5.1]
|
|||||||
|
|
||||||
add_reference :vehicles, :customers, index: true
|
add_reference :vehicles, :customers, index: true
|
||||||
add_reference :issues, :vehicle, index: true
|
add_reference :issues, :vehicle, index: true
|
||||||
add_reference :projects, :vehicle, index: true
|
|
||||||
}
|
}
|
||||||
rescue
|
rescue
|
||||||
logger.error "Failed to create vehicles & refrences"
|
Rails.logger.error "Failed to create vehicles & refrences"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,10 +14,9 @@ class UpdateVehicles < ActiveRecord::Migration[5.1]
|
|||||||
reversible do |direction|
|
reversible do |direction|
|
||||||
direction.up {
|
direction.up {
|
||||||
rename_column :issues, :vehicles_id, :vehicle_id
|
rename_column :issues, :vehicles_id, :vehicle_id
|
||||||
rename_column :projects, :vehicles_id, :vehicle_id
|
|
||||||
}
|
}
|
||||||
rescue
|
rescue
|
||||||
logger.error "Failed to update to use vehicle_id"
|
Rails.logger.error "Failed to update to use vehicle_id"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
3
init.rb
3
init.rb
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
|||||||
name 'Redmine QBO Vehicles plugin'
|
name 'Redmine QBO Vehicles plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
||||||
version '2026.1.0'
|
version '2026.1.1'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine :version_or_higher => '6.1.0'
|
requires_redmine :version_or_higher => '6.1.0'
|
||||||
@@ -28,7 +28,6 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
|||||||
|
|
||||||
# Add safe attributes for core models
|
# Add safe attributes for core models
|
||||||
Issue.safe_attributes 'vehicle_id'
|
Issue.safe_attributes 'vehicle_id'
|
||||||
Project.safe_attributes 'vehicle_id'
|
|
||||||
|
|
||||||
# Permissions for security
|
# Permissions for security
|
||||||
permission :view_vehicles, :vehicles => :new, :public => false
|
permission :view_vehicles, :vehicles => :new, :public => false
|
||||||
|
|||||||
64
lib/vehicles/hooks/invoice_hook_listener.rb
Normal file
64
lib/vehicles/hooks/invoice_hook_listener.rb
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2016 - 2026 rick barrette
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
module Vehicles
|
||||||
|
module Hooks
|
||||||
|
|
||||||
|
class InvoiceHookListener < Redmine::Hook::ViewListener
|
||||||
|
|
||||||
|
include IssuesHelper
|
||||||
|
|
||||||
|
# Called by Redmine QBO Invoice
|
||||||
|
def process_invoice_custom_fields(context={})
|
||||||
|
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields"
|
||||||
|
issue = context[:issue]
|
||||||
|
invoice = context[:invoice]
|
||||||
|
|
||||||
|
# update the invoive custom fields with infomation from the issue if available
|
||||||
|
context[:invoice].custom_fields.each do |cf|
|
||||||
|
|
||||||
|
Rails.logger.info "Checking invoice.custom field: #{cf.name}"
|
||||||
|
|
||||||
|
# VIN from the attached vehicle
|
||||||
|
begin
|
||||||
|
if cf.name.eql? "VIN"
|
||||||
|
# Only update if blank to prevent infite loops
|
||||||
|
# TODO check cf_sync_confict flag once implemented
|
||||||
|
if cf.string_value.to_s.blank?
|
||||||
|
|
||||||
|
Rails.logger.info "VIN was blank, updating the invoice vin in quickbooks"
|
||||||
|
vin = context[:issue].vehicle.vin
|
||||||
|
break if vin.nil?
|
||||||
|
|
||||||
|
if not cf.string_value.to_s.eql? vin
|
||||||
|
cf.string_value = vin.to_s
|
||||||
|
Rails.logger.info "VIN has changed"
|
||||||
|
context[:is_changed] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
#do nothing
|
||||||
|
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields failed, skipping"
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return context if context[:is_changed]
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -21,11 +21,6 @@ module Vehicles
|
|||||||
f = context[:form]
|
f = context[:form]
|
||||||
issue = context[:issue]
|
issue = context[:issue]
|
||||||
|
|
||||||
# check project level vehicle ownership first
|
|
||||||
# if context[:project]
|
|
||||||
# selected_vehicle = context[:project].vehicle.id unless context[:project].vehicle.nil?
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Check to see if the issue already belongs to a customer
|
# Check to see if the issue already belongs to a customer
|
||||||
selected_vehicle = issue.vehicle.id unless issue.vehicle.nil?
|
selected_vehicle = issue.vehicle.id unless issue.vehicle.nil?
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
#The MIT License (MIT)
|
|
||||||
#
|
|
||||||
#Copyright (c) 2016 - 2026 rick barrette
|
|
||||||
#
|
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
module Vehicles
|
|
||||||
module Hooks
|
|
||||||
|
|
||||||
class ProjectsFormHookListener < Redmine::Hook::ViewListener
|
|
||||||
|
|
||||||
# Edit Project Form
|
|
||||||
def view_projects_form(context={})
|
|
||||||
f = context[:form]
|
|
||||||
|
|
||||||
# Check to see if there is a quickbooks user attached to the issue
|
|
||||||
selected_customer = context[:project].customer ? context[:project].customer : nil
|
|
||||||
selected_vehicle = context[:project].vehicle_id ? context[:project].vehicle_id : nil
|
|
||||||
|
|
||||||
# Load customer information
|
|
||||||
customer = Customer.find_by_id(selected_customer) if selected_customer
|
|
||||||
search_customer = f.autocomplete_field :customer,
|
|
||||||
autocomplete_customer_name_customers_path,
|
|
||||||
:selected => selected_customer,
|
|
||||||
:update_elements => {:id => '#project_customer_id', :value => '#project_customer'}
|
|
||||||
|
|
||||||
customer_id = f.hidden_field :customer_id, :id => "project_customer_id"
|
|
||||||
|
|
||||||
if context[:project].customer
|
|
||||||
vehicles = customer.vehicles.pluck(:name, :id).sort!
|
|
||||||
else
|
|
||||||
vehicles = [nil].compact
|
|
||||||
end
|
|
||||||
|
|
||||||
vehicle = f.select :vehicle_id, vehicles, :selected => selected_vehicle, include_blank: true
|
|
||||||
|
|
||||||
return "<p><label for=\"project_customer\">Customer</label>#{search_customer} #{customer_id}</p> <p>#{vehicle}</p>"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,271 +0,0 @@
|
|||||||
#The MIT License (MIT)
|
|
||||||
#
|
|
||||||
#Copyright (c) 2016 - 2026 rick barrette
|
|
||||||
#
|
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
require_dependency 'redmine/export/pdf'
|
|
||||||
require_dependency 'redmine/export/pdf/issues_pdf_helper'
|
|
||||||
|
|
||||||
module Vehicles
|
|
||||||
module Patches
|
|
||||||
|
|
||||||
module PdfPatch
|
|
||||||
|
|
||||||
def self.included(base)
|
|
||||||
base.send(:include, InstanceMethods)
|
|
||||||
base.class_eval do
|
|
||||||
alias_method :issue_to_pdf, :issue_to_pdf_with_patch
|
|
||||||
alias_method :issue_to_pdf_with_patch, :issue_to_pdf
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module InstanceMethods
|
|
||||||
|
|
||||||
def issue_to_pdf_with_patch(issue, assoc={})
|
|
||||||
pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
|
|
||||||
pdf.set_title("#{issue.project} - #{issue.tracker} ##{issue.id}")
|
|
||||||
pdf.alias_nb_pages
|
|
||||||
pdf.footer_date = format_date(Date.today)
|
|
||||||
pdf.add_page
|
|
||||||
pdf.SetFontStyle('B',11)
|
|
||||||
buf = "#{issue.project} - #{issue.tracker} ##{issue.id}"
|
|
||||||
pdf.RDMMultiCell(190, 5, buf)
|
|
||||||
pdf.SetFontStyle('',8)
|
|
||||||
base_x = pdf.get_x
|
|
||||||
i = 1
|
|
||||||
issue.ancestors.visible.each do |ancestor|
|
|
||||||
pdf.set_x(base_x + i)
|
|
||||||
buf = "#{ancestor.tracker} # #{ancestor.id} (#{ancestor.status.to_s}): #{ancestor.subject}"
|
|
||||||
pdf.RDMMultiCell(190 - i, 5, buf)
|
|
||||||
i += 1 if i < 35
|
|
||||||
end
|
|
||||||
pdf.SetFontStyle('B',11)
|
|
||||||
pdf.RDMMultiCell(190 - i, 5, issue.subject.to_s)
|
|
||||||
pdf.SetFontStyle('',8)
|
|
||||||
pdf.RDMMultiCell(190, 5, "#{format_time(issue.created_on)} - #{issue.author}")
|
|
||||||
pdf.ln
|
|
||||||
|
|
||||||
customer = issue.customer.name if issue.customer
|
|
||||||
left = []
|
|
||||||
left << [l(:field_status), issue.status]
|
|
||||||
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]
|
|
||||||
|
|
||||||
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)
|
|
||||||
right << [l(:field_notes), notes]
|
|
||||||
|
|
||||||
rows = left.size > right.size ? left.size : right.size
|
|
||||||
while left.size < rows
|
|
||||||
left << nil
|
|
||||||
end
|
|
||||||
while right.size < rows
|
|
||||||
right << nil
|
|
||||||
end
|
|
||||||
|
|
||||||
half = (issue.visible_custom_field_values.size / 2.0).ceil
|
|
||||||
issue.visible_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'
|
|
||||||
border_first = 'R'
|
|
||||||
border_last = 'L'
|
|
||||||
else
|
|
||||||
border_first_top = 'LT'
|
|
||||||
border_last_top = 'RT'
|
|
||||||
border_first = 'L'
|
|
||||||
border_last = 'R'
|
|
||||||
end
|
|
||||||
|
|
||||||
rows = left.size > right.size ? left.size : right.size
|
|
||||||
rows.times do |i|
|
|
||||||
heights = []
|
|
||||||
pdf.SetFontStyle('B',9)
|
|
||||||
item = left[i]
|
|
||||||
heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
|
|
||||||
item = right[i]
|
|
||||||
heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
|
|
||||||
pdf.SetFontStyle('',9)
|
|
||||||
item = left[i]
|
|
||||||
heights << pdf.get_string_height(60, item ? item.last.to_s : "")
|
|
||||||
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
|
|
||||||
)
|
|
||||||
pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
|
|
||||||
|
|
||||||
unless issue.leaf?
|
|
||||||
truncate_length = (!is_cjk? ? 90 : 65)
|
|
||||||
pdf.SetFontStyle('B',9)
|
|
||||||
pdf.RDMCell(35+155,5, l(:label_subtask_plural) + ":", "LTR")
|
|
||||||
pdf.ln
|
|
||||||
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
|
|
||||||
buf = "#{child.tracker} # #{child.id}: #{child.subject}".
|
|
||||||
truncate(truncate_length)
|
|
||||||
level = 10 if level >= 10
|
|
||||||
pdf.SetFontStyle('',8)
|
|
||||||
pdf.RDMCell(35+135,5, (level >=1 ? " " * level : "") + buf, border_first)
|
|
||||||
pdf.SetFontStyle('B',8)
|
|
||||||
pdf.RDMCell(20,5, child.status.to_s, border_last)
|
|
||||||
pdf.ln
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
relations = issue.relations.select { |r| r.other_issue(issue).visible? }
|
|
||||||
unless relations.empty?
|
|
||||||
truncate_length = (!is_cjk? ? 80 : 60)
|
|
||||||
pdf.SetFontStyle('B',9)
|
|
||||||
pdf.RDMCell(35+155,5, l(:label_related_issues) + ":", "LTR")
|
|
||||||
pdf.ln
|
|
||||||
relations.each do |relation|
|
|
||||||
buf = relation.to_s(issue) {|other|
|
|
||||||
text = ""
|
|
||||||
if Setting.cross_project_issue_relations?
|
|
||||||
text += "#{relation.other_issue(issue).project} - "
|
|
||||||
end
|
|
||||||
text += "#{other.tracker} ##{other.id}: #{other.subject}"
|
|
||||||
text
|
|
||||||
}
|
|
||||||
buf = buf.truncate(truncate_length)
|
|
||||||
pdf.SetFontStyle('', 8)
|
|
||||||
pdf.RDMCell(35+155-60, 5, buf, border_first)
|
|
||||||
pdf.SetFontStyle('B',8)
|
|
||||||
pdf.RDMCell(20,5, relation.other_issue(issue).status.to_s, "")
|
|
||||||
pdf.RDMCell(20,5, format_date(relation.other_issue(issue).start_date), "")
|
|
||||||
pdf.RDMCell(20,5, format_date(relation.other_issue(issue).due_date), border_last)
|
|
||||||
pdf.ln
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.RDMCell(190,5, "", "T")
|
|
||||||
pdf.ln
|
|
||||||
|
|
||||||
if issue.changesets.any? &&
|
|
||||||
User.current.allowed_to?(:view_changesets, issue.project)
|
|
||||||
pdf.SetFontStyle('B',9)
|
|
||||||
pdf.RDMCell(190,5, l(:label_associated_revisions), "B")
|
|
||||||
pdf.ln
|
|
||||||
for changeset in issue.changesets
|
|
||||||
pdf.SetFontStyle('B',8)
|
|
||||||
csstr = "#{l(:label_revision)} #{changeset.format_identifier} - "
|
|
||||||
csstr += format_time(changeset.committed_on) + " - " + changeset.author.to_s
|
|
||||||
pdf.RDMCell(190, 5, csstr)
|
|
||||||
pdf.ln
|
|
||||||
unless changeset.comments.blank?
|
|
||||||
pdf.SetFontStyle('',8)
|
|
||||||
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")
|
|
||||||
pdf.ln
|
|
||||||
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?
|
|
||||||
pdf.RDMCell(190,5, title)
|
|
||||||
pdf.ln
|
|
||||||
pdf.SetFontStyle('I',8)
|
|
||||||
details_to_strings(journal.visible_details, true).each do |string|
|
|
||||||
pdf.RDMMultiCell(190,5, "- " + string)
|
|
||||||
end
|
|
||||||
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
|
|
||||||
)
|
|
||||||
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")
|
|
||||||
pdf.ln
|
|
||||||
for attachment in issue.attachments
|
|
||||||
pdf.SetFontStyle('',8)
|
|
||||||
pdf.RDMCell(80,5, attachment.filename)
|
|
||||||
pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
|
|
||||||
pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R")
|
|
||||||
pdf.RDMCell(65,5, attachment.author.name,0,0,"R")
|
|
||||||
pdf.ln
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Check to see if there is an estimate attached, then combine them
|
|
||||||
if issue.estimate
|
|
||||||
pdf = CombinePDF.parse(pdf.output, allow_optional_content: true)
|
|
||||||
pdf << CombinePDF.parse(issue.estimate.pdf)
|
|
||||||
return pdf.to_pdf
|
|
||||||
end
|
|
||||||
|
|
||||||
return pdf.output
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Redmine::Export::PDF::IssuesPdfHelper.send(:include, PdfPatch)
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#The MIT License (MIT)
|
|
||||||
#
|
|
||||||
#Copyright (c) 2016 - 2026 rick barrette
|
|
||||||
#
|
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
require_dependency 'project'
|
|
||||||
|
|
||||||
module Vehicles
|
|
||||||
module Patches
|
|
||||||
|
|
||||||
# Patches Redmine's Projects dynamically.
|
|
||||||
# Adds a relationships
|
|
||||||
module ProjectPatch
|
|
||||||
|
|
||||||
ActiveSupport.on_load(:active_record) do
|
|
||||||
|
|
||||||
Project.class_eval do
|
|
||||||
belongs_to :vehicle
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user