Add a button to send the order to the supplier
This commit is contained in:
parent
b4ce8c31cc
commit
f27bbc2ffa
7 changed files with 65 additions and 0 deletions
|
@ -114,6 +114,15 @@ class OrdersController < ApplicationController
|
|||
redirect_to orders_url, alert: I18n.t('errors.general_msg', :msg => error.message)
|
||||
end
|
||||
|
||||
# Send a order to the supplier.
|
||||
def send_result_to_supplier
|
||||
order = Order.find(params[:id])
|
||||
Mailer.order_result_supplier(@current_user, order).deliver_now
|
||||
redirect_to order, notice: I18n.t('orders.send_to_supplier.notice')
|
||||
rescue => error
|
||||
redirect_to order, alert: I18n.t('errors.general_msg', :msg => error.message)
|
||||
end
|
||||
|
||||
def receive
|
||||
@order = Order.find(params[:id])
|
||||
unless request.post?
|
||||
|
|
|
@ -49,6 +49,23 @@ class Mailer < ActionMailer::Base
|
|||
subject: I18n.t('mailer.order_result.subject', name: group_order.order.name)
|
||||
end
|
||||
|
||||
# Sends order result to the supplier
|
||||
def order_result_supplier(user, order, options = {})
|
||||
@user = user
|
||||
@order = order
|
||||
@supplier = order.supplier
|
||||
|
||||
add_order_result_attachments order, options
|
||||
|
||||
subject = I18n.t('mailer.order_result_supplier.subject', :name => order.supplier.name)
|
||||
subject += " (#{I18n.t('activerecord.attributes.order.pickup')}: #{format_date(order.pickup)})" if order.pickup
|
||||
|
||||
mail to: order.supplier.email,
|
||||
cc: user,
|
||||
reply_to: user,
|
||||
subject: subject
|
||||
end
|
||||
|
||||
# Notify user if account balance is less than zero
|
||||
def negative_balance(user,transaction)
|
||||
@group = user.ordergroup
|
||||
|
@ -117,4 +134,10 @@ class Mailer < ActionMailer::Base
|
|||
MailDeliveryStatus.create email: message.to[0], message: error.message
|
||||
end
|
||||
|
||||
# separate method to allow plugins to mess with the attachments
|
||||
def add_order_result_attachments(order, options = {})
|
||||
attachments['order.pdf'] = OrderFax.new(order, options).to_pdf
|
||||
attachments['order.csv'] = OrderCsv.new(order, options).to_csv
|
||||
end
|
||||
|
||||
end
|
||||
|
|
1
app/views/mailer/order_result_supplier.text.haml
Normal file
1
app/views/mailer/order_result_supplier.text.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= raw t '.text', user: show_user(@user), foodcoop: FoodsoftConfig[:name]
|
|
@ -87,6 +87,7 @@
|
|||
= link_to t('.stock_order'), new_group_order_path(:order_id => @order.id, :stock_order => true), class: 'btn'
|
||||
= link_to t('ui.edit'), edit_order_path(@order), class: 'btn'
|
||||
- elsif not @order.closed? and not @order.stockit?
|
||||
= link_to t('.send_to_supplier'), send_result_to_supplier_order_path(@order), method: :post, class: 'btn btn-primary'
|
||||
= receive_button @order
|
||||
- unless @order.closed?
|
||||
= link_to t('ui.delete'), @order, data: {confirm: t('.confirm_delete')}, method: :delete,
|
||||
|
|
|
@ -1220,6 +1220,18 @@ de:
|
|||
die Bestellung für "%{order}" wurde am %{when} von %{user} beendet.
|
||||
Für euch wurden die folgenden Artikel bestellt:
|
||||
text1: "o Gesamtpreis: %{sum}\n\nBestellung online einsehen: %{order_url}\n\n\nViele Grüße von %{foodcoop} "
|
||||
order_result_supplier:
|
||||
subject: Neue Bestellung für %{name}
|
||||
text: |
|
||||
Guten Tag,
|
||||
|
||||
die Foodcoop %{foodcoop} möchte gerne eine Bestellung abgeben.
|
||||
|
||||
Im Anhang befinden sich ein PDF und eine CSV-Tabelle.
|
||||
|
||||
Mit freundlichen Grüßen
|
||||
%{user}
|
||||
%{foodcoop}
|
||||
reset_password:
|
||||
subject: Neues Password für %{username}
|
||||
text: |-
|
||||
|
@ -1418,6 +1430,8 @@ de:
|
|||
submit: Bestellung in Empfang nehmen
|
||||
surplus_options: 'Verteilungsoptionen:'
|
||||
title: "»%{order}« in Empfang nehmen"
|
||||
send_to_supplier:
|
||||
notice: Die Bestellung wurde an die Lieferantin geschickt.
|
||||
show:
|
||||
action_end: Beenden!
|
||||
amounts: 'Netto/Bruttosumme:'
|
||||
|
@ -1452,6 +1466,7 @@ de:
|
|||
default: Suche nach Artikeln ...
|
||||
groups: Suche nach Bestellgruppen ...
|
||||
search_reset: Suche zurücksetzen
|
||||
send_to_supplier: An Lieferantin schicken
|
||||
show_invoice: Rechnung anzeigen
|
||||
sort_article: Sortiert nach Artikeln
|
||||
sort_group: Sortiert nach Gruppen
|
||||
|
|
|
@ -1231,6 +1231,18 @@ en:
|
|||
|
||||
|
||||
Kind regards from %{foodcoop}.
|
||||
order_result_supplier:
|
||||
subject: New order for %{name}
|
||||
text: |
|
||||
Hi!
|
||||
|
||||
Foodcoop %{foodcoop} would like to place an order.
|
||||
|
||||
Please find a PDF and spreadsheet attached.
|
||||
|
||||
Kind regards,
|
||||
%{user}
|
||||
%{foodcoop}
|
||||
reset_password:
|
||||
subject: New password for %{username}
|
||||
text: |
|
||||
|
@ -1428,6 +1440,8 @@ en:
|
|||
submit: Receive order
|
||||
surplus_options: 'Distribution options:'
|
||||
title: Receiving %{order}
|
||||
send_to_supplier:
|
||||
notice: The order has been sent to the supplier.
|
||||
show:
|
||||
action_end: Close!
|
||||
amounts: 'Net/gross sum:'
|
||||
|
@ -1462,6 +1476,7 @@ en:
|
|||
default: Search for articles...
|
||||
groups: Search for ordergroups...
|
||||
search_reset: Reset search
|
||||
send_to_supplier: Send to supplier
|
||||
show_invoice: Show invoice
|
||||
sort_article: Sorted in articles
|
||||
sort_group: Sorted in groups
|
||||
|
|
|
@ -39,6 +39,7 @@ Foodsoft::Application.routes.draw do
|
|||
member do
|
||||
post :finish
|
||||
post :add_comment
|
||||
post :send_result_to_supplier
|
||||
|
||||
get :receive
|
||||
post :receive
|
||||
|
|
Loading…
Reference in a new issue