Class: PickupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pickups_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

current

Methods included from PathHelper

#finance_group_transactions_path

Instance Method Details

#documentObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/pickups_controller.rb', line 8

def document
  return redirect_to pickups_path, alert: t('.empty_selection') unless params[:orders]

  order_ids = params[:orders].map(&:to_i)

  if params[:articles_pdf]
    klass = OrderByArticles
  elsif params[:groups_pdf]
    klass = OrderByGroups
  elsif params[:matrix_pdf]
    klass = OrderMatrix
  end

  return redirect_to pickups_path, alert: t('.invalid_document') unless klass

  date = params[:date]
  pdf = klass.new(order_ids, title: t('.title', date: date), show_supplier: true)
  send_data pdf.to_pdf, filename: t('.filename', date: date) + '.pdf', type: 'application/pdf'
end

#indexObject



4
5
6
# File 'app/controllers/pickups_controller.rb', line 4

def index
  @orders = Order.finished_not_closed.order('pickup DESC').group_by { |o| o.pickup }
end