Before a few renames
This commit is contained in:
@@ -6,20 +6,20 @@ module IdCard
|
||||
def edit
|
||||
@employer = Employer.find_by(slug: params[:employer_id])
|
||||
if @employer.id_card_enabled?
|
||||
@setup = @employer.id_card_configuration
|
||||
@configuration = @employer.id_card_configuration
|
||||
else
|
||||
@setup = @employer.create_id_card_configuration
|
||||
@configuration = @employer.create_id_card_configuration
|
||||
end
|
||||
render :edit
|
||||
end
|
||||
|
||||
def update
|
||||
setup_params = IdCard::Configuration.permitted_params(params)
|
||||
@setup = IdCard::Configuration.find(params[:id])
|
||||
@configuration = IdCard::Configuration.find(params[:id])
|
||||
|
||||
if @setup.update(setup_params)
|
||||
if @configuration.update(setup_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@setup.employer.slug), notice: 'ID Card Configuration was successfully updated.'
|
||||
redirect_to employer_path(@configuration.employer.slug), notice: 'ID Card Configuration was successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -30,8 +30,8 @@ module IdCard
|
||||
def general
|
||||
provider_defaults = IdCard::ProviderSection.defaults
|
||||
@provider_options = provider_defaults.map { |p| ["Default #{p.title}", p.id] }.concat(provider_defaults.map { |p| ["New #{p.title}", "new|#{p.id}"] })
|
||||
if @setup.provider_section_id.present? && provider_defaults.map(&:id).exclude?(@setup.provider_section_id)
|
||||
@provider_options.insert(0, ["#{@employer.name} Custom", @setup.provider_section_id])
|
||||
if @configuration.provider_section_id.present? && provider_defaults.map(&:id).exclude?(@configuration.provider_section_id)
|
||||
@provider_options.insert(0, ["#{@employer.name} Custom", @configuration.provider_section_id])
|
||||
end
|
||||
@rx_options = IdCard::RxSection.all
|
||||
@fairos_rx_id = IdCard::RxSection.find_by(title: "FairosRx").id
|
||||
@@ -45,7 +45,7 @@ module IdCard
|
||||
params[:id_card_configuration]["provider_section_id"] = new_provider_section.id
|
||||
end
|
||||
general_params = IdCard::Configuration.permitted_params(params)
|
||||
if @setup.update(general_params)
|
||||
if @configuration.update(general_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@employer.slug), notice: 'ID Card Configuration was successfully updated.'
|
||||
else
|
||||
@@ -61,9 +61,9 @@ module IdCard
|
||||
|
||||
def update_plans
|
||||
plans_params = IdCard::Plan.permitted_params(params)
|
||||
if @setup.update(plans_params)
|
||||
if @configuration.update(plans_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@setup.employer.slug), notice: 'ID Card Plans successfully updated.'
|
||||
redirect_to employer_path(@configuration.employer.slug), notice: 'ID Card Plans successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :plans, status: :unprocessable_entity
|
||||
@@ -77,9 +77,9 @@ module IdCard
|
||||
|
||||
def update_field_exceptions
|
||||
field_exceptions_params = IdCard::FieldException.permitted_params(params)
|
||||
if @setup.update(field_exceptions_params)
|
||||
if @configuration.update(field_exceptions_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@setup.employer.slug), notice: 'ID Card Exceptions successfully updated.'
|
||||
redirect_to employer_path(@configuration.employer.slug), notice: 'ID Card Exceptions successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :field_exceptions, status: :unprocessable_entity
|
||||
@@ -100,9 +100,9 @@ module IdCard
|
||||
def set_employer_and_setup
|
||||
@employer = Employer.find_by(slug: params[:employer_id])
|
||||
if @employer.id_card_configuration.present?
|
||||
@setup = @employer.id_card_configuration
|
||||
@configuration = @employer.id_card_configuration
|
||||
else
|
||||
@setup = @employer.create_id_card_configuration
|
||||
@configuration = @employer.create_id_card_configuration
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,49 @@
|
||||
module IdCard
|
||||
class PrintDataController < ApplicationController
|
||||
|
||||
def generate_sample
|
||||
@employer = Employer.find_by(slug: params[:employer_slug])
|
||||
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
|
||||
@employer = Employer.find_by(slug: params[:employer_slug])
|
||||
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
|
||||
@employer = Employer.find_by(slug: params[:employer_slug])
|
||||
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
|
||||
@employer = Employer.find_by(slug: params[:employer_slug])
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -1,32 +0,0 @@
|
||||
module IdCard
|
||||
class PrinterController < ApplicationController
|
||||
|
||||
# View Methods
|
||||
def index
|
||||
@employer_configurations = IdCard::Configuration.active.to_a.sort_by { |config| config.pl_plan_key.to_i }
|
||||
add_queued_count_to_card_configuration
|
||||
render :index
|
||||
end
|
||||
|
||||
# API Methods
|
||||
|
||||
def print_queued
|
||||
@queue_counts = EmployerCards::GetQueuedCards.new().call
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def add_queued_count_to_card_configuration
|
||||
@queue_counts = EmployerCards::GetQueuedCounts.new().call
|
||||
@queue_counts.each do |qc|
|
||||
match = @employer_configurations.find { |configuration| configuration.pl_plan_key == qc["PLPlanKey"] }
|
||||
if match.present?
|
||||
match.queued_card_count = qc["QueuedCardsCount"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user