Before a few renames

This commit is contained in:
Jason Jordan
2026-03-19 00:42:27 -04:00
parent 011ee91707
commit 3300819ed5
46 changed files with 994 additions and 467 deletions
+23 -18
View File
@@ -1,40 +1,45 @@
module IdCardPrinter
class PdfProcessor
def initialize(pl_plan_key, layout, zip)
@pl_plan_key = pl_plan_key
@employer_card_config = Employer.find_by(pl_plan_key: pl_plan_key).id_card_configuration
def initialize(employer, layout, zip = false)
@employer = employer
@card_config = @employer.id_card_configuration
@layout = layout
@zip = zip
end
def call
# if @zip
# group_cards_pdf_array = []
# else
# group_cards_pdf = CombinePDF.new
# end
group_cards_pdf_array = []
IdCard::PrintData.where(pl_plan_key: @pl_plan_key).each do |card|
url = IdCardPrinter::JasperUrlGenerator.new(@pl_plan_key, card.family_id, @layout).call
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key).each do |card|
url = IdCardPrinter::JasperUrlGenerator.new(@employer.pl_plan_key, card.family_id, @layout).call
puts url
card_pdf = IdCardPrinter::JasperPdfGenerator.new(url).call
if @zip
card_filename = "#{card.name.gsub(", ", "_")}_digital_card_#{Date.today}.pdf"
card_filename = "#{card.full_name_last_name_first.gsub(", ", "_")}_digital_card_#{Date.today}.pdf"
group_cards_pdf_array << { name: card_filename, data: card_pdf.to_pdf }
else
group_cards_pdf_array << card_pdf
end
end
if @zip
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
group_cards_pdf_array.each do |file|
zio.put_next_entry(file[:name])
zio.write(file[:data])
end
end
else
todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
end
# if @zip
# group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
# group_cards_pdf_array.each do |file|
# zio.put_next_entry(file[:name])
# zio.write(file[:data])
# end
# end
# # else
# # todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
# # group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
# end
group_cards_pdf
group_cards_pdf_array
end
end
end