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' %>

View File

@@ -1,6 +1,6 @@
#The MIT License (MIT)
#
#Copyright (c) 2017 rick barrette
#Copyright (c) 2022 rick barrette
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
@@ -9,6 +9,7 @@
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# English strings go here for Rails i18n
# Usage t(:label)
en:
# my_label: "My label"
field_customer: "Customer"
@@ -16,9 +17,11 @@ en:
field_qbo_employee: "Employee"
field_qbo_invoice: "Invoice"
field_qbo_estimate: "Estimate"
field_vehicles: "Vehicle"
field_vehicles: "Vehicles"
field_vehicle: "Vehicle"
field_vin: "VIN"
field_notes: "Notes"
field_qbo_billed: "Billed"
label_week: "Week"
label_search_estimates: "Search Estimates"
label_search: "Search"

View File

@@ -20,6 +20,7 @@ get 'qbo/sync', :to => 'qbo#sync'
# Estimate & Invoice PDF
get 'qbo/estimate/:id', :to => 'estimate#show', as: :estimate
get 'qbo/estimate/doc/:id', :to => 'estimate#doc', as: :estimate_doc
get 'qbo/invoice/:id', :to => 'invoice#show', as: :invoice
#manual billing
@@ -47,3 +48,5 @@ end
#allow for just vehicles too
resources :vehicles
#resources :qbo_estimates

View File

@@ -1,3 +1,3 @@
class ViewHookListener < Redmine::Hook::ViewListener
render_on :view_layouts_base_sidebar, :partial => "customers/sidebar"
render_on :view_layouts_base_sidebar, :partial => "qbo/sidebar"
end