diff --git a/init.rb b/init.rb index 6174772..f5105ca 100644 --- a/init.rb +++ b/init.rb @@ -38,7 +38,6 @@ Redmine::Plugin.register :redmine_qbo do # Register top menu items 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 diff --git a/lib/hooks/issues_form_hook_listener.rb b/lib/hooks/issues_form_hook_listener.rb index a880a31..7fa1d0b 100644 --- a/lib/hooks/issues_form_hook_listener.rb +++ b/lib/hooks/issues_form_hook_listener.rb @@ -22,14 +22,12 @@ module Hooks # This is done to preload customer information if the entire project is dedicated to a customer if context[:project] selected_customer = context[:project].customer ? context[:project].customer.id : nil - selected_vehicle = context[:project].vehicle ? context[:project].vehicle.id : nil end # Check to see if the issue already belongs to a customer selected_customer = issue.customer ? issue.customer.id : nil selected_estimate = issue.estimate ? issue.estimate.id : nil - selected_vehicle = issue.vehicles_id ? issue.vehicles_id : nil - + # Gernerate edit.js link js_link = issue.new_record? ? "updateIssueFrom('/projects/rmt/issues/new.js', this)" : "updateIssueFrom('/issues/#{issue.id}/edit.js', this)" @@ -51,23 +49,16 @@ module Hooks :id => "issue_customer_id", :onchange => js_link - # Load estimates & vehicles + # Load estimates 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} else - vehicles = [nil].compact estimates = [nil].compact 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 - vehicle = f.select :vehicles_id, vehicles, :selected => selected_vehicle, include_blank: true - + # Pass all prebuilt form components to our partial context[:controller].send(:render_to_string, { :partial => 'issues/form_hook', @@ -76,7 +67,6 @@ module Hooks customer_id: customer_id, js_link: js_link, select_estimate: select_estimate, - vehicle: vehicle } } ) diff --git a/lib/hooks/issues_show_hook_listener.rb b/lib/hooks/issues_show_hook_listener.rb index 2dac4d4..0495c0c 100644 --- a/lib/hooks/issues_show_hook_listener.rb +++ b/lib/hooks/issues_show_hook_listener.rb @@ -38,26 +38,12 @@ module Hooks 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, { :partial => 'issues/show_details', locals: { customer: customer, estimate_link: estimate_link, - invoice_link: invoice_link, - vehicle: vehicle, - split_vin: split_vin, - notes: notes + invoice_link: invoice_link } }) end diff --git a/lib/hooks/projects_form_hook_listener.rb b/lib/hooks/projects_form_hook_listener.rb index d35b911..962c706 100644 --- a/lib/hooks/projects_form_hook_listener.rb +++ b/lib/hooks/projects_form_hook_listener.rb @@ -18,22 +18,13 @@ module Hooks # 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 "
#{search_customer} #{customer_id}
#{vehicle}
" + return "#{search_customer} #{customer_id}
" end end diff --git a/lib/patches/issue_patch.rb b/lib/patches/issue_patch.rb index deb0253..1487d78 100644 --- a/lib/patches/issue_patch.rb +++ b/lib/patches/issue_patch.rb @@ -28,7 +28,6 @@ module Patches belongs_to :customer_token, primary_key: :id belongs_to :estimate, primary_key: :id has_and_belongs_to_many :invoices - belongs_to :vehicle, primary_key: :id end end diff --git a/lib/patches/pdf_patch.rb b/lib/patches/pdf_patch.rb index c01342a..076d068 100644 --- a/lib/patches/pdf_patch.rb +++ b/lib/patches/pdf_patch.rb @@ -58,14 +58,6 @@ module Patches #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') diff --git a/lib/patches/project_patch.rb b/lib/patches/project_patch.rb index a495ff6..35408d1 100644 --- a/lib/patches/project_patch.rb +++ b/lib/patches/project_patch.rb @@ -24,7 +24,6 @@ module Patches # Same as typing in the class base.class_eval do belongs_to :customer, primary_key: :id - belongs_to :vehicle, primary_key: :id end end