Fases 7 e 8 — PDFs Prawn + QR + Painel Motorista + Notificações
This commit is contained in:
68
app/services/pdf/base_pdf.rb
Normal file
68
app/services/pdf/base_pdf.rb
Normal file
@@ -0,0 +1,68 @@
|
||||
# app/services/pdf/base_pdf.rb
|
||||
#
|
||||
# Layout base dos PDFs da Gade: cabeçalho preto com logo laranja,
|
||||
# rodapé com data de geração. Herdar e implementar #corpo.
|
||||
#
|
||||
module Pdf
|
||||
class BasePdf
|
||||
LARANJA = 'F97316'
|
||||
PRETO = '0A0A0A'
|
||||
CINZA = '6B7280'
|
||||
|
||||
def initialize
|
||||
@pdf = Prawn::Document.new(page_size: 'A4', margin: [40, 40, 60, 40])
|
||||
end
|
||||
|
||||
def render
|
||||
cabecalho
|
||||
corpo
|
||||
rodape
|
||||
@pdf.render
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cabecalho
|
||||
@pdf.fill_color PRETO
|
||||
@pdf.fill_rectangle [-40, @pdf.cursor + 40], @pdf.bounds.width + 80, 70
|
||||
|
||||
@pdf.fill_color LARANJA
|
||||
@pdf.fill_rectangle [-40 + 0, @pdf.cursor + 40], 8, 70 # faixa laranja lateral
|
||||
|
||||
@pdf.fill_color 'FFFFFF'
|
||||
@pdf.text_box 'GADE HOSPITALAR',
|
||||
at: [10, @pdf.cursor + 20], size: 20, style: :bold
|
||||
@pdf.fill_color LARANJA
|
||||
@pdf.text_box 'Sistema de Controle de Custos Logísticos',
|
||||
at: [10, @pdf.cursor - 4], size: 10
|
||||
|
||||
@pdf.fill_color '000000'
|
||||
@pdf.move_down 55
|
||||
end
|
||||
|
||||
def rodape
|
||||
@pdf.repeat(:all) do
|
||||
@pdf.bounding_box [0, 20], width: @pdf.bounds.width do
|
||||
@pdf.fill_color CINZA
|
||||
@pdf.text "Gerado em #{Time.current.strftime('%d/%m/%Y %H:%M')} · Gade Hospitalar — documento interno",
|
||||
size: 8, align: :center
|
||||
@pdf.fill_color '000000'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def moeda(v)
|
||||
"R$ #{format('%.2f', v.to_f)}".gsub('.', ',')
|
||||
end
|
||||
|
||||
def secao(titulo)
|
||||
@pdf.move_down 14
|
||||
@pdf.fill_color LARANJA
|
||||
@pdf.text titulo, size: 13, style: :bold
|
||||
@pdf.stroke_color LARANJA
|
||||
@pdf.stroke_horizontal_rule
|
||||
@pdf.fill_color '000000'
|
||||
@pdf.move_down 8
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user