extract procedure

This commit is contained in:
simon lehericey 2022-04-06 00:20:52 +02:00
parent 4d3412daf5
commit 2c195e3ce2
2 changed files with 9 additions and 3 deletions

View file

@ -108,14 +108,19 @@ class PiecesJustificativesService
end end
def self.generate_dossier_export(dossiers) def self.generate_dossier_export(dossiers)
return [] if dossiers.empty?
pdfs = [] pdfs = []
procedure = dossiers.first.procedure
dossiers.find_each do |dossier| dossiers.find_each do |dossier|
pdf = ApplicationController pdf = ApplicationController
.render(template: 'dossiers/show', formats: [:pdf], .render(template: 'dossiers/show', formats: [:pdf],
assigns: { assigns: {
include_infos_administration: true, include_infos_administration: true,
dossier: dossier dossier: dossier,
procedure: procedure
}) })
a = FakeAttachment.new( a = FakeAttachment.new(

View file

@ -205,6 +205,7 @@ def add_etats_dossier(pdf, dossier)
end end
prawn_document(page_size: "A4") do |pdf| prawn_document(page_size: "A4") do |pdf|
@procedure ||= @dossier.procedure
pdf.font_families.update( 'marianne' => { pdf.font_families.update( 'marianne' => {
normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ), normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ),
bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ), bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ),
@ -216,8 +217,8 @@ prawn_document(page_size: "A4") do |pdf|
end end
format_in_2_columns(pdf, 'Dossier Nº', @dossier.id.to_s) format_in_2_columns(pdf, 'Dossier Nº', @dossier.id.to_s)
format_in_2_columns(pdf, 'Démarche', @dossier.procedure.libelle) format_in_2_columns(pdf, 'Démarche', @procedure.libelle)
format_in_2_columns(pdf, 'Organisme', @dossier.procedure.organisation_name) format_in_2_columns(pdf, 'Organisme', @procedure.organisation_name)
add_etat_dossier(pdf, @dossier) add_etat_dossier(pdf, @dossier)