11 Commits

Author SHA1 Message Date
joelthomastrenser 1e6fc4e7bd Merged PR 952: SRS01 Authentication
Implemented Authentication Logic

Related work items: #930, #932, #933, #935, #936
2026-04-17 13:28:49 +05:30
Ajmal Jalaludeen 853ed05e8d Corrected date format and removed unwanted spaces across all files. 2026-04-13 10:07:20 +05:30
Tinu Johnson 85f97f30f9 Add missing header 2026-04-13 09:56:41 +05:30
Tinu Johnson 83f1c4183c Add destructor in datastore 2026-04-13 09:40:34 +05:30
Tinu Johnson 75b69f8c11 Convert shared pointer to raw pointer 2026-04-13 09:40:31 +05:30
joelthomastrenser 7e0becaa3e Merged PR 949: Add files and function header documentation 2026-04-08 17:32:07 +05:30
Jissin Sam Mathew 6c05d2b352 Add files and function header documentation across Views 2026-04-08 17:29:21 +05:30
Ajmal Jalaludeen 2757e5ca98 Add file and function header documentation across Controller, DataStore and Utility files 2026-04-08 17:28:07 +05:30
Princy Jerin 21549b4c24 Add file and function header documentation across Model files 2026-04-08 17:26:20 +05:30
Tinu Johnson 9a791eadcd Add file and function header documentation across Model files 2026-04-08 17:24:12 +05:30
joelthomastrenser def0f4022b Add file and function header documentation across Services and Main files 2026-04-08 17:21:41 +05:30
117 changed files with 1560 additions and 1754 deletions
-3
View File
@@ -426,6 +426,3 @@ FodyWeavers.xsd
*.msix
*.msm
*.msp
# CSV Files
*.csv
@@ -1,28 +0,0 @@
#include "pch.h"
#include "FileIO.h"
std::vector<std::string> FileIO::readAllLines(const std::string& path)
{
std::ifstream file(path);
if (!file.is_open())
{
std::ofstream newFile(path);
newFile.close();
file.open(path);
} std::vector<std::string> lines;
std::string line;
while (std::getline(file, line))
lines.push_back(line);
return lines;
}
void FileIO::writeAllLines(const std::string& path,
const std::vector<std::string>& lines)
{
std::ofstream file(path, std::ios::trunc);
if (!file.is_open())
throw std::runtime_error("Failed to open file " + path);
for (const auto& line : lines)
file << line << '\n';
}
@@ -1,18 +0,0 @@
#pragma once
#include<memory>
#include<vector>
#include<fstream>
#include<string>
#include<stdexcept>
#ifdef TRENSERFILEMANAGER_EXPORTS
#define TRENSERFILEMANAGER_API __declspec(dllexport)
#else
#define TRENSERFILEMANAGER_API __declspec(dllimport)
#endif
class TRENSERFILEMANAGER_API FileIO {
public:
static std::vector<std::string> readAllLines(const std::string& path);
static void writeAllLines(const std::string& path, const std::vector<std::string>& lines);
};
@@ -1,41 +0,0 @@
#pragma once
#include "FileIO.h"
template <typename T> using objects = std::map<std::string, std::shared_ptr<T>>;
template <typename T>
class FileManager
{
private:
std::string m_filePath;
public:
FileManager() : m_filePath("") {}
FileManager(const std::string& filePath) : m_filePath(filePath) {}
objects<T> load();
void save(const objects<T>&);
};
template <typename T>
objects<T> FileManager<T>::load()
{
objects<T> records;
auto lines = FileIO::readAllLines(m_filePath);
for (const auto& record : lines)
{
auto object = T::deserialize(record);
records[object->getId()] = object;
}
return records;
}
template <typename T>
void FileManager<T>::save(const objects<T>& records)
{
std::vector<std::string> lines;
for (const auto& recordPair : records)
{
lines.push_back(recordPair.second->serialize());
}
FileIO::writeAllLines(m_filePath, lines);
}
@@ -135,14 +135,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="FileIO.h" />
<ClInclude Include="FileManager.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="FileIO.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@@ -21,12 +21,6 @@
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FileManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FileIO.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -35,8 +29,5 @@
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileIO.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
@@ -9,10 +9,5 @@
// add headers that you want to pre-compile here
#include "framework.h"
#include<memory>
#include<vector>
#include<fstream>
#include<string>
#include<stdexcept>
#endif //PCH_H
@@ -1,5 +1,12 @@
/*
* File: Trenser.Zenvy.cpp
* Description: Zenvy Main
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "UserInterface.h"
#include "FileManager.h"
int main()
{
UserInterface userInterFace;
@@ -102,17 +102,12 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)models;$(ProjectDir)controllers;$(ProjectDir)services;$(ProjectDir)utilities;$(ProjectDir)factories;$(ProjectDir)datastores;$(ProjectDir)views;%(AdditionalIncludeDirectories);..\..\Trenser.FileManager\Trenser.FileManager</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)models;$(ProjectDir)controllers;$(ProjectDir)services;$(ProjectDir)utilities;$(ProjectDir)factories;$(ProjectDir)datastores;$(ProjectDir)views;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\Trenser.FileManager\$(IntDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Trenser.FileManager.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "..\..\Trenser.FileManager\$(IntDir)Trenser.FileManager.dll" "$(OutDir)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -122,17 +117,11 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>;..\..\Trenser.FileManager\Trenser.FileManager</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\Trenser.FileManager\$(IntDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Trenser.FileManager.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "..\..\Trenser.FileManager\$(IntDir)Trenser.FileManager.dll" "$(OutDir)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="controllers\ZenvyController.cpp" />
@@ -161,7 +150,7 @@
<ClCompile Include="services\AttendanceManagementService.cpp" />
<ClCompile Include="services\AuthenticationManagementService.cpp" />
<ClCompile Include="services\BookingManagementService.cpp" />
<ClCompile Include="services\EmployeeManagementService.cpp" />
<ClCompile Include="services\EmployeeManagememtService.cpp" />
<ClCompile Include="services\LeaveManagementService.cpp" />
<ClCompile Include="services\LogService.cpp" />
<ClCompile Include="services\NotificationManagementService.cpp" />
@@ -173,11 +162,9 @@
<ClCompile Include="models\Employee.cpp" />
<ClCompile Include="models\HRManager.cpp" />
<ClCompile Include="Trenser.Zenvy.cpp" />
<ClCompile Include="utilities\AuthorizationHelper.cpp" />
<ClCompile Include="utilities\Enums.cpp" />
<ClCompile Include="utilities\InputHelper.cpp" />
<ClCompile Include="utilities\OutputHelper.cpp" />
<ClCompile Include="utilities\StringHelper.cpp" />
<ClCompile Include="utilities\Timestamp.cpp" />
<ClCompile Include="utilities\Validator.cpp" />
<ClCompile Include="views\AdminMenu.cpp" />
@@ -185,7 +172,6 @@
<ClCompile Include="views\FinanceExecutiveMenu.cpp" />
<ClCompile Include="views\HRManagerMenu.cpp" />
<ClCompile Include="views\ITExecutiveMenu.cpp" />
<ClCompile Include="views\MenuHelper.cpp" />
<ClCompile Include="views\TalentExecutiveMenu.cpp" />
<ClCompile Include="views\TeamExecutiveMenu.cpp" />
<ClCompile Include="views\TeamLeadMenu.cpp" />
@@ -218,7 +204,7 @@
<ClInclude Include="services\AttendanceManagementService.h" />
<ClInclude Include="services\AuthenticationManagementService.h" />
<ClInclude Include="services\BookingManagementService.h" />
<ClInclude Include="services\EmployeeManagementService.h" />
<ClInclude Include="services\EmployeeManagememtService.h" />
<ClInclude Include="services\LeaveManagementService.h" />
<ClInclude Include="services\LogService.h" />
<ClInclude Include="services\NotificationManagementService.h" />
@@ -226,11 +212,9 @@
<ClInclude Include="services\TalentAcquisitionManagementService.h" />
<ClInclude Include="services\TeamManagementService.h" />
<ClInclude Include="services\TicketManagementService.h" />
<ClInclude Include="utilities\AuthorizationHelper.h" />
<ClInclude Include="utilities\Enums.h" />
<ClInclude Include="utilities\InputHelper.h" />
<ClInclude Include="utilities\OutputHelper.h" />
<ClInclude Include="utilities\StringHelper.h" />
<ClInclude Include="utilities\Timestamp.h" />
<ClInclude Include="utilities\Validator.h" />
<ClInclude Include="views\AdminMenu.h" />
@@ -238,7 +222,6 @@
<ClInclude Include="views\FinanceExecutiveMenu.h" />
<ClInclude Include="views\HRManagerMenu.h" />
<ClInclude Include="views\ITExecutiveMenu.h" />
<ClInclude Include="views\MenuHelper.h" />
<ClInclude Include="views\TalentExecutiveMenu.h" />
<ClInclude Include="views\TeamExecutiveMenu.h" />
<ClInclude Include="views\TeamLeadMenu.h" />
@@ -39,6 +39,9 @@
<ClCompile Include="services\AuthenticationManagementService.cpp">
<Filter>Services</Filter>
</ClCompile>
<ClCompile Include="services\EmployeeManagememtService.cpp">
<Filter>Services</Filter>
</ClCompile>
<ClCompile Include="services\AttendanceManagementService.cpp">
<Filter>Services</Filter>
</ClCompile>
@@ -189,23 +192,14 @@
<ClCompile Include="services\ApplicationConfig.cpp">
<Filter>Services</Filter>
</ClCompile>
<ClCompile Include="services\EmployeeManagementService.cpp">
<Filter>Services</Filter>
</ClCompile>
<ClCompile Include="views\MenuHelper.cpp">
<Filter>Views</Filter>
</ClCompile>
<ClCompile Include="utilities\AuthorizationHelper.cpp">
<Filter>Services</Filter>
</ClCompile>
<ClCompile Include="utilities\StringHelper.cpp">
<Filter>Utilities</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="services\AuthenticationManagementService.h">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\EmployeeManagememtService.h">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\TicketManagementService.h">
<Filter>Services</Filter>
</ClInclude>
@@ -344,18 +338,6 @@
<ClInclude Include="services\ApplicationConfig.h">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="services\EmployeeManagementService.h">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="views\MenuHelper.h">
<Filter>Views</Filter>
</ClInclude>
<ClInclude Include="utilities\AuthorizationHelper.h">
<Filter>Services</Filter>
</ClInclude>
<ClInclude Include="utilities\StringHelper.h">
<Filter>Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClInclude Include="models\Employee.h">
@@ -1,53 +1,68 @@
/*
* File: ZenvyController.cpp
* Description : Controls data flow between UI and Service Layers.
* Author: Trenser
* Created : 01-Apr-2026
*/
#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)
{
return m_authenticationManagementService->login(email, password);
}
/*
* 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::logout()
{
m_authenticationManagementService->logout();
}
/*
* Function: changePassword
* Description: updates the password of the currently authenticated employee.
* Parameters:
* password - the new password to be set for the employee
* Returns:
* void - no return value
*/
void ZenvyController::changePassword(const std::string& password)
{
m_authenticationManagementService->changePassword(password);
}
//Employee Management
void ZenvyController::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone)
ZenvyController::~ZenvyController()
{
m_employeeManagementService->createEmployee(employeeType, employeeDesignation, email, name, phone);
}
bool ZenvyController::deactivateEmployee(const std::string& id)
{
return m_employeeManagementService->deactivateEmployee(id);
}
void ZenvyController::updateProfile(const std::string& name, const std::string& phone)
{
m_employeeManagementService->updateProfile(name,phone);
}
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);
}
std::shared_ptr<const Employee> ZenvyController::getCurrentEmployee()
{
return m_employeeManagementService->getCurrentEmployee();
}
Employees ZenvyController::getEmployees()
{
return m_employeeManagementService->getEmployees();
}
void ZenvyController::loadStates()
{
m_employeeManagementService->loadEmployees();
delete m_authenticationManagementService;
delete m_attendanceManagementService;
delete m_bookingManagementService;
delete m_employeeManagememtService;
delete m_leaveManagementService;
delete m_notificationManagementService;
delete m_payslipManagementService;
delete m_talentAcquisitionManagementService;
delete m_teamManagementService;
delete m_ticketManagementService;
}
@@ -1,10 +1,16 @@
/*
* File: ZenvyController.h
* Description : Controls data flow between UI and Service Layers.
* Author: Trenser
* Created : 01-Apr-2026
*/
#pragma once
#include <memory>
#include <utility>
#include "AuthenticationManagementService.h"
#include "AttendanceManagementService.h"
#include "BookingManagementService.h"
#include "EmployeeManagementService.h"
#include "EmployeeManagememtService.h"
#include "LeaveManagementService.h"
#include "NotificationManagementService.h"
#include "PayslipManagementService.h"
@@ -16,44 +22,30 @@
class ZenvyController
{
private:
std::shared_ptr<AuthenticationManagementService> m_authenticationManagementService;
std::shared_ptr<AttendanceManagementService> m_attendanceManagementService;
std::shared_ptr<BookingManagementService> m_bookingManagementService;
std::shared_ptr<EmployeeManagementService> m_employeeManagementService;
std::shared_ptr<LeaveManagementService> m_leaveManagementService;
std::shared_ptr<NotificationManagementService> m_notificationManagementService;
std::shared_ptr<PayslipManagementService> m_payslipManagementService;
std::shared_ptr<TalentAcquisitionManagementService> m_talentAcquisitionManagementService;
std::shared_ptr<TeamManagementService> m_teamManagementService;
std::shared_ptr<TicketManagementService> m_ticketManagementService;
AuthenticationManagementService* m_authenticationManagementService;
AttendanceManagementService* m_attendanceManagementService;
BookingManagementService* m_bookingManagementService;
EmployeeManagememtService* m_employeeManagememtService;
LeaveManagementService* m_leaveManagementService;
NotificationManagementService* m_notificationManagementService;
PayslipManagementService* m_payslipManagementService;
TalentAcquisitionManagementService* m_talentAcquisitionManagementService;
TeamManagementService* m_teamManagementService;
TicketManagementService* m_ticketManagementService;
public:
ZenvyController() :
m_authenticationManagementService(std::make_shared<AuthenticationManagementService>()),
m_attendanceManagementService(std::make_shared<AttendanceManagementService>()),
m_bookingManagementService(std::make_shared<BookingManagementService>()),
m_employeeManagementService(std::make_shared<EmployeeManagementService>()),
m_leaveManagementService(std::make_shared<LeaveManagementService>()),
m_notificationManagementService(std::make_shared<NotificationManagementService>()),
m_payslipManagementService(std::make_shared<PayslipManagementService>()),
m_talentAcquisitionManagementService(std::make_shared<TalentAcquisitionManagementService>()),
m_teamManagementService(std::make_shared<TeamManagementService>()),
m_ticketManagementService(std::make_shared<TicketManagementService>()) {};
//Authentication
AuthenticationDTO login(const std::string& email, const std::string& password);
void logout();
void changePassword(const std::string&);
//Employee Management
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
bool deactivateEmployee(const std::string&);
Employees getEmployees();
std::shared_ptr<const Employee> getCurrentEmployee();
void updateProfile(const std::string&,const std::string&);
//Payslip management
void updateSalary(const std::string&, double, double, double, double, double);
//File Management
void loadStates();
};
ZenvyController() :
m_authenticationManagementService(new AuthenticationManagementService()),
m_attendanceManagementService(new AttendanceManagementService()),
m_bookingManagementService(new BookingManagementService()),
m_employeeManagememtService(new EmployeeManagememtService()),
m_leaveManagementService(new LeaveManagementService()),
m_notificationManagementService(new NotificationManagementService()),
m_payslipManagementService(new PayslipManagementService()),
m_talentAcquisitionManagementService(new TalentAcquisitionManagementService()),
m_teamManagementService(new TeamManagementService()),
m_ticketManagementService(new TicketManagementService()) {};
AuthenticationDTO login(const std::string& email, const std::string& password);
void logout();
void changePassword(const std::string&);
~ZenvyController();
};
@@ -1,5 +1,20 @@
/*
* File: DataStore.cpp
* Description: Central Storage for all the System Data.
* Author: Trenser
* Created: 01-Apr-2026
*/
#include "DataStore.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()
{
@@ -7,24 +22,91 @@ DataStore& DataStore::getInstance()
return dataStore;
}
/*
* Function: getLogs
* Description: retrieves the log map containing system logs.
* Parameters:
* None
* Returns:
* logMap& - reference to the log map.
*/
logMap& DataStore::getLogs()
{
return m_logs;
}
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee()
/*
* Function: getAuthenticatedEmployee
* Description: returns the currently authenticated employee.
* Parameters:
* None
* Returns:
* std::shared_ptr<Employee>& - reference to the authenticated employee object.
*/
Employee*& DataStore::getAuthenticatedEmployee()
{
return m_authenticatedEmployee;
}
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee)
/*
* Function: setAuthenticatedEmployee
* Description: sets the currently authenticated employee.
* Parameters:
* authenticatedEmployee - shared pointer to the employee object to be set as authenticated.
* Returns:
* void - no return value.
*/
void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee)
{
m_authenticatedEmployee = authenticatedEmployee;
}
/*
* Function: getEmployees
* Description: retrieves the employee map containing all employees.
* Parameters:
* None
* Returns:
* employeeMap& - reference to the employee map.
*/
employeeMap& DataStore::getEmployees()
{
return m_employees;
}
/*
* Function: getAuthenticatedUser
* Description: alias for getAuthenticatedEmployee, returns the currently authenticated employee.
* Parameters:
* None
* Returns:
* std::shared_ptr<Employee>& - reference to the authenticated employee object.
*/
Employee* DataStore::getAuthenticatedUser()
{
return m_authenticatedEmployee;
}
DataStore::~DataStore()
{
for (auto& pair : m_employees)
{
delete pair.second;
}
m_employees.clear();
for (auto& pair : m_logs)
{
delete pair.second;
}
m_logs.clear();
if (m_authenticatedEmployee)
{
delete m_authenticatedEmployee;
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
#include <memory>
#include <map>
#include "Employee.h"
#include "Log.h"
@@ -19,16 +25,16 @@
#include "Announcement.h"
#include "Faq.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>;
using employeeMap = std::map<std::string,Employee*>;
using logMap = std::map<util::Timestamp, Log*>;
class DataStore
{
private:
std::shared_ptr<Employee> m_authenticatedEmployee;
Employee* m_authenticatedEmployee;
employeeMap m_employees;
logMap m_logs;
DataStore() = default;
DataStore() : m_authenticatedEmployee(nullptr) {};
public:
static DataStore& getInstance();
DataStore(const DataStore&) = delete;
@@ -36,7 +42,9 @@ public:
DataStore(DataStore&&) = delete;
DataStore& operator=(DataStore&&) = delete;
employeeMap& getEmployees();
Employee* getAuthenticatedUser();
logMap& getLogs();
std::shared_ptr<Employee>& getAuthenticatedEmployee();
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
Employee*& getAuthenticatedEmployee();
void setAuthenticatedEmployee(Employee*);
~DataStore();
};
@@ -1,13 +1,30 @@
/*
* File: Factory.h
* Description: Provides a generic factory utility to create shared_ptr instances of objects.
* Author: Ajmal J S
* Created: 01-Apr-2026
*/
#pragma once
#include <memory>
#include <utility>
class Factory
{
public:
/*
* Function: getObject
* Description: Creates and returns a shared_ptr to an object of type T.
* Parameters:
* T - the type of object to be created
* Args - constructor arguments forwarded to T's constructor
* Returns:
* std::shared_ptr<T> - a shared pointer managing the newly created object
*/
template<typename T, typename... Args>
static std::shared_ptr<T> getObject(Args&&... args)
static T* getObject(Args&&... args)
{
return std::make_shared<T>(std::forward<Args>(args)...);
return T*(std::forward<Args>(args)...);
}
};
@@ -1 +1,7 @@
/*
* File: Admin.cpp
* Description: Admin model class
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Admin.h"
+7 -26
View File
@@ -1,32 +1,13 @@
/*
* File: Admin.h
* Description: Admin model class
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once
#include "Employee.h"
class Admin : public Employee
{
public:
Admin() = default;
Admin(
const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::ADMIN, payroll) {};
Admin(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::ADMIN,
accountStatus) {}
~Admin() = default;
};
@@ -1,7 +1,12 @@
/*
* File: Announcement.cpp
* Description: The Announcement class defines a simple object for managing announcement details.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Announcement.h"
int Announcement::m_anid = 0;
//Getters and Setters
const std::string& Announcement::getAnnouncementId() const
{
return m_id;
@@ -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
#include <string>
#include "Timestamp.h"
@@ -5,14 +11,14 @@
class Announcement
{
private:
static int m_anid;
std::string m_id;
util::Timestamp m_timestamp;
std::string m_message;
public:
Announcement() : m_id("AN" + std::to_string(++m_anid)), m_timestamp(), m_message("") {}
Announcement(const std::string& message)
: m_id("AN" + std::to_string(++m_anid)), m_message(message) {}
Announcement() : m_id(""), m_timestamp(), m_message("") {}
Announcement(const std::string& id,
const std::string& message)
: m_id(id), m_message(message) {}
const std::string& getAnnouncementId() const;
const util::Timestamp& getAnnouncementTimestamp() const;
const std::string& getAnnouncementMessage() const;
@@ -1,7 +1,12 @@
/*
* 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"
int Attendance::m_aid = 0;
//Getters and Setters
const std::string& Attendance::getAttendanceId() const
{
return m_id;
@@ -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
#include <string>
#include "Timestamp.h"
@@ -5,15 +11,15 @@
class Attendance
{
private:
static int m_aid;
std::string m_id;
util::Timestamp m_loginTime;
util::Timestamp m_logoutTime;
public:
Attendance() : m_id("AD" + std::to_string(++m_aid)), m_loginTime(), m_logoutTime() {}
Attendance(const util::Timestamp& loginTime,
Attendance() : m_id(""), m_loginTime(), m_logoutTime() {}
Attendance(const std::string& id,
const util::Timestamp& loginTime,
const util::Timestamp& logoutTime)
: m_id("AD" + std::to_string(++m_aid)), m_loginTime(loginTime), m_logoutTime(logoutTime) {}
: m_id(id), m_loginTime(loginTime), m_logoutTime(logoutTime) {}
const std::string& getAttendanceId() const;
const util::Timestamp& getLoginTime() const;
const util::Timestamp& getLogoutTime() const;
@@ -1,7 +1,12 @@
/*
* 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"
int Booking::m_bid = 0;
//Getters and Setters
const std::string& Booking::getBookingId() const
{
return m_id;
@@ -22,7 +27,7 @@ const std::string& Booking::getEmployeeId() const
return m_employeeId;
}
std::shared_ptr<Team> Booking::getTeam() const
Team* Booking::getTeam() const
{
return m_team;
}
@@ -47,7 +52,7 @@ void Booking::setEmployeeId(const std::string& employeeId)
m_employeeId = employeeId;
}
void Booking::setTeam(std::shared_ptr<Team> team)
void Booking::setTeam(Team* team)
{
m_team = team;
}
+13 -9
View File
@@ -1,35 +1,39 @@
/*
* 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
#include <string>
#include <memory>
#include "Team.h"
#include "Timestamp.h"
class Booking
{
private:
static int m_bid;
std::string m_id;
util::Timestamp m_startTime;
util::Timestamp m_endTime;
std::string m_employeeId;
std::shared_ptr<Team> m_team;
Team* m_team;
public:
Booking() : m_id("BK" + std::to_string(++m_bid)), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {}
Booking(const util::Timestamp& startTime,
Booking() : m_id(""), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {};
Booking(const std::string& id,
const util::Timestamp& startTime,
const util::Timestamp& endTime,
const std::string& employeeId,
std::shared_ptr<Team> team)
: m_id("BK" + std::to_string(++m_bid)), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
Team* team) : m_id(id), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {};
const std::string& getBookingId() const;
const util::Timestamp& getStartTime() const;
const util::Timestamp& getEndTime() const;
const std::string& getEmployeeId() const;
std::shared_ptr<Team> getTeam() const;
Team* getTeam() const;
void setBookingId(const std::string& id);
void setStartTime(const util::Timestamp& startTime);
void setEndTime(const util::Timestamp& endTime);
void setEmployeeId(const std::string& employeeId);
void setTeam(std::shared_ptr<Team> team);
void setTeam(Team* team);
double getDurationInHours() const;
double getDurationInMinutes() const;
};
@@ -1,7 +1,12 @@
/*
* File: Candidate.cpp
* Description: The Candidate class stores and manages a candidates information.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "Candidate.h"
int Candidate::m_cid = 0;
//Getters and Setters
const std::string& Candidate::getCandidateId() const
{
return m_id;
+10 -4
View File
@@ -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
#include <string>
#include "Enums.h"
@@ -5,19 +11,19 @@
class Candidate
{
private:
static int m_cid;
std::string m_id;
std::string m_name;
long int m_phone;
std::string m_qualification;
Enums::CandidateStatus m_status;
public:
Candidate() : m_id("CD" + std::to_string(++m_cid)), m_name(""), m_phone(0), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
Candidate(const std::string& name,
Candidate() : m_id(""), m_name(""), m_phone(0), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
Candidate(const std::string& id,
const std::string& name,
long int phone,
const std::string& qualification,
Enums::CandidateStatus status)
: m_id("CD" + std::to_string(++m_cid)), m_name(name), m_phone(phone), m_qualification(qualification), m_status(status) {}
: m_id(id), m_name(name), m_phone(phone), m_qualification(qualification), m_status(status) {}
const std::string& getCandidateId() const;
const std::string& getCandidateName() const;
long int getCandidatePhone() const;
+13 -141
View File
@@ -1,45 +1,13 @@
#include <sstream>
/*
* 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 "Employee.h"
#include "Factory.h"
#include "StringHelper.h"
#include "Admin.h"
#include "HRManager.h"
#include "ITExecutive.h"
#include "TalentExecutive.h"
#include "TeamExecutive.h"
#include "FinanceExecutive.h"
#include "GeneralEmployee.h"
int Employee::m_uid = 0;
Employee::Employee(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::EmployeeType employeeType,
Enums::AccountStatus accountStatus)
: m_id(id),
m_password(password),
m_name(name),
m_phone(phone),
m_email(email),
m_accountStatus(accountStatus),
m_teamStatus(teamStatus),
m_teamId(teamId),
m_employeeType(employeeType),
m_payroll()
{
int idNumber = util::extractNumber(m_id);
if (idNumber > m_uid)
{
m_uid = idNumber;
}
}
const std::string& Employee::getId() const
//Getters and Setters
const std::string& Employee::getEmployeeId() const
{
return m_id;
}
@@ -79,7 +47,7 @@ const std::string& Employee::getEmployeeTeamId() const
return m_teamId;
}
std::shared_ptr<Payroll> Employee::getPayroll() const
Payroll* Employee::getPayroll() const
{
return m_payroll;
}
@@ -134,12 +102,12 @@ void Employee::setEmployeeTeamId(const std::string& teamId)
m_teamId = teamId;
}
void Employee::setEmployeePayroll(std::shared_ptr<Payroll> payroll)
void Employee::setEmployeePayroll(Payroll* payroll)
{
m_payroll = payroll;
}
void Employee::addPayslip(std::shared_ptr<Payslip> payslip)
void Employee::addPayslip(Payslip* payslip)
{
if (payslip)
{
@@ -147,7 +115,7 @@ void Employee::addPayslip(std::shared_ptr<Payslip> payslip)
}
}
void Employee::addAttendance(std::shared_ptr<Attendance> attendance)
void Employee::addAttendance(Attendance* attendance)
{
if (attendance)
{
@@ -155,7 +123,7 @@ void Employee::addAttendance(std::shared_ptr<Attendance> attendance)
}
}
void Employee::addLeave(std::shared_ptr<Leave> leave)
void Employee::addLeave(Leave* leave)
{
if (leave)
{
@@ -167,99 +135,3 @@ Enums::EmployeeType Employee::getEmployeeType() const
{
return m_employeeType;
}
std::string Employee::serialize() const
{
std::ostringstream serializedEmployee;
serializedEmployee << m_id << ','
<< m_email << ','
<< m_name << ','
<< m_phone << ','
<< m_password << ','
<< m_teamId << ','
<< Enums::getTeamStatusString(m_teamStatus) << ','
<< Enums::getAccountStatusString(m_accountStatus) << ','
<< Enums::getEmployeeTypeString(m_employeeType);
return serializedEmployee.str();
}
std::shared_ptr<Employee> Employee::deserialize(const std::string& record)
{
std::string id, name, phone, password, email;
std::string teamId, teamStatusString, accountStatusString, employeeTypeString;
std::istringstream serializedEmployee(record);
getline(serializedEmployee, id, ',');
getline(serializedEmployee, email, ',');
getline(serializedEmployee, name, ',');
getline(serializedEmployee, phone, ',');
getline(serializedEmployee, password, ',');
getline(serializedEmployee, teamId, ',');
getline(serializedEmployee, teamStatusString, ',');
getline(serializedEmployee, accountStatusString, ',');
getline(serializedEmployee, employeeTypeString, ',');
Enums::TeamStatus teamStatus = Enums::getTeamStatus(teamStatusString);
Enums::AccountStatus accountStatus = Enums::getAccountStatus(accountStatusString);
Enums::EmployeeType employeeType = Enums::getEmployeeType(employeeTypeString);
switch (employeeType)
{
case Enums::EmployeeType::IT:
return Factory::getObject<ITExecutive>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
accountStatus
);
case Enums::EmployeeType::FINANCE:
return Factory::getObject<FinanceExecutive>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
accountStatus
);
case Enums::EmployeeType::HR:
return Factory::getObject<HRManager>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
accountStatus
);
case Enums::EmployeeType::TEAM:
return Factory::getObject<TeamExecutive>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
accountStatus
);
case Enums::EmployeeType::ADMIN:
return Factory::getObject<Admin>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
accountStatus
);
case Enums::EmployeeType::GENERAL:
throw std::runtime_error("Cannot deserialize GeneralEmployee!");
default:
return nullptr;
}
}
+21 -44
View File
@@ -1,21 +1,24 @@
/*
* 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
#include <string>
#include <memory>
#include <map>
#include "Payslip.h"
#include "Attendance.h"
#include "Leave.h"
#include "Payroll.h"
#include "Enums.h"
#include "ApplicationConfig.h"
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>;
using attendanceMap = std::map<int, std::map<std::string, std::shared_ptr<Attendance>>>;
using leaveMap = std::map<std::string, std::shared_ptr<Leave>>;
using payslipMap = std::map<std::string, Payslip*>;
using attendanceMap = std::map<int, std::map<std::string, Attendance*>>;
using leaveMap = std::map<std::string, Leave*>;
class Employee
{
protected:
static int m_uid;
private:
std::string m_id;
std::string m_password;
std::string m_name;
@@ -24,47 +27,23 @@ protected:
Enums::AccountStatus m_accountStatus;
Enums::TeamStatus m_teamStatus;
std::string m_teamId;
std::shared_ptr<Payroll> m_payroll;
Payroll* m_payroll;
payslipMap m_payslips;
attendanceMap m_attendances;
leaveMap m_leaves;
Enums::EmployeeType m_employeeType;
public:
Employee()
: m_id("EMP" + std::to_string(++m_uid)),
m_password(Config::Authentication::DEFAULT_PASSWORD),
m_name(""),
m_phone(""),
m_email(""),
m_accountStatus(Enums::AccountStatus::ACTIVE),
m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM),
m_teamId(""),
m_employeeType(Enums::EmployeeType::GENERAL) {}
Employee(const std::string& name,
const std::string& phone,
const std::string& email,
Enums::EmployeeType employeeType,
std::shared_ptr<Payroll> payroll)
: m_id("EMP" + std::to_string(++m_uid)),
m_password(Config::Authentication::DEFAULT_PASSWORD),
m_name(name),
m_phone(phone),
m_email(email),
m_accountStatus(Enums::AccountStatus::ACTIVE),
m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM),
m_teamId(""),
m_employeeType(employeeType),
m_payroll(payroll) {}
Employee() : m_id(""), m_password(""), m_name(""), m_phone(""), m_email(""), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(""), m_employeeType(Enums::EmployeeType::GENERAL) {}
Employee(const std::string& id,
const std::string& password,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::EmployeeType employeeType,
Enums::AccountStatus accountStatus);
const std::string& getId() const;
Payroll* payroll)
: m_id(id), m_password(password), m_name(name), m_phone(phone), m_email(email), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(teamId), m_employeeType(employeeType), m_payroll(payroll) { }
const std::string& getEmployeeId() const;
const std::string& getEmployeePassword() const;
const std::string& getEmployeeName() const;
const std::string& getEmployeePhone() const;
@@ -72,7 +51,7 @@ public:
Enums::AccountStatus getEmployeeAccountStatus() const;
Enums::TeamStatus getEmployeeTeamStatus() const;
const std::string& getEmployeeTeamId() const;
std::shared_ptr<Payroll> getPayroll() const;
Payroll* getPayroll() const;
const payslipMap& getEmployeePayslips() const;
const attendanceMap& getEmployeeAttendances() const;
const leaveMap& getEmployeeLeaves() const;
@@ -83,12 +62,10 @@ public:
void setEmployeeAccountStatus(Enums::AccountStatus status);
void setEmployeeTeamStatus(Enums::TeamStatus status);
void setEmployeeTeamId(const std::string& teamId);
void setEmployeePayroll(std::shared_ptr<Payroll> payroll);
void addPayslip(std::shared_ptr<Payslip> payslip);
void addAttendance(std::shared_ptr<Attendance> attendance);
void addLeave(std::shared_ptr<Leave> leave);
void setEmployeePayroll(Payroll* payroll);
void addPayslip(Payslip* payslip);
void addAttendance(Attendance* attendance);
void addLeave(Leave* leave);
Enums::EmployeeType getEmployeeType() const;
virtual std::string serialize() const;
static std::shared_ptr<Employee> deserialize(const std::string&);
virtual ~Employee() = default;
};
@@ -1 +1,7 @@
/*
* File: Faq.h
* Description: Faq model class.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include "Faq.h"
+6
View File
@@ -1,3 +1,9 @@
/*
* File: Faq.h
* Description: Faq model class.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once
class Faq
@@ -1 +1,7 @@
/*
* File: FinanceExecutive.h
* Description: FinanceExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "FinanceExecutive.h"
@@ -1,33 +1,13 @@
/*
* File: FinanceExecutive.h
* Description: FinanceExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once
#include "Employee.h"
class FinanceExecutive : public Employee
{
public:
FinanceExecutive() = default;
FinanceExecutive(
const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::FINANCE, payroll) {};
FinanceExecutive(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::FINANCE,
accountStatus) {}
~FinanceExecutive() = default;
};
@@ -1,7 +1,12 @@
#include <sstream>
/*
* File: GeneralEmployee.h
* Description: The GeneralEmployee class represents a general employee with a specific designation.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "GeneralEmployee.h"
#include "Factory.h"
//Getters and Setters
Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
{
return m_designation;
@@ -10,52 +15,4 @@ Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
void GeneralEmployee::setDesignation(Enums::EmployeeDesignation designation)
{
m_designation = designation;
}
std::string GeneralEmployee::serialize() const
{
std::ostringstream serializedEmployee;
serializedEmployee << m_id << ','
<< m_email << ','
<< m_name << ','
<< m_phone << ','
<< m_password << ','
<< m_teamId << ','
<< Enums::getTeamStatusString(m_teamStatus) << ','
<< Enums::getAccountStatusString(m_accountStatus) << ','
<< Enums::getEmployeeTypeString(m_employeeType) << ','
<< Enums::getEmployeeDesignationString(m_designation);
return serializedEmployee.str();
}
std::shared_ptr<GeneralEmployee> GeneralEmployee::deserialize(const std::string& record)
{
std::string id, name, phone, password, email;
std::string teamId, teamStatusString, accountStatusString, employeeTypeString, employeeDesignationString;
std::istringstream serializedEmployee(record);
getline(serializedEmployee, id, ',');
getline(serializedEmployee, email, ',');
getline(serializedEmployee, name, ',');
getline(serializedEmployee, phone, ',');
getline(serializedEmployee, password, ',');
getline(serializedEmployee, teamId, ',');
getline(serializedEmployee, teamStatusString, ',');
getline(serializedEmployee, accountStatusString, ',');
getline(serializedEmployee, employeeTypeString, ',');
getline(serializedEmployee, employeeDesignationString, ',');
Enums::TeamStatus teamStatus = Enums::getTeamStatus(teamStatusString);
Enums::AccountStatus accountStatus = Enums::getAccountStatus(accountStatusString);
Enums::EmployeeType employeeType = Enums::getEmployeeType(employeeTypeString);
Enums::EmployeeDesignation employeeDesignation = Enums::getEmployeeDesignation(employeeDesignationString);
return Factory::getObject<GeneralEmployee>(
id,
name,
phone,
password,
email,
teamId,
teamStatus,
employeeDesignation,
accountStatus
);
}
@@ -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
#include "Employee.h"
#include "Enums.h"
@@ -7,41 +13,16 @@ class GeneralEmployee : public Employee
private:
Enums::EmployeeDesignation m_designation;
public:
GeneralEmployee()
: m_designation(Enums::EmployeeDesignation::JUNIOR) {}
GeneralEmployee(const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll,
Enums::EmployeeDesignation designation)
: Employee(name,
phone,
email,
Enums::EmployeeType::GENERAL,
payroll),
m_designation(designation) {}
GeneralEmployee() : m_designation(Enums::EmployeeDesignation::JUNIOR) {}
GeneralEmployee(const std::string& id,
const std::string& password,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::EmployeeDesignation employeeDesignation,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::GENERAL,
accountStatus),
m_designation(employeeDesignation) {}
Payroll* payroll,
Enums::EmployeeDesignation designation) : Employee(id, password, name, phone, email, teamId,Enums::EmployeeType::GENERAL, payroll), m_designation(designation) {}
Enums::EmployeeDesignation getDesignation() const;
void setDesignation(Enums::EmployeeDesignation designation);
std::string serialize() const override;
static std::shared_ptr<GeneralEmployee> deserialize(const std::string&);
~GeneralEmployee() = default;
};
@@ -1 +1,7 @@
/*
* File: HRManager.cpp
* Description: HRManager model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "HRManager.h"
+6 -26
View File
@@ -1,33 +1,13 @@
/*
* File: HRManager.h
* Description: HRManager model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once
#include "Employee.h"
class HRManager : public Employee
{
public:
HRManager() = default;
HRManager(
const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::HR, payroll) {};
HRManager(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::HR,
accountStatus) {}
~HRManager() = default;
};
@@ -1 +1,7 @@
/*
* File: ITExecutive.cpp
* Description: ITExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#include "ITExecutive.h"
@@ -1,33 +1,13 @@
/*
* File: ITExecutive.h
* Description: ITExecutive model class.
* Author: Trenser
* Created: 31-Mar-2026
*/
#pragma once
#include "Employee.h"
class ITExecutive : public Employee
{
public:
ITExecutive() = default;
ITExecutive(
const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::IT, payroll) {};
ITExecutive(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::IT,
accountStatus) {}
~ITExecutive() = default;
};
@@ -1,7 +1,13 @@
/*
File: JobListing.cpp
* Description : Represents a job opening along with its details and applied candidates.
* Author : Trenser
* Created : 01-Apr-2026
*/
#include "JobListing.h"
int JobListing::m_jid = 0;
//Getters and setters
const std::string& JobListing::getJobId() const
{
return m_id;
@@ -1,15 +1,21 @@
/*
File: JobListing.h
* Description : Represents a job opening along with its details and applied candidates.
* Author : Trenser
* Created : 01-Apr-2026
*/
#pragma once
#include <string>
#include <map>
#include <memory>
#include "Candidate.h"
#include "Enums.h"
using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>;
using candidateMap = std::map<std::string, Candidate*>;
class JobListing
{
private:
static int m_jid;
std::string m_id;
std::string m_name;
std::string m_description;
@@ -17,13 +23,14 @@ private:
int m_numberOfVacancies;
candidateMap m_candidates;
public:
JobListing() : m_id("JL" + std::to_string(++m_jid)), m_name(""), m_description(""), m_status(Enums::JobListingStatus::CLOSED), m_numberOfVacancies(0) {}
JobListing(const std::string& name,
JobListing() : m_id(""), m_name(""), m_description(""), m_status(Enums::JobListingStatus::CLOSED), m_numberOfVacancies(0) {}
JobListing(const std::string& id,
const std::string& name,
const std::string& description,
Enums::JobListingStatus status,
int numberOfVacancies,
const candidateMap& candidates)
: m_id("JL" + std::to_string(++m_jid)), m_name(name), m_description(description), m_status(status), m_numberOfVacancies(numberOfVacancies), m_candidates(candidates) {}
: m_id(id), m_name(name), m_description(description), m_status(status), m_numberOfVacancies(numberOfVacancies), m_candidates(candidates) {}
const std::string& getJobId() const;
const std::string& getJobName() const;
const std::string& getJobDescription() const;
+8 -2
View File
@@ -1,7 +1,13 @@
/*
File: Leave.cpp
* Description : Stores information related to an employees leave application.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Leave.h"
int Leave::m_lid = 0;
//Getters and setters
const std::string& Leave::getLeaveId() const
{
return m_id;
+11 -4
View File
@@ -1,3 +1,10 @@
/*
File: Leave.h
* Description : Stores information related to an employees leave application.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include <string>
#include "Enums.h"
@@ -6,7 +13,6 @@
class Leave
{
private:
static int m_lid;
std::string m_id;
std::string m_employeeId;
util::Timestamp m_timestamp;
@@ -16,12 +22,13 @@ private:
static int m_numberOfMedicalLeave;
Enums::LeaveType m_leaveType;
public:
Leave() : m_id("LV" + std::to_string(++m_lid)), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
Leave(const std::string& employeeId,
Leave() : m_id(""), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
Leave(const std::string& id,
const std::string& employeeId,
const util::Timestamp& timestamp,
const std::string& reason,
Enums::LeaveType leaveType)
: m_id("LV" + std::to_string(++m_lid)), m_employeeId(employeeId), m_timestamp(timestamp), m_reason(reason), m_leaveType(leaveType) {}
: m_id(id), m_employeeId(employeeId), m_timestamp(timestamp), m_reason(reason), m_leaveType(leaveType) {}
const std::string& getLeaveId() const;
const std::string& getEmployeeId() const;
const util::Timestamp& getTimestamp() const;
@@ -1,5 +1,13 @@
/*
File: Log.cpp
* Description : Represents a log entry containing a timestamp and an associated message.
* Author : Trenser
* Created : 01-Apr-2026
*/
#include "Log.h"
//Getters and setters
const util::Timestamp& Log::getTimestamp() const
{
return m_timestamp;
+7
View File
@@ -1,3 +1,10 @@
/*
File: Log.h
* Description : Represents a log entry containing a timestamp and an associated message.
* Author : Trenser
* Created : 01-Apr-2026
*/
#pragma once
#include <string>
#include "Timestamp.h"
@@ -1,7 +1,13 @@
/*
File: Notification.cpp
* Description : Represents an employee notification with message and status details.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Notification.h"
int Notification::m_nid = 0;
//Getters and setters
const std::string& Notification::getNotificationId() const
{
return m_id;
@@ -1,3 +1,10 @@
/*
File: Notification.h
* Description : Represents an employee notification with message and status details.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include <string>
#include "Enums.h"
@@ -6,18 +13,18 @@
class Notification
{
private:
static int m_nid;
std::string m_id;
std::string m_employeeId;
std::string m_message;
util::Timestamp m_timestamp;
Enums::NotificationStatus m_notificationStatus;
public:
Notification() : m_id("NF" + std::to_string(++m_nid)), m_employeeId(""), m_message(""), m_timestamp(), m_notificationStatus(Enums::NotificationStatus::UNREAD) {}
Notification(const std::string& employeeId,
Notification() : m_id(""), m_employeeId(""), m_message(""), m_timestamp(), m_notificationStatus(Enums::NotificationStatus::UNREAD) {}
Notification(const std::string& id,
const std::string& employeeId,
const std::string& message,
Enums::NotificationStatus notificationStatus)
: m_id("NF" + std::to_string(++m_nid)), m_employeeId(employeeId), m_message(message), m_notificationStatus(notificationStatus) {}
: m_id(id), m_employeeId(employeeId), m_message(message), m_notificationStatus(notificationStatus) {}
const std::string& getNotificationId() const;
const std::string& getEmployeeId() const;
const std::string& getNotificationMessage() const;
+10 -4
View File
@@ -1,7 +1,13 @@
/*
File: Payroll.cpp
* Description : Stores payroll and salary breakdown details for an employee.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Payroll.h"
int Payroll::m_prid = 0;
//Getters and setters
const std::string& Payroll::getPayrollId() const
{
return m_id;
@@ -32,9 +38,9 @@ double Payroll::getEmployerPFContribution() const
return m_employerPFContribution;
}
void Payroll::setBasicSalary(double basicSalary)
void Payroll::setPayrollID(const std::string& id)
{
m_basicSalary = basicSalary;
m_id = id;
}
void Payroll::setHouseRentAllowance(double value)
+16 -9
View File
@@ -1,10 +1,16 @@
/*
File: Payroll.h
* Description : Stores payroll and salary breakdown details for an employee.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include <string>
class Payroll
{
private:
static int m_prid;
std::string m_id;
double m_basicSalary;
double m_houseRentAllowance;
@@ -12,22 +18,23 @@ private:
double m_employeePFContribution;
double m_employerPFContribution;
public:
Payroll() : m_id("PR" + std::to_string(++m_prid)), m_basicSalary(0.0), m_houseRentAllowance(0.0), m_foodAllowance(0.0), m_employeePFContribution(0.0), m_employerPFContribution(0.0) {}
Payroll(double basicSalary,
Payroll() : m_id(""), m_basicSalary(0.0), m_houseRentAllowance(0.0), m_foodAllowance(0.0), m_employeePFContribution(0.0), m_employerPFContribution(0.0) {}
Payroll(const std::string& id,
double basicSalary,
double houseRentAllowance,
double foodAllowance,
double employeePFContribution,
double employerPFContribution)
: m_id("PR" + std::to_string(++m_prid)), m_basicSalary(basicSalary), m_houseRentAllowance(houseRentAllowance), m_foodAllowance(foodAllowance), m_employeePFContribution(employeePFContribution), m_employerPFContribution(employerPFContribution) {}
: m_id(id), m_basicSalary(basicSalary), m_houseRentAllowance(houseRentAllowance), m_foodAllowance(foodAllowance), m_employeePFContribution(employeePFContribution), m_employerPFContribution(employerPFContribution) {}
const std::string& getPayrollId() const;
double getBasicSalary() const;
double getHouseRentAllowance() const;
double getFoodAllowance() const;
double getEmployeePFContribution() const;
double getEmployerPFContribution() const;
void setBasicSalary(double);
void setHouseRentAllowance(double);
void setFoodAllowance(double);
void setEmployeePFContribution(double);
void setEmployerPFContribution(double);
void setPayrollID(const std::string& id);
void setHouseRentAllowance(double value);
void setFoodAllowance(double value);
void setEmployeePFContribution(double value);
void setEmployerPFContribution(double value);
};
@@ -1,7 +1,13 @@
/*
File: Payslip.cpp
* Description : Models a payslip entity that stores salary information.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Payslip.h"
int Payslip::m_pid = 0;
//Getters and setters
const std::string& Payslip::getPayslipId() const
{
return m_id;
+9 -3
View File
@@ -1,15 +1,21 @@
/*
File: Payslip.h
* Description : Models a payslip entity that stores salary information.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include <string>
class Payslip
{
private:
static int m_pid;
std::string m_id;
double m_salary;
public:
Payslip() : m_id("PS" + std::to_string(++m_pid)), m_salary(0.0) {}
Payslip(const double salary) : m_id("PS" + std::to_string(++m_pid)), m_salary(salary) {}
Payslip() : m_id(""), m_salary(0.0) {}
Payslip(const std::string& id, double salary) : m_id(id), m_salary(salary) {}
const std::string& getPayslipId() const;
double getSalary() const;
void setPayslipId(const std::string& id);
+9 -3
View File
@@ -1,7 +1,13 @@
/*
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"
int Room::m_rid = 0;
//Getters and setters
const std::string& Room::getRoomId() const
{
return m_id;
@@ -27,7 +33,7 @@ void Room::setRoomName(const std::string& name)
m_name = name;
}
void Room::addBooking(std::shared_ptr<Booking> booking)
void Room::addBooking(Booking* booking)
{
if (booking)
{
+11 -5
View File
@@ -1,24 +1,30 @@
/*
File: Room.h
* Description : Models a room entity that maintains room details and manages its bookings.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include <string>
#include <map>
#include <memory>
#include "Booking.h"
using bookingMap = std::map<std::string, std::shared_ptr<Booking>>;
using bookingMap = std::map<std::string, Booking*>;
class Room
{
private:
static int m_rid;
std::string m_id;
std::string m_name;
bookingMap m_bookings;
public:
Room() : m_id("RM" + std::to_string(++m_rid)), m_name("") {}
Room(const std::string& name) : m_id("RM" + std::to_string(++m_rid)), m_name(name) {}
Room() : m_id(""), m_name("") {}
Room(const std::string& id, const std::string& name) : m_id(id), m_name(name) {}
const std::string& getRoomId() const;
const std::string& getRoomName() const;
const bookingMap& getBookings() const;
void setRoomId(const std::string& id);
void setRoomName(const std::string& name);
void addBooking(std::shared_ptr<Booking> booking);
void addBooking(Booking* booking);
};
@@ -1 +1,8 @@
/*
File: TalentExecutive.cpp
* Description : Represents information related to a talent executive in the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "TalentExecutive.h"
@@ -1,16 +1,14 @@
/*
File: TalentExecutive.h
* Description : Represents information related to a talent executive in the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include "Employee.h"
class TalentExecutive : public Employee
{
public:
TalentExecutive() = default;
TalentExecutive(
const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::TAG, payroll) {};
~TalentExecutive() = default;
};
+10 -4
View File
@@ -1,7 +1,13 @@
/*
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"
int Team::m_tmid = 0;
//Getters and setters
const std::string& Team::getTeamId() const
{
return m_id;
@@ -12,7 +18,7 @@ const std::string& Team::getTeamName() const
return m_name;
}
std::shared_ptr<Employee> Team::getTeamLead() const
Employee* Team::getTeamLead() const
{
return m_lead;
}
@@ -37,7 +43,7 @@ void Team::setTeamName(const std::string& name)
m_name = name;
}
void Team::setTeamLead(std::shared_ptr<Employee> lead)
void Team::setTeamLead(Employee* lead)
{
m_lead = lead;
}
+15 -9
View File
@@ -1,35 +1,41 @@
/*
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
#include <string>
#include <map>
#include <memory>
#include "Employee.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
using employeeMap = std::map<std::string, Employee*>;
class Team
{
private:
static int m_tmid;
std::string m_id;
std::string m_name;
std::shared_ptr<Employee> m_lead;
Employee* m_lead;
employeeMap m_employees;
int m_maximumNumberOfEmployees;
public:
Team() : m_id("TM" + std::to_string(++m_tmid)), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
Team(
Team() : m_id(""), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
Team(const std::string& id,
const std::string& name,
std::shared_ptr<Employee> lead,
Employee* lead,
int maximumNumberOfEmployees)
: m_id("TM" + std::to_string(++m_tmid)), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
: m_id(id), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
}
const std::string& getTeamId() const;
const std::string& getTeamName() const;
std::shared_ptr<Employee> getTeamLead() const;
Employee* getTeamLead() const;
const employeeMap& getEmployeesInTeam() const;
int getMaximumNumberOfEmployeesInTeam() const;
void setTeamId(const std::string& id);
void setTeamName(const std::string& name);
void setTeamLead(std::shared_ptr<Employee> lead);
void setTeamLead(Employee* lead);
void setEmployeesInTeam(const employeeMap& employees);
void setMaximumNumberOfEmployeesInTeam(int maximumNumberOfEmployees);
};
@@ -1 +1,8 @@
/*
File: TeamExecutive.cpp
* Description : Represents information related to a team executive within the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "TeamExecutive.h"
@@ -1,33 +1,14 @@
/*
File: TeamExecutive.h
* Description : Represents information related to a team executive within the system.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include "Employee.h"
class TeamExecutive : public Employee
{
public:
TeamExecutive() = default;
TeamExecutive(
const std::string& name,
const std::string& phone,
const std::string& email,
std::shared_ptr<Payroll> payroll
) :Employee(name, phone, email, Enums::EmployeeType::TEAM, payroll) {};
TeamExecutive(const std::string& id,
const std::string& name,
const std::string& phone,
const std::string& password,
const std::string& email,
const std::string& teamId,
Enums::TeamStatus teamStatus,
Enums::AccountStatus accountStatus)
: Employee(id,
name,
phone,
password,
email,
teamId,
teamStatus,
Enums::EmployeeType::TEAM,
accountStatus) {}
~TeamExecutive() = default;
};
@@ -1,7 +1,13 @@
/*
File: Ticket.cpp
* Description : Represents a support ticket with its associated details and status.
* Author : Trenser
* Created : 31-Mar-2026
*/
#include "Ticket.h"
int Ticket::m_tid = 0;
//Getters and setters
const std::string& Ticket::getTicketId() const
{
return m_id;
+10 -4
View File
@@ -1,3 +1,10 @@
/*
File: Ticket.h
* Description : Represents a support ticket with its associated details and status.
* Author : Trenser
* Created : 31-Mar-2026
*/
#pragma once
#include <string>
#include "Enums.h"
@@ -5,20 +12,19 @@
class Ticket
{
private:
static int m_tid;
std::string m_id;
Enums::TicketType m_type;
std::string m_description;
Enums::TicketStatus m_status;
std::string m_employeeId;
public:
Ticket() : m_id("TKT" + std::to_string(++m_tid)), m_type(Enums::TicketType::UNKNOWN), m_description(""), m_status(Enums::TicketStatus::OPEN), m_employeeId("") {}
Ticket(
Ticket() : m_id(""), m_type(Enums::TicketType::UNKNOWN), m_description(""), m_status(Enums::TicketStatus::OPEN), m_employeeId("") {}
Ticket(const std::string& id,
Enums::TicketType type,
const std::string& description,
const std::string& employeeId,
Enums::TicketStatus status)
: m_id("TKT" + std::to_string(++m_tid)), m_type(type), m_description(description), m_status(status), m_employeeId(employeeId) {}
: m_id(id), m_type(type), m_description(description), m_status(status), m_employeeId(employeeId) {}
const std::string& getTicketId() const;
Enums::TicketType getTicketType() const;
const std::string& getDescription() const;
@@ -1 +1,8 @@
/*
* File: ApplicationConfig.cpp
* Description: Global Application Config
* Author: Trenser
* Created: 06-Apr-2026
*/
#include "ApplicationConfig.h"
@@ -1,3 +1,10 @@
/*
* File: ApplicationConfig.h
* Description: Global Application Config
* Author: Trenser
* Created: 06-Apr-2026
*/
#pragma once
namespace Config
@@ -6,34 +13,4 @@ namespace Config
{
constexpr const char* DEFAULT_PASSWORD = "password";
}
namespace Payroll
{
constexpr double SENIOR_BASIC_SALARY = 0.0;
constexpr double SENIOR_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double SENIOR_FOOD_ALLOWANCE = 0.0;
constexpr double SENIOR_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double SENIOR_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double JUNIOR_BASIC_SALARY = 0.0;
constexpr double JUNIOR_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double JUNIOR_FOOD_ALLOWANCE = 0.0;
constexpr double JUNIOR_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double JUNIOR_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double HR_MANAGER_BASIC_SALARY = 0.0;
constexpr double HR_MANAGER_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double HR_MANAGER_FOOD_ALLOWANCE = 0.0;
constexpr double HR_MANAGER_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double HR_MANAGER_EMPLOYER_PF_CONTRIBUTION = 0.0;
constexpr double EXECUTIVE_BASIC_SALARY = 0.0;
constexpr double EXECUTIVE_HOUSE_RENT_ALLOWANCE = 0.0;
constexpr double EXECUTIVE_FOOD_ALLOWANCE = 0.0;
constexpr double EXECUTIVE_EMPLOYEE_PF_CONTRIBUTION = 0.0;
constexpr double EXECUTIVE_EMPLOYER_PF_CONTRIBUTION = 0.0;
}
namespace File
{
constexpr const char* EMPLOYEES_FILE = "files/Employee.csv";
constexpr const char* GENERAL_EMPLOYEES_FILE = "files/GeneralEmployee.csv";
}
}
@@ -1 +1,8 @@
/*
* File: AttendanceManagementService.cpp
* Description: Handles Attendance related operations
* Author: Trenser
* Created: 30-Apr-2026
*/
#include "AttendanceManagementService.h"
@@ -1,3 +1,10 @@
/*
* File: AttendanceManagementService.h
* Description: Handles Attendance related operations
* Author: Trenser
* Created: 30-Apr-2026
*/
#pragma once
class AttendanceManagementService
{
@@ -1,70 +1,110 @@
/*
* File: AuthenticationManagementService.cpp
* Description: Handles authentication related operations
* Author: Trenser
* Created: 30-Mar-2026
*/
#include <stdexcept>
#include "AuthenticationManagementService.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)
{
employeeMap& employees = m_dataStore.getEmployees();
Enums::LoginStatus loginStatus = Enums::LoginStatus::USER_NOT_FOUND;
Enums::EmployeeType employeeType = Enums::EmployeeType::INVALID;
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
for (const auto& employee : employees)
{
if (employee.second->getEmployeeEmail() == email)
{
if (employee.second->getEmployeePassword() == password)
{
if (password == Config::Authentication::DEFAULT_PASSWORD)
{
loginStatus = Enums::LoginStatus::FIRST_LOGIN;
}
else
{
loginStatus = Enums::LoginStatus::SUCCESS;
}
employeeType = employee.second->getEmployeeType();
if (employeeType == Enums::EmployeeType::GENERAL)
{
std::shared_ptr<GeneralEmployee> generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>(employee.second);
if (generalEmployee)
{
employeeDesignation = generalEmployee->getDesignation();
}
else
{
throw std::runtime_error("Invalid Employee Type");
}
}
m_dataStore.setAuthenticatedEmployee(employee.second);
}
else
{
loginStatus = Enums::LoginStatus::INVALID_PASSWORD;
}
break;
}
}
return std::make_tuple(loginStatus, employeeType, employeeDesignation);
employeeMap& employees = m_dataStore.getEmployees();
Enums::LoginStatus loginStatus = Enums::LoginStatus::USER_NOT_FOUND;
Enums::EmployeeType employeeType = Enums::EmployeeType::INVALID;
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
for (const auto& employee : employees)
{
if (employee.second->getEmployeeEmail() == email)
{
if (employee.second->getEmployeePassword() == password)
{
if (password == Config::Authentication::DEFAULT_PASSWORD)
{
loginStatus = Enums::LoginStatus::FIRST_LOGIN;
}
else
{
loginStatus = Enums::LoginStatus::SUCCESS;
}
employeeType = employee.second->getEmployeeType();
if (employeeType == Enums::EmployeeType::GENERAL)
{
GeneralEmployee* generalEmployee = dynamic_cast<GeneralEmployee*>(employee.second);
if (generalEmployee)
{
employeeDesignation = generalEmployee->getDesignation();
}
else
{
throw std::runtime_error("Invalid Employee Type");
}
}
m_dataStore.setAuthenticatedEmployee(employee.second);
}
else
{
loginStatus = Enums::LoginStatus::INVALID_PASSWORD;
}
break;
}
}
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)
{
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedEmployee();
if (authenticatedUser)
{
authenticatedUser->setEmployeePassword(password);
}
else
{
throw std::runtime_error("User not found");
}
Employee* authenticatedUser = m_dataStore.getAuthenticatedUser();
if (authenticatedUser)
{
authenticatedUser->setEmployeePassword(password);
}
else
{
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() {
if (m_dataStore.getAuthenticatedEmployee()) {
if (m_dataStore.getAuthenticatedEmployee())
{
m_dataStore.getAuthenticatedEmployee() = nullptr;
}
else {
else
{
throw std::runtime_error("No user currently logged In...");
}
}
@@ -1,3 +1,10 @@
/*
* File: AuthenticationManagementService.h
* Description: Handles authentication related operations
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
#include <string>
#include <map>
@@ -19,4 +26,3 @@ public:
void logout();
void changePassword(const std::string&);
};
@@ -1 +1,8 @@
/*
* File: BookingManagementService.cpp
* Description: Handle operations related to booking meetings
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "BookingManagementService.h"
@@ -1,3 +1,10 @@
/*
* File: BookingManagementService.h
* Description: Handle operations related to booking meetings
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class BookingManagementService
{
@@ -0,0 +1,8 @@
/*
* File: EmployeeManagementService.cpp
* Description: Handle operations related to employees
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "EmployeeManagememtService.h"
@@ -0,0 +1,12 @@
/*
* File: EmployeeManagementService.h
* Description: Handle operations related to employees
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class EmployeeManagememtService
{
};
@@ -1,223 +0,0 @@
#include <stdexcept>
#include "EmployeeManagementService.h"
#include "Factory.h"
#include "Validator.h"
#include "AuthorizationHelper.h"
#include "Enums.h"
#include "HRManager.h"
#include "ITExecutive.h"
#include "TalentExecutive.h"
#include "TeamExecutive.h"
#include "FinanceExecutive.h"
#include "GeneralEmployee.h"
#include "FileManager.h"
#include "ApplicationConfig.h"
static bool hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const employeeMap& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeeType() == employeeType && employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
{
return true;
}
}
return false;
}
static bool isEmailDuplicate(const std::string& email, const employeeMap& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeeEmail() == email)
{
return true;
}
}
return false;
}
static bool isPhoneDuplicate(const std::string& phone, const employeeMap& employees)
{
for (const auto& employeePair : employees)
{
const auto& employee = employeePair.second;
if (employee->getEmployeePhone() == phone)
{
return true;
}
}
return false;
}
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();
std::shared_ptr<Employee> authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
if (!authenticatedEmployee)
{
throw std::runtime_error("No authenticated user");
}
Enums::EmployeeType authenticatedEmployeeType = authenticatedEmployee->getEmployeeType();
std::shared_ptr<Employee> employee;
std::shared_ptr<Payroll> payroll;
if (employeeType != Enums::EmployeeType::GENERAL && hasActiveEmployeeOfType(employeeType, employees))
{
throw std::runtime_error("Cannot create more than one employee of type " + Enums::getEmployeeTypeString(employeeType));
}
if (!util::isEmailValid(email))
{
throw std::runtime_error("Invalid Email");
}
if (!util::isPhoneNumberValid(phone))
{
throw std::runtime_error("Invalid Phone");
}
if (isEmailDuplicate(email, employees))
{
throw std::runtime_error("Duplicate Email");
}
if (isPhoneDuplicate(phone, employees))
{
throw std::runtime_error("Duplicate Phone Number!");
}
switch (employeeType)
{
case Enums::EmployeeType::HR:
util::enforceAuthorization(authenticatedEmployeeType, Enums::EmployeeType::ADMIN);
payroll = Factory::getObject<Payroll>(Config::Payroll::HR_MANAGER_BASIC_SALARY,
Config::Payroll::HR_MANAGER_HOUSE_RENT_ALLOWANCE,
Config::Payroll::HR_MANAGER_FOOD_ALLOWANCE,
Config::Payroll::HR_MANAGER_EMPLOYEE_PF_CONTRIBUTION,
Config::Payroll::HR_MANAGER_EMPLOYER_PF_CONTRIBUTION);
employee = Factory::getObject<HRManager>(name, phone, email, payroll);
break;
case Enums::EmployeeType::IT:
case Enums::EmployeeType::FINANCE:
case Enums::EmployeeType::TEAM:
case Enums::EmployeeType::TAG:
util::enforceAuthorization(authenticatedEmployeeType, Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
payroll = Factory::getObject<Payroll>(Config::Payroll::EXECUTIVE_BASIC_SALARY,
Config::Payroll::EXECUTIVE_HOUSE_RENT_ALLOWANCE,
Config::Payroll::EXECUTIVE_FOOD_ALLOWANCE,
Config::Payroll::EXECUTIVE_EMPLOYEE_PF_CONTRIBUTION,
Config::Payroll::EXECUTIVE_EMPLOYER_PF_CONTRIBUTION);
switch (employeeType)
{
case Enums::EmployeeType::IT:
employee = Factory::getObject<ITExecutive>(name, phone, email, payroll);
break;
case Enums::EmployeeType::FINANCE:
employee = Factory::getObject<FinanceExecutive>(name, phone, email, payroll);
break;
case Enums::EmployeeType::TEAM:
employee = Factory::getObject<TeamExecutive>(name, phone, email, payroll);
break;
case Enums::EmployeeType::TAG:
employee = Factory::getObject <TalentExecutive> (name, phone, email, payroll);
break;
}
break;
case Enums::EmployeeType::GENERAL:
util::enforceAuthorization(authenticatedEmployeeType, Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
switch (employeeDesignation)
{
case Enums::EmployeeDesignation::JUNIOR:
payroll = Factory::getObject<Payroll>(Config::Payroll::JUNIOR_BASIC_SALARY,
Config::Payroll::JUNIOR_HOUSE_RENT_ALLOWANCE,
Config::Payroll::JUNIOR_FOOD_ALLOWANCE,
Config::Payroll::JUNIOR_EMPLOYEE_PF_CONTRIBUTION,
Config::Payroll::JUNIOR_EMPLOYER_PF_CONTRIBUTION);
break;
case Enums::EmployeeDesignation::SENIOR:
payroll = Factory::getObject<Payroll>(Config::Payroll::SENIOR_BASIC_SALARY,
Config::Payroll::SENIOR_HOUSE_RENT_ALLOWANCE,
Config::Payroll::SENIOR_FOOD_ALLOWANCE,
Config::Payroll::SENIOR_EMPLOYEE_PF_CONTRIBUTION,
Config::Payroll::SENIOR_EMPLOYER_PF_CONTRIBUTION);
break;
default:
throw std::runtime_error("Invalid General Employee Designation");
}
employee = Factory::getObject<GeneralEmployee>(name, phone, email, payroll, employeeDesignation);
break;
default:
throw std::runtime_error("Invalid Employee Type");
}
m_dataStore.getEmployees().emplace(std::make_pair(employee->getId(), employee));
}
bool EmployeeManagementService::deactivateEmployee(const std::string& id)
{
auto& authenticatedEmployee = m_dataStore.getAuthenticatedEmployee();
util::enforceAuthorization(authenticatedEmployee->getEmployeeType(), Enums::EmployeeType::ADMIN, Enums::EmployeeType::HR);
auto& employee = m_dataStore.getEmployees();
auto iterator = employee.find(id);
if (iterator == employee.end())
{
return false;
}
if (iterator->second->getEmployeeType() == Enums::EmployeeType::ADMIN)
{
throw std::runtime_error("Cannot deactivate Admin Account");
}
iterator->second->setEmployeeAccountStatus(Enums::AccountStatus::INACTIVE);
return true;
}
Employees EmployeeManagementService::getEmployees()
{
Employees result;
auto& employees = m_dataStore.getEmployees();
if (employees.size() <= 0)
{
return result;
}
for (const auto& iterator : employees)
{
if (iterator.second->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
{
result.push_back(iterator.second);
}
}
return result;
}
std::shared_ptr<const Employee> EmployeeManagementService::getCurrentEmployee()
{
return m_dataStore.getAuthenticatedEmployee();
}
void EmployeeManagementService::updateProfile(const std::string& name,const std::string& phone)
{
std::shared_ptr<Employee> employee = m_dataStore.getAuthenticatedEmployee();
employee->setEmployeeName(name);
employee->setEmployeePhone(phone);
}
void EmployeeManagementService::loadEmployees()
{
FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE);
FileManager<GeneralEmployee> generalEmployeeFileManager(Config::File::GENERAL_EMPLOYEES_FILE);
bool isAdminFound = false;
auto& employees = m_dataStore.getEmployees();
auto employeesMap = employeeFileManager.load();
auto generalEmployeesMap = generalEmployeeFileManager.load();
employees.insert(employeesMap.begin(), employeesMap.end());
employees.insert(generalEmployeesMap.begin(), generalEmployeesMap.end());
for (auto& employeePair : employees)
{
if (employeePair.second->getEmployeeType() == Enums::EmployeeType::ADMIN)
{
isAdminFound = true;
break;
}
}
if (!isAdminFound)
{
auto admin = Factory::getObject<Admin>("Admin", "", "admin@trenser.com", nullptr);
employees.emplace(std::make_pair(admin->getId(), admin));
}
}
@@ -1,21 +0,0 @@
#pragma once
#include <vector>
#include <tuple>
#include "DataStore.h"
#include "Enums.h"
using Employees = std::vector<std::shared_ptr<const Employee>>;
class EmployeeManagementService
{
private:
DataStore& m_dataStore;
public:
EmployeeManagementService() : m_dataStore(DataStore::getInstance()) {};
void createEmployee(Enums::EmployeeType, Enums::EmployeeDesignation, const std::string&, const std::string&, const std::string&);
bool deactivateEmployee(const std::string&);
Employees getEmployees();
void updateProfile(const std::string&,const std::string&);
std::shared_ptr<const Employee> getCurrentEmployee();
void loadEmployees();
};
@@ -1 +1,8 @@
/*
* File: LeaveManagementService.cpp
* Description: Handle operations related to leaves
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "LeaveManagementService.h"
@@ -1,3 +1,10 @@
/*
* File: LeaveManagementService.h
* Description: Handle operations related to leaves
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class LeaveManagementService
{
@@ -1,3 +1,10 @@
/*
* File: Log.cpp
* Description: Handle operations related to logging
* Author: Trenser
* Created: 01-Apr-2026
*/
#include "LogService.h"
#include "Log.h"
#include "Factory.h"
@@ -7,6 +14,6 @@ void LogService::log(const std::string& message)
{
DataStore& dataStore = DataStore::getInstance();
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));
}
@@ -1,3 +1,10 @@
/*
* File: Log.h
* Description: Handle operations related to logging
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once
#include "Log.h"
@@ -1 +1,8 @@
/*
* File: NotificationManagementService.cpp
* Description: Handle operations related to notifications
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "NotificationManagementService.h"
@@ -1,5 +1,11 @@
/*
* File: NotificationManagementService.h
* Description: Handle operations related to notifications
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class NotificationManagementService
{
};
@@ -1,21 +1,8 @@
#include "PayslipManagementService.h"
#include "AuthorizationHelper.h"
#include "Enums.h"
/*
* File: PayslipManagementService.cpp
* Description: Handle operations related to employee payslips
* Author: Trenser
* Created: 30-Mar-2026
*/
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);
auto employee = m_dataStore.getEmployees().find(employeeId);
if (employee != m_dataStore.getEmployees().end() && employee->second->getEmployeeType() != Enums::EmployeeType::ADMIN)
{
(employee->second)->getPayroll()->setBasicSalary(basicSalary);
(employee->second)->getPayroll()->setHouseRentAllowance(houseRentAllowance);
(employee->second)->getPayroll()->setFoodAllowance(foodAllowance);
(employee->second)->getPayroll()->setEmployeePFContribution(employeePFContribution);
(employee->second)->getPayroll()->setEmployerPFContribution(employerPFContribution);
}
else
{
throw std::runtime_error("Employee not found, unable to update the salary");
}
}
#include "PayslipManagementService.h"
@@ -1,13 +1,12 @@
#pragma once
#include <string>
#include<stdexcept>
#include"DataStore.h"
/*
* File: PayslipManagementService.h
* Description: Handle operations related to employee payslips
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class PayslipManagementService
{
private:
DataStore& m_dataStore;
public:
PayslipManagementService() : m_dataStore(DataStore::getInstance()) {};
void updateSalary(const std::string&, double, double, double, double, double);
};
@@ -1 +1,8 @@
/*
* File: TalentAcquisitionManagementService.cpp
* Description: Handle operations related to Talent Acquisition
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "TalentAcquisitionManagementService.h"
@@ -1,5 +1,11 @@
/*
* File: TalentAcquisitionManagementService.h
* Description: Handle operations related to Talent Acquisition
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class TalentAcquisitionManagementService
{
};
@@ -1 +1,8 @@
/*
* File: TeamManagementService.cpp
* Description: Handle operations related to Team Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "TeamManagementService.h"
@@ -1,3 +1,10 @@
/*
* File: TeamManagementService.h
* Description: Handle operations related to Team Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class TeamManagementService
{
@@ -1 +1,8 @@
/*
* File: TicketManagementService.h
* Description: Handle operations related to Ticket Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#include "TicketManagementService.h"
@@ -1,3 +1,10 @@
/*
* File: TicketManagementService.h
* Description: Handle operations related to Ticket Management
* Author: Trenser
* Created: 30-Mar-2026
*/
#pragma once
class TicketManagementService
{
@@ -1 +0,0 @@
#include "AuthorizationHelper.h"
@@ -1,31 +0,0 @@
#pragma once
#include <stdexcept>
#include "Enums.h"
namespace util
{
inline bool isAuthorized(Enums::EmployeeType current, Enums::EmployeeType first)
{
return current == first;
}
template <typename... Rest>
inline bool isAuthorized(Enums::EmployeeType current, Enums::EmployeeType first,
Rest... rest)
{
if (current == first)
{
return true;
}
return isAuthorized(current, rest...);
}
template <typename... Allowed>
inline void enforceAuthorization(Enums::EmployeeType current, Allowed... allowed)
{
if (!isAuthorized(current, allowed...))
{
throw std::runtime_error("You are unauthorized to perform this operation!");
}
}
}
+7 -117
View File
@@ -1,5 +1,11 @@
/*
* 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
#include <string>
namespace Enums {
@@ -90,120 +96,4 @@ namespace Enums {
USER_NOT_FOUND,
INVALID_PASSWORD
};
inline std::string getAccountStatusString(AccountStatus status)
{
switch (status)
{
case AccountStatus::ACTIVE:
return "ACTIVE";
case AccountStatus::INACTIVE:
return "INACTIVE";
default:
return "UNKNOWN";
}
}
inline std::string getEmployeeTypeString(EmployeeType type)
{
switch (type)
{
case EmployeeType::GENERAL:
return "GENERAL";
case EmployeeType::IT:
return "IT";
case EmployeeType::FINANCE:
return "FINANCE";
case EmployeeType::TAG:
return "TAG";
case EmployeeType::HR:
return "HR";
case EmployeeType::TEAM:
return "TEAM";
case EmployeeType::ADMIN:
return "ADMIN";
case EmployeeType::INVALID:
return "INVALID";
default:
return "UNKNOWN";
}
}
inline std::string getTeamStatusString(TeamStatus status)
{
switch (status)
{
case TeamStatus::IN_TEAM:
return "IN_TEAM";
case TeamStatus::NOT_IN_TEAM:
return "NOT_IN_TEAM";
default:
return "UNKNOWN";
}
}
inline std::string getEmployeeDesignationString(EmployeeDesignation designation)
{
switch (designation)
{
case EmployeeDesignation::JUNIOR:
return "JUNIOR";
case EmployeeDesignation::SENIOR:
return "SENIOR";
case EmployeeDesignation::TEAM_LEAD:
return "TEAM_LEAD";
case EmployeeDesignation::INVALID:
return "INVALID";
default:
return "UNKNOWN";
}
}
inline AccountStatus getAccountStatus(const std::string& input)
{
if (input == "ACTIVE")
return AccountStatus::ACTIVE;
if (input == "INACTIVE")
return AccountStatus::INACTIVE;
return AccountStatus::INACTIVE;
}
inline EmployeeType getEmployeeType(const std::string& input)
{
if (input == "GENERAL")
return EmployeeType::GENERAL;
if (input == "IT")
return EmployeeType::IT;
if (input == "FINANCE")
return EmployeeType::FINANCE;
if (input == "TAG")
return EmployeeType::TAG;
if (input == "HR")
return EmployeeType::HR;
if (input == "TEAM")
return EmployeeType::TEAM;
if (input == "ADMIN")
return EmployeeType::ADMIN;
return EmployeeType::INVALID;
}
inline TeamStatus getTeamStatus(const std::string& str)
{
if (str == "IN_TEAM")
return TeamStatus::IN_TEAM;
if (str == "NOT_IN_TEAM")
return TeamStatus::NOT_IN_TEAM;
return TeamStatus::NOT_IN_TEAM;
}
inline EmployeeDesignation getEmployeeDesignation(const std::string& input)
{
if (input == "JUNIOR")
return EmployeeDesignation::JUNIOR;
if (input == "SENIOR")
return EmployeeDesignation::SENIOR;
if (input == "TEAM_LEAD")
return EmployeeDesignation::TEAM_LEAD;
return EmployeeDesignation::INVALID;
}
}
@@ -1,5 +1,11 @@
#pragma once
/*
* File: InputHelper.h
* Description: Handles input validation and error handling
* Author: Smitha
* Created: 08-Apr-2026
*/
#pragma once
#include <iostream>
#include <limits>
#include <string>
@@ -7,6 +13,15 @@
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>
inline void read(T& value)
{
@@ -18,14 +33,29 @@ 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)
{
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()
{
std::cout << std::endl;
system("pause");
}
}
@@ -1,5 +1,20 @@
/*
* File: OutputHelper.cpp
* Description: Provides functions to help with console output.
* Author: Trenser
* Created: 01-04-2026
*/
#include "outputHelper.h"
/*
* Function: clear
* Description: Clears the console screen output.
* Parameters: None
* Returns:
* void - no return value
*/
void util::clear()
{
std::cout << "\x1B[2J\x1B[H" << std::flush;
@@ -1,3 +1,10 @@
/*
* File: OutputHelper.h
* Description: Provides functions to help with console output.
* Author: Trenser
* Created: 01-04-2026
*/
#pragma once
#include <iostream>
@@ -1,15 +0,0 @@
#include "StringHelper.h"
#include <cctype>
int util::extractNumber(const std::string& input)
{
int result = 0;
for (char character : input)
{
if (std::isdigit(static_cast<unsigned char>(character)))
{
result = result * 10 + (character - '0');
}
}
return result;
}
@@ -1,7 +0,0 @@
#pragma once
#include <string>
namespace util
{
int extractNumber(const std::string&);
}
@@ -1,18 +1,56 @@
/*
* 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 <iomanip>
#include <stdexcept>
#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()
{
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)
{
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)
{
std::tm timeStruct = {};
@@ -26,6 +64,15 @@ util::Timestamp util::Timestamp::fromString(const std::string& timeString)
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::tm timeStruct = {};
@@ -35,11 +82,30 @@ std::string util::Timestamp::toString() const
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)
{
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
{
std::tm timeStruct{};
@@ -50,36 +116,101 @@ int util::Timestamp::getDateAsInt() const
return year * 10000 + month * 100 + day;
}
/*
* 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)
{
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)
{
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
{
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
{
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
{
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
{
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
{
return m_time == other.m_time;
@@ -1,3 +1,12 @@
/*
* 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
#include <ctime>
#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 "Validator.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) {
if (phoneNumber.size() != 10)
{
@@ -16,6 +32,15 @@ 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) {
size_t index = email.find('@');
if (index == std::string::npos) return false;
@@ -30,6 +55,19 @@ bool util::isEmailValid(const std::string& email) {
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)
{
@@ -1,3 +1,10 @@
/*
* File: Validator.h
* Description: Validates inputs like phone number, email, password
* Author: Trenser
* Created: 01-Apr-2026
*/
#pragma once
#include<string>
#include<algorithm>
+38 -15
View File
@@ -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 "AdminMenu.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "MenuHelper.h"
#include"InputHelper.h"
#include"OutputHelper.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()
{
bool isMenuActive = true;
@@ -13,7 +28,7 @@ void AdminMenu::run()
{
int choice;
util::clear();
std::cout << "Admin Menu\n1. Create User\n2. View Employee\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Logout\nEnter your Choice: ";
std::cout << "Zenvy - HR Management System\n1. Create HRManager\n2. Create Employee\n3. View Employee\n4. Deactivate Employee\n5. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
@@ -28,27 +43,35 @@ 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)
{
switch (choice)
{
case 1:
createEmployee(m_zenvyController);
/*case 1:
m_zenvyController.createHRManager();
break;
case 2:
m_zenvyController.createEmployee();
break;
/*case 2:
m_zenvyController.viewEmployee();
break;*/
case 3:
deactivateEmployee(m_zenvyController);
m_zenvyController.viewEmployee();
break;
case 4:
m_zenvyController.deactivateEmployee();
break;*/
case 5:
updateProfile(m_zenvyController);
break;
case 6:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
util::pressEnter();
}
return true;
}
}
@@ -1,13 +1,19 @@
/*
* File: AdminMenu.h
* Description: Declaration of the AdminMenu class and related functions.
* Author: Trenser
* Created: 02-Apr-2026
*/
#pragma once
#include<memory>
#include"ZenvyController.h"
class AdminMenu
{
private:
std::shared_ptr<ZenvyController> m_zenvyController;
ZenvyController* m_zenvyController;
public:
AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {};
AdminMenu() :m_zenvyController(new ZenvyController()) {};
void run();
bool handleOperation(int);
};
@@ -1,9 +1,23 @@
/*
* File: EmployeeMenu.cpp
* Description: Implements the EmployeeMenu class functions including menu loop and operation handling.
* Author: Trenser
* Created: 02-Apr-2026
*/
#include <iostream>
#include "EmployeeMenu.h"
#include "InputHelper.h"
#include "OutputHelper.h"
#include "MenuHelper.h"
#include"InputHelper.h"
#include"OutputHelper.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()
{
bool isMenuActive = true;
@@ -13,7 +27,7 @@ void EmployeeMenu::run()
{
int choice;
util::clear();
std::cout << "Employee Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticke\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. Logout\nEnter your Choice: ";
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticke\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. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
@@ -28,12 +42,20 @@ 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)
{
switch (choice)
{
/*
case 1:
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
@@ -52,7 +74,7 @@ bool EmployeeMenu::handleOperation(int choice)
m_zenvyController.viewTicketHistory();
break;
case 7:
viewEmployees();
m_zenvyController.viewEmployees();
break;
case 8:
m_zenvyController.searchEmployee();
@@ -73,16 +95,9 @@ bool EmployeeMenu::handleOperation(int choice)
m_zenvyController.viewAnnouncements();
break;*/
case 14:
updateProfile(m_zenvyController);
break;
case 15:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
util::pressEnter();
}
return true;
}
}

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