mirror of
https://github.com/internetee/registry.git
synced 2025-05-29 09:00:02 +02:00
Invoice forwarding in admin #2566
This commit is contained in:
parent
bfd3e07981
commit
2e7f5a74c5
3 changed files with 32 additions and 1 deletions
|
@ -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
|
||||
|
|
15
app/views/admin/invoices/forward.haml
Normal file
15
app/views/admin/invoices/forward.haml
Normal file
|
@ -0,0 +1,15 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:back_to_invoice), admin_invoice_path(@invoice), class: 'btn btn-default')
|
||||
= render 'shared/title', name: t(:forward_invoice)
|
||||
|
||||
= form_for([:admin, @invoice], url: { action: :forward }, method: :post) do |f|
|
||||
.row
|
||||
.col-md-4.col-md-offset-4
|
||||
= render 'shared/full_errors', object: @invoice
|
||||
.form-group
|
||||
= f.label :billing_email
|
||||
= f.text_field :billing_email, class: 'form-control', autocomplete: 'off'
|
||||
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
= button_tag(t(:forward), class: 'btn btn-warning')
|
|
@ -4,10 +4,11 @@
|
|||
= @invoice
|
||||
.col-sm-6
|
||||
%h1.text-right.text-center-xs
|
||||
= link_to(t(:download), admin_invoice_download_pdf_path(@invoice), class: 'btn btn-default')
|
||||
= link_to(t(:forward), admin_invoice_forward_path(@invoice), class: 'btn btn-default')
|
||||
- if !@invoice.cancelled? && !@invoice.binded?
|
||||
= link_to(t(:cancel), cancel_admin_invoice_path(@invoice), method: :patch, class: 'btn btn-warning')
|
||||
= link_to(t(:back), admin_invoices_path, class: 'btn btn-default')
|
||||
= link_to(t(:download), admin_invoice_download_pdf_path(@invoice), class: 'btn btn-default')
|
||||
%hr
|
||||
= render 'shared/full_errors', object: @invoice
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue