Class: Admin::QbSyncsController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/admin/qb_syncs_controller.rb', line 8

def index

  if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
    @datatable = Effective::Datatables::QbSyncs.new()
  else
    @datatable = EffectiveQbSyncDatatable.new(self)
  end

  @page_title = 'Quickbooks Synchronizations'
end

#instructionsObject



42
43
44
# File 'app/controllers/admin/qb_syncs_controller.rb', line 42

def instructions
  @page_title = 'Quickbooks Setup Instructions'
end

#qwcObject



46
47
48
49
50
51
52
# File 'app/controllers/admin/qb_syncs_controller.rb', line 46

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

#showObject



19
20
21
22
23
24
# File 'app/controllers/admin/qb_syncs_controller.rb', line 19

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

#updateObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/admin/qb_syncs_controller.rb', line 26

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