245 lines
7.0 KiB
C++
245 lines
7.0 KiB
C++
/*
|
|
* File: ZenvyController.cpp
|
|
* Description : Controls data flow between UI and Service Layers.
|
|
* Author: Trenser
|
|
* Created : 01-Apr-2026
|
|
*/
|
|
#include "ZenvyController.h"
|
|
|
|
/*
|
|
* Function: login
|
|
* Description: authenticates the employee based on email and password
|
|
* Parameters:
|
|
* email - email of the employee
|
|
* password - password of the employee
|
|
* Returns:
|
|
* Tuple - login status, employee type, employee designation
|
|
* login status - success or failed
|
|
* employee type - type of the employee logged in
|
|
* employee designation - designation if employee type is GENERAL.
|
|
*/
|
|
AuthenticationDTO ZenvyController::login(const std::string& email, const std::string& password)
|
|
{
|
|
return m_authenticationManagementService->login(email, password);
|
|
}
|
|
|
|
/*
|
|
* Function: logout
|
|
* Description: logs out the currently authenticated employee
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::logout()
|
|
{
|
|
m_authenticationManagementService->logout();
|
|
}
|
|
|
|
/*
|
|
* Function: changePassword
|
|
* Description: updates the password of the currently authenticated employee
|
|
* Parameters:
|
|
* password - the new password to be set for the employee
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::changePassword(const std::string& password)
|
|
{
|
|
m_authenticationManagementService->changePassword(password);
|
|
}
|
|
|
|
/*
|
|
* Function: createEmployee
|
|
* Description: creates a new employee with the given details
|
|
* Parameters:
|
|
* employeeType - type of employee to be created
|
|
* employeeDesignation - designation of the employee
|
|
* email - email address of the employee
|
|
* name - name of the employee
|
|
* phone - phone number of the employee
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone) const
|
|
{
|
|
m_employeeManagementService->createEmployee(employeeType, employeeDesignation, email, name, phone);
|
|
}
|
|
|
|
/*
|
|
* Function: deactivateEmployee
|
|
* Description: deactivates an employee based on employee ID
|
|
* Parameters:
|
|
* id - unique employee ID
|
|
* Returns:
|
|
* bool - true if deactivated successfully, false otherwise
|
|
*/
|
|
bool ZenvyController::deactivateEmployee(const std::string& id) const
|
|
{
|
|
return m_employeeManagementService->deactivateEmployee(id);
|
|
}
|
|
|
|
/*
|
|
* Function: updateProfile
|
|
* Description: updates the profile of the currently authenticated employee
|
|
* Parameters:
|
|
* name - updated name of the employee
|
|
* phone - updated phone number
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::updateProfile(const std::string& name, const std::string& phone)
|
|
{
|
|
m_employeeManagementService->updateProfile(name, phone);
|
|
}
|
|
|
|
/*
|
|
* Function: searchEmployee
|
|
* Description: searches employees based on name
|
|
* Parameters:
|
|
* name - name or partial name of the employee
|
|
* Returns:
|
|
* Pair of employee type and list of matching employees
|
|
*/
|
|
std::pair<Enums::EmployeeType, std::vector<const Employee*>> ZenvyController::searchEmployee(const std::string& name)
|
|
{
|
|
return m_employeeManagementService->searchEmployee(name);
|
|
}
|
|
|
|
/*
|
|
* Function: getCurrentEmployee
|
|
* Description: retrieves the currently authenticated employee
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* Pointer to the authenticated employee
|
|
*/
|
|
const Employee* ZenvyController::getCurrentEmployee() const
|
|
{
|
|
return m_employeeManagementService->getCurrentEmployee();
|
|
}
|
|
|
|
/*
|
|
* Function: updateDesignation
|
|
* Description: updates the designation of an employee
|
|
* Parameters:
|
|
* id - unique employee ID
|
|
* designation - new designation to be assigned
|
|
* Returns:
|
|
* bool - true if update is successful, false otherwise
|
|
*/
|
|
bool ZenvyController::updateDesignation(const std::string& id, Enums::EmployeeDesignation designation)
|
|
{
|
|
return m_employeeManagementService->updateDesignation(id, designation);
|
|
}
|
|
|
|
/*
|
|
* Function: getShorlistedCandidates
|
|
* Description: retrieves the list of shortlisted candidates
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* Vector of shortlisted candidate pointers
|
|
*/
|
|
std::vector<Candidate*> ZenvyController::getShorlistedCandidates() const
|
|
{
|
|
return m_employeeManagementService->getShorlistedCandidates();
|
|
}
|
|
|
|
/*
|
|
* Function: updateSalary
|
|
* Description: updates salary details of an employee
|
|
* Parameters:
|
|
* employeeId - unique employee ID
|
|
* basicSalary - basic salary amount
|
|
* houseRentAllowance - HRA amount
|
|
* foodAllowance - food allowance amount
|
|
* employeePFContribution - employee PF contribution
|
|
* employerPFContribution - employer PF contribution
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
|
|
{
|
|
m_payslipManagementService->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
|
|
}
|
|
|
|
/*
|
|
* Function: generatePayslips
|
|
* Description: generates payslips for all eligible employees
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::generatePayslips()
|
|
{
|
|
m_payslipManagementService->generatePayslips();
|
|
}
|
|
|
|
/*
|
|
* Function: loadStates
|
|
* Description: loads persisted application data into memory
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::loadStates()
|
|
{
|
|
m_employeeManagementService->loadEmployees();
|
|
m_payslipManagementService->loadPayrolls();
|
|
m_payslipManagementService->loadPayslips();
|
|
}
|
|
|
|
/*
|
|
* Function: persistStates
|
|
* Description: saves current application data to storage
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
void ZenvyController::persistStates()
|
|
{
|
|
m_employeeManagementService->saveEmployees();
|
|
m_payslipManagementService->savePayrolls();
|
|
m_payslipManagementService->savePayslips();
|
|
}
|
|
|
|
/*
|
|
* Function: getPayslipForMonth
|
|
* Description: retrieves payroll and payslip details for a specific month
|
|
* Parameters:
|
|
* employeeId - unique employee ID
|
|
* year - year of the payslip
|
|
* month - month of the payslip
|
|
* Returns:
|
|
* Pair of payroll and payslip pointers
|
|
*/
|
|
std::pair<Payroll*, Payslip*> ZenvyController::getPayslipForMonth(const std::string& employeeId, int year, int month)
|
|
{
|
|
return m_payslipManagementService->getPayslipForMonth(employeeId, year, month);
|
|
}
|
|
|
|
/*
|
|
* Function: ~ZenvyController
|
|
* Description: cleans up dynamically allocated service objects
|
|
* Parameters:
|
|
* None
|
|
* Returns:
|
|
* void - no return value
|
|
*/
|
|
ZenvyController::~ZenvyController()
|
|
{
|
|
delete m_authenticationManagementService;
|
|
delete m_attendanceManagementService;
|
|
delete m_bookingManagementService;
|
|
delete m_employeeManagementService;
|
|
delete m_leaveManagementService;
|
|
delete m_notificationManagementService;
|
|
delete m_payslipManagementService;
|
|
delete m_talentAcquisitionManagementService;
|
|
delete m_teamManagementService;
|
|
delete m_ticketManagementService;
|
|
} |