Files
baclight/app/controllers/employers_controller.rb
T
2026-05-06 13:28:16 -04:00

92 lines
2.6 KiB
Ruby

class EmployersController < ApplicationController
# View Methods
def index
@uninitialized = Employer.in_automation_initilization
@with_active_id_card_setup = Employer.with_active_id_card_setup
current_group_numbers = @with_active_id_card_setup.pluck(:group_number)
valid_group_numbers = ["62210","61986","42018","41283","0230643","43190","0230642","0230644","0230646","0233955","600102","0249127","0257902","0257947","600112","0260085","600114","0261611","600117","0261684","0261685","0261826","600121","0265450","600123","0267470","0268540","0268599"]
@beta_unassigned_group_numbers = valid_group_numbers - current_group_numbers
@deactivated = Employer.deactivated
end
def show
@employer = Employer.find_by(slug: params[:id])
end
def new
@employer = Employer.new
render :new
end
def create
employer_params = Employer.permitted_params(params)
@employer = Employer.new(employer_params)
if @employer.save
redirect_to employer_path(@employer.slug), notice: 'Employer Saved'
else
render :new, status: :unprocessable_entity
end
end
def edit
@employer = Employer.find_by(slug: params[:id])
render :edit
end
def update
employer_params = Employer.permitted_params(params)
@employer = Employer.find(params[:id])
if @employer.update(employer_params)
puts "sucess"
redirect_to employer_path(@employer.slug), notice: 'Employer was successfully updated.'
else
puts "fail"
render :edit, status: :unprocessable_entity
end
end
def destroy
@employer = Employer.find(params[:id])
@employer.destroy
redirect_to employers_path, notice: "#{@employer.name} was successfully deleted."
end
# API Methods
def refresh_employer_information
@employer = Employer.find(params[:id])
@employer.sync_with_vhcs
redirect_to employer_path(@employer.slug)
end
def refresh_employer_members_information
@employer = Employer.find(params[:id])
@employer.sync_members_with_vhcs
redirect_to employer_path(@employer.slug)
end
def beta_automation_simulation
BetaAutomationSimulationService.new().call
redirect_to employers_path
end
def import
word_doc = params[:employer][:import_from_word]
if word_doc.present? && word_doc.is_a?(ActionDispatch::Http::UploadedFile)
@employer = BenefitsWordDocService::WordDocProcessor.new(word_doc.tempfile).call
@employer.save
redirect_to employer_path(@employer.slug), notice: 'Employer Imported'
else
@employer = Employer.new
render :new
end
end
private
end