Updated settings page

This commit is contained in:
2026-03-17 21:23:29 -04:00
parent 3e6650ee65
commit f60e507029
5 changed files with 101 additions and 96 deletions

View File

@@ -0,0 +1,26 @@
#The MIT License (MIT)
#
#Copyright (c) 2016 - 2026 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:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#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.
class EmployeeController < ApplicationController
include AuthHelper
before_action :require_user, unless: -> { session[:token].nil? }
def sync
Employee.sync
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
end
private
# Logs messages with a consistent prefix for easier debugging.
def log(msg)
Rails.logger.info "[EmployeeController] #{msg}"
end
end

View File

@@ -24,6 +24,11 @@ class EstimateController < ApplicationController
render_pdf(@estimate) render_pdf(@estimate)
end end
def sync
Estimate.sync
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
end
private private
# Loads the estimate based on ID or doc number, with a fallback to sync if not found locally. # Loads the estimate based on ID or doc number, with a fallback to sync if not found locally.

View File

@@ -1,111 +1,79 @@
<!--
The MIT License (MIT)
Copyright (c) 2016 - 2026 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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
-->
<!-- somewhere in your document include the Javascript -->
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script> <script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
<!-- configure the Intuit object: 'grantUrl' is a URL in your application which kicks off the flow, see below -->
<script> <script>
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_authenticate_path %>'}); intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_authenticate_path %>'});
</script> </script>
<table > <div class="box tabular">
<tbody> <p>
<label><%= t(:label_client_id) %></label>
<%= text_field_tag 'settings[settingsOAuthConsumerKey]', settings['settingsOAuthConsumerKey'], size: 50 %>
</p>
<p>
<label><%= t(:label_client_secret) %></label>
<%= password_field_tag 'settings[settingsOAuthConsumerSecret]', settings['settingsOAuthConsumerSecret'], size: 50 %>
</p>
<tr> <p>
<th><%=t(:label_client_id)%></th> <label><%= t(:label_webhook_token) %></label>
<td> <%= text_field_tag 'settings[settingsWebhookToken]', settings['settingsWebhookToken'], size: 50 %>
<input </p>
type="text"
style="width:350px"
id="settingsOAuthConsumerKey"
value="<%= settings['settingsOAuthConsumerKey'] %>"
name="settings[settingsOAuthConsumerKey]" >
</td>
</tr>
<tr> <p>
<th><%=t(:label_client_secret)%></th> <label><%= t(:label_sandbox) %></label>
<td> <%= check_box_tag 'settings[sandbox]', 1, settings[:sandbox] %>
<input </p>
type="text"
style="width:350px"
id="settingsOAuthConsumerSecret"
value="<%= settings['settingsOAuthConsumerSecret'] %>"
name="settings[settingsOAuthConsumerSecret]" >
</td>
</tr>
<tr>
<th><%=t(:label_webhook_token)%></th>
<td>
<input
type="text"
style="width:350px"
id="settingsWebhookToken"
value="<%= settings['settingsWebhookToken'] %>"
name="settings[settingsWebhookToken]" >
</td>
</tr>
<tr> <hr />
<th><%=t(:label_sandbox)%></th>
<td>
<%= check_box_tag 'settings[sandbox]', @settings[:sandbox], @settings[:sandbox] %>
</td>
</tr>
<tr> <p>
<th><%=t(:label_oauth_expires)%></th> <label><%= t(:label_oauth_expires) %></label>
<td><%= Qbo.oauth2_access_token_expires_at %> <span class="icon <%= Qbo.oauth2_access_token_expires_at&.future? ? 'icon-ok' : 'icon-warning' %>">
</tr> <%= Qbo.oauth2_access_token_expires_at || 'N/A' %>
</span>
<tr> </p>
<th><%=t(:label_oauth2_refresh_token_expires_at)%></th>
<td><%= Qbo.oauth2_refresh_token_expires_at %>
</tr>
</tbody> <p>
</table> <label><%= t(:label_customer_count) %></label>
<%= Customer.count %>
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Customer.last_sync %>)</em>
</p>
<br/> <p>
<%=t(:label_oauth_note)%> <label><%= t(:label_employee_count) %></label>
<br/> <%= Employee.count %>
<br/> <em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Employee.last_sync %>)</em>
</p>
<!-- this will display a button that the user clicks to start the flow --> <p>
<ipp:connectToIntuit></ipp:connectToIntuit> <label><%= t(:label_invoice_count) %></label>
<%= Invoice.count %>
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Item.last_sync %>)</em>
</p>
<br/> <p>
<br/> <label><%= t(:label_estimate_count) %></label>
<%= Estimate.count %>
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Account.last_sync %>)</em>
</p>
<div> <p>
<b><%=t(:label_customer_count)%>:</b> <%= Customer.count%> @ <%= Customer.last_sync %> <label><%= t(:label_last_sync) %> (QBO)</label>
</div> <%= Qbo.exists? ? Qbo.last_sync : 'Never synced' %>
</p>
<div>
<b><%=t(:label_employee_count)%>:</b> <%= Employee.count %> @ <%= Employee.last_sync %>
</div>
<div>
<b><%=t(:label_invoice_count)%>:</b> <%= Invoice.count %> @ <%= Invoice.last_sync%>
</div>
<div>
<b><%=t(:label_estimate_count)%>:</b> <%= Estimate.count %> @ <%= Estimate.last_sync %>
</div>
<br/>
<div>
<b><%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %> <%= link_to t(:label_sync_now), qbo_sync_path(full_sync: true) %>
</div> </div>
<fieldset class="box">
<legend>Management & Synchronization</legend>
<div style="margin-bottom: 20px;">
<ipp:connectToIntuit></ipp:connectToIntuit>
</div>
<div style="margin-bottom: 15px;">
<%= link_to t(:label_sync_now_customers), customers_sync_path(full_sync: true), class: 'button icon icon-reload' %>
<%= link_to t(:label_sync_now_employees), employees_sync_path, class: 'button icon icon-reload' %>
<%= link_to t(:label_sync_now_invoices), invoices_sync_path(full_sync: true), class: 'button icon icon-reload' %>
<%= link_to t(:label_sync_now_estimate), estimates_sync_path, class: 'button icon icon-reload' %>
</div>
</fieldset>

View File

@@ -82,6 +82,10 @@ en:
label_shipping_address: "Shipping Address" label_shipping_address: "Shipping Address"
label_sync: "Sync" label_sync: "Sync"
label_sync_now: "Sync Now" label_sync_now: "Sync Now"
label_sync_now_customers: "Sync Customers"
label_sync_now_employees: "Sync Employees"
label_sync_now_invoices: "Sync Invoices"
label_sync_now_estimate: "Sync Estimates"
label_syncing: "Syncing QuickBooks" label_syncing: "Syncing QuickBooks"
label_trim: "Trim" label_trim: "Trim"
label_webhook_token: "Intuit QBO Webhook Token" label_webhook_token: "Intuit QBO Webhook Token"

View File

@@ -14,6 +14,8 @@ get 'qbo/oauth_callback', to: 'qbo#oauth_callback'
#manual sync #manual sync
get 'qbo/sync', to: 'qbo#sync' get 'qbo/sync', to: 'qbo#sync'
get 'customers/sync', to: 'customers#sync'
get 'employees/sync', to: 'employee#sync'
get 'invoices/sync', to: 'invoice#sync' get 'invoices/sync', to: 'invoice#sync'
get 'estimates/sync', to: 'estimate#sync' get 'estimates/sync', to: 'estimate#sync'