Add view to sort orders by pickup day
This commit is contained in:
parent
bd49a64cd7
commit
209ad615b4
7 changed files with 90 additions and 1 deletions
26
app/controllers/pickups_controller.rb
Normal file
26
app/controllers/pickups_controller.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
class PickupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@orders = Order.finished_not_closed.order('pickup DESC').group_by { |o| o.pickup }
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue