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
|
34
app/views/pickups/index.html.haml
Normal file
34
app/views/pickups/index.html.haml
Normal file
|
@ -0,0 +1,34 @@
|
|||
- title t('.title')
|
||||
|
||||
- @orders.each do |pickup, orders|
|
||||
= form_tag document_pickups_path do
|
||||
= hidden_field_tag 'date', l(pickup, format: :long)
|
||||
%h2
|
||||
- if pickup
|
||||
= l pickup, format: :long
|
||||
- else
|
||||
= t '.without_pickup'
|
||||
%span{style:'float:right'}
|
||||
= submit_tag t('.article_pdf'), name: 'articles_pdf', class: 'btn'
|
||||
= submit_tag t('.group_pdf'), name: 'groups_pdf', class: 'btn'
|
||||
= submit_tag t('.matrix_pdf'), name: 'matrix_pdf', class: 'btn'
|
||||
|
||||
%table.table.table-striped
|
||||
%thead
|
||||
%tr
|
||||
%th{style:'width:50%'}= heading_helper Order, :name
|
||||
%th{style:'width:50%'}= heading_helper Order, :note
|
||||
%th{style:'width:1px'}= t 'ui.actions'
|
||||
%tbody
|
||||
- for order in orders
|
||||
%tr
|
||||
%td
|
||||
= check_box_tag "orders[]", order.id, true #, style: 'float:left'
|
||||
- if current_user.role_orders?
|
||||
= link_to order.name, order_path(order)
|
||||
- else
|
||||
= order.name
|
||||
%td= truncate order.note
|
||||
%td{style:'white-space:nowrap'}
|
||||
= render 'shared/order_download_button', order: order, klass: 'btn-small'
|
||||
= receive_button order, class: 'btn-small'
|
|
@ -1451,6 +1451,7 @@ de:
|
|||
archive: Meine Bestellungen
|
||||
manage: Bestellverwaltung
|
||||
ordering: Bestellen!
|
||||
pickups: Abholtage
|
||||
title: Bestellungen
|
||||
tasks: Aufgaben
|
||||
wiki:
|
||||
|
@ -1672,6 +1673,17 @@ de:
|
|||
title: "%{title} - Version %{version}"
|
||||
title_version: Version
|
||||
view_current: Aktuelle Version sehen
|
||||
pickups:
|
||||
document:
|
||||
empty_selection: Es muss zumindest eine Bestellung ausgewählt sein.
|
||||
filename: Abholungen für %{date}
|
||||
invalid_document: Ungültiger Dokumententyp
|
||||
title: Abholungen für %{date}
|
||||
index:
|
||||
article_pdf: Artikel PDF
|
||||
group_pdf: Gruppen PDF
|
||||
matrix_pdf: Matrix PDF
|
||||
title: Abholtage
|
||||
sessions:
|
||||
logged_in: Angemeldet!
|
||||
logged_out: Abgemeldet!
|
||||
|
|
|
@ -1461,6 +1461,7 @@ en:
|
|||
archive: My Orders
|
||||
manage: Manage orders
|
||||
ordering: Place order!
|
||||
pickups: Pickup days
|
||||
title: Orders
|
||||
tasks: Tasks
|
||||
wiki:
|
||||
|
@ -1682,6 +1683,17 @@ en:
|
|||
title: "%{title} - version %{version}"
|
||||
title_version: Version
|
||||
view_current: See current version
|
||||
pickups:
|
||||
document:
|
||||
empty_selection: At least one order must be selected.
|
||||
filename: Pickup for %{date}
|
||||
invalid_document: Invalid document type
|
||||
title: Pickup for %{date}
|
||||
index:
|
||||
article_pdf: Article PDF
|
||||
group_pdf: Group PDF
|
||||
matrix_pdf: Matrix PDF
|
||||
title: Pickup days
|
||||
sessions:
|
||||
logged_in: Logged in!
|
||||
logged_out: Logged out!
|
||||
|
|
|
@ -24,6 +24,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
|||
subnav.item :ordering, I18n.t('navigation.orders.ordering'), group_orders_path
|
||||
subnav.item :ordering_archive, I18n.t('navigation.orders.archive'), archive_group_orders_path
|
||||
subnav.item :orders, I18n.t('navigation.orders.manage'), orders_path, if: Proc.new { current_user.role_orders? }
|
||||
subnav.item :pickups, I18n.t('navigation.orders.pickups'), pickups_path, if: Proc.new { current_user.role_orders? }
|
||||
end
|
||||
|
||||
primary.item :articles, I18n.t('navigation.articles.title'), '#',
|
||||
|
|
|
@ -51,6 +51,10 @@ Foodsoft::Application.routes.draw do
|
|||
resources :order_articles
|
||||
end
|
||||
|
||||
resources :pickups, only: [:index] do
|
||||
post :document, on: :collection
|
||||
end
|
||||
|
||||
resources :group_orders do
|
||||
get :archive, on: :collection
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ class RenderPDF < Prawn::Document
|
|||
}
|
||||
)
|
||||
|
||||
header = title
|
||||
header = options[:title] || title
|
||||
footer = I18n.l(Time.now, format: :long)
|
||||
|
||||
header_size = 0
|
||||
|
|
Loading…
Reference in a new issue