Class: PickupsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

current

Instance Method Details

#documentObject


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

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


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

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