From 6556197dd065578a1f149756d30c993a3bfdb7f6 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 14 Jan 2016 21:49:26 -0500 Subject: [PATCH] Readded nil checks --- app/controllers/qbo_controller.rb | 6 ++++++ lib/issues_show_hook_listener.rb | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/qbo_controller.rb b/app/controllers/qbo_controller.rb index a7331bb..28a5d4e 100644 --- a/app/controllers/qbo_controller.rb +++ b/app/controllers/qbo_controller.rb @@ -74,4 +74,10 @@ class QboController < ApplicationController redirect_to qbo_path(:redmine_qbo), :flash => { :notice => "Successfully synced to Quickbooks" } end + + def pdf + @pdf = "#{base.url_for_resource('estimate')}/#{params['qbo_estimate_id']}/pdf" + send_data @pdf, filename: "estimate.pdf", type: :pdf + end + end diff --git a/lib/issues_show_hook_listener.rb b/lib/issues_show_hook_listener.rb index 1d677c9..9eb5d67 100644 --- a/lib/issues_show_hook_listener.rb +++ b/lib/issues_show_hook_listener.rb @@ -21,18 +21,22 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener issue = context[:issue] # Check to see if there is a quickbooks user attached to the issue - #unless context[:issue].qbo_customer_id.nil? + unless issue.qbo_customer.nil? @customer = issue.qbo_customer.name - #end + end # Check to see if there is a quickbooks item attached to the issue - @item = issue.qbo_item.name + unless issue.qbo_item.nil? + @item = issue.qbo_item.name + end # Estimate Number unless (issue.qbo_estimate.nil?) QboEstimate.update(issue.qbo_estimate.id) @estimate = issue.qbo_estimate.doc_number end + base = QboEstimate.get_base.service + #base.initialize return "
@@ -47,9 +51,9 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
Estimate:
-
#{@estimate}
+
" end -end \ No newline at end of file +end