Merged PR 975: Convert smart pointers to native pointers

This commit is contained in:
2026-04-17 12:32:00 +05:30
106 changed files with 2241 additions and 482 deletions
@@ -2,7 +2,7 @@
#include <stdexcept> #include <stdexcept>
#include "FileIO.h" #include "FileIO.h"
template <typename T> using objects = std::map<std::string, std::shared_ptr<T>>; template <typename T> using objects = std::map<std::string, T*>;
template <typename T> template <typename T>
class FileManager class FileManager
@@ -1,3 +1,10 @@
/*
* File: Trenser.Zenvy.cpp
* Description: Zenvy Main
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "UserInterface.h" #include "UserInterface.h"
#include "FileManager.h" #include "FileManager.h"
int main() int main()
@@ -1,83 +1,245 @@
/*
* File: ZenvyController.cpp
* Description : Controls data flow between UI and Service Layers.
* Author: Trenser
* Created : 01-Apr-2026
*/
#include "ZenvyController.h" #include "ZenvyController.h"
//Authentication /*
* 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) AuthenticationDTO ZenvyController::login(const std::string& email, const std::string& password)
{ {
return m_authenticationManagementService->login(email, 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() void ZenvyController::logout()
{ {
m_authenticationManagementService->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) void ZenvyController::changePassword(const std::string& password)
{ {
m_authenticationManagementService->changePassword(password); m_authenticationManagementService->changePassword(password);
} }
//Employee Management /*
void ZenvyController::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone) * 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); m_employeeManagementService->createEmployee(employeeType, employeeDesignation, email, name, phone);
} }
bool ZenvyController::deactivateEmployee(const std::string& id) /*
* 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); 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) void ZenvyController::updateProfile(const std::string& name, const std::string& phone)
{ {
m_employeeManagementService->updateProfile(name,phone); m_employeeManagementService->updateProfile(name, phone);
} }
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> ZenvyController::searchEmployee(const std::string& name) /*
* 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); return m_employeeManagementService->searchEmployee(name);
} }
std::shared_ptr<const Employee> ZenvyController::getCurrentEmployee() /*
* 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(); return m_employeeManagementService->getCurrentEmployee();
} }
bool ZenvyController::updateDesignation(const std::string& id,Enums::EmployeeDesignation designation) /*
* 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); return m_employeeManagementService->updateDesignation(id, designation);
} }
std::vector<std::shared_ptr<Candidate>> ZenvyController::getShorlistedCandidates() /*
* 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(); return m_employeeManagementService->getShorlistedCandidates();
} }
//Payslip Management /*
* 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) 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); 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() void ZenvyController::generatePayslips()
{ {
m_payslipManagementService->generatePayslips(); m_payslipManagementService->generatePayslips();
} }
/*
* Function: loadStates
* Description: loads persisted application data into memory
* Parameters:
* None
* Returns:
* void - no return value
*/
void ZenvyController::loadStates() void ZenvyController::loadStates()
{ {
m_employeeManagementService->loadEmployees(); m_employeeManagementService->loadEmployees();
m_payslipManagementService->loadPayrolls(); m_payslipManagementService->loadPayrolls();
m_payslipManagementService->loadPayslips(); m_payslipManagementService->loadPayslips();
} }
/*
* Function: persistStates
* Description: saves current application data to storage
* Parameters:
* None
* Returns:
* void - no return value
*/
void ZenvyController::persistStates() void ZenvyController::persistStates()
{ {
m_employeeManagementService->saveEmployees(); m_employeeManagementService->saveEmployees();
m_payslipManagementService->savePayrolls(); m_payslipManagementService->savePayrolls();
m_payslipManagementService->savePayslips(); m_payslipManagementService->savePayslips();
} }
std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>> ZenvyController::getPayslipForMonth(const std::string& employeeId, int year, int month) /*
* 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); 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;
} }
@@ -1,5 +1,11 @@
/*
* File: ZenvyController.h
* Description : Controls data flow between UI and Service Layers.
* Author: Trenser
* Created : 01-Apr-2026
*/
#pragma once #pragma once
#include <memory>
#include <utility> #include <utility>
#include "AuthenticationManagementService.h" #include "AuthenticationManagementService.h"
#include "AttendanceManagementService.h" #include "AttendanceManagementService.h"
@@ -16,55 +22,56 @@
class ZenvyController class ZenvyController
{ {
private: private:
std::shared_ptr<AuthenticationManagementService> m_authenticationManagementService; AuthenticationManagementService* m_authenticationManagementService;
std::shared_ptr<AttendanceManagementService> m_attendanceManagementService; AttendanceManagementService* m_attendanceManagementService;
std::shared_ptr<BookingManagementService> m_bookingManagementService; BookingManagementService* m_bookingManagementService;
std::shared_ptr<EmployeeManagementService> m_employeeManagementService; EmployeeManagementService* m_employeeManagementService;
std::shared_ptr<LeaveManagementService> m_leaveManagementService; LeaveManagementService* m_leaveManagementService;
std::shared_ptr<NotificationManagementService> m_notificationManagementService; NotificationManagementService* m_notificationManagementService;
std::shared_ptr<PayslipManagementService> m_payslipManagementService; PayslipManagementService* m_payslipManagementService;
std::shared_ptr<TalentAcquisitionManagementService> m_talentAcquisitionManagementService; TalentAcquisitionManagementService* m_talentAcquisitionManagementService;
std::shared_ptr<TeamManagementService> m_teamManagementService; TeamManagementService* m_teamManagementService;
std::shared_ptr<TicketManagementService> m_ticketManagementService; TicketManagementService* m_ticketManagementService;
public: public:
ZenvyController() : ZenvyController() :
m_authenticationManagementService(std::make_shared<AuthenticationManagementService>()), m_authenticationManagementService(new AuthenticationManagementService()),
m_attendanceManagementService(std::make_shared<AttendanceManagementService>()), m_attendanceManagementService(new AttendanceManagementService()),
m_bookingManagementService(std::make_shared<BookingManagementService>()), m_bookingManagementService(new BookingManagementService()),
m_employeeManagementService(std::make_shared<EmployeeManagementService>()), m_employeeManagementService(new EmployeeManagementService()),
m_leaveManagementService(std::make_shared<LeaveManagementService>()), m_leaveManagementService(new LeaveManagementService()),
m_notificationManagementService(std::make_shared<NotificationManagementService>()), m_notificationManagementService(new NotificationManagementService()),
m_payslipManagementService(std::make_shared<PayslipManagementService>()), m_payslipManagementService(new PayslipManagementService()),
m_talentAcquisitionManagementService(std::make_shared<TalentAcquisitionManagementService>()), m_talentAcquisitionManagementService(new TalentAcquisitionManagementService()),
m_teamManagementService(std::make_shared<TeamManagementService>()), m_teamManagementService(new TeamManagementService()),
m_ticketManagementService(std::make_shared<TicketManagementService>()) {}; m_ticketManagementService(new TicketManagementService()) {};
~ZenvyController();
//Authentication //Authentication
AuthenticationDTO login(const std::string& email, const std::string& password); AuthenticationDTO login(const std::string& email, const std::string& password);
void logout(); void logout();
void changePassword(const std::string&); void changePassword(const std::string&);
//Employee Management //Employee Management
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&); void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&) const;
bool deactivateEmployee(const std::string&); bool deactivateEmployee(const std::string&) const;
std::shared_ptr<const Employee> getCurrentEmployee(); const Employee* getCurrentEmployee() const;
void updateProfile(const std::string&,const std::string&); void updateProfile(const std::string&, const std::string&);
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&); std::pair<Enums::EmployeeType, std::vector<const Employee*>> searchEmployee(const std::string&);
bool updateDesignation(const std::string&,Enums::EmployeeDesignation); bool updateDesignation(const std::string&, Enums::EmployeeDesignation);
std::vector<std::shared_ptr<Candidate>> getShorlistedCandidates(); std::vector<Candidate*> getShorlistedCandidates() const;
template <typename ...Types> template <typename ...Types>
Employees getEmployees(Types ...types) Employees getEmployees(Types ...types) const
{ {
return m_employeeManagementService->getEmployees(types...); return m_employeeManagementService->getEmployees(types...);
} }
//Payslip management //Payslip management
void updateSalary(const std::string&, double, double, double, double, double); void updateSalary(const std::string&, double, double, double, double, double);
void generatePayslips(); void generatePayslips();
std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>>getPayslipForMonth(const std::string&, int, int); std::pair<Payroll*, Payslip*>getPayslipForMonth(const std::string&, int, int);
//File Management //File Management
void loadStates(); void loadStates();
void persistStates(); void persistStates();
}; };
@@ -1,43 +1,152 @@
/*
* File: DataStore.cpp
* Description: Central Storage for all the System Data.
* Author: Trenser
* Created: 01-Apr-2026
*/
#include "DataStore.h" #include "DataStore.h"
#include "EmployeeManagementService.h" #include "EmployeeManagementService.h"
/*
* Function: getInstance
* Description: provides a singleton instance of the DataStore.
* Parameters:
* None
* Returns:
* DataStore& - reference to the single DataStore object.
*/
DataStore& DataStore::getInstance() DataStore& DataStore::getInstance()
{ {
static DataStore dataStore; static DataStore dataStore;
return dataStore; return dataStore;
} }
/*
* Function: getLogs
* Description: retrieves the log map containing system logs.
* Parameters:
* None
* Returns:
* logMap& - reference to the log map.
*/
logMap& DataStore::getLogs() logMap& DataStore::getLogs()
{ {
return m_logs; return m_logs;
} }
candidateMap& DataStore::getCandidates() /*
* Function: getAuthenticatedEmployee
* Description: retrieves the currently authenticated employee.
* Parameters:
* None
* Returns:
* Employee*& - reference to the authenticated employee pointer.
*/
Employee*& DataStore::getAuthenticatedEmployee()
{ {
return m_candidates; return m_authenticatedEmployee;
} }
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee() /*
* Function: setAuthenticatedEmployee
* Description: sets the currently authenticated employee.
* Parameters:
* authenticatedEmployee - pointer to the employee to be set as authenticated.
* Returns:
* void - no return value.
*/
void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee)
{ {
return m_authenticatedEmployee; m_authenticatedEmployee = authenticatedEmployee;
}
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee)
{
m_authenticatedEmployee = authenticatedEmployee;
} }
/*
* Function: getEmployees
* Description: retrieves the map containing all employees.
* Parameters:
* None
* Returns:
* employeeMap& - reference to the employee map.
*/
employeeMap& DataStore::getEmployees() employeeMap& DataStore::getEmployees()
{ {
return m_employees; return m_employees;
} }
/*
* Function: getPayrolls
* Description: retrieves the map containing all payroll records.
* Parameters:
* None
* Returns:
* payrollMap& - reference to the payroll map.
*/
payrollMap& DataStore::getPayrolls() payrollMap& DataStore::getPayrolls()
{ {
return m_payrolls; return m_payrolls;
} }
/*
* Function: getPayslips
* Description: retrieves the map containing all payslip records.
* Parameters:
* None
* Returns:
* payslipMap& - reference to the payslip map.
*/
payslipMap& DataStore::getPayslips() payslipMap& DataStore::getPayslips()
{ {
return m_payslips; return m_payslips;
}
/*
* Function: getCandidates
* Description: retrieves the map containing all shortlisted candidates.
* Parameters:
* None
* Returns:
* candidateMap& - reference to the candidate map.
*/
candidateMap& DataStore::getCandidates()
{
return m_candidates;
}
/*
* Function: ~DataStore
* Description: releases all dynamically allocated objects stored in the DataStore.
* Parameters:
* None
* Returns:
* void - no return value.
*/
DataStore::~DataStore()
{
for (auto& pair : m_employees)
{
delete pair.second;
}
m_employees.clear();
for (auto& pair : m_payrolls)
{
delete pair.second;
}
m_payrolls.clear();
for (auto& pair : m_payslips)
{
delete pair.second;
}
m_payslips.clear();
for (auto& pair : m_logs)
{
delete pair.second;
}
m_logs.clear();
for (auto& pair : m_candidates)
{
delete pair.second;
}
m_candidates.clear();
m_authenticatedEmployee = nullptr;
} }
@@ -1,5 +1,11 @@
/*
* File: DataStore.h
* Description: Central Storage for all the System Data.
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once #pragma once
#include <memory>
#include <map> #include <map>
#include "Employee.h" #include "Employee.h"
#include "Log.h" #include "Log.h"
@@ -21,33 +27,34 @@
#include "Payroll.h" #include "Payroll.h"
#include "Payslip.h" #include "Payslip.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>; using employeeMap = std::map<std::string, Employee*>;
using payrollMap = std::map<std::string, std::shared_ptr<Payroll>>; using payrollMap = std::map<std::string, Payroll*>;
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>; using payslipMap = std::map<std::string, Payslip*>;
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>; using logMap = std::map<util::Timestamp, Log*>;
using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>; using candidateMap = std::map<std::string, Candidate*>;
class DataStore class DataStore
{ {
private: private:
std::shared_ptr<Employee> m_authenticatedEmployee; Employee* m_authenticatedEmployee;
employeeMap m_employees; employeeMap m_employees;
payrollMap m_payrolls; payrollMap m_payrolls;
payslipMap m_payslips; payslipMap m_payslips;
logMap m_logs; logMap m_logs;
candidateMap m_candidates; candidateMap m_candidates;
DataStore() = default; DataStore() : m_authenticatedEmployee(nullptr) {};
public: public:
static DataStore& getInstance(); static DataStore& getInstance();
DataStore(const DataStore&) = delete; DataStore(const DataStore&) = delete;
DataStore& operator=(const DataStore&) = delete; DataStore& operator=(const DataStore&) = delete;
DataStore(DataStore&&) = delete; DataStore(DataStore&&) = delete;
DataStore& operator=(DataStore&&) = delete; DataStore& operator=(DataStore&&) = delete;
employeeMap& getEmployees(); employeeMap& getEmployees();
payrollMap& getPayrolls(); payrollMap& getPayrolls();
payslipMap& getPayslips(); payslipMap& getPayslips();
logMap& getLogs(); logMap& getLogs();
candidateMap& getCandidates(); candidateMap& getCandidates();
std::shared_ptr<Employee>& getAuthenticatedEmployee(); Employee*& getAuthenticatedEmployee();
void setAuthenticatedEmployee(std::shared_ptr < Employee>); void setAuthenticatedEmployee(Employee*);
~DataStore();
}; };
@@ -1,13 +1,29 @@
/*
* File: Factory.h
* Description: Provides a generic factory utility to create objects.
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once #pragma once
#include <memory>
#include <utility> #include <utility>
class Factory class Factory
{ {
public: public:
template<typename T, typename... Args>
static std::shared_ptr<T> getObject(Args&&... args) /*
{ * Function: getObject
return std::make_shared<T>(std::forward<Args>(args)...); * Description: Creates and returns a dynamically allocated object of type T.
} * Parameters:
* T - the type of object to be created
* Args - constructor arguments forwarded to T's constructor
* Returns:
* T* - pointer to the newly created object
*/
template<typename T, typename... Args>
static T* getObject(Args&&... args)
{
return new T(std::forward<Args>(args)...);
}
}; };
@@ -1 +1,7 @@
/*
* File: Admin.cpp
* Description: Admin model class
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Admin.h" #include "Admin.h"
+7 -1
View File
@@ -1,3 +1,9 @@
/*
* File: Admin.h
* Description: Admin model class
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -9,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::ADMIN, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::ADMIN, payroll) {};
Admin(const std::string& id, Admin(const std::string& id,
const std::string& name, const std::string& name,
@@ -1,3 +1,9 @@
/*
* File: Announcement.cpp
* Description: The Announcement class defines a simple object for managing announcement details.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Announcement.h" #include "Announcement.h"
int Announcement::m_uid = 0; int Announcement::m_uid = 0;
@@ -1,3 +1,9 @@
/*
* File: Announcement.h
* Description: The Announcement class defines a simple object for managing announcement details.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Timestamp.h" #include "Timestamp.h"
@@ -1,3 +1,9 @@
/*
* File: Attendance.cpp
* Description: The Attendance class represents an attendance record by storing an ID, login and logout timestamps.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Attendance.h" #include "Attendance.h"
int Attendance::m_uid = 0; int Attendance::m_uid = 0;
@@ -1,3 +1,9 @@
/*
* File: Attendance.h
* Description: The Attendance class represents an attendance record by storing an ID, login and logout timestamps.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Timestamp.h" #include "Timestamp.h"
@@ -1,3 +1,9 @@
/*
* File: Booking.cpp
* Description: The Booking class represents a timebased booking with employee and team details and supports duration calculation.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Booking.h" #include "Booking.h"
int Booking::m_uid = 0; int Booking::m_uid = 0;
@@ -22,7 +28,7 @@ const std::string& Booking::getEmployeeId() const
return m_employeeId; return m_employeeId;
} }
std::shared_ptr<Team> Booking::getTeam() const Team* Booking::getTeam() const
{ {
return m_team; return m_team;
} }
@@ -47,7 +53,7 @@ void Booking::setEmployeeId(const std::string& employeeId)
m_employeeId = employeeId; m_employeeId = employeeId;
} }
void Booking::setTeam(std::shared_ptr<Team> team) void Booking::setTeam(Team* team)
{ {
m_team = team; m_team = team;
} }
+10 -5
View File
@@ -1,6 +1,11 @@
/*
* File: Booking.h
* Description: The Booking class represents a time?based booking with employee and team details and supports duration calculation.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
#include "Team.h" #include "Team.h"
#include "Timestamp.h" #include "Timestamp.h"
@@ -12,24 +17,24 @@ private:
util::Timestamp m_startTime; util::Timestamp m_startTime;
util::Timestamp m_endTime; util::Timestamp m_endTime;
std::string m_employeeId; std::string m_employeeId;
std::shared_ptr<Team> m_team; Team* m_team;
public: public:
Booking() : m_id("BK" + std::to_string(++m_uid)), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {} Booking() : m_id("BK" + std::to_string(++m_uid)), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {}
Booking(const util::Timestamp& startTime, Booking(const util::Timestamp& startTime,
const util::Timestamp& endTime, const util::Timestamp& endTime,
const std::string& employeeId, const std::string& employeeId,
std::shared_ptr<Team> team) Team* team)
: m_id("BK" + std::to_string(++m_uid)), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {} : m_id("BK" + std::to_string(++m_uid)), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
const std::string& getBookingId() const; const std::string& getBookingId() const;
const util::Timestamp& getStartTime() const; const util::Timestamp& getStartTime() const;
const util::Timestamp& getEndTime() const; const util::Timestamp& getEndTime() const;
const std::string& getEmployeeId() const; const std::string& getEmployeeId() const;
std::shared_ptr<Team> getTeam() const; Team* getTeam() const;
void setBookingId(const std::string& id); void setBookingId(const std::string& id);
void setStartTime(const util::Timestamp& startTime); void setStartTime(const util::Timestamp& startTime);
void setEndTime(const util::Timestamp& endTime); void setEndTime(const util::Timestamp& endTime);
void setEmployeeId(const std::string& employeeId); void setEmployeeId(const std::string& employeeId);
void setTeam(std::shared_ptr<Team> team); void setTeam(Team* team);
double getDurationInHours() const; double getDurationInHours() const;
double getDurationInMinutes() const; double getDurationInMinutes() const;
}; };
@@ -1,3 +1,9 @@
/*
* File: Candidate.cpp
* Description: The Candidate class stores and manages a candidates information.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Candidate.h" #include "Candidate.h"
int Candidate::m_uid = 0; int Candidate::m_uid = 0;
@@ -1,3 +1,9 @@
/*
* File: Candidate.h
* Description: The Candidate class stores and manages a candidates information.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
+62 -16
View File
@@ -1,3 +1,9 @@
/*
* File: Employee.cpp
* Description: The Employee class manages employee information and associated work records such as payroll, attendance, leaves, and payslips.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include <sstream> #include <sstream>
#include "Employee.h" #include "Employee.h"
#include "Factory.h" #include "Factory.h"
@@ -79,7 +85,7 @@ const std::string& Employee::getEmployeeTeamId() const
return m_teamId; return m_teamId;
} }
std::shared_ptr<Payroll> Employee::getPayroll() const Payroll* Employee::getPayroll() const
{ {
return m_payroll; return m_payroll;
} }
@@ -99,6 +105,16 @@ const leaveMap& Employee::getEmployeeLeaves() const
return m_leaves; return m_leaves;
} }
Enums::EmployeeType Employee::getEmployeeType() const
{
return m_employeeType;
}
std::string Employee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
}
void Employee::setEmployeeId(const std::string& id) void Employee::setEmployeeId(const std::string& id)
{ {
m_id = id; m_id = id;
@@ -134,12 +150,20 @@ void Employee::setEmployeeTeamId(const std::string& teamId)
m_teamId = teamId; m_teamId = teamId;
} }
void Employee::setEmployeePayroll(std::shared_ptr<Payroll> payroll) void Employee::setEmployeePayroll(Payroll* payroll)
{ {
m_payroll = payroll; m_payroll = payroll;
} }
void Employee::addPayslip(std::shared_ptr<Payslip> payslip) /*
* Function: addPayslip
* Description : Adds a payslip to the employee's payslip records
* Parameters :
payslip - Pointer to the Payslip object to be added
* Returns :
void
*/
void Employee::addPayslip(Payslip* payslip)
{ {
if (payslip) if (payslip)
{ {
@@ -147,7 +171,15 @@ void Employee::addPayslip(std::shared_ptr<Payslip> payslip)
} }
} }
void Employee::addAttendance(std::shared_ptr<Attendance> attendance) /*
* Function: addAttendance
* Description: Adds an attendance record to the employee's attendance history
* Parameters:
* attendance - Pointer to the Attendance object containing login information
* Returns:
* void
*/
void Employee::addAttendance(Attendance* attendance)
{ {
if (attendance) if (attendance)
{ {
@@ -155,7 +187,15 @@ void Employee::addAttendance(std::shared_ptr<Attendance> attendance)
} }
} }
void Employee::addLeave(std::shared_ptr<Leave> leave) /*
* Function: addLeave
* Description: Adds a leave record to the employee's leave history
* Parameters:
* leave - Pointer to the Leave object to be added
* Returns:
* void
*/
void Employee::addLeave(Leave* leave)
{ {
if (leave) if (leave)
{ {
@@ -163,11 +203,14 @@ void Employee::addLeave(std::shared_ptr<Leave> leave)
} }
} }
Enums::EmployeeType Employee::getEmployeeType() const /*
{ * Function: serialize
return m_employeeType; * Description: Serializes the employee object's core details into a comma-separated string
} * Parameters:
None
* Returns:
A string containing serialized employee data in CSV format
*/
std::string Employee::serialize() const std::string Employee::serialize() const
{ {
std::ostringstream serializedEmployee; std::ostringstream serializedEmployee;
@@ -183,7 +226,15 @@ std::string Employee::serialize() const
return serializedEmployee.str(); return serializedEmployee.str();
} }
std::shared_ptr<Employee> Employee::deserialize(const std::string& record) /*
* Function: deserialize
* Description: Creates and returns an Employee object from a serialized comma-separated record string
* Parameters:
record - A string containing serialized employee data in CSV format
* Returns:
Pointer to a newly created Employee object based on the employee type
*/
Employee* Employee::deserialize(const std::string& record)
{ {
std::string id, name, phone, password, email; std::string id, name, phone, password, email;
std::string teamId, teamStatusString, accountStatusString, employeeTypeString; std::string teamId, teamStatusString, accountStatusString, employeeTypeString;
@@ -274,8 +325,3 @@ std::shared_ptr<Employee> Employee::deserialize(const std::string& record)
return nullptr; return nullptr;
} }
} }
std::string Employee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
}
+18 -12
View File
@@ -1,6 +1,11 @@
/*
* File: Employee.h
* Description: The Employee class manages employee information and associated work records such as payroll, attendance, leaves, and payslips.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
#include <map> #include <map>
#include "Payslip.h" #include "Payslip.h"
#include "Attendance.h" #include "Attendance.h"
@@ -8,9 +13,9 @@
#include "Payroll.h" #include "Payroll.h"
#include "Enums.h" #include "Enums.h"
#include "ApplicationConfig.h" #include "ApplicationConfig.h"
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>; using payslipMap = std::map<std::string, Payslip*>;
using attendanceMap = std::map<int, std::map<std::string, std::shared_ptr<Attendance>>>; using attendanceMap = std::map<int, std::map<std::string, Attendance*>>;
using leaveMap = std::map<std::string, std::shared_ptr<Leave>>; using leaveMap = std::map<std::string, Leave*>;
class Employee class Employee
{ {
@@ -24,7 +29,7 @@ protected:
Enums::AccountStatus m_accountStatus; Enums::AccountStatus m_accountStatus;
Enums::TeamStatus m_teamStatus; Enums::TeamStatus m_teamStatus;
std::string m_teamId; std::string m_teamId;
std::shared_ptr<Payroll> m_payroll; Payroll* m_payroll;
payslipMap m_payslips; payslipMap m_payslips;
attendanceMap m_attendances; attendanceMap m_attendances;
leaveMap m_leaves; leaveMap m_leaves;
@@ -39,12 +44,13 @@ public:
m_accountStatus(Enums::AccountStatus::ACTIVE), m_accountStatus(Enums::AccountStatus::ACTIVE),
m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM),
m_teamId(""), m_teamId(""),
m_payroll(nullptr),
m_employeeType(Enums::EmployeeType::GENERAL) {} m_employeeType(Enums::EmployeeType::GENERAL) {}
Employee(const std::string& name, Employee(const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
Enums::EmployeeType employeeType, Enums::EmployeeType employeeType,
std::shared_ptr<Payroll> payroll) Payroll* payroll)
: m_id("EMP" + std::to_string(++m_uid)), : m_id("EMP" + std::to_string(++m_uid)),
m_password(Config::Authentication::DEFAULT_PASSWORD), m_password(Config::Authentication::DEFAULT_PASSWORD),
m_name(name), m_name(name),
@@ -72,7 +78,7 @@ public:
Enums::AccountStatus getEmployeeAccountStatus() const; Enums::AccountStatus getEmployeeAccountStatus() const;
Enums::TeamStatus getEmployeeTeamStatus() const; Enums::TeamStatus getEmployeeTeamStatus() const;
const std::string& getEmployeeTeamId() const; const std::string& getEmployeeTeamId() const;
std::shared_ptr<Payroll> getPayroll() const; Payroll* getPayroll() const;
const payslipMap& getEmployeePayslips() const; const payslipMap& getEmployeePayslips() const;
const attendanceMap& getEmployeeAttendances() const; const attendanceMap& getEmployeeAttendances() const;
const leaveMap& getEmployeeLeaves() const; const leaveMap& getEmployeeLeaves() const;
@@ -83,13 +89,13 @@ public:
void setEmployeeAccountStatus(Enums::AccountStatus status); void setEmployeeAccountStatus(Enums::AccountStatus status);
void setEmployeeTeamStatus(Enums::TeamStatus status); void setEmployeeTeamStatus(Enums::TeamStatus status);
void setEmployeeTeamId(const std::string& teamId); void setEmployeeTeamId(const std::string& teamId);
void setEmployeePayroll(std::shared_ptr<Payroll> payroll); void setEmployeePayroll(Payroll* payroll);
void addPayslip(std::shared_ptr<Payslip> payslip); void addPayslip(Payslip* payslip);
void addAttendance(std::shared_ptr<Attendance> attendance); void addAttendance(Attendance* attendance);
void addLeave(std::shared_ptr<Leave> leave); void addLeave(Leave* leave);
Enums::EmployeeType getEmployeeType() const; Enums::EmployeeType getEmployeeType() const;
virtual std::string serialize() const; virtual std::string serialize() const;
static std::shared_ptr<Employee> deserialize(const std::string&); static Employee* deserialize(const std::string&);
static std::string getHeaders(); static std::string getHeaders();
virtual ~Employee() = default; virtual ~Employee() = default;
}; };
@@ -1 +1,7 @@
/*
* File: Faq.h
* Description: Faq model class.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include "Faq.h" #include "Faq.h"
+6 -1
View File
@@ -1,6 +1,11 @@
/*
* File: Faq.h
* Description: Faq model class.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
class Faq class Faq
{ {
}; };
@@ -1 +1,7 @@
/*
* File: FinanceExecutive.h
* Description: FinanceExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "FinanceExecutive.h" #include "FinanceExecutive.h"
@@ -1,3 +1,9 @@
/*
* File: FinanceExecutive.h
* Description: FinanceExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -9,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::FINANCE, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::FINANCE, payroll) {};
FinanceExecutive(const std::string& id, FinanceExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -30,4 +36,3 @@ public:
accountStatus) {} accountStatus) {}
~FinanceExecutive() = default; ~FinanceExecutive() = default;
}; };
@@ -1,3 +1,9 @@
/*
* File: GeneralEmployee.h
* Description: The GeneralEmployee class represents a general employee with a specific designation.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include <sstream> #include <sstream>
#include "GeneralEmployee.h" #include "GeneralEmployee.h"
#include "Factory.h" #include "Factory.h"
@@ -7,11 +13,24 @@ Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
return m_designation; return m_designation;
} }
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
}
void GeneralEmployee::setDesignation(Enums::EmployeeDesignation designation) void GeneralEmployee::setDesignation(Enums::EmployeeDesignation designation)
{ {
m_designation = designation; m_designation = designation;
} }
/*
* Function: serialize
* Description: Serializes the general employee's details, including designation, into a comma-separated string
* Parameters:
None
* Returns:
A string containing serialized general employee data in CSV format
*/
std::string GeneralEmployee::serialize() const std::string GeneralEmployee::serialize() const
{ {
std::ostringstream serializedEmployee; std::ostringstream serializedEmployee;
@@ -28,7 +47,15 @@ std::string GeneralEmployee::serialize() const
return serializedEmployee.str(); return serializedEmployee.str();
} }
std::shared_ptr<GeneralEmployee> GeneralEmployee::deserialize(const std::string& record) /*
* Function: deserialize
* Description: Creates and returns a GeneralEmployee object from a serialized comma-separated record string
* Parameters:
record - A string containing serialized general employee data in CSV format
* Returns:
Pointer to a newly created GeneralEmployee object
*/
GeneralEmployee* GeneralEmployee::deserialize(const std::string& record)
{ {
std::string id, name, phone, password, email; std::string id, name, phone, password, email;
std::string teamId, teamStatusString, accountStatusString, employeeTypeString, employeeDesignationString; std::string teamId, teamStatusString, accountStatusString, employeeTypeString, employeeDesignationString;
@@ -59,8 +86,3 @@ std::shared_ptr<GeneralEmployee> GeneralEmployee::deserialize(const std::string&
accountStatus accountStatus
); );
} }
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
}
@@ -1,3 +1,9 @@
/*
* File: GeneralEmployee.h
* Description: The GeneralEmployee class represents a general employee with a specific designation.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
#include "Enums.h" #include "Enums.h"
@@ -12,7 +18,7 @@ public:
GeneralEmployee(const std::string& name, GeneralEmployee(const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll, Payroll* payroll,
Enums::EmployeeDesignation designation) Enums::EmployeeDesignation designation)
: Employee(name, : Employee(name,
phone, phone,
@@ -42,7 +48,7 @@ public:
Enums::EmployeeDesignation getDesignation() const; Enums::EmployeeDesignation getDesignation() const;
void setDesignation(Enums::EmployeeDesignation designation); void setDesignation(Enums::EmployeeDesignation designation);
std::string serialize() const override; std::string serialize() const override;
static std::shared_ptr<GeneralEmployee> deserialize(const std::string&); static GeneralEmployee* deserialize(const std::string&);
static std::string getHeaders(); static std::string getHeaders();
~GeneralEmployee() = default; ~GeneralEmployee() = default;
}; };
@@ -1 +1,7 @@
/*
* File: HRManager.cpp
* Description: HRManager model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "HRManager.h" #include "HRManager.h"
@@ -1,3 +1,9 @@
/*
* File: HRManager.h
* Description: HRManager model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -9,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::HR, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::HR, payroll) {};
HRManager(const std::string& id, HRManager(const std::string& id,
const std::string& name, const std::string& name,
@@ -30,4 +36,3 @@ public:
accountStatus) {} accountStatus) {}
~HRManager() = default; ~HRManager() = default;
}; };
@@ -1 +1,7 @@
/*
* File: ITExecutive.cpp
* Description: ITExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "ITExecutive.h" #include "ITExecutive.h"
@@ -1,3 +1,9 @@
/*
* File: ITExecutive.h
* Description: ITExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -9,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::IT, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::IT, payroll) {};
ITExecutive(const std::string& id, ITExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -30,4 +36,3 @@ public:
accountStatus) {} accountStatus) {}
~ITExecutive() = default; ~ITExecutive() = default;
}; };
@@ -1,3 +1,9 @@
/*
File: JobListing.cpp
* Description : Represents a job opening along with its details and applied candidates.
* Author : Trenser
* Created : 01-Apr-2026
*/
#include "JobListing.h" #include "JobListing.h"
int JobListing::m_uid = 0; int JobListing::m_uid = 0;
@@ -1,10 +1,15 @@
/*
File: JobListing.h
* Description : Represents a job opening along with its details and applied candidates.
* Author : Trenser
* Created : 01-Apr-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
#include <memory>
#include "Candidate.h" #include "Candidate.h"
#include "Enums.h" #include "Enums.h"
using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>; using candidateMap = std::map<std::string, Candidate*>;
class JobListing class JobListing
{ {
+6 -36
View File
@@ -1,3 +1,9 @@
/*
File: Leave.cpp
* Description : Stores information related to an employees leave application.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Leave.h" #include "Leave.h"
int Leave::m_uid = 0; int Leave::m_uid = 0;
@@ -22,21 +28,6 @@ const std::string& Leave::getLeaveReason() const
return m_reason; return m_reason;
} }
int Leave::getNumberOfGeneralLeave()
{
return m_numberOfGeneralLeave;
}
int Leave::getNumberOfRestrictedLeave()
{
return m_numberOfRestrictedLeave;
}
int Leave::getNumberOfMedicalLeave()
{
return m_numberOfMedicalLeave;
}
Enums::LeaveType Leave::getLeaveType() const Enums::LeaveType Leave::getLeaveType() const
{ {
return m_leaveType; return m_leaveType;
@@ -62,28 +53,7 @@ void Leave::setLeaveReason(const std::string& reason)
m_reason = reason; m_reason = reason;
} }
void Leave::setNumberOfGeneralLeave(int value)
{
m_numberOfGeneralLeave = value;
}
void Leave::setNumberOfRestrictedLeave(int value)
{
m_numberOfRestrictedLeave = value;
}
void Leave::setNumberOfMedicalLeave(int value)
{
m_numberOfMedicalLeave = value;
}
void Leave::setLeaveType(Enums::LeaveType type) void Leave::setLeaveType(Enums::LeaveType type)
{ {
m_leaveType = type; m_leaveType = type;
} }
int Leave::m_numberOfGeneralLeave = 12;
int Leave::m_numberOfRestrictedLeave = 2;
int Leave::m_numberOfMedicalLeave = 6;
+6 -9
View File
@@ -1,3 +1,9 @@
/*
File: Leave.h
* Description : Stores information related to an employees leave application.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
@@ -11,9 +17,6 @@ private:
std::string m_employeeId; std::string m_employeeId;
util::Timestamp m_timestamp; util::Timestamp m_timestamp;
std::string m_reason; std::string m_reason;
static int m_numberOfGeneralLeave;
static int m_numberOfRestrictedLeave;
static int m_numberOfMedicalLeave;
Enums::LeaveType m_leaveType; Enums::LeaveType m_leaveType;
public: public:
Leave() : m_id("LV" + std::to_string(++m_uid)), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {} Leave() : m_id("LV" + std::to_string(++m_uid)), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
@@ -26,16 +29,10 @@ public:
const std::string& getEmployeeId() const; const std::string& getEmployeeId() const;
const util::Timestamp& getTimestamp() const; const util::Timestamp& getTimestamp() const;
const std::string& getLeaveReason() const; const std::string& getLeaveReason() const;
static int getNumberOfGeneralLeave();
static int getNumberOfRestrictedLeave();
static int getNumberOfMedicalLeave();
Enums::LeaveType getLeaveType() const; Enums::LeaveType getLeaveType() const;
void setLeaveId(const std::string& id); void setLeaveId(const std::string& id);
void setEmployeeId(const std::string& employeeId); void setEmployeeId(const std::string& employeeId);
void setTimestamp(const util::Timestamp& timestamp); void setTimestamp(const util::Timestamp& timestamp);
void setLeaveReason(const std::string& reason); void setLeaveReason(const std::string& reason);
void setNumberOfGeneralLeave(int value);
void setNumberOfRestrictedLeave(int value);
void setNumberOfMedicalLeave(int value);
void setLeaveType(Enums::LeaveType type); void setLeaveType(Enums::LeaveType type);
}; };
@@ -1,3 +1,9 @@
/*
File: Log.cpp
* Description : Represents a log entry containing a timestamp and an associated message.
* Author : Trenser
* Created : 01-Apr-2026
*/
#include "Log.h" #include "Log.h"
const util::Timestamp& Log::getTimestamp() const const util::Timestamp& Log::getTimestamp() const
+6
View File
@@ -1,3 +1,9 @@
/*
File: Log.h
* Description : Represents a log entry containing a timestamp and an associated message.
* Author : Trenser
* Created : 01-Apr-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Timestamp.h" #include "Timestamp.h"
@@ -1,3 +1,9 @@
/*
File: Notification.cpp
* Description : Represents an employee notification with message and status details.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Notification.h" #include "Notification.h"
int Notification::m_uid = 0; int Notification::m_uid = 0;
@@ -1,3 +1,9 @@
/*
File: Notification.h
* Description : Represents an employee notification with message and status details.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
+28 -7
View File
@@ -1,5 +1,10 @@
/*
File: Payroll.cpp
* Description : Stores payroll and salary breakdown details for an employee.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include <sstream> #include <sstream>
#include <stdexcept>
#include "Payroll.h" #include "Payroll.h"
#include "StringHelper.h" #include "StringHelper.h"
#include "Factory.h" #include "Factory.h"
@@ -68,6 +73,11 @@ double Payroll::getEmployerPFContribution() const
return m_employerPFContribution; return m_employerPFContribution;
} }
std::string Payroll::getHeaders()
{
return "PayrollId,EmployeeId,BasicSalary,HouseRentAllowance,FoodAllowance,EmployeePFContribution,EmployerPFContribution";
}
void Payroll::setBasicSalary(double basicSalary) void Payroll::setBasicSalary(double basicSalary)
{ {
m_basicSalary = basicSalary; m_basicSalary = basicSalary;
@@ -93,6 +103,14 @@ void Payroll::setEmployerPFContribution(double value)
m_employerPFContribution = value; m_employerPFContribution = value;
} }
/*
Function: serialize
Description: Converts the payroll object into a comma-separated string.
Parameters:
None
Returns:
A serialized string representation of the payroll.
*/
std::string Payroll::serialize() const std::string Payroll::serialize() const
{ {
std::ostringstream serializedPayroll; std::ostringstream serializedPayroll;
@@ -106,7 +124,15 @@ std::string Payroll::serialize() const
return serializedPayroll.str(); return serializedPayroll.str();
} }
std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record) /*
Function: deserialize
Description: Creates a Payroll object from a serialized comma-separated string.
Parameters:
record - Serialized payroll data.
Returns:
Pointer to a Payroll object.
*/
Payroll* Payroll::deserialize(const std::string& record)
{ {
std::string id, employeeId; std::string id, employeeId;
std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString; std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString;
@@ -140,8 +166,3 @@ std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
throw std::runtime_error("Failed to deserialize Payroll object"); throw std::runtime_error("Failed to deserialize Payroll object");
} }
} }
std::string Payroll::getHeaders()
{
return "PayrollId,EmployeeId,BasicSalary,HouseRentAllowance,FoodAllowance,EmployeePFContribution,EmployerPFContribution";
}
+8 -3
View File
@@ -1,6 +1,11 @@
/*
File: Payroll.h
* Description : Stores payroll and salary breakdown details for an employee.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
#include "Timestamp.h" #include "Timestamp.h"
class Payroll class Payroll
@@ -49,12 +54,12 @@ public:
double getFoodAllowance() const; double getFoodAllowance() const;
double getEmployeePFContribution() const; double getEmployeePFContribution() const;
double getEmployerPFContribution() const; double getEmployerPFContribution() const;
static std::string getHeaders();
void setBasicSalary(double); void setBasicSalary(double);
void setHouseRentAllowance(double); void setHouseRentAllowance(double);
void setFoodAllowance(double); void setFoodAllowance(double);
void setEmployeePFContribution(double); void setEmployeePFContribution(double);
void setEmployerPFContribution(double); void setEmployerPFContribution(double);
std::string serialize() const; std::string serialize() const;
static std::shared_ptr<Payroll> deserialize(const std::string&); static Payroll* deserialize(const std::string&);
static std::string getHeaders();
}; };
+28 -6
View File
@@ -1,3 +1,9 @@
/*
File: Payslip.cpp
* Description : Models a payslip entity that stores salary information.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include <sstream> #include <sstream>
#include "Payslip.h" #include "Payslip.h"
#include "StringHelper.h" #include "StringHelper.h"
@@ -51,6 +57,19 @@ const std::string& Payslip::getEmployeeId() const
return m_employeeId; return m_employeeId;
} }
std::string Payslip::getHeaders()
{
return "PayslipId,EmployeeId,Salary,Timestamp";
}
/*
Function: serialize
Description: Converts the payslip object into a comma-separated string.
Parameters:
None
Returns:
A serialized string representation of the payslip.
*/
std::string Payslip::serialize() const std::string Payslip::serialize() const
{ {
std::ostringstream serializedPayslip; std::ostringstream serializedPayslip;
@@ -61,7 +80,15 @@ std::string Payslip::serialize() const
return serializedPayslip.str(); return serializedPayslip.str();
} }
std::shared_ptr<Payslip> Payslip::deserialize(const std::string& record) /*
Function: deserialize
Description: Creates a Payslip object from a serialized comma-separated string.
Parameters:
record - Serialized payslip data.
Returns:
Pointer to a Payslip object.
*/
Payslip* Payslip::deserialize(const std::string& record)
{ {
std::string id, employeeId, timestampString; std::string id, employeeId, timestampString;
std::string salaryString; std::string salaryString;
@@ -87,8 +114,3 @@ std::shared_ptr<Payslip> Payslip::deserialize(const std::string& record)
throw std::runtime_error("Failed to deserialize Payslip object"); throw std::runtime_error("Failed to deserialize Payslip object");
} }
} }
std::string Payslip::getHeaders()
{
return "PayslipId,EmployeeId,Salary,Timestamp";
}
+8 -3
View File
@@ -1,5 +1,10 @@
/*
File: Payslip.h
* Description : Models a payslip entity that stores salary information.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <memory>
#include <string> #include <string>
#include "Timestamp.h" #include "Timestamp.h"
@@ -20,11 +25,11 @@ public:
util::Timestamp timestamp); util::Timestamp timestamp);
const std::string& getId() const; const std::string& getId() const;
double getSalary() const; double getSalary() const;
static std::string getHeaders();
void setPayslipId(const std::string& id); void setPayslipId(const std::string& id);
void setSalary(double salary); void setSalary(double salary);
const util::Timestamp& getTimestamp() const; const util::Timestamp& getTimestamp() const;
const std::string& getEmployeeId() const; const std::string& getEmployeeId() const;
std::string serialize() const; std::string serialize() const;
static std::shared_ptr<Payslip> deserialize(const std::string&); static Payslip* deserialize(const std::string&);
static std::string getHeaders();
}; };
+15 -1
View File
@@ -1,3 +1,9 @@
/*
File: Room.cpp
* Description : Models a room entity that maintains room details and manages its bookings.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Room.h" #include "Room.h"
int Room::m_uid = 0; int Room::m_uid = 0;
@@ -27,7 +33,15 @@ void Room::setRoomName(const std::string& name)
m_name = name; m_name = name;
} }
void Room::addBooking(std::shared_ptr<Booking> booking) /*
Function: addBooking
Description: Adds a valid booking to the rooms booking list using the booking ID as the key.
Parameters:
booking - A pointer to a Booking object to be added to the room.
Returns:
void
*/
void Room::addBooking(Booking* booking)
{ {
if (booking) if (booking)
{ {
+8 -3
View File
@@ -1,9 +1,14 @@
/*
File: Room.h
* Description : Models a room entity that maintains room details and manages its bookings.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
#include <memory>
#include "Booking.h" #include "Booking.h"
using bookingMap = std::map<std::string, std::shared_ptr<Booking>>; using bookingMap = std::map<std::string, Booking*>;
class Room class Room
{ {
@@ -20,5 +25,5 @@ public:
const bookingMap& getBookings() const; const bookingMap& getBookings() const;
void setRoomId(const std::string& id); void setRoomId(const std::string& id);
void setRoomName(const std::string& name); void setRoomName(const std::string& name);
void addBooking(std::shared_ptr<Booking> booking); void addBooking(Booking* booking);
}; };
@@ -1 +1,7 @@
/*
File: TalentExecutive.cpp
* Description : Represents information related to a talent executive in the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "TalentExecutive.h" #include "TalentExecutive.h"
@@ -1,3 +1,9 @@
/*
File: TalentExecutive.h
* Description : Represents information related to a talent executive in the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -9,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::TALENT_ACQUISITION, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::TALENT_ACQUISITION, payroll) {};
TalentExecutive(const std::string& id, TalentExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -31,4 +37,3 @@ public:
} }
~TalentExecutive() = default; ~TalentExecutive() = default;
}; };
+8 -2
View File
@@ -1,3 +1,9 @@
/*
File: Team.cpp
* Description : Models a team entity that maintains team identity, leadership, employee list, and size limitations.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Team.h" #include "Team.h"
int Team::m_uid = 0; int Team::m_uid = 0;
@@ -12,7 +18,7 @@ const std::string& Team::getTeamName() const
return m_name; return m_name;
} }
std::shared_ptr<Employee> Team::getTeamLead() const Employee* Team::getTeamLead() const
{ {
return m_lead; return m_lead;
} }
@@ -37,7 +43,7 @@ void Team::setTeamName(const std::string& name)
m_name = name; m_name = name;
} }
void Team::setTeamLead(std::shared_ptr<Employee> lead) void Team::setTeamLead(Employee* lead)
{ {
m_lead = lead; m_lead = lead;
} }
+11 -6
View File
@@ -1,9 +1,14 @@
/*
File: Team.h
* Description : Models a team entity that maintains team identity, leadership, employee list, and size limitations.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
#include <memory>
#include "Employee.h" #include "Employee.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>; using employeeMap = std::map<std::string, Employee*>;
class Team class Team
{ {
@@ -11,25 +16,25 @@ private:
static int m_uid; static int m_uid;
std::string m_id; std::string m_id;
std::string m_name; std::string m_name;
std::shared_ptr<Employee> m_lead; Employee* m_lead;
employeeMap m_employees; employeeMap m_employees;
int m_maximumNumberOfEmployees; int m_maximumNumberOfEmployees;
public: public:
Team() : m_id("TM" + std::to_string(++m_uid)), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {} Team() : m_id("TM" + std::to_string(++m_uid)), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
Team( Team(
const std::string& name, const std::string& name,
std::shared_ptr<Employee> lead, Employee* lead,
int maximumNumberOfEmployees) int maximumNumberOfEmployees)
: m_id("TM" + std::to_string(++m_uid)), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) { : m_id("TM" + std::to_string(++m_uid)), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
} }
const std::string& getTeamId() const; const std::string& getTeamId() const;
const std::string& getTeamName() const; const std::string& getTeamName() const;
std::shared_ptr<Employee> getTeamLead() const; Employee* getTeamLead() const;
const employeeMap& getEmployeesInTeam() const; const employeeMap& getEmployeesInTeam() const;
int getMaximumNumberOfEmployeesInTeam() const; int getMaximumNumberOfEmployeesInTeam() const;
void setTeamId(const std::string& id); void setTeamId(const std::string& id);
void setTeamName(const std::string& name); void setTeamName(const std::string& name);
void setTeamLead(std::shared_ptr<Employee> lead); void setTeamLead(Employee* lead);
void setEmployeesInTeam(const employeeMap& employees); void setEmployeesInTeam(const employeeMap& employees);
void setMaximumNumberOfEmployeesInTeam(int maximumNumberOfEmployees); void setMaximumNumberOfEmployeesInTeam(int maximumNumberOfEmployees);
}; };
@@ -1 +1,7 @@
/*
File: TeamExecutive.cpp
* Description : Represents information related to a team executive within the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "TeamExecutive.h" #include "TeamExecutive.h"
@@ -1,3 +1,9 @@
/*
File: TeamExecutive.h
* Description : Represents information related to a team executive within the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -9,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::TEAM, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::TEAM, payroll) {};
TeamExecutive(const std::string& id, TeamExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -30,4 +36,3 @@ public:
accountStatus) {} accountStatus) {}
~TeamExecutive() = default; ~TeamExecutive() = default;
}; };
@@ -1,3 +1,9 @@
/*
File: Ticket.cpp
* Description : Represents a support ticket with its associated details and status.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Ticket.h" #include "Ticket.h"
int Ticket::m_uid = 0; int Ticket::m_uid = 0;
@@ -1,3 +1,9 @@
/*
File: Ticket.h
* Description : Represents a support ticket with its associated details and status.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
@@ -1 +1,7 @@
/*
* File: ApplicationConfig.cpp
* Description: Global Application Config
* Author: Trenser
* Created: 06-Apr-2026
*/
#include "ApplicationConfig.h" #include "ApplicationConfig.h"
@@ -1,3 +1,9 @@
/*
* File: ApplicationConfig.h
* Description: Global Application Config
* Author: Trenser
* Created: 06-Apr-2026
*/
#pragma once #pragma once
namespace Config namespace Config
@@ -1 +1,7 @@
/*
* File: AttendanceManagementService.cpp
* Description: Handles Attendance related operations
* Author: Trenser
* Created: 30-Apr-2026
*/
#include "AttendanceManagementService.h" #include "AttendanceManagementService.h"
@@ -1,3 +1,9 @@
/*
* File: AttendanceManagementService.h
* Description: Handles Attendance related operations
* Author: Trenser
* Created: 30-Apr-2026
*/
#pragma once #pragma once
class AttendanceManagementService class AttendanceManagementService
{ {
@@ -1,7 +1,24 @@
/*
* File: AuthenticationManagementService.cpp
* Description: Handles authentication related operations
* Author: Trenser
* Created: 30-Mar-2026
*/
#include <stdexcept> #include <stdexcept>
#include "AuthenticationManagementService.h" #include "AuthenticationManagementService.h"
#include "ApplicationConfig.h" #include "ApplicationConfig.h"
/*
* Function: login
* Description: Authenticates a user using email and password, determines login status,
* employee type, and designation, and sets the authenticated employee
* in the data store.
* Parameters:
* email - employee email address
* password - employee password
* Returns:
* AuthenticationDTO containing login status, employee type, and employee designation
*/
AuthenticationDTO AuthenticationManagementService::login(const std::string& email, const std::string& password) AuthenticationDTO AuthenticationManagementService::login(const std::string& email, const std::string& password)
{ {
employeeMap& employees = m_dataStore.getEmployees(); employeeMap& employees = m_dataStore.getEmployees();
@@ -29,7 +46,7 @@ AuthenticationDTO AuthenticationManagementService::login(const std::string& emai
employeeType = employee.second->getEmployeeType(); employeeType = employee.second->getEmployeeType();
if (employeeType == Enums::EmployeeType::GENERAL) if (employeeType == Enums::EmployeeType::GENERAL)
{ {
std::shared_ptr<GeneralEmployee> generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>(employee.second); GeneralEmployee* generalEmployee = dynamic_cast<GeneralEmployee*>(employee.second);
if (generalEmployee) if (generalEmployee)
{ {
employeeDesignation = generalEmployee->getDesignation(); employeeDesignation = generalEmployee->getDesignation();
@@ -51,24 +68,46 @@ AuthenticationDTO AuthenticationManagementService::login(const std::string& emai
return std::make_tuple(loginStatus, employeeType, employeeDesignation); return std::make_tuple(loginStatus, employeeType, employeeDesignation);
} }
/*
* Function: changePassword
* Description: Updates the password of the currently authenticated user.
* Parameters:
* password - new password to be set
* Returns:
* None
* Throws:
* runtime_error if no authenticated user is found
*/
void AuthenticationManagementService::changePassword(const std::string& password) void AuthenticationManagementService::changePassword(const std::string& password)
{ {
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedEmployee(); Employee* authenticatedUser = m_dataStore.getAuthenticatedEmployee();
if (authenticatedUser) if (authenticatedUser)
{ {
authenticatedUser->setEmployeePassword(password); authenticatedUser->setEmployeePassword(password);
} }
else else
{ {
throw std::runtime_error("User not found"); throw std::runtime_error("User not found");
} }
} }
/*
* Function: logout
* Description: Logs out the currently authenticated user by clearing authentication data.
* Parameters:
* None
* Returns:
* None
* Throws:
* runtime_error if no user is currently logged in
*/
void AuthenticationManagementService::logout() { void AuthenticationManagementService::logout() {
if (m_dataStore.getAuthenticatedEmployee()) { if (m_dataStore.getAuthenticatedEmployee())
{
m_dataStore.getAuthenticatedEmployee() = nullptr; m_dataStore.getAuthenticatedEmployee() = nullptr;
} }
else { else
{
throw std::runtime_error("No user currently logged In..."); throw std::runtime_error("No user currently logged In...");
} }
} }
@@ -1,3 +1,9 @@
/*
* File: AuthenticationManagementService.h
* Description: Handles authentication related operations
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
@@ -19,4 +25,3 @@ public:
void logout(); void logout();
void changePassword(const std::string&); void changePassword(const std::string&);
}; };
@@ -1 +1,7 @@
/*
* File: BookingManagementService.cpp
* Description: Handle operations related to booking meetings
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "BookingManagementService.h" #include "BookingManagementService.h"
@@ -1,3 +1,9 @@
/*
* File: BookingManagementService.h
* Description: Handle operations related to booking meetings
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
class BookingManagementService class BookingManagementService
{ {
@@ -1,3 +1,11 @@
/*
* File: EmployeeManagementService.h
* Description: Provides services for managing employees, including creation, deactivation,
* designation updates, profile modifications, searching, and retrieval of
* shortlisted candidates.
* Author: Trenser
* Created: 07-Apr-2026
*/
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
@@ -15,17 +23,30 @@
#include "FileManager.h" #include "FileManager.h"
#include "ApplicationConfig.h" #include "ApplicationConfig.h"
/*
* Function: createEmployee
* Description: Creates a new employee of the specified type and designation, validates
* email and phone, enforces authorization, and associates payroll.
* Parameters:
* employeeType - type of employee (HR, IT, Finance, Team, Talent Acquisition, General)
* employeeDesignation - designation for general employees (Junior, Senior)
* email - employee email address
* name - employee name
* phone - employee phone number
* Returns:
* None
*/
void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone) void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone)
{ {
auto& employees = m_dataStore.getEmployees(); auto& employees = m_dataStore.getEmployees();
std::shared_ptr<Employee> authenticatedEmployee = m_dataStore.getAuthenticatedEmployee(); Employee* authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
if (!authenticatedEmployee) if (!authenticatedEmployee)
{ {
throw std::runtime_error("No authenticated user"); throw std::runtime_error("No authenticated user");
} }
Enums::EmployeeType authenticatedEmployeeType = authenticatedEmployee->getEmployeeType(); Enums::EmployeeType authenticatedEmployeeType = authenticatedEmployee->getEmployeeType();
std::shared_ptr<Employee> employee; Employee* employee = nullptr;
std::shared_ptr<Payroll> payroll; Payroll* payroll = nullptr;
if (employeeType != Enums::EmployeeType::GENERAL && util::hasActiveEmployeeOfType(employeeType, employees)) if (employeeType != Enums::EmployeeType::GENERAL && util::hasActiveEmployeeOfType(employeeType, employees))
{ {
throw std::runtime_error("Cannot create more than one employee of type " + Enums::getEmployeeTypeString(employeeType)); throw std::runtime_error("Cannot create more than one employee of type " + Enums::getEmployeeTypeString(employeeType));
@@ -113,6 +134,16 @@ void EmployeeManagementService::createEmployee(Enums::EmployeeType employeeType,
m_dataStore.getPayrolls().emplace(std::make_pair(payroll->getId(), payroll)); m_dataStore.getPayrolls().emplace(std::make_pair(payroll->getId(), payroll));
m_dataStore.getEmployees().emplace(std::make_pair(employee->getId(), employee)); m_dataStore.getEmployees().emplace(std::make_pair(employee->getId(), employee));
} }
/*
* Function: deactivateEmployee
* Description: Deactivates an employee account by setting its status to INACTIVE.
* Prevents deactivation of Admin accounts.
* Parameters:
* id - unique identifier of the employee
* Returns:
* bool - true if deactivation succeeded, false otherwise
*/
bool EmployeeManagementService::deactivateEmployee(const std::string& id) bool EmployeeManagementService::deactivateEmployee(const std::string& id)
{ {
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee(); auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
@@ -131,17 +162,26 @@ bool EmployeeManagementService::deactivateEmployee(const std::string& id)
return true; return true;
} }
/*
* Function: updateDesignation
* Description: Updates the designation of a general employee.
* Parameters:
* id - unique identifier of the employee
* designation - new designation to assign
* Returns:
* bool - true if update succeeded, false otherwise
*/
bool EmployeeManagementService::updateDesignation(const std::string& id, Enums::EmployeeDesignation designation) bool EmployeeManagementService::updateDesignation(const std::string& id, Enums::EmployeeDesignation designation)
{ {
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee(); auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR); util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
std::map<std::string, std::shared_ptr<Employee>> employees = m_dataStore.getEmployees(); std::map<std::string, Employee*> employees = m_dataStore.getEmployees();
auto employeeIterator = employees.find(id); auto employeeIterator = employees.find(id);
if (employeeIterator == employees.end()) if (employeeIterator == employees.end())
{ {
return false; return false;
} }
auto generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>((*employeeIterator).second); auto generalEmployee = dynamic_cast<GeneralEmployee*>((*employeeIterator).second);
if (generalEmployee) if (generalEmployee)
{ {
generalEmployee->setDesignation(designation); generalEmployee->setDesignation(designation);
@@ -149,24 +189,50 @@ bool EmployeeManagementService::updateDesignation(const std::string& id, Enums::
return true; return true;
} }
std::shared_ptr<const Employee> EmployeeManagementService::getCurrentEmployee() /*
* Function: getCurrentEmployee
* Description: Retrieves the currently authenticated employee from the DataStore.
* Parameters:
* None
* Returns:
* const Employee* - pointer to the current employee
*/
const Employee* EmployeeManagementService::getCurrentEmployee()
{ {
return m_dataStore.getAuthenticatedEmployee(); return m_dataStore.getAuthenticatedEmployee();
} }
/*
* Function: updateProfile
* Description: Updates the name and phone number of the currently authenticated employee.
* Parameters:
* name - new employee name
* phone - new employee phone number
* Returns:
* None
*/
void EmployeeManagementService::updateProfile(const std::string& name,const std::string& phone) void EmployeeManagementService::updateProfile(const std::string& name,const std::string& phone)
{ {
std::shared_ptr<Employee> employee = m_dataStore.getAuthenticatedEmployee(); Employee* employee = m_dataStore.getAuthenticatedEmployee();
employee->setEmployeeName(name); employee->setEmployeeName(name);
employee->setEmployeePhone(phone); employee->setEmployeePhone(phone);
} }
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> EmployeeManagementService::searchEmployee(const std::string& name) /*
* Function: searchEmployee
* Description: Searches employees by name and returns matches along
* with the type of the current authenticated employee.
* Parameters:
* name - search string for employee name
* Returns:
* pair<Enums::EmployeeType, vector<const Employee*>> - current user type and matching employees
*/
std::pair<Enums::EmployeeType, std::vector<const Employee*>> EmployeeManagementService::searchEmployee(const std::string& name)
{ {
std::shared_ptr<Employee> currentUser = m_dataStore.getAuthenticatedEmployee(); Employee* currentUser = m_dataStore.getAuthenticatedEmployee();
Enums::EmployeeType employeeType = currentUser->getEmployeeType(); Enums::EmployeeType employeeType = currentUser->getEmployeeType();
employeeMap& employees = m_dataStore.getEmployees(); employeeMap& employees = m_dataStore.getEmployees();
std::vector<std::shared_ptr<const Employee>> employeeList; std::vector<const Employee*> employeeList;
if (employees.empty()) if (employees.empty())
{ {
return std::make_pair(employeeType, employeeList); return std::make_pair(employeeType, employeeList);
@@ -189,6 +255,36 @@ std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> Emp
return { employeeType, employeeList }; return { employeeType, employeeList };
} }
/*
* Function: getShorlistedCandidates
* Description: Retrieves candidates with status SHORTLISTED from the DataStore.
* Parameters:
* None
* Returns:
* vector<Candidate*> - list of shortlisted candidates
*/
std::vector<Candidate*> EmployeeManagementService::getShorlistedCandidates()
{
candidateMap candidates = m_dataStore.getCandidates();
std::vector<Candidate*> shortlistedCandidates;
for (auto& candidate : candidates)
{
if (candidate.second->getCandidateStatus() == Enums::CandidateStatus::SHORTLISTED)
{
shortlistedCandidates.push_back(candidate.second);
}
}
return shortlistedCandidates;
}
/*
* Function: loadEmployees
* Description: Loads employees and general employees from FileManager into the DataStore.
* Parameters:
* None
* Returns:
* None
*/
void EmployeeManagementService::loadEmployees() void EmployeeManagementService::loadEmployees()
{ {
FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE); FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE);
@@ -214,18 +310,26 @@ void EmployeeManagementService::loadEmployees()
} }
} }
/*
* Function: saveEmployees
* Description: Saves employees and general employees from the DataStore into FileManager.
* Parameters:
* None
* Returns:
* None
*/
void EmployeeManagementService::saveEmployees() void EmployeeManagementService::saveEmployees()
{ {
FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE); FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE);
FileManager<GeneralEmployee> generalEmployeeFileManager(Config::File::GENERAL_EMPLOYEES_FILE); FileManager<GeneralEmployee> generalEmployeeFileManager(Config::File::GENERAL_EMPLOYEES_FILE);
const auto& allEmployees = m_dataStore.getEmployees(); const auto& allEmployees = m_dataStore.getEmployees();
employeeMap employees; employeeMap employees;
std::map<std::string, std::shared_ptr<GeneralEmployee>> generalEmployees; std::map<std::string, GeneralEmployee*> generalEmployees;
for (auto& employeePair : allEmployees) for (auto& employeePair : allEmployees)
{ {
if (employeePair.second->getEmployeeType() == Enums::EmployeeType::GENERAL) if (employeePair.second->getEmployeeType() == Enums::EmployeeType::GENERAL)
{ {
generalEmployees.emplace(employeePair.first, std::static_pointer_cast<GeneralEmployee>(employeePair.second)); generalEmployees.emplace(employeePair.first, static_cast<GeneralEmployee*>(employeePair.second));
} }
else else
{ {
@@ -235,17 +339,3 @@ void EmployeeManagementService::saveEmployees()
employeeFileManager.save(employees); employeeFileManager.save(employees);
generalEmployeeFileManager.save(generalEmployees); generalEmployeeFileManager.save(generalEmployees);
} }
std::vector<std::shared_ptr<Candidate>> EmployeeManagementService::getShorlistedCandidates()
{
candidateMap candidates = m_dataStore.getCandidates();
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates;
for (auto& candidate : candidates)
{
if (candidate.second->getCandidateStatus() == Enums::CandidateStatus::SHORTLISTED)
{
shortlistedCandidates.push_back(candidate.second);
}
}
return shortlistedCandidates;
}
@@ -1,3 +1,11 @@
/*
* File: EmployeeManagementService.h
* Description: Provides services for managing employees, including creation, deactivation,
* designation updates, profile modifications, searching, and retrieval of
* shortlisted candidates.
* Author: Trenser
* Created: 07-Apr-2026
*/
#pragma once #pragma once
#include <vector> #include <vector>
#include <tuple> #include <tuple>
@@ -7,24 +15,33 @@
#include "Enums.h" #include "Enums.h"
#include "StringHelper.h" #include "StringHelper.h"
using Employees = std::vector<std::shared_ptr<const Employee>>; using Employees = std::vector<const Employee*>;
class EmployeeManagementService class EmployeeManagementService
{ {
private: private:
DataStore& m_dataStore; DataStore& m_dataStore;
public: public:
EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {}; EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {};
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&); void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
bool deactivateEmployee(const std::string&); bool deactivateEmployee(const std::string&);
bool updateDesignation(const std::string&,Enums::EmployeeDesignation); bool updateDesignation(const std::string&, Enums::EmployeeDesignation);
void updateProfile(const std::string&,const std::string&); void updateProfile(const std::string&, const std::string&);
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchEmployee(const std::string&); std::pair<Enums::EmployeeType, std::vector<const Employee*>> searchEmployee(const std::string&);
std::shared_ptr<const Employee> getCurrentEmployee(); const Employee* getCurrentEmployee();
std::vector<std::shared_ptr<Candidate>> getShorlistedCandidates(); std::vector<Candidate*> getShorlistedCandidates();
void loadEmployees(); void loadEmployees();
void saveEmployees(); void saveEmployees();
/*
* Function: getEmployees (template)
* Description: Retrieves active employees filtered by specified types. Excludes admin employees
* if no filter is provided.
* Parameters:
* types... - variadic list of employee types
* Returns:
* Employees - vector of pointers to filtered employees
*/
template<typename... Types> template<typename... Types>
Employees getEmployees(Types... types) Employees getEmployees(Types... types)
{ {
@@ -52,8 +69,8 @@ public:
std::sort( std::sort(
filteredEmployees.begin(), filteredEmployees.begin(),
filteredEmployees.end(), filteredEmployees.end(),
[](const std::shared_ptr<const Employee>& employeeOne, [](const Employee* employeeOne,
const std::shared_ptr<const Employee>& employeeTwo) const Employee* employeeTwo)
{ {
return util::extractNumber(employeeOne->getId()) < return util::extractNumber(employeeOne->getId()) <
util::extractNumber(employeeTwo->getId()); util::extractNumber(employeeTwo->getId());
@@ -1 +1,7 @@
/*
* File: LeaveManagementService.cpp
* Description: Handle operations related to leaves
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "LeaveManagementService.h" #include "LeaveManagementService.h"
@@ -1,3 +1,9 @@
/*
* File: LeaveManagementService.h
* Description: Handle operations related to leaves
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
class LeaveManagementService class LeaveManagementService
{ {
@@ -1,12 +1,27 @@
/*
* File: Log.cpp
* Description: Handle operations related to logging
* Author: Trenser
* Created: 01-Apr-2026
*/
#include "LogService.h" #include "LogService.h"
#include "Log.h" #include "Log.h"
#include "Factory.h" #include "Factory.h"
#include "DataStore.h" #include "DataStore.h"
/*
* Function: log
* Description: Creates a new log entry with the given message, assigns a timestamp,
* and stores it in the DataStore.
* Parameters:
* message - string containing the log message to be recorded
* Returns:
* void - no return value
*/
void LogService::log(const std::string& message) void LogService::log(const std::string& message)
{ {
DataStore& dataStore = DataStore::getInstance(); DataStore& dataStore = DataStore::getInstance();
logMap& logs = dataStore.getLogs(); logMap& logs = dataStore.getLogs();
std::shared_ptr<Log> log = Factory::getObject<Log>(message); Log* log = Factory::getObject<Log>(message);
logs.emplace(std::make_pair(log->getTimestamp(), log)); logs.emplace(std::make_pair(log->getTimestamp(), log));
} }
@@ -1,3 +1,9 @@
/*
* File: Log.h
* Description: Handle operations related to logging
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once #pragma once
#include "Log.h" #include "Log.h"
@@ -1 +1,7 @@
/*
* File: NotificationManagementService.cpp
* Description: Handle operations related to notifications
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "NotificationManagementService.h" #include "NotificationManagementService.h"
@@ -1,5 +1,10 @@
/*
* File: NotificationManagementService.h
* Description: Handle operations related to notifications
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
class NotificationManagementService class NotificationManagementService
{ {
}; };
@@ -1,3 +1,9 @@
/*
* File: PayslipManagementService.cpp
* Description: Handle operations related to employee payslips
* Author: Trenser
* Created: 30-Mar-2026
*/
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
#include "PayslipManagementService.h" #include "PayslipManagementService.h"
@@ -7,6 +13,20 @@
#include "FileManager.h" #include "FileManager.h"
#include "Factory.h" #include "Factory.h"
/*
* Function: updateSalary
* Description: Updates the payroll details of a given employee, including salary components
* and PF contributions.
* Parameters:
* employeeId - unique identifier of the employee
* basicSalary - basic salary of the employee
* houseRentAllowance - HRA component
* foodAllowance - food allowance component
* employeePFContribution - employee PF contribution
* employerPFContribution - employer PF contribution
* Returns:
* void - throws runtime_error if employee not found or unauthorized
*/
void PayslipManagementService::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution) void PayslipManagementService::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution)
{ {
util::enforceAuthorization(m_dataStore.getAuthenticatedEmployee()->getEmployeeType(), Enums::EmployeeType::FINANCE); util::enforceAuthorization(m_dataStore.getAuthenticatedEmployee()->getEmployeeType(), Enums::EmployeeType::FINANCE);
@@ -26,6 +46,14 @@ void PayslipManagementService::updateSalary(const std::string& employeeId, doubl
} }
} }
/*
* Function: generatePayslips
* Description: Generates payslips for all employees for the current month and year.
* Parameters:
* None
* Returns:
* void - creates and stores payslips in DataStore
*/
void PayslipManagementService::generatePayslips() void PayslipManagementService::generatePayslips()
{ {
util::enforceAuthorization(m_dataStore.getAuthenticatedEmployee()->getEmployeeType(), Enums::EmployeeType::FINANCE); util::enforceAuthorization(m_dataStore.getAuthenticatedEmployee()->getEmployeeType(), Enums::EmployeeType::FINANCE);
@@ -55,13 +83,22 @@ void PayslipManagementService::generatePayslips()
auto payroll = employee->getPayroll(); auto payroll = employee->getPayroll();
double salary; double salary;
salary = payroll->getBasicSalary() + payroll->getFoodAllowance() + payroll->getHouseRentAllowance() - payroll->getEmployeePFContribution() - payroll->getEmployerPFContribution(); salary = payroll->getBasicSalary() + payroll->getFoodAllowance() + payroll->getHouseRentAllowance() - payroll->getEmployeePFContribution() - payroll->getEmployerPFContribution();
std::shared_ptr<Payslip> payslip = Factory::getObject<Payslip>(salary, employee->getId()); Payslip* payslip = Factory::getObject<Payslip>(salary, employee->getId());
employee->addPayslip(payslip); employee->addPayslip(payslip);
payslips.emplace(payslip->getId(), payslip); payslips.emplace(payslip->getId(), payslip);
} }
} }
} }
/*
* Function: loadPayrolls
* Description: Loads payroll objects from persistent storage and associates them
* with existing employees.
* Parameters:
* None
* Returns:
* void - updates DataStore with loaded payrolls
*/
void PayslipManagementService::loadPayrolls() void PayslipManagementService::loadPayrolls()
{ {
FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE); FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE);
@@ -80,6 +117,14 @@ void PayslipManagementService::loadPayrolls()
payrolls.insert(payrollObjects.begin(), payrollObjects.end()); payrolls.insert(payrollObjects.begin(), payrollObjects.end());
} }
/*
* Function: savePayrolls
* Description: Saves all payroll objects from DataStore into persistent storage.
* Parameters:
* None
* Returns:
* None
*/
void PayslipManagementService::savePayrolls() void PayslipManagementService::savePayrolls()
{ {
FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE); FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE);
@@ -87,7 +132,18 @@ void PayslipManagementService::savePayrolls()
payrollFileManager.save(payrolls); payrollFileManager.save(payrolls);
} }
std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>> PayslipManagementService::getPayslipForMonth(const std::string& employeeId, int year, int month) /*
* Function: getPayslipForMonth
* Description: Retrieves the payroll and payslip of a given employee for a specific
* month and year.
* Parameters:
* employeeId - unique identifier of the employee
* year - year of the payslip
* month - month of the payslip
* Returns:
* pair<Payroll*, Payslip*> - payroll and payslip for the given month.
*/
std::pair<Payroll*, Payslip*> PayslipManagementService::getPayslipForMonth(const std::string& employeeId, int year, int month)
{ {
auto& employees = m_dataStore.getEmployees(); auto& employees = m_dataStore.getEmployees();
auto employeeIterator = employees.find(employeeId); auto employeeIterator = employees.find(employeeId);
@@ -110,6 +166,15 @@ std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>> PayslipManagementS
return { nullptr, nullptr }; return { nullptr, nullptr };
} }
/*
* Function: loadPayslips
* Description: Loads payslip objects from FileManager and associates them
* with existing employees.
* Parameters:
* None
* Returns:
* void - updates DataStore with loaded payslips
*/
void PayslipManagementService::loadPayslips() void PayslipManagementService::loadPayslips()
{ {
FileManager<Payslip> payslipFileManager(Config::File::PAYSLIP_FILE); FileManager<Payslip> payslipFileManager(Config::File::PAYSLIP_FILE);
@@ -128,6 +193,14 @@ void PayslipManagementService::loadPayslips()
payslips.insert(payslipObjects.begin(), payslipObjects.end()); payslips.insert(payslipObjects.begin(), payslipObjects.end());
} }
/*
* Function: savePayslips
* Description: Saves all payslip objects from DataStore into FileManager.
* Parameters:
* None
* Returns:
* void
*/
void PayslipManagementService::savePayslips() void PayslipManagementService::savePayslips()
{ {
FileManager<Payslip> payslipFileManager(Config::File::PAYSLIP_FILE); FileManager<Payslip> payslipFileManager(Config::File::PAYSLIP_FILE);
@@ -1,9 +1,15 @@
/*
* File: PayslipManagementService.h
* Description: Handle operations related to employee payslips
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
#include <string> #include <string>
#include<stdexcept> #include<stdexcept>
#include"DataStore.h" #include"DataStore.h"
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>; using payslipMap = std::map<std::string, Payslip*>;
class PayslipManagementService class PayslipManagementService
{ {
@@ -13,7 +19,7 @@ public:
PayslipManagementService() : m_dataStore(DataStore::getInstance()) {}; PayslipManagementService() : m_dataStore(DataStore::getInstance()) {};
void updateSalary(const std::string&, double, double, double, double, double); void updateSalary(const std::string&, double, double, double, double, double);
void generatePayslips(); void generatePayslips();
std::pair<std::shared_ptr<Payroll>, std::shared_ptr<Payslip>>getPayslipForMonth(const std::string&, int, int); std::pair<Payroll*, Payslip*>getPayslipForMonth(const std::string&, int, int);
void loadPayrolls(); void loadPayrolls();
void savePayrolls(); void savePayrolls();
void loadPayslips(); void loadPayslips();
@@ -1 +1,7 @@
/*
* File: TalentAcquisitionManagementService.cpp
* Description: Handle operations related to Talent Acquisition
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "TalentAcquisitionManagementService.h" #include "TalentAcquisitionManagementService.h"
@@ -1,5 +1,10 @@
/*
* File: TalentAcquisitionManagementService.h
* Description: Handle operations related to Talent Acquisition
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
class TalentAcquisitionManagementService class TalentAcquisitionManagementService
{ {
}; };
@@ -1 +1,7 @@
/*
* File: TeamManagementService.cpp
* Description: Handle operations related to Team Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "TeamManagementService.h" #include "TeamManagementService.h"
@@ -1,3 +1,9 @@
/*
* File: TeamManagementService.h
* Description: Handle operations related to Team Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
class TeamManagementService class TeamManagementService
{ {
@@ -1 +1,7 @@
/*
* File: TicketManagementService.h
* Description: Handle operations related to Ticket Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "TicketManagementService.h" #include "TicketManagementService.h"
@@ -1,3 +1,9 @@
/*
* File: TicketManagementService.h
* Description: Handle operations related to Ticket Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once #pragma once
class TicketManagementService class TicketManagementService
{ {
@@ -1,14 +1,40 @@
/*
* File: AuthorizationHelper.h
* Description : Provides utility functions to check and enforce authorization
* based on allowed employee types.
* Author : Trenser
* Created : 07-Apr-2026
*/
#pragma once #pragma once
#include <stdexcept> #include <stdexcept>
#include "Enums.h" #include "Enums.h"
namespace util namespace util
{ {
/*
* Function: isAuthorized
* Description: Checks if the current employee type matches the specified allowed type.
* Parameters:
* current - the employee type of the current user
* first - the allowed employee type to compare against
* Returns:
* bool - true if current matches the allowed type, false otherwise
*/
inline bool isAuthorized(Enums::EmployeeType current, Enums::EmployeeType first) inline bool isAuthorized(Enums::EmployeeType current, Enums::EmployeeType first)
{ {
return current == first; return current == first;
} }
/*
* Function: isAuthorized
* Description: Checks if the current employee type matches any of the specified allowed types.
* Parameters:
* current - the employee type of the current user
* first - the first allowed employee type
* rest - additional allowed employee types
* Returns:
* bool - true if current matches any of the allowed types, false otherwise
*/
template <typename... Rest> template <typename... Rest>
inline bool isAuthorized(Enums::EmployeeType current, Enums::EmployeeType first, inline bool isAuthorized(Enums::EmployeeType current, Enums::EmployeeType first,
Rest... rest) Rest... rest)
@@ -20,6 +46,16 @@ namespace util
return isAuthorized(current, rest...); return isAuthorized(current, rest...);
} }
/*
* Function: enforceAuthorization
* Description: Enforces authorization by checking if the current employee type
* is among the allowed types.
* Parameters:
* current - the employee type of the current user
* alloweds - one or more allowed employee types
* Returns:
* void - throws runtime_error if current is not authorized
*/
template <typename... Allowed> template <typename... Allowed>
inline void enforceAuthorization(Enums::EmployeeType current, Allowed... allowed) inline void enforceAuthorization(Enums::EmployeeType current, Allowed... allowed)
{ {
+96 -2
View File
@@ -1,3 +1,10 @@
/*
* File: Enums.h
* Description: Defines strongly typed enumerations for statuses, types, and designations used across the HRMS system.
* Author: Smitha
* Created: 01-04-2026
*/
#pragma once #pragma once
#include <string> #include <string>
@@ -109,6 +116,14 @@ namespace Enums {
INVALID INVALID
}; };
/*
* Function: getAccountStatusString
* Description: Converts AccountStatus enum value to string.
* Parameters:
* status - account status enum
* Returns:
* std::string - string representation of status
*/
inline std::string getAccountStatusString(AccountStatus status) inline std::string getAccountStatusString(AccountStatus status)
{ {
switch (status) switch (status)
@@ -122,6 +137,14 @@ namespace Enums {
} }
} }
/*
* Function: getEmployeeTypeString
* Description: Converts EmployeeType enum value to string.
* Parameters:
* type - employee type enum
* Returns:
* std::string - string representation of employee type
*/
inline std::string getEmployeeTypeString(EmployeeType type) inline std::string getEmployeeTypeString(EmployeeType type)
{ {
switch (type) switch (type)
@@ -147,6 +170,14 @@ namespace Enums {
} }
} }
/*
* Function: getTeamStatusString
* Description: Converts TeamStatus enum value to string.
* Parameters:
* status - team status enum
* Returns:
* std::string - string representation of team status
*/
inline std::string getTeamStatusString(TeamStatus status) inline std::string getTeamStatusString(TeamStatus status)
{ {
switch (status) switch (status)
@@ -160,6 +191,14 @@ namespace Enums {
} }
} }
/*
* Function: getEmployeeDesignationString
* Description: Converts EmployeeDesignation enum value to string.
* Parameters:
* designation - employee designation enum
* Returns:
* std::string - string representation of designation
*/
inline std::string getEmployeeDesignationString(EmployeeDesignation designation) inline std::string getEmployeeDesignationString(EmployeeDesignation designation)
{ {
switch (designation) switch (designation)
@@ -177,6 +216,14 @@ namespace Enums {
} }
} }
/*
* Function: getCandidateStatusString
* Description: Converts CandidateStatus enum value to string.
* Parameters:
* status - candidate status enum
* Returns:
* std::string - string representation of candidate status
*/
inline std::string getCandidateStatusString(CandidateStatus status) inline std::string getCandidateStatusString(CandidateStatus status)
{ {
switch (status) switch (status)
@@ -188,11 +235,19 @@ namespace Enums {
} }
} }
/*
* Function: getMonthString
* Description: Converts Month enum value to month name.
* Parameters:
* month - month enum
* Returns:
* std::string - month name
*/
inline std::string getMonthString(Month month) inline std::string getMonthString(Month month)
{ {
switch (month) switch (month)
{ {
case Month::JANUARY : case Month::JANUARY:
return "January"; return "January";
case Month::FEBRUARY: case Month::FEBRUARY:
return "February"; return "February";
@@ -223,6 +278,14 @@ namespace Enums {
} }
} }
/*
* Function: getAccountStatus
* Description: Converts string to AccountStatus enum.
* Parameters:
* input - string representation of account status
* Returns:
* AccountStatus - enum value
*/
inline AccountStatus getAccountStatus(const std::string& input) inline AccountStatus getAccountStatus(const std::string& input)
{ {
if (input == "ACTIVE") if (input == "ACTIVE")
@@ -236,6 +299,14 @@ namespace Enums {
return AccountStatus::INACTIVE; return AccountStatus::INACTIVE;
} }
/*
* Function: getEmployeeType
* Description: Converts string to EmployeeType enum.
* Parameters:
* input - string representation of employee type
* Returns:
* EmployeeType - enum value
*/
inline EmployeeType getEmployeeType(const std::string& input) inline EmployeeType getEmployeeType(const std::string& input)
{ {
if (input == "GENERAL") if (input == "GENERAL")
@@ -269,6 +340,14 @@ namespace Enums {
return EmployeeType::INVALID; return EmployeeType::INVALID;
} }
/*
* Function: getTeamStatus
* Description: Converts string to TeamStatus enum.
* Parameters:
* str - string representation of team status
* Returns:
* TeamStatus - enum value
*/
inline TeamStatus getTeamStatus(const std::string& str) inline TeamStatus getTeamStatus(const std::string& str)
{ {
if (str == "IN_TEAM") if (str == "IN_TEAM")
@@ -282,6 +361,14 @@ namespace Enums {
return TeamStatus::NOT_IN_TEAM; return TeamStatus::NOT_IN_TEAM;
} }
/*
* Function: getEmployeeDesignation
* Description: Converts string to EmployeeDesignation enum.
* Parameters:
* input - string representation of designation
* Returns:
* EmployeeDesignation - enum value
*/
inline EmployeeDesignation getEmployeeDesignation(const std::string& input) inline EmployeeDesignation getEmployeeDesignation(const std::string& input)
{ {
if (input == "JUNIOR") if (input == "JUNIOR")
@@ -299,6 +386,14 @@ namespace Enums {
return EmployeeDesignation::INVALID; return EmployeeDesignation::INVALID;
} }
/*
* Function: getMonth
* Description: Converts integer to Month enum.
* Parameters:
* inputMonth - month number (112)
* Returns:
* Month - enum value
*/
inline Month getMonth(const int inputMonth) inline Month getMonth(const int inputMonth)
{ {
switch (inputMonth) switch (inputMonth)
@@ -333,4 +428,3 @@ namespace Enums {
} }
} }
@@ -1,3 +1,9 @@
/*
* File: InputHelper.h
* Description: Handles input validation and error handling
* Author: Smitha
* Created: 08-Apr-2026
*/
#pragma once #pragma once
#include <iostream> #include <iostream>
#include <limits> #include <limits>
@@ -6,6 +12,14 @@
namespace util namespace util
{ {
/*
* Function: read
* Description: Reads input from console into a variable of type T.
* Parameters:
* value - reference to a variable of type T where the input will be stored
* Returns:
* void - throws runtime_error if input is invalid
*/
template <typename T> template <typename T>
inline void read(T& value) inline void read(T& value)
{ {
@@ -17,11 +31,25 @@ namespace util
} }
} }
/*
* Function: read
* Description: Reads a line of text input from console into a string.
* Parameters:
* value - reference to a string where the input will be stored
* Returns:
* void - no return value
*/
inline void read(std::string& value) inline void read(std::string& value)
{ {
std::getline(std::cin >> std::ws, value); std::getline(std::cin >> std::ws, value);
} }
/*
* Function: pressEnter
* Description: Pauses execution until the user presses Enter.
* Parameters: None
* Returns: void - no return value
*/
inline void pressEnter() inline void pressEnter()
{ {
std::cout << std::endl; std::cout << std::endl;
@@ -1,5 +1,18 @@
/*
* File: OutputHelper.cpp
* Description: Provides functions to help with console output.
* Author: Trenser
* Created: 01-04-2026
*/
#include "outputHelper.h" #include "outputHelper.h"
/*
* Function: clear
* Description: Clears the console screen output.
* Parameters: None
* Returns:
* void - no return value
*/
void util::clear() void util::clear()
{ {
std::cout << "\x1B[2J\x1B[H" << std::flush; std::cout << "\x1B[2J\x1B[H" << std::flush;
@@ -1,3 +1,9 @@
/*
* File: OutputHelper.h
* Description: Provides functions to help with console output.
* Author: Trenser
* Created: 01-04-2026
*/
#pragma once #pragma once
#include <iostream> #include <iostream>
@@ -1,6 +1,20 @@
/*
* File: StringHelper.cpp
* Description: Provides functions to help with string manipulation.
* Author: Trenser
* Created: 10-04-2026
*/
#include "StringHelper.h" #include "StringHelper.h"
#include <cctype> #include <cctype>
/*
* Function: extractNumber
* Description: Extracts and returns the numeric value formed by digits in the input string.
* Parameters:
* input - string containing numeric and non-numeric characters
* Returns:
* int - number extracted from the input string
*/
int util::extractNumber(const std::string& input) int util::extractNumber(const std::string& input)
{ {
int result = 0; int result = 0;
@@ -1,3 +1,9 @@
/*
* File: StringHelper.h
* Description: Provides functions to help with string manipulation.
* Author: Trenser
* Created: 10-04-2026
*/
#pragma once #pragma once
#include <string> #include <string>
@@ -1,18 +1,52 @@
/*
* File: Timestamp.cpp
* Description: Provides a utility class for representing and manipulating time values.
* Supports conversion between string and time formats, duration calculations
* (hours, minutes, seconds), date extraction, and comparison operators.
* Author: Trenser
* Created: 01-Apr-2026
*/
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <stdexcept> #include <stdexcept>
#include "Timestamp.h" #include "Timestamp.h"
/*
* Function: Timestamp
* Description: Default constructor that initializes the timestamp to the current system time.
* Parameters:
* None
* Returns:
* Timestamp object
*/
util::Timestamp::Timestamp() util::Timestamp::Timestamp()
{ {
m_time = std::time(nullptr); m_time = std::time(nullptr);
} }
/*
* Function: Timestamp (overloaded)
* Description: Constructor that initializes the timestamp with a given time value.
* Parameters:
* timeValue - time_t value representing a specific time
* Returns:
* Timestamp object
*/
util::Timestamp::Timestamp(std::time_t timeValue) util::Timestamp::Timestamp(std::time_t timeValue)
{ {
m_time = timeValue; m_time = timeValue;
} }
/*
* Function: fromString
* Description: Creates a Timestamp object from a formatted string.
* Parameters:
* timeString - string in the format "YYYY-MM-DD HH:MM:SS"
* Returns:
* Timestamp object representing the parsed time
* Throws:
* runtime_error if the string format is invalid
*/
util::Timestamp util::Timestamp::fromString(const std::string& timeString) util::Timestamp util::Timestamp::fromString(const std::string& timeString)
{ {
std::tm timeStruct = {}; std::tm timeStruct = {};
@@ -26,6 +60,14 @@ util::Timestamp util::Timestamp::fromString(const std::string& timeString)
return Timestamp(parsedTimestamp); return Timestamp(parsedTimestamp);
} }
/*
* Function: toString
* Description: Converts the Timestamp object into a formatted string.
* Parameters:
* None
* Returns:
* string - formatted as "YYYY-MM-DD HH:MM:SS"
*/
std::string util::Timestamp::toString() const std::string util::Timestamp::toString() const
{ {
std::tm timeStruct = {}; std::tm timeStruct = {};
@@ -35,11 +77,28 @@ std::string util::Timestamp::toString() const
return outputStream.str(); return outputStream.str();
} }
/*
* Function: getDurationInSeconds
* Description: Calculates the duration between two timestamps in seconds.
* Parameters:
* startTimestamp - starting time
* endTimestamp - ending time
* Returns:
* double - duration in seconds
*/
double util::Timestamp::getDurationInSeconds(const Timestamp& startTimestamp, const Timestamp& endTimestamp) double util::Timestamp::getDurationInSeconds(const Timestamp& startTimestamp, const Timestamp& endTimestamp)
{ {
return std::difftime(endTimestamp.m_time, startTimestamp.m_time); return std::difftime(endTimestamp.m_time, startTimestamp.m_time);
} }
/*
* Function: getDateAsInt
* Description: Returns the date portion of the timestamp as an integer in YYYYMMDD format.
* Parameters:
* None
* Returns:
* int - date as YYYYMMDD
*/
int util::Timestamp::getDateAsInt() const int util::Timestamp::getDateAsInt() const
{ {
std::tm timeStruct{}; std::tm timeStruct{};
@@ -50,6 +109,14 @@ int util::Timestamp::getDateAsInt() const
return year * 10000 + month * 100 + day; return year * 10000 + month * 100 + day;
} }
/*
* Function: getMonth
* Description: Extracts the month value from the timestamp.
* Parameters:
* None
* Returns:
* int - month value (1 to 12)
*/
int util::Timestamp::getMonth() const int util::Timestamp::getMonth() const
{ {
std::tm timeStruct{}; std::tm timeStruct{};
@@ -57,6 +124,14 @@ int util::Timestamp::getMonth() const
return timeStruct.tm_mon + 1; return timeStruct.tm_mon + 1;
} }
/*
* Function: getYear
* Description: Extracts the year value from the timestamp.
* Parameters:
* None
* Returns:
* int - year value
*/
int util::Timestamp::getYear() const int util::Timestamp::getYear() const
{ {
std::tm timeStruct{}; std::tm timeStruct{};
@@ -64,6 +139,14 @@ int util::Timestamp::getYear() const
return timeStruct.tm_year + 1900; return timeStruct.tm_year + 1900;
} }
/*
* Function: getDay
* Description: Extracts the day value from the timestamp.
* Parameters:
* None
* Returns:
* int - day of the month
*/
int util::Timestamp::getDay() const int util::Timestamp::getDay() const
{ {
std::tm timeStruct{}; std::tm timeStruct{};
@@ -71,36 +154,94 @@ int util::Timestamp::getDay() const
return timeStruct.tm_mday; return timeStruct.tm_mday;
} }
/*
* Function: getDurationInMinutes
* Description: Calculates the duration between two timestamps in minutes.
* Parameters:
* startTimestamp - starting time
* endTimestamp - ending time
* Returns:
* double - duration in minutes
*/
double util::Timestamp::getDurationInMinutes(const Timestamp& startTimestamp, const Timestamp& endTimestamp) double util::Timestamp::getDurationInMinutes(const Timestamp& startTimestamp, const Timestamp& endTimestamp)
{ {
return getDurationInSeconds(startTimestamp, endTimestamp) / 60.0; return getDurationInSeconds(startTimestamp, endTimestamp) / 60.0;
} }
/*
* Function: getDurationInHours
* Description: Calculates the duration between two timestamps in hours.
* Parameters:
* startTimestamp - starting time
* endTimestamp - ending time
* Returns:
* double - duration in hours
*/
double util::Timestamp::getDurationInHours(const Timestamp& startTimestamp, const Timestamp& endTimestamp) double util::Timestamp::getDurationInHours(const Timestamp& startTimestamp, const Timestamp& endTimestamp)
{ {
return getDurationInSeconds(startTimestamp, endTimestamp) / 3600.0; return getDurationInSeconds(startTimestamp, endTimestamp) / 3600.0;
} }
/*
* Function: operator<
* Description: Compares two timestamps to check if one is earlier than the other.
* Parameters:
* other - Timestamp to compare against
* Returns:
* bool - true if current timestamp is earlier
*/
bool util::Timestamp::operator<(const Timestamp& other) const bool util::Timestamp::operator<(const Timestamp& other) const
{ {
return m_time < other.m_time; return m_time < other.m_time;
} }
/*
* Function: operator>
* Description: Compares two timestamps to check if one is later than the other.
* Parameters:
* other - Timestamp to compare against
* Returns:
* bool - true if current timestamp is later
*/
bool util::Timestamp::operator>(const Timestamp& other) const bool util::Timestamp::operator>(const Timestamp& other) const
{ {
return m_time > other.m_time; return m_time > other.m_time;
} }
/*
* Function: operator<=
* Description: Compares two timestamps to check if one is earlier or equal.
* Parameters:
* other - Timestamp to compare against
* Returns:
* bool - true if current timestamp is earlier or equal
*/
bool util::Timestamp::operator<=(const Timestamp& other) const bool util::Timestamp::operator<=(const Timestamp& other) const
{ {
return m_time <= other.m_time; return m_time <= other.m_time;
} }
/*
* Function: operator>=
* Description: Compares two timestamps to check if one is later or equal.
* Parameters:
* other - Timestamp to compare against
* Returns:
* bool - true if current timestamp is later or equal
*/
bool util::Timestamp::operator>=(const Timestamp& other) const bool util::Timestamp::operator>=(const Timestamp& other) const
{ {
return m_time >= other.m_time; return m_time >= other.m_time;
} }
/*
* Function: operator==
* Description: Compares two timestamps for equality.
* Parameters:
* other - Timestamp to compare against
* Returns:
* bool - true if both timestamps are equal
*/
bool util::Timestamp::operator==(const Timestamp& other) const bool util::Timestamp::operator==(const Timestamp& other) const
{ {
return m_time == other.m_time; return m_time == other.m_time;
@@ -1,3 +1,11 @@
/*
* File: Timestamp.h
* Description: Provides a utility class for representing and manipulating time values.
* Supports conversion between string and time formats, duration calculations
* (hours, minutes, seconds), date extraction, and comparison operators.
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once #pragma once
#include <ctime> #include <ctime>
#include <string> #include <string>
@@ -1,8 +1,24 @@
/*
* File: Validator.cpp
* Description: Validates inputs like phone number, email, password
* Author: Trenser
* Created: 01-Apr-2026
*/
#include <string>
#include <cctype> #include <cctype>
#include "Validator.h" #include "Validator.h"
#include "Employee.h" #include "Employee.h"
#include "ApplicationConfig.h" #include "ApplicationConfig.h"
/*
* Function: isPhoneNumberValid
* Description: Validates whether the given string is a valid phone number.
* Parameters:
* phoneNumber - string containing the phone number to validate
* Returns:
* bool - true if the phone number is valid (10 digits, all numeric), false otherwise
*/
bool util::isPhoneNumberValid(const std::string& phoneNumber) { bool util::isPhoneNumberValid(const std::string& phoneNumber) {
if (phoneNumber.size() != 10) if (phoneNumber.size() != 10)
{ {
@@ -16,6 +32,14 @@ bool util::isPhoneNumberValid(const std::string& phoneNumber) {
); );
} }
/*
* Function: isEmailValid
* Description: Validates whether the given string is a properly formatted email address.
* Parameters:
* email - string containing the email address to validate
* Returns:
* bool - true if the email contains exactly one '@' character and is not at the start or end, false otherwise
*/
bool util::isEmailValid(const std::string& email) { bool util::isEmailValid(const std::string& email) {
size_t index = email.find('@'); size_t index = email.find('@');
if (index == std::string::npos) if (index == std::string::npos)
@@ -33,7 +57,19 @@ bool util::isEmailValid(const std::string& email) {
return true; return true;
} }
/*
* Function: isPasswordValid
* Description: Validates whether the given string meets password requirements.
* Parameters:
* password - string containing the password to validate
* Returns:
* bool - true if the password is valid, false otherwise
* Notes:
* - Must not equal the default password
* - Must be at least 8 characters long
* - Must contain at least one uppercase letter, one lowercase letter, one digit, and one special character
* - Must not contain whitespace
*/
bool util::isPasswordValid(const std::string& password) bool util::isPasswordValid(const std::string& password)
{ {
if (password == Config::Authentication::DEFAULT_PASSWORD) if (password == Config::Authentication::DEFAULT_PASSWORD)
@@ -73,7 +109,16 @@ bool util::isPasswordValid(const std::string& password)
return hasUpper && hasLower && hasDigit && hasSpecial; return hasUpper && hasLower && hasDigit && hasSpecial;
} }
bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map<std::string, std::shared_ptr<Employee>> & employees) /*
* Function: hasActiveEmployeeOfType
* Description: Checks whether there is any active employee of the given employee type.
* Parameters:
* employeeType - the type of employee to check against
* employees - map of employee ID to Employee* objects
* Returns:
* bool - true if an active employee of the given type exists, otherwise false
*/
bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map<std::string, Employee*>& employees)
{ {
for (const auto& employeePair : employees) for (const auto& employeePair : employees)
{ {
@@ -86,7 +131,16 @@ bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::
return false; return false;
} }
bool util::isEmailDuplicate(const std::string& email, const std::map<std::string, std::shared_ptr<Employee>>& employees) /*
* Function: isEmailDuplicate
* Description: Checks if an email already exists among the given employees.
* Parameters:
* email - the email address to check
* employees - map of employee ID to Employee* objects
* Returns:
* bool - true if a duplicate email is found, otherwise false
*/
bool util::isEmailDuplicate(const std::string& email, const std::map<std::string, Employee*>& employees)
{ {
for (const auto& employeePair : employees) for (const auto& employeePair : employees)
{ {
@@ -99,7 +153,16 @@ bool util::isEmailDuplicate(const std::string& email, const std::map<std::string
return false; return false;
} }
bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string, std::shared_ptr<Employee>>& employees) /*
* Function: isPhoneDuplicate
* Description: Checks if a phone number already exists among the given employees.
* Parameters:
* phone - the phone number to check
* employees - map of employee ID to Employee* objects
* Returns:
* bool - true if a duplicate phone number is found, otherwise false
*/
bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string, Employee*>& employees)
{ {
for (const auto& employeePair : employees) for (const auto& employeePair : employees)
{ {
@@ -112,7 +175,16 @@ bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string
return false; return false;
} }
bool util::isPhoneDuplicate(const std::string& phone, const std::vector<std::shared_ptr<const Employee>>& employees) /*
* Function: isPhoneDuplicate (overloaded)
* Description: Checks if a phone number already exists in a vector of employees.
* Parameters:
* phone - the phone number to check
* employees - vector of Employee* pointers
* Returns:
* bool - true if a duplicate phone number is found, otherwise false
*/
bool util::isPhoneDuplicate(const std::string& phone, const std::vector<const Employee*>& employees)
{ {
for (const auto& employee : employees) for (const auto& employee : employees)
{ {
@@ -1,3 +1,9 @@
/*
* File: Validator.h
* Description: Validates inputs like phone number, email, password
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once #pragma once
#include<string> #include<string>
#include<map> #include<map>
@@ -14,8 +20,8 @@ namespace util
bool isPhoneNumberValid(const std::string&); bool isPhoneNumberValid(const std::string&);
bool isEmailValid(const std::string&); bool isEmailValid(const std::string&);
bool isPasswordValid(const std::string&); bool isPasswordValid(const std::string&);
bool hasActiveEmployeeOfType(Enums::EmployeeType, const std::map<std::string, std::shared_ptr<Employee>>&); bool hasActiveEmployeeOfType(Enums::EmployeeType, const std::map<std::string, Employee*>&);
bool isEmailDuplicate(const std::string&, const std::map<std::string, std::shared_ptr<Employee>>&); bool isEmailDuplicate(const std::string&, const std::map<std::string, Employee*>&);
bool isPhoneDuplicate(const std::string&, const std::map<std::string, std::shared_ptr<Employee>>&); bool isPhoneDuplicate(const std::string&, const std::map<std::string, Employee*>&);
bool isPhoneDuplicate(const std::string&, const std::vector<std::shared_ptr<const Employee>>&); bool isPhoneDuplicate(const std::string&, const std::vector<const Employee*>&);
} }
@@ -1,9 +1,24 @@
/*
* File: AdminMenu.cpp
* Description: Handles user-related operations such as creation, authentication, and validation.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream> #include <iostream>
#include "AdminMenu.h" #include "AdminMenu.h"
#include"InputHelper.h" #include"InputHelper.h"
#include"OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h" #include "MenuHelper.h"
/*
* Function: AdminMenu::run
* Description: Starts and manages the administrator menu loop. Continuously displays
* options to the administrator until logout is selected or an exception occurs.
* Parameters:
* None
* Returns:
* None
*/
void AdminMenu::run() void AdminMenu::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -28,6 +43,15 @@ void AdminMenu::run()
} }
} }
/*
* Function: AdminMenu::handleOperation
* Description: Processes the administrators menu choice and executes the corresponding action.
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the administrator chooses to logout
*/
bool AdminMenu::handleOperation(int choice) bool AdminMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -1,14 +1,18 @@
/*
* File: AdminMenu.h
* Description: Declaration of the AdminMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class AdminMenu class AdminMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {}; AdminMenu() :m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -1,3 +1,9 @@
/*
* File: EmployeeMenu.cpp
* Description: Implements the EmployeeMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream> #include <iostream>
#include<iomanip> #include<iomanip>
#include "EmployeeMenu.h" #include "EmployeeMenu.h"
@@ -5,6 +11,14 @@
#include "OutputHelper.h" #include "OutputHelper.h"
#include "MenuHelper.h" #include "MenuHelper.h"
/*
* Function: EmployeeMenu::run
* Description: Starts the employee menu loop and displays available options until logout is selected
* Parameters:
* None
* Returns:
* None
*/
void EmployeeMenu::run() void EmployeeMenu::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -14,7 +28,7 @@ void EmployeeMenu::run()
{ {
int choice; int choice;
util::clear(); util::clear();
std::cout << "Employee Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticket\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notification\n13. View Announcements\n14. Update Profile\n15. View Profile\n16. Exit\nEnter your Choice: "; std::cout << "Employee Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticket\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notifications\n13. View Announcements\n14. Update Profile\n15. View Profile\n16. Exit\nEnter your Choice: ";
util::read(choice); util::read(choice);
if (!handleOperation(choice)) if (!handleOperation(choice))
{ {
@@ -29,6 +43,15 @@ void EmployeeMenu::run()
} }
} }
/*
* Function: EmployeeMenu::handleOperation
* Description: Handles the employees menu choice and executes the corresponding action
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the employee chooses to logout
*/
bool EmployeeMenu::handleOperation(int choice) bool EmployeeMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -1,14 +1,18 @@
/*
* File: EmployeeMenu.h
* Description: Declaration of the EmployeeMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class EmployeeMenu class EmployeeMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
EmployeeMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; EmployeeMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -1,3 +1,9 @@
/*
* File: FinanceExecutiveMenu.cpp
* Description: Implements the FinanceExecutiveMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream> #include <iostream>
#include "FinanceExecutiveMenu.h" #include "FinanceExecutiveMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
@@ -5,6 +11,14 @@
#include "MenuHelper.h" #include "MenuHelper.h"
#include "Timestamp.h" #include "Timestamp.h"
/*
* Function: FinanceExecutiveMenu::run
* Description: Starts the finance executive menu loop and displays available options until logout is selected
* Parameters:
* None
* Returns:
* None
*/
void FinanceExecutiveMenu::run() void FinanceExecutiveMenu::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -14,7 +28,7 @@ void FinanceExecutiveMenu::run()
{ {
int choice; int choice;
util::clear(); util::clear();
std::cout << "Finance Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Generate Payslips\n10. Update Payroll\n11. Update Profile\n12. View Profile \n13. Logout\nEnter your Choice: "; std::cout << "Finance Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notifications\n7. View Announcements\n8. Resolve Ticket\n9. Generate Payslips\n10. Update Payroll\n11. Update Profile\n12. View Profile \n13. Logout\nEnter your Choice: ";
util::read(choice); util::read(choice);
if (!handleOperation(choice)) if (!handleOperation(choice))
{ {
@@ -61,6 +75,15 @@ void FinanceExecutiveMenu::generatePayslips()
util::pressEnter(); util::pressEnter();
} }
/*
* Function: FinanceExecutiveMenu::handleOperation
* Description: Handles the finance executives menu choice and executes the corresponding action
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the finance executive chooses to logout
*/
bool FinanceExecutiveMenu::handleOperation(int choice) bool FinanceExecutiveMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -1,3 +1,9 @@
/*
* File: FinanceExecutiveMenu.h
* Description: Declaration of the FinanceExecutiveMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
#include<memory> #include<memory>
#include<iostream> #include<iostream>
@@ -8,12 +14,11 @@
class FinanceExecutiveMenu class FinanceExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; FinanceExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
void updatePayroll(); void updatePayroll();
void generatePayslips(); void generatePayslips();
}; };
@@ -1,9 +1,23 @@
/*
* File: HRManagerMenu.cpp
* Description: Implements the HRManagerMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream> #include <iostream>
#include "HRManagerMenu.h" #include "HRManagerMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "MenuHelper.h" #include "MenuHelper.h"
/*
* Function: HRManagerMenu::run
* Description: Starts the HR manager menu loop and displays available options until logout is selected
* Parameters:
* None
* Returns:
* None
*/
void HRManagerMenu::run() void HRManagerMenu::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -13,7 +27,7 @@ void HRManagerMenu::run()
{ {
int choice; int choice;
util::clear(); util::clear();
std::cout << "HR Manager Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Update Profile\n12. Deactivate Employee\n13. View Profile\n14. Update Designation\n15. Add Shortlisted Candidate as Employee\n16. Logout\nEnter your Choice: "; std::cout << "HR Manager Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notifications\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Update Profile\n12. Deactivate Employee\n13. View Profile\n14. Update Designation\n15. Add Shortlisted Candidate as Employee\n16. Logout\nEnter your Choice: ";
util::read(choice); util::read(choice);
if (!handleOperation(choice)) if (!handleOperation(choice))
{ {
@@ -28,6 +42,15 @@ void HRManagerMenu::run()
} }
} }
/*
* Function: HRManagerMenu::handleOperation
* Description: Handles the HR managers menu choice and executes the corresponding action
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the HR manager chooses to logout
*/
bool HRManagerMenu::handleOperation(int choice) bool HRManagerMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -1,14 +1,18 @@
/*
* File: HRManagerMenu.h
* Description: Declaration of the EmployeeMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class HRManagerMenu class HRManagerMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
HRManagerMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; HRManagerMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -1,9 +1,23 @@
/*
* File: ITExecutiveMenu.cpp
* Description: Implements the ITExecutiveMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream> #include <iostream>
#include "ITExecutiveMenu.h" #include "ITExecutiveMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "MenuHelper.h" #include "MenuHelper.h"
/*
* Function: ITExecutiveMenu::run
* Description: Starts the IT executive menu loop and displays available options until logout is selected
* Parameters:
* None
* Returns:
* None
*/
void ITExecutiveMenu::run() void ITExecutiveMenu::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -13,7 +27,7 @@ void ITExecutiveMenu::run()
{ {
int choice; int choice;
util::clear(); util::clear();
std::cout << "IT Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Update Profile\n10. View Profile\n11. Logout\nEnter your Choice: "; std::cout << "IT Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notifications\n7. View Announcements\n8. Resolve Ticket\n9. Update Profile\n10. View Profile\n11. Logout\nEnter your Choice: ";
util::read(choice); util::read(choice);
if (!handleOperation(choice)) if (!handleOperation(choice))
{ {
@@ -28,6 +42,15 @@ void ITExecutiveMenu::run()
} }
} }
/*
* Function: ITExecutiveMenu::handleOperation
* Description: Handles the IT executives menu choice and executes the corresponding action
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the IT executive chooses to logout
*/
bool ITExecutiveMenu::handleOperation(int choice) bool ITExecutiveMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -1,14 +1,18 @@
/*
* File: ITExecutiveMenu.h
* Description: Declaration of the ITExecutiveMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class ITExecutiveMenu class ITExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
ITExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; ITExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -1,6 +1,22 @@
/*
* File: MenuHelper.cpp
* Description: Inline functions and utilities for employee management,
* including profile handling, payslip viewing, search,
* and employee activation/deactivation.
* Author: Trenser
* Created: 08-Apr-2026
*/
#include <stdexcept> #include <stdexcept>
#include "MenuHelper.h" #include "MenuHelper.h"
/*
* Function: getEmployeeType
* Description: Retrieves a valid employee type based on the authority of the current user
* Parameters:
* employeeType - the type of the employee requesting to create another employee
* Returns:
* Enums::EmployeeType - selected employee type or INVALID if choice is invalid
*/
static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType) static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
{ {
int choice; int choice;
@@ -50,6 +66,13 @@ static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
return Enums::EmployeeType::INVALID; return Enums::EmployeeType::INVALID;
} }
/*
* Function: getEmployeeDesignation
* Description: Retrieves the designation (Senior or Junior) for a new employee
* Parameters: None
* Returns:
* Enums::EmployeeDesignation - selected designation or INVALID if choice is invalid
*/
static Enums::EmployeeDesignation getEmployeeDesignation() static Enums::EmployeeDesignation getEmployeeDesignation()
{ {
int choice; int choice;
@@ -70,9 +93,16 @@ static Enums::EmployeeDesignation getEmployeeDesignation()
} }
} }
void createEmployee(std::shared_ptr<ZenvyController> controller) /*
* Function: createEmployee
* Description: Creates a new employee record and adds it to the system
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
void createEmployee(ZenvyController* m_zenvyController)
{ {
auto currentEmployee = controller->getCurrentEmployee(); auto currentEmployee = m_zenvyController->getCurrentEmployee();
Enums::EmployeeType employeeType = getEmployeeType(currentEmployee->getEmployeeType()); Enums::EmployeeType employeeType = getEmployeeType(currentEmployee->getEmployeeType());
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID; Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
std::string name, email, phone; std::string name, email, phone;
@@ -98,12 +128,19 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
util::read(email); util::read(email);
std::cout << "Enter Phone: "; std::cout << "Enter Phone: ";
util::read(phone); util::read(phone);
controller->createEmployee(employeeType, employeeDesignation, email, name, phone); m_zenvyController->createEmployee(employeeType, employeeDesignation, email, name, phone);
std::cout << "\nCreated Employee Successfully."; std::cout << "\nCreated Employee Successfully.";
util::pressEnter(); util::pressEnter();
} }
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController) /*
* Function: updateDesignation
* Description: Updates the designation of an existing employee
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
void updateDesignation(ZenvyController* m_zenvyController)
{ {
std::string selectedEmployeeId = selectEmployeeId(m_zenvyController->getEmployees(Enums::EmployeeType::GENERAL)); std::string selectedEmployeeId = selectEmployeeId(m_zenvyController->getEmployees(Enums::EmployeeType::GENERAL));
if (selectedEmployeeId.empty()) if (selectedEmployeeId.empty())
@@ -123,7 +160,14 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
} }
} }
void displayCandidateDetails(const std::vector<std::shared_ptr<Candidate>>& shorlistedCandidates) /*
* Function: displayCandidateDetails
* Description: Displays details of shortlisted candidates
* Parameters:
* shorlistedCandidates - vector of candidate pointers to display
* Returns: void
*/
void displayCandidateDetails(const std::vector<Candidate*> shorlistedCandidates)
{ {
util::clear(); util::clear();
std::cout << std::left std::cout << std::left
@@ -148,12 +192,19 @@ void displayCandidateDetails(const std::vector<std::shared_ptr<Candidate>>& shor
} }
} }
void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& controller) /*
* Function: addShortlistedCandidateAsEmployee
* Description: Converts a shortlisted candidate into an employee record
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
void addShortlistedCandidateAsEmployee(const ZenvyController* m_zenvyController)
{ {
int index; int index;
std::string name, email, phone; std::string name, email, phone;
util::clear(); util::clear();
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates = controller->getShorlistedCandidates(); std::vector<Candidate*> shortlistedCandidates = m_zenvyController->getShorlistedCandidates();
if (shortlistedCandidates.empty()) if (shortlistedCandidates.empty())
{ {
std::cout << "No candidates Found!"; std::cout << "No candidates Found!";
@@ -163,13 +214,13 @@ void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& c
displayCandidateDetails(shortlistedCandidates); displayCandidateDetails(shortlistedCandidates);
std::cout << "Enter the Index: "; std::cout << "Enter the Index: ";
util::read(index); util::read(index);
auto currentEmployee = controller->getCurrentEmployee(); auto currentEmployee = m_zenvyController->getCurrentEmployee();
Enums::EmployeeType employeeType; Enums::EmployeeType employeeType;
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID; Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
if (index > 0 && index <= shortlistedCandidates.size()) if (index > 0 && index <= shortlistedCandidates.size())
{ {
employeeType = getEmployeeType(currentEmployee->getEmployeeType()); employeeType = getEmployeeType(currentEmployee->getEmployeeType());
std::shared_ptr<Candidate> candidate = shortlistedCandidates[index - 1]; Candidate* candidate = shortlistedCandidates[index - 1];
switch (employeeType) switch (employeeType)
{ {
case Enums::EmployeeType::INVALID: case Enums::EmployeeType::INVALID:
@@ -190,7 +241,7 @@ void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& c
util::read(email); util::read(email);
name = candidate->getCandidateName(); name = candidate->getCandidateName();
phone = candidate->getCandidatePhone(); phone = candidate->getCandidatePhone();
controller->createEmployee(employeeType, employeeDesignation, email, name, phone); m_zenvyController->createEmployee(employeeType, employeeDesignation, email, name, phone);
candidate->setCandidateStatus(Enums::CandidateStatus::HIRED); candidate->setCandidateStatus(Enums::CandidateStatus::HIRED);
std::cout << "\nCreated Employee Successfully."; std::cout << "\nCreated Employee Successfully.";
util::pressEnter(); util::pressEnter();
+88 -25
View File
@@ -1,6 +1,13 @@
/*
* File: MenuHelper.h
* Description: Inline functions and utilities for employee management,
* including profile handling, payslip viewing, search,
* and employee activation/deactivation.
* Author: Trenser
* Created: 08-Apr-2026
*/
#pragma once #pragma once
#include <map> #include <map>
#include <memory>
#include <vector> #include <vector>
#include <string> #include <string>
#include <iostream> #include <iostream>
@@ -15,12 +22,21 @@
#include "MenuHelper.h" #include "MenuHelper.h"
#include "Validator.h" #include "Validator.h"
void createEmployee(std::shared_ptr<ZenvyController> controller); void createEmployee(ZenvyController* m_zenvyController);
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController); void updateDesignation(ZenvyController* m_zenvyController);
void displayCandidateDetails(const std::vector<const Candidate*> shorlistedCandidates);
void addShortlistedCandidateAsEmployee(const ZenvyController* m_zenvyController);
inline void viewPayslipHistory(std::shared_ptr<ZenvyController> controller) /*
* Function: viewPayslipHistory
* Description: Displays the payslip history of the current employee
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void viewPayslipHistory(ZenvyController* m_zenvyController)
{ {
auto employeePayslips = controller->getCurrentEmployee()->getEmployeePayslips(); auto& employeePayslips = m_zenvyController->getCurrentEmployee()->getEmployeePayslips();
util::clear(); util::clear();
if (employeePayslips.empty()) if (employeePayslips.empty())
{ {
@@ -51,10 +67,17 @@ inline void viewPayslipHistory(std::shared_ptr<ZenvyController> controller)
util::pressEnter(); util::pressEnter();
} }
inline void viewProfile(std::shared_ptr<ZenvyController> controller) /*
* Function: viewProfile
* Description: Displays the profile details of the current employee
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void viewProfile(ZenvyController* m_zenvyController)
{ {
util::clear(); util::clear();
std::shared_ptr<const Employee> currentEmployee = controller->getCurrentEmployee(); const Employee* currentEmployee = m_zenvyController->getCurrentEmployee();
if (currentEmployee) if (currentEmployee)
{ {
std::cout << std::left std::cout << std::left
@@ -64,7 +87,7 @@ inline void viewProfile(std::shared_ptr<ZenvyController> controller)
<< "Email: " << currentEmployee->getEmployeeEmail() << std::endl << "Email: " << currentEmployee->getEmployeeEmail() << std::endl
<< "Phone: " << currentEmployee->getEmployeePhone() << std::endl; << "Phone: " << currentEmployee->getEmployeePhone() << std::endl;
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::GENERAL) { if (currentEmployee->getEmployeeType() == Enums::EmployeeType::GENERAL) {
if (auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(currentEmployee)) if (auto generalEmployee = dynamic_cast<const GeneralEmployee*>(currentEmployee))
{ {
std::cout << "Designation: " << Enums::getEmployeeDesignationString(generalEmployee->getDesignation()) << std::endl; std::cout << "Designation: " << Enums::getEmployeeDesignationString(generalEmployee->getDesignation()) << std::endl;
} }
@@ -94,10 +117,14 @@ inline void viewProfile(std::shared_ptr<ZenvyController> controller)
} }
} }
void displayCandidateDetails(const std::vector<std::shared_ptr<const Candidate>>& shorlistedCandidates); /*
void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& controller); * Function: updateProfile
* Description: Allows the current employee to update their profile information
inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController) * Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void updateProfile(ZenvyController* m_zenvyController)
{ {
int choice; int choice;
std::string name, phone; std::string name, phone;
@@ -148,10 +175,18 @@ inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
} }
} }
inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>> allEmployees) /*
* Function: selectEmployeeId
* Description: Displays a list of employees and allows selection by index
* Parameters:
* allEmployees - vector of employee pointers to choose from
* Returns:
* string - selected employee ID
*/
inline std::string selectEmployeeId(const std::vector<const Employee*>& allEmployees)
{ {
int choice; int choice;
std::map<int, std::shared_ptr<const Employee>> employeeList; std::map<int, const Employee*> employeeList;
int index = 0; int index = 0;
util::clear(); util::clear();
if (allEmployees.empty()) if (allEmployees.empty())
@@ -177,7 +212,7 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
<< std::setw(20) << "Employee Designation" << std::endl; << std::setw(20) << "Employee Designation" << std::endl;
for (const auto& employee : employeeList) for (const auto& employee : employeeList)
{ {
auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(employee.second); auto generalEmployee = dynamic_cast<const GeneralEmployee*>(employee.second);
std::cout << std::left std::cout << std::left
<< std::setw(10) << employee.first << std::setw(10) << employee.first
<< std::setw(15) << employee.second->getId() << std::setw(15) << employee.second->getId()
@@ -209,14 +244,21 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
} }
} }
inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller) /*
* Function: deactivateEmployee
* Description: Deactivates an employee based on selection
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void deactivateEmployee(const ZenvyController* m_zenvyController)
{ {
std::string selectedEmployeeId = selectEmployeeId(controller->getEmployees()); std::string selectedEmployeeId = selectEmployeeId(m_zenvyController->getEmployees());
if (selectedEmployeeId.empty()) if (selectedEmployeeId.empty())
{ {
return; return;
} }
if (controller->deactivateEmployee(selectedEmployeeId)) if (m_zenvyController->deactivateEmployee(selectedEmployeeId))
{ {
std::cout << "Employee deactivated successfully\n"; std::cout << "Employee deactivated successfully\n";
util::pressEnter(); util::pressEnter();
@@ -228,7 +270,14 @@ inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controlle
} }
} }
inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController) /*
* Function: viewEmployees
* Description: Displays a list of all employees in the system
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void viewEmployees(ZenvyController* m_zenvyController)
{ {
util::clear(); util::clear();
std::cout << "Employee List\n"; std::cout << "Employee List\n";
@@ -261,13 +310,20 @@ inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
util::pressEnter(); util::pressEnter();
} }
inline void searchEmployee(std::shared_ptr<ZenvyController> m_zenvyController) /*
* Function: searchEmployee
* Description: Searches for employees by name and displays matching results
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void searchEmployee(ZenvyController* m_zenvyController)
{ {
std::string name; std::string name;
util::clear(); util::clear();
std::cout << "Enter Employee Name: "; std::cout << "Enter Employee Name: ";
util::read(name); util::read(name);
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name); std::pair<Enums::EmployeeType, std::vector<const Employee*>> searchResults = m_zenvyController->searchEmployee(name);
if (!(searchResults.second).empty()) if (!(searchResults.second).empty())
{ {
std::cout << std::left std::cout << std::left
@@ -333,7 +389,14 @@ inline void searchEmployee(std::shared_ptr<ZenvyController> m_zenvyController)
util::pressEnter(); util::pressEnter();
} }
inline void viewPayslip(std::shared_ptr<ZenvyController> controller) /*
* Function: viewPayslip
* Description: Displays the payslip of the current employee for a given month and year
* Parameters:
* m_zenvyController - pointer to the ZenvyController managing employees
* Returns: void
*/
inline void viewPayslip(ZenvyController* m_zenvyController)
{ {
int year, month; int year, month;
util::clear(); util::clear();
@@ -341,20 +404,20 @@ inline void viewPayslip(std::shared_ptr<ZenvyController> controller)
util::read(year); util::read(year);
std::cout << "Enter the month: "; std::cout << "Enter the month: ";
util::read(month); util::read(month);
auto employee = controller->getCurrentEmployee(); auto employee = m_zenvyController->getCurrentEmployee();
if (!employee) if (!employee)
{ {
std::cout << "No authenticated employee.\n"; std::cout << "No authenticated employee.\n";
util::pressEnter(); util::pressEnter();
return; return;
} }
auto result = controller->getPayslipForMonth(employee->getId(), year, month); auto result = m_zenvyController->getPayslipForMonth(employee->getId(), year, month);
auto payroll = result.first; auto payroll = result.first;
auto payslip = result.second; auto payslip = result.second;
if (payroll && payslip) if (payroll && payslip)
{ {
util::clear(); util::clear();
std::cout << "Payslip for " << employee->getEmployeeName() << " (" << year << "-" << std::setw(2) << std::setfill('0') << month << ")\n\n"; std::cout << "Payslip for " << employee->getEmployeeName() << " (" << year << "-" << std::setw(2) << month << ")\n\n";
std::cout << "Basic Salary : " << payroll->getBasicSalary() << "\n"; std::cout << "Basic Salary : " << payroll->getBasicSalary() << "\n";
std::cout << "House Rent Allowance : " << payroll->getHouseRentAllowance() << "\n"; std::cout << "House Rent Allowance : " << payroll->getHouseRentAllowance() << "\n";
std::cout << "Food Allowance : " << payroll->getFoodAllowance() << "\n"; std::cout << "Food Allowance : " << payroll->getFoodAllowance() << "\n";
@@ -1,9 +1,23 @@
/*
* File: TalentExecutiveMenu.cpp
* Description: Implements the TalentExecutiveMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream> #include <iostream>
#include "TalentExecutiveMenu.h" #include "TalentExecutiveMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
#include "MenuHelper.h" #include "MenuHelper.h"
/*
* Function: TalentExecutiveMenu::run
* Description: Starts the talent executive menu loop and displays available options until logout is selected
* Parameters:
* None
* Returns:
* None
*/
void TalentExecutiveMenu::run() void TalentExecutiveMenu::run()
{ {
bool isMenuActive = true; bool isMenuActive = true;
@@ -13,7 +27,7 @@ void TalentExecutiveMenu::run()
{ {
int choice; int choice;
util::clear(); util::clear();
std::cout << "Talent Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create New Job\n9. View Job Opening\n10. Add Candidate\n11. UpdateCandidate Status\n12. View Shortlisted Candidate\n13. Update Profile\n14. View Profile\n15. Logout\nEnter your Choice: "; std::cout << "Talent Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notifications\n7. View Announcements\n8. Create New Job\n9. View Job Opening\n10. Add Candidate\n11. Update Candidate Status\n12. View Shortlisted Candidate\n13. Update Profile\n14. View Profile\n15. Logout\nEnter your Choice: ";
util::read(choice); util::read(choice);
if (!handleOperation(choice)) if (!handleOperation(choice))
{ {
@@ -28,6 +42,15 @@ void TalentExecutiveMenu::run()
} }
} }
/*
* Function: TalentExecutiveMenu::handleOperation
* Description: Handles the talent executives menu choice and executes the corresponding action
* Parameters:
* choice - integer representing the selected menu option
* Returns:
* true - if the menu should remain active
* false - if the talent executive chooses to logout
*/
bool TalentExecutiveMenu::handleOperation(int choice) bool TalentExecutiveMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
@@ -1,14 +1,18 @@
/*
* File: TalentExecutiveMenu.h
* Description: Declaration of the TalentExecutiveMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class TalentExecutiveMenu class TalentExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
TalentExecutiveMenu() : m_zenvyController(std::make_shared < ZenvyController>()) {}; TalentExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };

Some files were not shown because too many files have changed in this diff Show More