Before a few renames
This commit is contained in:
@@ -1,17 +1,38 @@
|
||||
module IdCardPrinter
|
||||
class EmployerCardsGenerator
|
||||
|
||||
def initialize(pl_plan_key, layout, zip=false)
|
||||
@pl_plan_key = pl_plan_key
|
||||
def initialize(employer, layout, zip=false)
|
||||
@employer = employer
|
||||
@layout = layout
|
||||
@zip = zip
|
||||
end
|
||||
|
||||
def call
|
||||
IdCard::PrintData.where(pl_plan_key: @pl_plan_key).destroy_all
|
||||
EmployerCards::DataFormatter.new(@pl_plan_key).call
|
||||
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key).destroy_all
|
||||
IdCardPrinter::EmployerDataFormatter.new(@employer).call
|
||||
|
||||
IdCardPrinter::PdfProcessor.new(@pl_plan_key, @layout, @zip).call
|
||||
pdf_array = IdCardPrinter::PdfProcessor.new(@employer, @layout, @zip).call
|
||||
|
||||
group_pdfs = combine_pdfs(pdf_array)
|
||||
group_pdfs
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def combine_pdfs(pdf_array)
|
||||
if @zip
|
||||
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
|
||||
pdf_array.each do |file|
|
||||
zio.put_next_entry(file[:name])
|
||||
zio.write(file[:data])
|
||||
end
|
||||
end
|
||||
else
|
||||
group_cards_pdf = CombinePDF.new
|
||||
pdf_array.each { |pdf| group_cards_pdf << pdf }
|
||||
end
|
||||
group_cards_pdf
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user