mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
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:
3
Gemfile
3
Gemfile
@@ -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'
|
||||
|
||||
@@ -10,6 +10,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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user