mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 02:39:37 +02:00
Basic pdf generating
This commit is contained in:
parent
e987e201ad
commit
727d1226ad
15 changed files with 298 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
class Registrar::InvoicesController < RegistrarController
|
||||
load_and_authorize_resource
|
||||
|
||||
before_action :set_invoice, only: [:show]
|
||||
before_action :set_invoice, only: [:show, :forward, :download_pdf]
|
||||
|
||||
def index
|
||||
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
||||
|
@ -13,6 +13,30 @@ class Registrar::InvoicesController < RegistrarController
|
|||
def show
|
||||
end
|
||||
|
||||
def forward
|
||||
@invoice.billing_email = @invoice.buyer.billing_email
|
||||
|
||||
return unless request.post?
|
||||
|
||||
@invoice.billing_email = params[:invoice][:billing_email]
|
||||
|
||||
if @invoice.forward
|
||||
flash[:notice] = t('invoice_forwared')
|
||||
redirect_to([:registrar, @invoice])
|
||||
else
|
||||
flash.now[:alert] = t('failed_to_forward_invoice')
|
||||
end
|
||||
end
|
||||
|
||||
def download_pdf
|
||||
# render 'pdf', layout: false
|
||||
|
||||
kit = PDFKit.new(render_to_string('pdf', layout: false))
|
||||
pdf = kit.to_pdf
|
||||
|
||||
send_data pdf, filename: "test.pdf"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_invoice
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue