Added estimate search in side bar

This commit is contained in:
2022-02-13 10:03:43 -05:00
parent f66fbf6656
commit 4582b8c5b9
8 changed files with 47 additions and 7 deletions

View File

@@ -18,10 +18,28 @@ class EstimateController < ApplicationController
# Downloads and forwards the estimate pdf
#
def show
base = QboEstimate.get_base
estimate = base.fetch_by_id(params[:id])
@pdf = base.pdf(estimate)
send_data @pdf, filename: "estimate #{estimate.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf"
e = QboEstimate.find_by_id(params[:id]) if params[:id]
e = QboEstimate.find_by_doc_number(params[:search]) if params[:search]
begin
send_data e.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf"
rescue
redirect_to :back, :flash => { :error => "Estimate not found" }
end
end
#
# Downloads estimate by document number
#
def doc
e = QboEstimate.find_by_doc_number(params[:id]) if params[:id]
e = QboEstimate.find_by_doc_number(params[:search]) if params[:search]
begin
send_data e.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf"
rescue
redirect_to :back, :flash => { :error => "Estimate not found" }
end
end
end

View File

@@ -55,4 +55,12 @@ class QboEstimate < ActiveRecord::Base
qbo_estimate.id = estimate.id
qbo_estimate.save!
end
# download the pdf from quickbooks
def pdf
base = QboEstimate.get_base
estimate = base.fetch_by_id(id)
return base.pdf(estimate)
end
end

View File

@@ -0,0 +1,4 @@
<%= form_tag("/qbo/estimate/doc", :method => "get", id: "est-search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: t(:label_search_estimates) %>
<%= submit_tag t(:label_search) %>
<% end %>

View File

@@ -0,0 +1,2 @@
<h3>Estimate</h3>
<%= render :partial => 'estimates/search' %>

View File

@@ -0,0 +1,2 @@
<%= render :partial => 'customers/sidebar' %>
<%= render :partial => 'estimates/sidebar' %>