From 5f1dea77cc13fa3c0bb18b2f05ca784bf3dbd3fe Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 22 Apr 2016 12:40:51 -0400 Subject: [PATCH] Update issues_form_hook_listener.rb --- lib/issues_form_hook_listener.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/issues_form_hook_listener.rb b/lib/issues_form_hook_listener.rb index 18b7d78..57f9a2f 100644 --- a/lib/issues_form_hook_listener.rb +++ b/lib/issues_form_hook_listener.rb @@ -13,6 +13,7 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener # Edit Issue Form # Show a dropdown for quickbooks contacts def view_issues_form_details_bottom(context={}) + @f = context[:form] # Check to see if there is a quickbooks user attached to the issue selected_customer = context[:issue].qbo_customer ? context[:issue].qbo_customer.id : nil @@ -20,20 +21,25 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener selected_invoice = context[:issue].qbo_invoice ? context[:issue].qbo_invoice.id : nil selected_estimate = context[:issue].qbo_estimate ? context[:issue].qbo_estimate.id : nil + @customer = QboCustomer.find_by_id(selected_customer).name if selected_customer + @vehicle = context[:issue].vehicle_id + # Generate the drop down list of quickbooks customers - select_customer = context[:form].select :qbo_customer_id, QboCustomer.all.pluck(:name, :id).sort, :selected => selected_customer, include_blank: true + select_customer = @f.select :qbo_customer_id, QboCustomer.all.pluck(:name, :id).sort, :selected => selected_customer, include_blank: true # Generate the drop down list of quickbooks items - select_item = context[:form].select :qbo_item_id, QboItem.all.pluck(:name, :id).sort, :selected => selected_item, include_blank: true + select_item = @f.select :qbo_item_id, QboItem.all.pluck(:name, :id).sort, :selected => selected_item, include_blank: true # Generate the drop down list of quickbooks invoices - select_invoice = context[:form].select :qbo_invoice_id, QboInvoice.all.pluck(:doc_number, :id).sort! {|x, y| y <=> x}, :selected => selected_invoice, include_blank: true + select_invoice = @f.select :qbo_invoice_id, QboInvoice.all.pluck(:doc_number, :id).sort! {|x, y| y <=> x}, :selected => selected_invoice, include_blank: true # Generate the drop down list of quickbooks extimates - select_estimate = context[:form].select :qbo_estimate_id, QboEstimate.all.pluck(:doc_number, :id).sort! {|x, y| y <=> x}, :selected => selected_estimate, include_blank: true + select_estimate = @f.select :qbo_estimate_id, QboEstimate.all.pluck(:doc_number, :id).sort! {|x, y| y <=> x}, :selected => selected_estimate, include_blank: true #@estimates_link = link_to qbo_update_estimates_path + render :partial => 'vehicles/details' + return "

#{select_customer}

#{select_item}

#{select_invoice}

#{select_estimate}

" end end