Estimate PDF is now dowloaded and served

TODO: The routes are somehow messed up and need to be fixed.

example: example.com/redmine/redmine/qbo/estimate/1
in lieu: example.com/redmine/qbo/estimate/1
This commit is contained in:
2016-01-17 10:40:37 -05:00
parent 2365fc2cf8
commit 98cd3d51e9
4 changed files with 12 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
source 'https://rubygems.org'
gem 'quickbooks-ruby'#, :git => 'https://github.com/rickbarrette/quickbooks-ruby.git', :branch => " rickbarrette-estimate-pdf-patch"
gem 'quickbooks-ruby', :git => 'https://github.com/rickbarrette/quickbooks-ruby.git'
gem 'quickbooks-ruby-base'
gem 'oauth-plugin'#, '~> 0.5.1'
gem 'oauth'

View File

@@ -11,6 +11,8 @@
class QboController < ApplicationController
unloadable
require 'open-uri'
#
# Called when the QBO Top Menu us shown
#
@@ -75,9 +77,13 @@ 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
#
# Downloads and forwards the estimate pdf
#
def estimate_pdf
base = QboEstimate.get_base.service
@pdf = base.pdf(base.fetch_by_id(params[:id]))
send_data @pdf, filename: "estimate.pdf", :disposition => 'inline', :type => "application/pdf"
end
end

View File

@@ -15,4 +15,4 @@ get 'qbo', :to=> 'qbo#index'
get 'qbo/authenticate', :to => 'qbo#authenticate'
get 'qbo/oauth_callback', :to => 'qbo#oauth_callback'
get 'qbo/sync', :to => 'qbo#sync'
get 'qbo/estimate/:id', :to => 'qbo#estimate_pdf', :as => :qbo_estimate_pdf

View File

@@ -35,8 +35,6 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
QboEstimate.update(issue.qbo_estimate.id)
@estimate = issue.qbo_estimate.doc_number
end
base = QboEstimate.get_base.service
#base.initialize
return "<div class=\"attributes\">
<div class=\"qbo_customer_id attribute\">
@@ -51,7 +49,7 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
<div class=\"qbo_estimate_id attribute\">
<div class=\"label\"><span>Estimate</span>:</div>
<div class=\"value\"><a href=\"</div>
<div class=\"value\">#{link_to @estimate, qbo_estimate_pdf_path(issue.qbo_estimate.id)}</div>
</div>
</div>"
end