2022-05-04 08:57:14 +02:00
|
|
|
require 'prawn/measurement_extensions'
|
|
|
|
|
|
|
|
#----- A4 page size
|
|
|
|
page_size = 'A4'
|
|
|
|
page_width = 595
|
|
|
|
|
2024-02-27 10:20:29 +01:00
|
|
|
# see, charte_graphique_de_letat.pdf
|
|
|
|
# a4: 210mm largueur
|
|
|
|
# margin left and right: 17mm
|
|
|
|
# calc ratio, 17*100/210: 8% de marge gauche/droite
|
|
|
|
# calc mm to pixel: 8*595/100: 47 <- final margin
|
2022-05-04 08:57:14 +02:00
|
|
|
#----- margins
|
2024-02-27 10:20:29 +01:00
|
|
|
top_margin = 47
|
|
|
|
right_margin = 47
|
|
|
|
bottom_margin = 47
|
|
|
|
left_margin = 47
|
2022-05-04 08:57:14 +02:00
|
|
|
|
2024-02-27 10:20:29 +01:00
|
|
|
body_width = page_width - left_margin - right_margin
|
2022-05-04 08:57:14 +02:00
|
|
|
|
|
|
|
prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], page_size: page_size) do |pdf|
|
|
|
|
pdf.font_families.update('marianne' => {
|
|
|
|
normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf'),
|
|
|
|
bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf')
|
|
|
|
})
|
|
|
|
pdf.font 'marianne'
|
|
|
|
|
2024-02-27 10:20:29 +01:00
|
|
|
grey = '3a3a3a'
|
|
|
|
black = '222222'
|
2022-05-04 08:57:14 +02:00
|
|
|
|
2022-08-31 11:12:47 +02:00
|
|
|
pdf.pad_bottom(30) do
|
|
|
|
pdf.image DOSSIER_PDF_EXPORT_LOGO_SRC, width: 300, position: :center
|
2022-05-04 08:57:14 +02:00
|
|
|
|
2022-08-31 11:12:47 +02:00
|
|
|
pdf.pad_top(15) do
|
|
|
|
pdf.fill_color grey
|
|
|
|
pdf.text t('.receipt'), size: 14, align: :center
|
|
|
|
end
|
2022-05-04 08:57:14 +02:00
|
|
|
end
|
|
|
|
|
2024-02-27 10:20:29 +01:00
|
|
|
pdf.bounding_box([0, pdf.cursor - 20], width: body_width) do
|
2022-05-04 08:57:14 +02:00
|
|
|
pdf.fill_color black
|
|
|
|
pdf.pad_top(40) { pdf.text @dossier.procedure.libelle, size: 14, character_spacing: -0.2, align: :center }
|
|
|
|
|
|
|
|
pdf.fill_color grey
|
2022-05-04 17:19:29 +02:00
|
|
|
description = t('.description', user_name: papertrail_requester_identity(@dossier), procedure: @dossier.procedure.libelle, date: l(@dossier.depose_at, format: '%e %B %Y'))
|
2022-05-04 08:57:14 +02:00
|
|
|
pdf.pad_top(30) { pdf.text description, size: 10, character_spacing: -0.2, align: :left }
|
|
|
|
|
|
|
|
pdf.fill_color black
|
|
|
|
pdf.pad_top(30) { pdf.text t('views.shared.dossiers.demande.requester_identity'), size: 14, character_spacing: -0.2, align: :justify }
|
|
|
|
|
|
|
|
if @dossier.individual.present?
|
|
|
|
pdf.pad_top(7) do
|
|
|
|
pdf.fill_color grey
|
|
|
|
pdf.text "#{Individual.human_attribute_name(:prenom)} : #{@dossier.individual.prenom}", size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
pdf.text "#{Individual.human_attribute_name(:nom)} : #{@dossier.individual.nom.upcase}", size: 10, character_spacing: -0.2, align: :justify
|
2024-04-18 10:21:32 +02:00
|
|
|
pdf.text "#{User.human_attribute_name(:email)} : #{@dossier.user_email_for(:display)}", size: 10, character_spacing: -0.2, align: :justify
|
2022-05-04 08:57:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if @dossier.etablissement.present?
|
|
|
|
pdf.pad_top(7) do
|
|
|
|
pdf.fill_color grey
|
|
|
|
pdf.text "Dénomination : " + raison_sociale_or_name(@dossier.etablissement), size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
pdf.text "SIRET : " + @dossier.etablissement.siret, size: 10, character_spacing: -0.2, align: :justify
|
2024-04-18 10:21:32 +02:00
|
|
|
pdf.text "#{User.human_attribute_name(:email)} : #{@dossier.user_email_for(:display)}", size: 10, character_spacing: -0.2, align: :justify
|
2022-05-04 08:57:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
pdf.fill_color black
|
|
|
|
pdf.pad_top(30) { pdf.text Dossier.model_name.human, size: 14, character_spacing: -0.2, align: :justify }
|
|
|
|
|
|
|
|
pdf.fill_color grey
|
|
|
|
pdf.pad_top(7) do
|
2022-08-31 11:23:25 +02:00
|
|
|
pdf.text "#{Dossier.human_attribute_name(:id)} : #{@dossier.id}", size: 10, character_spacing: -0.2, align: :justify
|
2022-05-04 17:18:59 +02:00
|
|
|
pdf.text t('.file_submitted_at') + ' : ' + l(@dossier.depose_at, format: '%e %B %Y'), size: 10, character_spacing: -0.2, align: :justify
|
2022-05-04 08:57:14 +02:00
|
|
|
pdf.text t('.dossier_state') + ' : ' + papertrail_dossier_state(@dossier), size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
end
|
|
|
|
|
2024-03-05 11:04:26 +01:00
|
|
|
service = @dossier.service
|
2022-05-04 08:57:14 +02:00
|
|
|
if service.present?
|
|
|
|
pdf.fill_color black
|
|
|
|
pdf.pad_top(30) { pdf.text t('.administrative_service'), size: 14, character_spacing: -0.2, align: :justify }
|
|
|
|
|
|
|
|
pdf.fill_color grey
|
|
|
|
pdf.pad_top(7) do
|
|
|
|
pdf.text "#{Service.model_name.human} : " + [service.nom, service.organisme].join(", "), size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
pdf.text "#{Service.human_attribute_name(:adresse)} : #{service.adresse}", size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
pdf.text "#{Service.human_attribute_name(:email)} : #{service.email}", size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
if service.telephone.present?
|
|
|
|
pdf.text "#{Service.human_attribute_name(:telephone)} : #{service.telephone}", size: 10, character_spacing: -0.2, align: :justify
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
pdf.fill_color black
|
|
|
|
pdf.pad_top(100) do
|
|
|
|
pdf.text t('.generated_at', date: l(Time.zone.now.to_date, format: :long)), size: 10, character_spacing: -0.2, align: :right
|
2024-03-20 11:34:54 +01:00
|
|
|
pdf.text t('.signature', app_name: Current.application_name), size: 10, character_spacing: -0.2, align: :right
|
2022-05-04 08:57:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|