<%# QuickBooks connection: app keys, webhook token, sandbox, and the OAuth connection %>

<%= l(:label_qbo_connection) %>

<%= text_field_tag 'settings[oauth_consumer_key]', settings[:oauth_consumer_key], size: 50 %>

<%= password_field_tag 'settings[oauth_consumer_secret]', settings[:oauth_consumer_secret], size: 50 %>

<%= text_field_tag 'settings[webhook_token]', settings[:webhook_token], size: 50 %>

<%= check_box_tag 'settings[sandbox]', 1, settings[:sandbox] %>

<%= Qbo.oauth2_access_token_expires_at ? format_time(Qbo.oauth2_access_token_expires_at) : 'N/A' %>

<%# Everything kept in step with QuickBooks: how many records there are, when each last changed, and a sync button for each. A type's sync re-reads all of its records from QuickBooks. %> <% sync_rows = [ [l(:label_customers), Customer, sync_customers_path, customers_path], [l(:label_employee_plural), Employee, employees_sync_path, nil], [l(:label_estimates), Estimate, estimates_sync_path, nil], [l(:label_invoices), Invoice, invoices_sync_path, nil], [l(:label_payments), Payment, sync_qbo_payments_path, nil], [l(:label_items), Item, sync_items_path, items_path], [l(:label_accounts), Account, sync_accounts_path, accounts_path] ] %>

<%= l(:label_management_and_sync) %>

<% sync_rows.each do |label, model, sync_path, list_path| %> <% end %>
<%= l(:label_qbo_records) %> <%= l(:label_last_sync) %>
<%= list_path ? link_to(label, list_path) : label %> <%= model.count %> <%= model.last_sync %> <%= link_to sprite_icon('reload', l(:label_sync)), sync_path, class: 'icon icon-reload' %>

<%= t(:label_default_account) %>: <%= Account.get_default || '–' %> <%= l(:text_default_account_info) %>

<%= t(:label_last_sync) %> (QBO): <%= Qbo.exists? ? Qbo.last_sync : l(:label_never_synced) %> <%= link_to sprite_icon('reload', l(:label_sync_changes)), qbo_sync_path, class: 'button icon icon-reload' %> <%= link_to sprite_icon('reload', l(:label_full_sync)), qbo_sync_path(full_sync: true), class: 'button icon icon-reload' %>

<%= l(:text_qbo_sync_info) %>
<%# Billing: estimates, issues from estimates and invoices %>

<%= l(:label_billing_settings) %>

<%= render partial: 'qbo/billing_settings', locals: { settings: settings } %>