Class: HrLite::Admin::EmployeesController
- Inherits:
-
LeadershipController
- Object
- HrLite::ApplicationController
- BaseController
- LeadershipController
- HrLite::Admin::EmployeesController
- Defined in:
- app/controllers/hr_lite/admin/employees_controller.rb
Overview
Employee HR profiles (leadership). No destroy — exits are a date; payroll history is a statutory record.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/hr_lite/admin/employees_controller.rb', line 20 def create @profile = EmployeeProfile.new(profile_params) if @profile.save redirect_to admin_employee_path(@profile), notice: "Employee profile created." else render :new, status: :unprocessable_entity end end |
#edit ⇒ Object
29 30 31 |
# File 'app/controllers/hr_lite/admin/employees_controller.rb', line 29 def edit @profile = EmployeeProfile.find(params[:id]) end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/hr_lite/admin/employees_controller.rb', line 6 def index @profiles = paginate(EmployeeProfile.includes(:user).order(:employee_code)) @users_without_profile = HrLite.employees.reject { |u| EmployeeProfile.exists?(user_id: u.id) } end |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/hr_lite/admin/employees_controller.rb', line 16 def new @profile = EmployeeProfile.new(user_id: params[:user_id], date_of_joining: Date.current) end |
#show ⇒ Object
11 12 13 14 |
# File 'app/controllers/hr_lite/admin/employees_controller.rb', line 11 def show @profile = EmployeeProfile.includes(:user).find(params[:id]) @structures = SalaryStructure.where(user_id: @profile.user_id).order(effective_from: :desc) end |
#update ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/hr_lite/admin/employees_controller.rb', line 33 def update @profile = EmployeeProfile.find(params[:id]) if @profile.update(profile_params) redirect_to admin_employee_path(@profile), notice: "Employee profile updated." else render :edit, status: :unprocessable_entity end end |