Signed-off-by: Adrian Hinz <ahinz@voicetelecom.pl>

This commit is contained in:
Adrian Hinz 2016-10-06 14:29:38 +02:00
parent 414c35b2c6
commit 4bc074febd
7 changed files with 58 additions and 1 deletions

View File

@ -35,7 +35,8 @@ gem 'jbuilder', '~> 2.5'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri

View File

@ -5,6 +5,14 @@ class InvoicesController < ApplicationController
def show
@invoice = Invoice.find(params[:id])
respond_to do |format|
format.html
format.pdf do
render pdf: "Faktura_VAT_#{@invoice.id}", # Excluding ".pdf" extension.
disposition: 'attachment',
exe_path: ''
end
end
end
def new

View File

@ -180,6 +180,30 @@
</table>
</div>
</div>
<div class="row">
<div class="col-md-12"><h1>&nbsp;</h1></div>
</div>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-4">
<table width="100%" border="1" class="table">
<tr><td>Sprzedający:</td></tr>
<tr>
<td height="150" valign="bottom" class="text-center" style="vertical-align:bottom;">Osoba upowazniona do wystawienia faktury VAT</td>
</tr>
</table>
</div>
<div class="col-md-2"></div>
<div class="col-md-4">
<table width="100%" border="1" class="table">
<tr><td>Kupujący:</td></tr>
<tr>
<td height="150" class="text-center" style="vertical-align:bottom;">Osoba upowazniona do odbioru faktury VAT</td>
</tr>
</table>
</div>
<div class="col-md-1"></div>
</div>
</div>
</div>

View File

@ -3,6 +3,7 @@
<div class="panel-title">Faktura: <%= @invoice.number %></div>
<div class="panel-options">
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left text-success\"></i> " + I18n.t('back')), invoices_path, title: I18n.t('back'), class: "text-primary" %>
<%= link_to 'PDF', invoice_path(@invoice, format: :pdf) %>
</div>
</div>
<div class="content-box-large box-with-header" style="background:#dddddd">

View File

@ -0,0 +1 @@
<%= render file: '/invoices/_show.html.erb' %>

View File

@ -2,3 +2,4 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
Mime::Type.register "application/pdf", :pdf

View File

@ -0,0 +1,21 @@
# WickedPDF Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `render :pdf` call.
#
# To learn more, check out the README:
#
# https://github.com/mileszs/wicked_pdf/blob/master/README.md
WickedPdf.config = {
# Path to the wkhtmltopdf executable: This usually isn't needed if using
# one of the wkhtmltopdf-binary family of gems.
# exe_path: 'c:/Program Files/wkhtmltopdf/bin/wkhtmltopdf',
# or
exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')
# Layout file to be used for all PDFs
# (but can be overridden in `render :pdf` calls)
# layout: 'pdf.html',
}