add bnn_upload plugin that overrides some controller methods to use order_bnn
This commit is contained in:
parent
f8c91b46cd
commit
b1ec0fd2fc
12 changed files with 70 additions and 27 deletions
|
|
@ -1,8 +0,0 @@
|
|||
class Mailer
|
||||
# attaches files to mail sent to supplier
|
||||
def add_order_result_attachments(order, options = {})
|
||||
attachments['order.pdf'] = OrderFax.new(order, options).to_pdf if options[:file_formats][:pdf].present?
|
||||
attachments['order.csv'] = OrderCsv.new(order, options).to_csv if options[:file_formats][:csv].present?
|
||||
attachments['order.bnn'] = OrderBnn.new(order, options).to_bnn if options[:file_formats][:bnn].present?
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
class OrdersController < ApplicationController
|
||||
# Send a order to the supplier.
|
||||
OrdersController.class_eval do
|
||||
def send_result_to_supplier
|
||||
order = Order.find(params[:id])
|
||||
options = { file_formats: params[:file_formats] }
|
||||
order.send_to_supplier!(@current_user, options)
|
||||
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)
|
||||
redirect_to order_path(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 send_result_to_supplier_modal
|
||||
@order = Order.find(params[:id])
|
||||
end
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Mailer.class_eval do
|
||||
require 'foodsoft_bnn_upload/order_bnn'
|
||||
def add_order_result_attachments(order, options = {})
|
||||
# attachments['order.pdf'] = ::OrderFax.new(order, options).to_pdf if options[:file_formats][:pdf].present?
|
||||
# attachments['order.csv'] = ::OrderCsv.new(order, options).to_csv if options[:file_formats][:csv].present?
|
||||
attachments['order.bnn'] = FoodsoftBnnUpload::OrderBnn.new(order, options).to_csv if options[:file_formats][:bnn].present?
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
class Order
|
||||
Order.class_eval do
|
||||
def send_to_supplier!(user, options = {})
|
||||
Mailer.deliver_now_with_default_locale do
|
||||
Mailer.order_result_supplier(user, self, options)
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
/ replace '#send_button'
|
||||
/ replace 'erb:contains("send_to_supplier")'
|
||||
- if FoodsoftBnnUpload.enabled?
|
||||
= link_to t('.send_to_supplier'), send_result_to_supplier_modal_order_path(@order), remote: true,
|
||||
class: "btn#{' btn-primary',
|
||||
data: {confirm: @order.last_sent_mail && t('.confirm_send_to_supplier', when: format_time(@order.last_sent_mail)) }
|
||||
= link_to t('.send_to_supplier'), order_send_result_to_supplier_modal_path(@order), class: 'btn btn-primary', remote: true
|
||||
|
|
@ -5,8 +5,10 @@
|
|||
.modal-body
|
||||
= f.check_box 'file_formats[pdf]'
|
||||
= f.label 'file_formats[pdf]', "PDF"
|
||||
= f.check_box 'file_formats[csv]'
|
||||
= f.label 'file_formats[csv]', "CSV"
|
||||
= f.check_box 'file_formats[bnn]'
|
||||
= f.label 'file_formats[bnn]', "BNN"
|
||||
.modal-footer
|
||||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||
= f.submit class: 'btn btn-primary'
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
$('#modalContainer').html('#{j(render("send_to_supplier_modal"))}');
|
||||
$('#modalContainer').html('#{escape_javascript(render("send_result_to_supplier_modal"))}');
|
||||
$('#modalContainer').modal();
|
||||
$('#modalContainer').submit(function() {$('#modalContainer').modal('hide');});
|
||||
Loading…
Add table
Add a link
Reference in a new issue