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
+110
View File
@@ -0,0 +1,110 @@
module IdCard
class PrintController < ApplicationController
# View Methods
def index
@employer_configs = IdCard::Configuration.active.to_a
@queue_counts = EmployerCards::GetQueuedCounts.new().call
add_queued_count_to_card_configuration
@queued = @employer_configs.select { |config| config.queued_card_count > 0 }.sort_by { |config| config.pl_plan_key.to_i }
@not_queued = @employer_configs.select { |config| config.queued_card_count == 0 }.sort_by { |config| config.pl_plan_key.to_i }
render :index
end
# API Methods
def print_all_queued
@queue_members = EmployerCards::GetQueuedCards.new().call
cards_pdf = IdCardPrinter::QueuedCardsGenerator.new(@queue_members).call
if cards_pdf.is_a?(CombinePDF::PDF)
send_data cards_pdf.to_pdf,
filename: "queued_cards_#{Date.today}.pdf",
type: "application/pdf",
disposition: 'attachment'
else
cards_pdf.rewind
send_data cards_pdf.read,
filename: "queued_cards_#{Date.today}.zip",
type: 'application/zip',
disposition: 'attachment'
end
end
def print_queued_by_employer
pl_plan_key = params[:id].to_s
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
@queue_members = EmployerCards::GetQueuedCards.new(pl_plan_key).call
cards_pdf = IdCardPrinter::QueuedCardsGenerator.new(@queue_members).call
send_data cards_pdf.to_pdf,
filename: "#{@employer.name.parameterize(separator: "_")}_queued_cards_#{Date.today}.pdf",
type: "application/pdf",
disposition: 'attachment'
end
def generate_sample
pl_plan_key = params[:id].to_s
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
sample_cards_pdf = IdCardPrinter::SampleCardsGenerator.new(@employer).call
send_data sample_cards_pdf.to_pdf,
filename: "#{@employer.name.parameterize(separator: "_")}_sample_cards_#{Date.today}.pdf",
type: "application/pdf",
disposition: 'attachment'
end
def generate_print
pl_plan_key = params[:id].to_s
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
cards_pdf = IdCardPrinter::EmployerCardsGenerator.new(@employer, "PrintCard").call
send_data cards_pdf.to_pdf,
filename: "#{@employer.name.parameterize(separator: "_")}_print_cards_#{Date.today}.pdf",
type: "application/pdf",
disposition: 'attachment'
end
def generate_mobile_display
pl_plan_key = params[:id].to_s
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
cards_pdf = IdCardPrinter::EmployerCardsGenerator.new(@employer, "MobileDisplayCard").call
send_data cards_pdf.to_pdf,
filename: "#{@employer.name.parameterize(separator: "_")}_mobile_display_cards_#{Date.today}.pdf",
type: "application/pdf",
disposition: 'attachment'
end
def generate_full_page
pl_plan_key = params[:id].to_s
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
cards_pdf = IdCardPrinter::EmployerCardsGenerator.new(@employer, "FullPageCard", true).call
cards_pdf.rewind
send_data cards_pdf.sysread,
filename: "#{@employer.name.parameterize(separator: "_")}_full_page_cards_#{Date.today}.zip",
type: 'application/zip',
disposition: 'attachment'
end
private
def add_queued_count_to_card_configuration
@queue_counts.each do |qc|
match = @employer_configs.find { |config| config.pl_plan_key == qc["PLPlanKey"] }
if match.present?
match.queued_card_count = qc["QueuedCardsCount"]
end
end
end
end
end