Before adding workers
This commit is contained in:
@@ -3,19 +3,19 @@ module IdCard
|
||||
|
||||
# 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 }
|
||||
@employer_setups = IdCard::Setup.active.to_a
|
||||
@queue_counts = IdCardQueueService::GetQueuedCounts.new().call
|
||||
add_queued_count_to_card_setup
|
||||
@queued = @employer_setups.select { |setup| setup.queued_card_count > 0 }.sort_by { |setup| setup.pl_plan_key.to_i }
|
||||
@not_queued = @employer_setups.select { |setup| setup.queued_card_count == 0 }.sort_by { |setup| setup.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
|
||||
@queue_members = IdCardQueueService::GetQueuedCards.new().call
|
||||
cards_pdf = IdCardPrinterService::QueuedCardsGenerator.new(@queue_members).call
|
||||
|
||||
if cards_pdf.is_a?(CombinePDF::PDF)
|
||||
send_data cards_pdf.to_pdf,
|
||||
@@ -35,8 +35,8 @@ module IdCard
|
||||
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
|
||||
@queue_members = IdCardQueueService::GetQueuedCards.new(pl_plan_key).call
|
||||
cards_pdf = IdCardPrinterService::QueuedCardsGenerator.new(@queue_members).call
|
||||
|
||||
send_data cards_pdf.to_pdf,
|
||||
filename: "#{@employer.name.parameterize(separator: "_")}_queued_cards_#{Date.today}.pdf",
|
||||
@@ -46,9 +46,14 @@ module IdCard
|
||||
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
|
||||
if Integer(params[:id], exception: false).is_a?(Integer)
|
||||
pl_plan_key = params[:id].to_s
|
||||
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
|
||||
else
|
||||
slug = params[:id]
|
||||
@employer = Employer.find_by(slug: slug)
|
||||
end
|
||||
sample_cards_pdf = IdCardPrinterService::SampleCardsGenerator.new(@employer).call
|
||||
|
||||
send_data sample_cards_pdf.to_pdf,
|
||||
filename: "#{@employer.name.parameterize(separator: "_")}_sample_cards_#{Date.today}.pdf",
|
||||
@@ -58,9 +63,14 @@ module IdCard
|
||||
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
|
||||
if Integer(params[:id], exception: false).is_a?(Integer)
|
||||
pl_plan_key = params[:id].to_s
|
||||
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
|
||||
else
|
||||
slug = params[:id]
|
||||
@employer = Employer.find_by(slug: slug)
|
||||
end
|
||||
cards_pdf = IdCardPrinterService::EmployerCardsGenerator.new(@employer, "PrintCard").call
|
||||
|
||||
send_data cards_pdf.to_pdf,
|
||||
filename: "#{@employer.name.parameterize(separator: "_")}_print_cards_#{Date.today}.pdf",
|
||||
@@ -70,9 +80,14 @@ module IdCard
|
||||
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
|
||||
if Integer(params[:id], exception: false).is_a?(Integer)
|
||||
pl_plan_key = params[:id].to_s
|
||||
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
|
||||
else
|
||||
slug = params[:id]
|
||||
@employer = Employer.find_by(slug: slug)
|
||||
end
|
||||
cards_pdf = IdCardPrinterService::EmployerCardsGenerator.new(@employer, "MobileDisplayCard").call
|
||||
|
||||
send_data cards_pdf.to_pdf,
|
||||
filename: "#{@employer.name.parameterize(separator: "_")}_mobile_display_cards_#{Date.today}.pdf",
|
||||
@@ -82,9 +97,14 @@ module IdCard
|
||||
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
|
||||
if Integer(params[:id], exception: false).is_a?(Integer)
|
||||
pl_plan_key = params[:id].to_s
|
||||
@employer = Employer.find_by(pl_plan_key: pl_plan_key)
|
||||
else
|
||||
slug = params[:id]
|
||||
@employer = Employer.find_by(slug: slug)
|
||||
end
|
||||
cards_pdf = IdCardPrinterService::EmployerCardsGenerator.new(@employer, "FullPageCard", true).call
|
||||
|
||||
cards_pdf.rewind
|
||||
send_data cards_pdf.sysread,
|
||||
@@ -97,9 +117,9 @@ module IdCard
|
||||
private
|
||||
|
||||
|
||||
def add_queued_count_to_card_configuration
|
||||
def add_queued_count_to_card_setup
|
||||
@queue_counts.each do |qc|
|
||||
match = @employer_configs.find { |config| config.pl_plan_key == qc["PLPlanKey"] }
|
||||
match = @employer_setups.find { |setup| setup.pl_plan_key == qc["PLPlanKey"] }
|
||||
if match.present?
|
||||
match.queued_card_count = qc["QueuedCardsCount"]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user