mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-02-13 09:13:58 -05:00
Removed Vehicles
This commit is contained in:
1
init.rb
1
init.rb
@@ -38,7 +38,6 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
|
|
||||||
# Register top menu items
|
# Register top menu items
|
||||||
menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new {User.current.logged?}
|
menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new {User.current.logged?}
|
||||||
menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? }
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,11 @@ module Hooks
|
|||||||
# This is done to preload customer information if the entire project is dedicated to a customer
|
# This is done to preload customer information if the entire project is dedicated to a customer
|
||||||
if context[:project]
|
if context[:project]
|
||||||
selected_customer = context[:project].customer ? context[:project].customer.id : nil
|
selected_customer = context[:project].customer ? context[:project].customer.id : nil
|
||||||
selected_vehicle = context[:project].vehicle ? context[:project].vehicle.id : nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check to see if the issue already belongs to a customer
|
# Check to see if the issue already belongs to a customer
|
||||||
selected_customer = issue.customer ? issue.customer.id : nil
|
selected_customer = issue.customer ? issue.customer.id : nil
|
||||||
selected_estimate = issue.estimate ? issue.estimate.id : nil
|
selected_estimate = issue.estimate ? issue.estimate.id : nil
|
||||||
selected_vehicle = issue.vehicles_id ? issue.vehicles_id : nil
|
|
||||||
|
|
||||||
# Gernerate edit.js link
|
# Gernerate edit.js link
|
||||||
js_link = issue.new_record? ? "updateIssueFrom('/projects/rmt/issues/new.js', this)" : "updateIssueFrom('/issues/#{issue.id}/edit.js', this)"
|
js_link = issue.new_record? ? "updateIssueFrom('/projects/rmt/issues/new.js', this)" : "updateIssueFrom('/issues/#{issue.id}/edit.js', this)"
|
||||||
@@ -51,22 +49,15 @@ module Hooks
|
|||||||
:id => "issue_customer_id",
|
:id => "issue_customer_id",
|
||||||
:onchange => js_link
|
:onchange => js_link
|
||||||
|
|
||||||
# Load estimates & vehicles
|
# Load estimates
|
||||||
if issue.customer
|
if issue.customer
|
||||||
if customer.vehicles
|
|
||||||
vehicles = customer.vehicles.pluck(:name, :id)
|
|
||||||
else
|
|
||||||
vehicles = [nil].compact
|
|
||||||
end
|
|
||||||
estimates = customer.estimates.pluck(:doc_number, :id).sort! {|x, y| y <=> x}
|
estimates = customer.estimates.pluck(:doc_number, :id).sort! {|x, y| y <=> x}
|
||||||
else
|
else
|
||||||
vehicles = [nil].compact
|
|
||||||
estimates = [nil].compact
|
estimates = [nil].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate the drop down list of quickbooks estimates & vehicles
|
# Generate the drop down list of quickbooks estimates
|
||||||
select_estimate = f.select :estimate_id, estimates, :selected => selected_estimate, include_blank: true
|
select_estimate = f.select :estimate_id, estimates, :selected => selected_estimate, include_blank: true
|
||||||
vehicle = f.select :vehicles_id, vehicles, :selected => selected_vehicle, include_blank: true
|
|
||||||
|
|
||||||
# Pass all prebuilt form components to our partial
|
# Pass all prebuilt form components to our partial
|
||||||
context[:controller].send(:render_to_string, {
|
context[:controller].send(:render_to_string, {
|
||||||
@@ -76,7 +67,6 @@ module Hooks
|
|||||||
customer_id: customer_id,
|
customer_id: customer_id,
|
||||||
js_link: js_link,
|
js_link: js_link,
|
||||||
select_estimate: select_estimate,
|
select_estimate: select_estimate,
|
||||||
vehicle: vehicle
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -38,26 +38,12 @@ module Hooks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
|
||||||
v = Vehicle.find(issue.vehicles_id)
|
|
||||||
vehicle = link_to v.to_s, vehicle_path( v.id )
|
|
||||||
vin = v.vin
|
|
||||||
notes = v.notes
|
|
||||||
rescue
|
|
||||||
#do nothing
|
|
||||||
end
|
|
||||||
|
|
||||||
split_vin = vin.scan(/.{1,9}/) if vin
|
|
||||||
|
|
||||||
context[:controller].send(:render_to_string, {
|
context[:controller].send(:render_to_string, {
|
||||||
:partial => 'issues/show_details',
|
:partial => 'issues/show_details',
|
||||||
locals: {
|
locals: {
|
||||||
customer: customer,
|
customer: customer,
|
||||||
estimate_link: estimate_link,
|
estimate_link: estimate_link,
|
||||||
invoice_link: invoice_link,
|
invoice_link: invoice_link
|
||||||
vehicle: vehicle,
|
|
||||||
split_vin: split_vin,
|
|
||||||
notes: notes
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,22 +18,13 @@ module Hooks
|
|||||||
|
|
||||||
# Check to see if there is a quickbooks user attached to the issue
|
# Check to see if there is a quickbooks user attached to the issue
|
||||||
selected_customer = context[:project].customer ? context[:project].customer : nil
|
selected_customer = context[:project].customer ? context[:project].customer : nil
|
||||||
selected_vehicle = context[:project].vehicle_id ? context[:project].vehicle_id : nil
|
|
||||||
|
|
||||||
# Load customer information
|
# Load customer information
|
||||||
customer = Customer.find_by_id(selected_customer) if selected_customer
|
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'}
|
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"
|
customer_id = f.hidden_field :customer_id, :id => "project_customer_id"
|
||||||
|
|
||||||
if context[:project].customer
|
return "<p><label for=\"project_customer\">Customer</label>#{search_customer} #{customer_id}</p>"
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ module Patches
|
|||||||
belongs_to :customer_token, primary_key: :id
|
belongs_to :customer_token, primary_key: :id
|
||||||
belongs_to :estimate, primary_key: :id
|
belongs_to :estimate, primary_key: :id
|
||||||
has_and_belongs_to_many :invoices
|
has_and_belongs_to_many :invoices
|
||||||
belongs_to :vehicle, primary_key: :id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,14 +58,6 @@ module Patches
|
|||||||
#left << [l(:field_category), issue.category] unless issue.disabled_core_fields.include?('category_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')
|
#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 = []
|
||||||
right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date')
|
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_due_date), format_date(issue.due_date)] unless issue.disabled_core_fields.include?('due_date')
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ module Patches
|
|||||||
# Same as typing in the class
|
# Same as typing in the class
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
belongs_to :customer, primary_key: :id
|
belongs_to :customer, primary_key: :id
|
||||||
belongs_to :vehicle, primary_key: :id
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user