Invoice forwarding in admin #2566

This commit is contained in:
Martin Lensment 2015-07-14 13:43:55 +03:00
parent bfd3e07981
commit 2e7f5a74c5
3 changed files with 32 additions and 1 deletions

View file

@ -41,6 +41,21 @@ class Admin::InvoicesController < AdminController
end
end
def forward
@invoice.billing_email = @invoice.buyer.billing_email
return unless request.post?
@invoice.billing_email = params[:invoice][:billing_email]
if @invoice.forward(render_to_string('registrar/invoices/pdf', layout: false))
flash[:notice] = t(:invoice_forwared)
redirect_to([:admin, @invoice])
else
flash.now[:alert] = t(:failed_to_forward_invoice)
end
end
def download_pdf
pdf = @invoice.pdf(render_to_string('registrar/invoices/pdf', layout: false))
send_data pdf, filename: @invoice.pdf_name