Class: Admin::QbSyncsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/qb_syncs_controller.rb

Instance Method Summary collapse

Instance Method Details

#index ⇒ Object



8
9
10
11
# File 'app/controllers/admin/qb_syncs_controller.rb', line 8

def index
  @datatable = Effective::Datatables::QbSyncs.new() if defined?(EffectiveDatatables)
  @page_title = 'Quickbooks Synchronizations'
end

#instructions ⇒ Object



36
37
38
# File 'app/controllers/admin/qb_syncs_controller.rb', line 36

def instructions
  @page_title = 'Quickbooks Setup Instructions'
end

#qwc ⇒ Object



40
41
42
43
44
45
46
# File 'app/controllers/admin/qb_syncs_controller.rb', line 40

def qwc
  @filename = Rails.application.class.parent_name.downcase + '.qwc'

  response.headers['Content-Disposition'] = "attachment; filename=\"#{@filename}\""

  render '/effective/qb_web_connector/quickbooks.qwc', layout: false
end

#show ⇒ Object



13
14
15
16
17
18
# File 'app/controllers/admin/qb_syncs_controller.rb', line 13

def show
  @qb_ticket = Effective::QbTicket.includes(:qb_requests, :qb_logs).find(params[:id])
  @page_title = "Quickbooks Sync ##{@qb_ticket.id}"

  @qb_order_items_form = Effective::QbOrderItemsForm.new(id: @qb_ticket.id, orders: @qb_ticket.orders)
end

#update ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/admin/qb_syncs_controller.rb', line 20

def update
  @qb_ticket = Effective::QbTicket.includes(:qb_requests, :qb_logs).find(params[:id])
  @page_title = "Quickbooks Sync ##{@qb_ticket.id}"

  @qb_order_items_form = Effective::QbOrderItemsForm.new(id: @qb_ticket.id, orders: @qb_ticket.orders)
  @qb_order_items_form.qb_order_items_attributes = permitted_qb_order_items_params[:qb_order_items_attributes].values

  if @qb_order_items_form.save
    flash[:success] = 'Successfully updated Quickbooks item names'
    redirect_to effective_qb_sync.admin_qb_sync_path(@qb_ticket)
  else
    flash.now[:danger] = 'Unable to update Quickbooks item names'
    render action: :show
  end
end