Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed1cf4e306 | |||
| 7fc468ac4b | |||
| 8668a615ea | |||
| 282ab721b5 | |||
| 2c9740e776 | |||
| aa21853a65 | |||
| 66c80fd055 | |||
| 47b44ccaa0 | |||
| 1d94f1680c | |||
| c50700e70c | |||
| eac6fa72df | |||
| 03be8f81d2 | |||
| 451ed4fec2 | |||
| d29e38ef75 | |||
| 2031f510d5 | |||
| 4d4974efd7 | |||
| a955b64462 | |||
| daf33e1aab | |||
| f85614ecc5 | |||
| e470dbc791 | |||
| a001b7d159 | |||
| 0290467528 | |||
| 63627075ef | |||
| c27ca5240a | |||
| f75bbaaae8 | |||
| b3b9299c70 | |||
| 6256b9ea82 | |||
| 1785660e94 | |||
| 247e5dc6f6 | |||
| ef5ac42a92 | |||
| 07bd979685 |
@@ -426,3 +426,6 @@ FodyWeavers.xsd
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# CSV Files
|
||||
*.csv
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#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';
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#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);
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#include <stdexcept>
|
||||
#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);
|
||||
bool isHeader = true;
|
||||
for (const auto& record : lines)
|
||||
{
|
||||
if (isHeader)
|
||||
{
|
||||
isHeader = false;
|
||||
continue;
|
||||
}
|
||||
auto object = T::deserialize(record);
|
||||
if (!object)
|
||||
{
|
||||
throw std::runtime_error("Failed to deserialize record");
|
||||
}
|
||||
records[object->getId()] = object;
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void FileManager<T>::save(const objects<T>& records)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
lines.push_back(T::getHeaders());
|
||||
for (const auto& recordPair : records)
|
||||
{
|
||||
lines.push_back(recordPair.second->serialize());
|
||||
}
|
||||
FileIO::writeAllLines(m_filePath, lines);
|
||||
}
|
||||
@@ -135,11 +135,14 @@
|
||||
</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,6 +21,12 @@
|
||||
<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">
|
||||
@@ -29,5 +35,8 @@
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileIO.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -9,5 +9,10 @@
|
||||
|
||||
// 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,4 +1,5 @@
|
||||
#include "UserInterface.h"
|
||||
#include "FileManager.h"
|
||||
int main()
|
||||
{
|
||||
UserInterface userInterFace;
|
||||
|
||||
@@ -102,12 +102,17 @@
|
||||
<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)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)models;$(ProjectDir)controllers;$(ProjectDir)services;$(ProjectDir)utilities;$(ProjectDir)factories;$(ProjectDir)datastores;$(ProjectDir)views;%(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>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
@@ -117,11 +122,17 @@
|
||||
<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" />
|
||||
@@ -150,7 +161,7 @@
|
||||
<ClCompile Include="services\AttendanceManagementService.cpp" />
|
||||
<ClCompile Include="services\AuthenticationManagementService.cpp" />
|
||||
<ClCompile Include="services\BookingManagementService.cpp" />
|
||||
<ClCompile Include="services\EmployeeManagememtService.cpp" />
|
||||
<ClCompile Include="services\EmployeeManagementService.cpp" />
|
||||
<ClCompile Include="services\LeaveManagementService.cpp" />
|
||||
<ClCompile Include="services\LogService.cpp" />
|
||||
<ClCompile Include="services\NotificationManagementService.cpp" />
|
||||
@@ -162,9 +173,11 @@
|
||||
<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" />
|
||||
@@ -172,6 +185,7 @@
|
||||
<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" />
|
||||
@@ -204,7 +218,7 @@
|
||||
<ClInclude Include="services\AttendanceManagementService.h" />
|
||||
<ClInclude Include="services\AuthenticationManagementService.h" />
|
||||
<ClInclude Include="services\BookingManagementService.h" />
|
||||
<ClInclude Include="services\EmployeeManagememtService.h" />
|
||||
<ClInclude Include="services\EmployeeManagementService.h" />
|
||||
<ClInclude Include="services\LeaveManagementService.h" />
|
||||
<ClInclude Include="services\LogService.h" />
|
||||
<ClInclude Include="services\NotificationManagementService.h" />
|
||||
@@ -212,9 +226,11 @@
|
||||
<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" />
|
||||
@@ -222,6 +238,7 @@
|
||||
<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,9 +39,6 @@
|
||||
<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>
|
||||
@@ -192,14 +189,23 @@
|
||||
<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>
|
||||
@@ -338,6 +344,18 @@
|
||||
<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">
|
||||
|
||||
@@ -15,3 +15,46 @@ 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)
|
||||
{
|
||||
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();
|
||||
m_payslipManagementService->loadPayrolls();
|
||||
}
|
||||
|
||||
void ZenvyController::persistStates()
|
||||
{
|
||||
m_employeeManagementService->saveEmployees();
|
||||
m_payslipManagementService->savePayrolls();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "AuthenticationManagementService.h"
|
||||
#include "AttendanceManagementService.h"
|
||||
#include "BookingManagementService.h"
|
||||
#include "EmployeeManagememtService.h"
|
||||
#include "EmployeeManagementService.h"
|
||||
#include "LeaveManagementService.h"
|
||||
#include "NotificationManagementService.h"
|
||||
#include "PayslipManagementService.h"
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
std::shared_ptr<AuthenticationManagementService> m_authenticationManagementService;
|
||||
std::shared_ptr<AttendanceManagementService> m_attendanceManagementService;
|
||||
std::shared_ptr<BookingManagementService> m_bookingManagementService;
|
||||
std::shared_ptr<EmployeeManagememtService> m_employeeManagememtService;
|
||||
std::shared_ptr<EmployeeManagementService> m_employeeManagementService;
|
||||
std::shared_ptr<LeaveManagementService> m_leaveManagementService;
|
||||
std::shared_ptr<NotificationManagementService> m_notificationManagementService;
|
||||
std::shared_ptr<PayslipManagementService> m_payslipManagementService;
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
m_authenticationManagementService(std::make_shared<AuthenticationManagementService>()),
|
||||
m_attendanceManagementService(std::make_shared<AttendanceManagementService>()),
|
||||
m_bookingManagementService(std::make_shared<BookingManagementService>()),
|
||||
m_employeeManagememtService(std::make_shared<EmployeeManagememtService>()),
|
||||
m_employeeManagementService(std::make_shared<EmployeeManagementService>()),
|
||||
m_leaveManagementService(std::make_shared<LeaveManagementService>()),
|
||||
m_notificationManagementService(std::make_shared<NotificationManagementService>()),
|
||||
m_payslipManagementService(std::make_shared<PayslipManagementService>()),
|
||||
@@ -43,4 +43,18 @@ public:
|
||||
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();
|
||||
void persistStates();
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "DataStore.h"
|
||||
#include "EmployeeManagementService.h"
|
||||
|
||||
DataStore& DataStore::getInstance()
|
||||
{
|
||||
@@ -26,8 +27,7 @@ employeeMap& DataStore::getEmployees()
|
||||
return m_employees;
|
||||
}
|
||||
|
||||
std::shared_ptr<Employee>& DataStore::getAuthenticatedUser()
|
||||
payrollMap& DataStore::getPayrolls()
|
||||
{
|
||||
return m_authenticatedEmployee;
|
||||
return m_payrolls;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
#include "Notification.h"
|
||||
#include "Announcement.h"
|
||||
#include "Faq.h"
|
||||
#include "Payroll.h"
|
||||
|
||||
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
|
||||
using payrollMap = std::map<std::string, std::shared_ptr<Payroll>>;
|
||||
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>;
|
||||
|
||||
class DataStore
|
||||
@@ -27,6 +29,7 @@ class DataStore
|
||||
private:
|
||||
std::shared_ptr<Employee> m_authenticatedEmployee;
|
||||
employeeMap m_employees;
|
||||
payrollMap m_payrolls;
|
||||
logMap m_logs;
|
||||
DataStore() = default;
|
||||
public:
|
||||
@@ -36,7 +39,7 @@ public:
|
||||
DataStore(DataStore&&) = delete;
|
||||
DataStore& operator=(DataStore&&) = delete;
|
||||
employeeMap& getEmployees();
|
||||
std::shared_ptr<Employee>& getAuthenticatedUser();
|
||||
payrollMap& getPayrolls();
|
||||
logMap& getLogs();
|
||||
std::shared_ptr<Employee>& getAuthenticatedEmployee();
|
||||
void setAuthenticatedEmployee(std::shared_ptr < Employee>);
|
||||
|
||||
@@ -3,4 +3,30 @@
|
||||
|
||||
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,5 +1,7 @@
|
||||
#include "Announcement.h"
|
||||
|
||||
int Announcement::m_uid = 0;
|
||||
|
||||
const std::string& Announcement::getAnnouncementId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
class Announcement
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
util::Timestamp m_timestamp;
|
||||
std::string m_message;
|
||||
public:
|
||||
Announcement() : m_id(""), m_timestamp(), m_message("") {}
|
||||
Announcement(const std::string& id,
|
||||
const std::string& message)
|
||||
: m_id(id), m_message(message) {}
|
||||
Announcement() : m_id("AN" + std::to_string(++m_uid)), m_timestamp(), m_message("") {}
|
||||
Announcement(const std::string& message)
|
||||
: m_id("AN" + std::to_string(++m_uid)), m_message(message) {}
|
||||
const std::string& getAnnouncementId() const;
|
||||
const util::Timestamp& getAnnouncementTimestamp() const;
|
||||
const std::string& getAnnouncementMessage() const;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Attendance.h"
|
||||
|
||||
int Attendance::m_uid = 0;
|
||||
|
||||
const std::string& Attendance::getAttendanceId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
class Attendance
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
util::Timestamp m_loginTime;
|
||||
util::Timestamp m_logoutTime;
|
||||
public:
|
||||
Attendance() : m_id(""), m_loginTime(), m_logoutTime() {}
|
||||
Attendance(const std::string& id,
|
||||
const util::Timestamp& loginTime,
|
||||
Attendance() : m_id("AD" + std::to_string(++m_uid)), m_loginTime(), m_logoutTime() {}
|
||||
Attendance(const util::Timestamp& loginTime,
|
||||
const util::Timestamp& logoutTime)
|
||||
: m_id(id), m_loginTime(loginTime), m_logoutTime(logoutTime) {}
|
||||
: m_id("AD" + std::to_string(++m_uid)), m_loginTime(loginTime), m_logoutTime(logoutTime) {}
|
||||
const std::string& getAttendanceId() const;
|
||||
const util::Timestamp& getLoginTime() const;
|
||||
const util::Timestamp& getLogoutTime() const;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Booking.h"
|
||||
|
||||
int Booking::m_uid = 0;
|
||||
|
||||
const std::string& Booking::getBookingId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
class Booking
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
util::Timestamp m_startTime;
|
||||
util::Timestamp m_endTime;
|
||||
std::string m_employeeId;
|
||||
std::shared_ptr<Team> m_team;
|
||||
public:
|
||||
Booking() : m_id(""), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {}
|
||||
Booking(const std::string& id,
|
||||
const util::Timestamp& startTime,
|
||||
Booking() : m_id("BK" + std::to_string(++m_uid)), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {}
|
||||
Booking(const util::Timestamp& startTime,
|
||||
const util::Timestamp& endTime,
|
||||
const std::string& employeeId,
|
||||
std::shared_ptr<Team> team)
|
||||
: m_id(id), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
|
||||
: m_id("BK" + std::to_string(++m_uid)), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
|
||||
const std::string& getBookingId() const;
|
||||
const util::Timestamp& getStartTime() const;
|
||||
const util::Timestamp& getEndTime() const;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Candidate.h"
|
||||
|
||||
int Candidate::m_uid = 0;
|
||||
|
||||
const std::string& Candidate::getCandidateId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -5,19 +5,19 @@
|
||||
class Candidate
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_name;
|
||||
long int m_phone;
|
||||
std::string m_qualification;
|
||||
Enums::CandidateStatus m_status;
|
||||
public:
|
||||
Candidate() : m_id(""), m_name(""), m_phone(0), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
|
||||
Candidate(const std::string& id,
|
||||
const std::string& name,
|
||||
Candidate() : m_id("CD" + std::to_string(++m_uid)), m_name(""), m_phone(0), m_qualification(""), m_status(Enums::CandidateStatus::PENDING) {}
|
||||
Candidate(const std::string& name,
|
||||
long int phone,
|
||||
const std::string& qualification,
|
||||
Enums::CandidateStatus status)
|
||||
: m_id(id), m_name(name), m_phone(phone), m_qualification(qualification), m_status(status) {}
|
||||
: m_id("CD" + std::to_string(++m_uid)), 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;
|
||||
|
||||
@@ -1,6 +1,45 @@
|
||||
#include <sstream>
|
||||
#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"
|
||||
|
||||
const std::string& Employee::getEmployeeId() const
|
||||
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
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
@@ -128,3 +167,115 @@ 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::TALENT_ACQUISITION:
|
||||
return Factory::getObject<TalentExecutive>(
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Employee::getHeaders()
|
||||
{
|
||||
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
|
||||
}
|
||||
|
||||
@@ -7,13 +7,15 @@
|
||||
#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>>;
|
||||
|
||||
class Employee
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_password;
|
||||
std::string m_name;
|
||||
@@ -28,17 +30,41 @@ private:
|
||||
leaveMap m_leaves;
|
||||
Enums::EmployeeType m_employeeType;
|
||||
public:
|
||||
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,
|
||||
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,
|
||||
const std::string& teamId,
|
||||
Enums::EmployeeType employeeType,
|
||||
std::shared_ptr<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;
|
||||
: 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(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);
|
||||
const std::string& getId() const;
|
||||
const std::string& getEmployeePassword() const;
|
||||
const std::string& getEmployeeName() const;
|
||||
const std::string& getEmployeePhone() const;
|
||||
@@ -62,5 +88,8 @@ public:
|
||||
void addAttendance(std::shared_ptr<Attendance> attendance);
|
||||
void addLeave(std::shared_ptr<Leave> leave);
|
||||
Enums::EmployeeType getEmployeeType() const;
|
||||
virtual std::string serialize() const;
|
||||
static std::shared_ptr<Employee> deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
virtual ~Employee() = default;
|
||||
};
|
||||
@@ -3,5 +3,31 @@
|
||||
|
||||
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,4 +1,6 @@
|
||||
#include <sstream>
|
||||
#include "GeneralEmployee.h"
|
||||
#include "Factory.h"
|
||||
|
||||
Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
|
||||
{
|
||||
@@ -8,4 +10,57 @@ 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
|
||||
);
|
||||
}
|
||||
|
||||
std::string GeneralEmployee::getHeaders()
|
||||
{
|
||||
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
|
||||
}
|
||||
@@ -7,16 +7,42 @@ class GeneralEmployee : public Employee
|
||||
private:
|
||||
Enums::EmployeeDesignation m_designation;
|
||||
public:
|
||||
GeneralEmployee() : m_designation(Enums::EmployeeDesignation::JUNIOR) {}
|
||||
GeneralEmployee(const std::string& id,
|
||||
const std::string& password,
|
||||
const std::string& name,
|
||||
GeneralEmployee()
|
||||
: m_designation(Enums::EmployeeDesignation::JUNIOR) {}
|
||||
GeneralEmployee(const std::string& name,
|
||||
const std::string& phone,
|
||||
const std::string& email,
|
||||
const std::string& teamId,
|
||||
std::shared_ptr<Payroll> payroll,
|
||||
Enums::EmployeeDesignation designation) : Employee(id, password, name, phone, email, teamId,Enums::EmployeeType::GENERAL, payroll), m_designation(designation) {}
|
||||
Enums::EmployeeDesignation designation)
|
||||
: Employee(name,
|
||||
phone,
|
||||
email,
|
||||
Enums::EmployeeType::GENERAL,
|
||||
payroll),
|
||||
m_designation(designation) {}
|
||||
GeneralEmployee(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::EmployeeDesignation employeeDesignation,
|
||||
Enums::AccountStatus accountStatus)
|
||||
: Employee(id,
|
||||
name,
|
||||
phone,
|
||||
password,
|
||||
email,
|
||||
teamId,
|
||||
teamStatus,
|
||||
Enums::EmployeeType::GENERAL,
|
||||
accountStatus),
|
||||
m_designation(employeeDesignation) {}
|
||||
Enums::EmployeeDesignation getDesignation() const;
|
||||
void setDesignation(Enums::EmployeeDesignation designation);
|
||||
std::string serialize() const override;
|
||||
static std::shared_ptr<GeneralEmployee> deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
~GeneralEmployee() = default;
|
||||
};
|
||||
@@ -3,5 +3,31 @@
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,5 +3,31 @@
|
||||
|
||||
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,5 +1,7 @@
|
||||
#include "JobListing.h"
|
||||
|
||||
int JobListing::m_uid = 0;
|
||||
|
||||
const std::string& JobListing::getJobId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -9,6 +9,7 @@ using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>;
|
||||
class JobListing
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
@@ -16,14 +17,13 @@ private:
|
||||
int m_numberOfVacancies;
|
||||
candidateMap m_candidates;
|
||||
public:
|
||||
JobListing() : m_id(""), m_name(""), m_description(""), m_status(Enums::JobListingStatus::CLOSED), m_numberOfVacancies(0) {}
|
||||
JobListing(const std::string& id,
|
||||
const std::string& name,
|
||||
JobListing() : m_id("JL" + std::to_string(++m_uid)), m_name(""), m_description(""), m_status(Enums::JobListingStatus::CLOSED), m_numberOfVacancies(0) {}
|
||||
JobListing(const std::string& name,
|
||||
const std::string& description,
|
||||
Enums::JobListingStatus status,
|
||||
int numberOfVacancies,
|
||||
const candidateMap& candidates)
|
||||
: m_id(id), m_name(name), m_description(description), m_status(status), m_numberOfVacancies(numberOfVacancies), m_candidates(candidates) {}
|
||||
: m_id("JL" + std::to_string(++m_uid)), 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;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Leave.h"
|
||||
|
||||
int Leave::m_uid = 0;
|
||||
|
||||
const std::string& Leave::getLeaveId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
class Leave
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_employeeId;
|
||||
util::Timestamp m_timestamp;
|
||||
@@ -15,13 +16,12 @@ private:
|
||||
static int m_numberOfMedicalLeave;
|
||||
Enums::LeaveType m_leaveType;
|
||||
public:
|
||||
Leave() : m_id(""), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
|
||||
Leave(const std::string& id,
|
||||
const std::string& employeeId,
|
||||
Leave() : m_id("LV" + std::to_string(++m_uid)), m_employeeId(""), m_timestamp(), m_reason(""), m_leaveType(Enums::LeaveType::GENERAL) {}
|
||||
Leave(const std::string& employeeId,
|
||||
const util::Timestamp& timestamp,
|
||||
const std::string& reason,
|
||||
Enums::LeaveType leaveType)
|
||||
: m_id(id), m_employeeId(employeeId), m_timestamp(timestamp), m_reason(reason), m_leaveType(leaveType) {}
|
||||
: m_id("LV" + std::to_string(++m_uid)), 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,7 @@
|
||||
#include "Notification.h"
|
||||
|
||||
int Notification::m_uid = 0;
|
||||
|
||||
const std::string& Notification::getNotificationId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
class Notification
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_employeeId;
|
||||
std::string m_message;
|
||||
util::Timestamp m_timestamp;
|
||||
Enums::NotificationStatus m_notificationStatus;
|
||||
public:
|
||||
Notification() : m_id(""), m_employeeId(""), m_message(""), m_timestamp(), m_notificationStatus(Enums::NotificationStatus::UNREAD) {}
|
||||
Notification(const std::string& id,
|
||||
const std::string& employeeId,
|
||||
Notification() : m_id("NF" + std::to_string(++m_uid)), m_employeeId(""), m_message(""), m_timestamp(), m_notificationStatus(Enums::NotificationStatus::UNREAD) {}
|
||||
Notification(const std::string& employeeId,
|
||||
const std::string& message,
|
||||
Enums::NotificationStatus notificationStatus)
|
||||
: m_id(id), m_employeeId(employeeId), m_message(message), m_notificationStatus(notificationStatus) {}
|
||||
: m_id("NF" + std::to_string(++m_uid)), m_employeeId(employeeId), m_message(message), m_notificationStatus(notificationStatus) {}
|
||||
const std::string& getNotificationId() const;
|
||||
const std::string& getEmployeeId() const;
|
||||
const std::string& getNotificationMessage() const;
|
||||
|
||||
@@ -1,10 +1,48 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include "Payroll.h"
|
||||
#include "StringHelper.h"
|
||||
#include "Factory.h"
|
||||
|
||||
const std::string& Payroll::getPayrollId() const
|
||||
int Payroll::m_uid = 0;
|
||||
|
||||
Payroll::Payroll(const std::string& id,
|
||||
const std::string& employeeId,
|
||||
double basicSalary,
|
||||
double houseRentAllowance,
|
||||
double foodAllowance,
|
||||
double employeePFContribution,
|
||||
double employerPFContribution)
|
||||
: m_id(id),
|
||||
m_employeeId(employeeId),
|
||||
m_basicSalary(basicSalary),
|
||||
m_houseRentAllowance(houseRentAllowance),
|
||||
m_foodAllowance(foodAllowance),
|
||||
m_employeePFContribution(employeePFContribution),
|
||||
m_employerPFContribution(employerPFContribution)
|
||||
{
|
||||
int idNumber = util::extractNumber(m_id);
|
||||
if (idNumber > m_uid)
|
||||
{
|
||||
m_uid = idNumber;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& Payroll::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
const std::string& Payroll::getEmployeeId() const
|
||||
{
|
||||
return m_employeeId;
|
||||
}
|
||||
|
||||
void Payroll::setEmployeeId(const std::string& employeeId)
|
||||
{
|
||||
m_employeeId = employeeId;
|
||||
}
|
||||
|
||||
double Payroll::getBasicSalary() const
|
||||
{
|
||||
return m_basicSalary;
|
||||
@@ -30,9 +68,9 @@ double Payroll::getEmployerPFContribution() const
|
||||
return m_employerPFContribution;
|
||||
}
|
||||
|
||||
void Payroll::setPayrollID(const std::string& id)
|
||||
void Payroll::setBasicSalary(double basicSalary)
|
||||
{
|
||||
m_id = id;
|
||||
m_basicSalary = basicSalary;
|
||||
}
|
||||
|
||||
void Payroll::setHouseRentAllowance(double value)
|
||||
@@ -53,4 +91,58 @@ void Payroll::setEmployeePFContribution(double value)
|
||||
void Payroll::setEmployerPFContribution(double value)
|
||||
{
|
||||
m_employerPFContribution = value;
|
||||
}
|
||||
|
||||
std::string Payroll::serialize() const
|
||||
{
|
||||
std::ostringstream serializedPayroll;
|
||||
serializedPayroll << m_id << ','
|
||||
<< m_employeeId << ','
|
||||
<< m_basicSalary << ','
|
||||
<< m_houseRentAllowance << ','
|
||||
<< m_foodAllowance << ','
|
||||
<< m_employeePFContribution << ','
|
||||
<< m_employerPFContribution;
|
||||
return serializedPayroll.str();
|
||||
}
|
||||
|
||||
std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
|
||||
{
|
||||
std::string id, employeeId;
|
||||
std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString;
|
||||
std::istringstream serializedPayroll(record);
|
||||
std::getline(serializedPayroll, id, ',');
|
||||
std::getline(serializedPayroll, employeeId, ',');
|
||||
std::getline(serializedPayroll, basicSalaryString, ',');
|
||||
std::getline(serializedPayroll, houseRentAllowanceString, ',');
|
||||
std::getline(serializedPayroll, foodAllowanceString, ',');
|
||||
std::getline(serializedPayroll, employeePFString, ',');
|
||||
std::getline(serializedPayroll, employerPFString, ',');
|
||||
|
||||
try
|
||||
{
|
||||
double basicSalary = std::stod(basicSalaryString);
|
||||
double houseRentAllowance = std::stod(houseRentAllowanceString);
|
||||
double foodAllowance = std::stod(foodAllowanceString);
|
||||
double employeePFContribution = std::stod(employeePFString);
|
||||
double employerPFContribution = std::stod(employerPFString);
|
||||
return Factory::getObject<Payroll>(
|
||||
id,
|
||||
employeeId,
|
||||
basicSalary,
|
||||
houseRentAllowance,
|
||||
foodAllowance,
|
||||
employeePFContribution,
|
||||
employerPFContribution
|
||||
);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw std::runtime_error("Failed to deserialize Payroll object");
|
||||
}
|
||||
}
|
||||
|
||||
std::string Payroll::getHeaders()
|
||||
{
|
||||
return "PayrollId,EmployeeId,BasicSalary,HouseRentAllowance,FoodAllowance,EmployeePFContribution,EmployerPFContribution";
|
||||
}
|
||||
@@ -1,33 +1,58 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class Payroll
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_employeeId;
|
||||
double m_basicSalary;
|
||||
double m_houseRentAllowance;
|
||||
double m_foodAllowance;
|
||||
double m_employeePFContribution;
|
||||
double m_employerPFContribution;
|
||||
public:
|
||||
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,
|
||||
Payroll()
|
||||
: m_id("PR" + std::to_string(++m_uid)),
|
||||
m_basicSalary(0.0),
|
||||
m_houseRentAllowance(0.0),
|
||||
m_foodAllowance(0.0),
|
||||
m_employeePFContribution(0.0),
|
||||
m_employerPFContribution(0.0) {}
|
||||
Payroll(double basicSalary,
|
||||
double houseRentAllowance,
|
||||
double foodAllowance,
|
||||
double employeePFContribution,
|
||||
double employerPFContribution)
|
||||
: m_id(id), m_basicSalary(basicSalary), m_houseRentAllowance(houseRentAllowance), m_foodAllowance(foodAllowance), m_employeePFContribution(employeePFContribution), m_employerPFContribution(employerPFContribution) {}
|
||||
const std::string& getPayrollId() const;
|
||||
: m_id("PR" + std::to_string(++m_uid)),
|
||||
m_basicSalary(basicSalary),
|
||||
m_houseRentAllowance(houseRentAllowance),
|
||||
m_foodAllowance(foodAllowance),
|
||||
m_employeePFContribution(employeePFContribution),
|
||||
m_employerPFContribution(employerPFContribution) {}
|
||||
Payroll(const std::string& id,
|
||||
const std::string& employeeId,
|
||||
double basicSalary,
|
||||
double houseRentAllowance,
|
||||
double foodAllowance,
|
||||
double employeePFContribution,
|
||||
double employerPFContribution);
|
||||
const std::string& getId() const;
|
||||
const std::string& getEmployeeId() const;
|
||||
void setEmployeeId(const std::string&);
|
||||
double getBasicSalary() const;
|
||||
double getHouseRentAllowance() const;
|
||||
double getFoodAllowance() const;
|
||||
double getEmployeePFContribution() const;
|
||||
double getEmployerPFContribution() const;
|
||||
void setPayrollID(const std::string& id);
|
||||
void setHouseRentAllowance(double value);
|
||||
void setFoodAllowance(double value);
|
||||
void setEmployeePFContribution(double value);
|
||||
void setEmployerPFContribution(double value);
|
||||
void setBasicSalary(double);
|
||||
void setHouseRentAllowance(double);
|
||||
void setFoodAllowance(double);
|
||||
void setEmployeePFContribution(double);
|
||||
void setEmployerPFContribution(double);
|
||||
virtual std::string serialize() const;
|
||||
static std::shared_ptr<Payroll> deserialize(const std::string&);
|
||||
static std::string getHeaders();
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Payslip.h"
|
||||
|
||||
int Payslip::m_uid = 0;
|
||||
|
||||
const std::string& Payslip::getPayslipId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
class Payslip
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
double m_salary;
|
||||
public:
|
||||
Payslip() : m_id(""), m_salary(0.0) {}
|
||||
Payslip(const std::string& id, double salary) : m_id(id), m_salary(salary) {}
|
||||
Payslip() : m_id("PS" + std::to_string(++m_uid)), m_salary(0.0) {}
|
||||
Payslip(const double salary) : m_id("PS" + std::to_string(++m_uid)), m_salary(salary) {}
|
||||
const std::string& getPayslipId() const;
|
||||
double getSalary() const;
|
||||
void setPayslipId(const std::string& id);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Room.h"
|
||||
|
||||
int Room::m_uid = 0;
|
||||
|
||||
const std::string& Room::getRoomId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -8,12 +8,13 @@ using bookingMap = std::map<std::string, std::shared_ptr<Booking>>;
|
||||
class Room
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_name;
|
||||
bookingMap m_bookings;
|
||||
public:
|
||||
Room() : m_id(""), m_name("") {}
|
||||
Room(const std::string& id, const std::string& name) : m_id(id), m_name(name) {}
|
||||
Room() : m_id("RM" + std::to_string(++m_uid)), m_name("") {}
|
||||
Room(const std::string& name) : m_id("RM" + std::to_string(++m_uid)), m_name(name) {}
|
||||
const std::string& getRoomId() const;
|
||||
const std::string& getRoomName() const;
|
||||
const bookingMap& getBookings() const;
|
||||
|
||||
@@ -3,5 +3,32 @@
|
||||
|
||||
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::TALENT_ACQUISITION, payroll) {};
|
||||
TalentExecutive(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::TALENT_ACQUISITION,
|
||||
accountStatus) {
|
||||
}
|
||||
~TalentExecutive() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Team.h"
|
||||
|
||||
int Team::m_uid = 0;
|
||||
|
||||
const std::string& Team::getTeamId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -8,18 +8,19 @@ using employeeMap = std::map<std::string, std::shared_ptr<Employee>>;
|
||||
class Team
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
std::string m_name;
|
||||
std::shared_ptr<Employee> m_lead;
|
||||
employeeMap m_employees;
|
||||
int m_maximumNumberOfEmployees;
|
||||
public:
|
||||
Team() : m_id(""), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
|
||||
Team(const std::string& id,
|
||||
Team() : m_id("TM" + std::to_string(++m_uid)), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
|
||||
Team(
|
||||
const std::string& name,
|
||||
std::shared_ptr<Employee> lead,
|
||||
int maximumNumberOfEmployees)
|
||||
: m_id(id), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
|
||||
: m_id("TM" + std::to_string(++m_uid)), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
|
||||
}
|
||||
const std::string& getTeamId() const;
|
||||
const std::string& getTeamName() const;
|
||||
|
||||
@@ -3,5 +3,31 @@
|
||||
|
||||
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,5 +1,7 @@
|
||||
#include "Ticket.h"
|
||||
|
||||
int Ticket::m_uid = 0;
|
||||
|
||||
const std::string& Ticket::getTicketId() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
class Ticket
|
||||
{
|
||||
private:
|
||||
static int m_uid;
|
||||
std::string m_id;
|
||||
Enums::TicketType m_type;
|
||||
std::string m_description;
|
||||
Enums::TicketStatus m_status;
|
||||
std::string m_employeeId;
|
||||
public:
|
||||
Ticket() : m_id(""), m_type(Enums::TicketType::UNKNOWN), m_description(""), m_status(Enums::TicketStatus::OPEN), m_employeeId("") {}
|
||||
Ticket(const std::string& id,
|
||||
Ticket() : m_id("TKT" + std::to_string(++m_uid)), m_type(Enums::TicketType::UNKNOWN), m_description(""), m_status(Enums::TicketStatus::OPEN), m_employeeId("") {}
|
||||
Ticket(
|
||||
Enums::TicketType type,
|
||||
const std::string& description,
|
||||
const std::string& employeeId,
|
||||
Enums::TicketStatus status)
|
||||
: m_id(id), m_type(type), m_description(description), m_status(status), m_employeeId(employeeId) {}
|
||||
: m_id("TKT" + std::to_string(++m_uid)), 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;
|
||||
|
||||
@@ -6,4 +6,35 @@ namespace Config
|
||||
{
|
||||
constexpr const char* DEFAULT_PASSWORD = "password";
|
||||
}
|
||||
|
||||
namespace Payroll
|
||||
{
|
||||
constexpr double SENIOR_BASIC_SALARY = 80000.0;
|
||||
constexpr double SENIOR_HOUSE_RENT_ALLOWANCE = 32000.0;
|
||||
constexpr double SENIOR_FOOD_ALLOWANCE = 3000.0;
|
||||
constexpr double SENIOR_EMPLOYEE_PF_CONTRIBUTION = 9600.0;
|
||||
constexpr double SENIOR_EMPLOYER_PF_CONTRIBUTION = 9600.0;
|
||||
constexpr double JUNIOR_BASIC_SALARY = 25000.0;
|
||||
constexpr double JUNIOR_HOUSE_RENT_ALLOWANCE = 10000.0;
|
||||
constexpr double JUNIOR_FOOD_ALLOWANCE = 1500.0;
|
||||
constexpr double JUNIOR_EMPLOYEE_PF_CONTRIBUTION = 3000.0;
|
||||
constexpr double JUNIOR_EMPLOYER_PF_CONTRIBUTION = 3000.0;
|
||||
constexpr double HR_MANAGER_BASIC_SALARY = 60000.0;
|
||||
constexpr double HR_MANAGER_HOUSE_RENT_ALLOWANCE = 24000.0;
|
||||
constexpr double HR_MANAGER_FOOD_ALLOWANCE = 2500.0;
|
||||
constexpr double HR_MANAGER_EMPLOYEE_PF_CONTRIBUTION = 7200.0;
|
||||
constexpr double HR_MANAGER_EMPLOYER_PF_CONTRIBUTION = 7200.0;
|
||||
constexpr double EXECUTIVE_BASIC_SALARY = 45000.0;
|
||||
constexpr double EXECUTIVE_HOUSE_RENT_ALLOWANCE = 18000.0;
|
||||
constexpr double EXECUTIVE_FOOD_ALLOWANCE = 2000.0;
|
||||
constexpr double EXECUTIVE_EMPLOYEE_PF_CONTRIBUTION = 5400.0;
|
||||
constexpr double EXECUTIVE_EMPLOYER_PF_CONTRIBUTION = 5400.0;
|
||||
}
|
||||
|
||||
namespace File
|
||||
{
|
||||
constexpr const char* EMPLOYEES_FILE = "files/Employee.csv";
|
||||
constexpr const char* GENERAL_EMPLOYEES_FILE = "files/GeneralEmployee.csv";
|
||||
constexpr const char* PAYROLL_FILE = "files/Payroll.csv";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ AuthenticationDTO AuthenticationManagementService::login(const std::string& emai
|
||||
|
||||
void AuthenticationManagementService::changePassword(const std::string& password)
|
||||
{
|
||||
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedUser();
|
||||
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedEmployee();
|
||||
if (authenticatedUser)
|
||||
{
|
||||
authenticatedUser->setEmployeePassword(password);
|
||||
@@ -61,8 +61,8 @@ void AuthenticationManagementService::changePassword(const std::string& password
|
||||
}
|
||||
|
||||
void AuthenticationManagementService::logout() {
|
||||
if (m_dataStore.getAuthenticatedUser()) {
|
||||
m_dataStore.getAuthenticatedUser() = nullptr;
|
||||
if (m_dataStore.getAuthenticatedEmployee()) {
|
||||
m_dataStore.getAuthenticatedEmployee() = nullptr;
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("No user currently logged In...");
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "EmployeeManagememtService.h"
|
||||
@@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
class EmployeeManagememtService
|
||||
{
|
||||
};
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
#include <map>
|
||||
#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"
|
||||
|
||||
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 && util::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 (util::isEmailDuplicate(email, employees))
|
||||
{
|
||||
throw std::runtime_error("Duplicate Email");
|
||||
}
|
||||
if (util::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::TALENT_ACQUISITION:
|
||||
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::TALENT_ACQUISITION:
|
||||
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");
|
||||
}
|
||||
payroll->setEmployeeId(employee->getId());
|
||||
m_dataStore.getPayrolls().emplace(std::make_pair(payroll->getId(), payroll));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
void EmployeeManagementService::saveEmployees()
|
||||
{
|
||||
FileManager<Employee> employeeFileManager(Config::File::EMPLOYEES_FILE);
|
||||
FileManager<GeneralEmployee> generalEmployeeFileManager(Config::File::GENERAL_EMPLOYEES_FILE);
|
||||
const auto& allEmployees = m_dataStore.getEmployees();
|
||||
employeeMap employees;
|
||||
std::map<std::string, std::shared_ptr<GeneralEmployee>> generalEmployees;
|
||||
for (auto& employeePair : allEmployees)
|
||||
{
|
||||
if (employeePair.second->getEmployeeType() == Enums::EmployeeType::GENERAL)
|
||||
{
|
||||
generalEmployees.emplace(employeePair.first, std::static_pointer_cast<GeneralEmployee>(employeePair.second));
|
||||
}
|
||||
else
|
||||
{
|
||||
employees.emplace(employeePair);
|
||||
}
|
||||
}
|
||||
employeeFileManager.save(employees);
|
||||
generalEmployeeFileManager.save(generalEmployees);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#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();
|
||||
void saveEmployees();
|
||||
};
|
||||
@@ -1 +1,50 @@
|
||||
#include <stdexcept>
|
||||
#include "PayslipManagementService.h"
|
||||
#include "ApplicationConfig.h"
|
||||
#include "AuthorizationHelper.h"
|
||||
#include "Enums.h"
|
||||
#include "FileManager.h"
|
||||
|
||||
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)
|
||||
{
|
||||
auto payroll = employee->second->getPayroll();
|
||||
payroll->setBasicSalary(basicSalary);
|
||||
payroll->setHouseRentAllowance(houseRentAllowance);
|
||||
payroll->setFoodAllowance(foodAllowance);
|
||||
payroll->setEmployeePFContribution(employeePFContribution);
|
||||
payroll->setEmployerPFContribution(employerPFContribution);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Employee not found, unable to update the salary");
|
||||
}
|
||||
}
|
||||
|
||||
void PayslipManagementService::loadPayrolls()
|
||||
{
|
||||
FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE);
|
||||
auto& payrolls = m_dataStore.getPayrolls();
|
||||
auto& employees = m_dataStore.getEmployees();
|
||||
auto payrollObjects = payrollFileManager.load();
|
||||
for (const auto& payrollPair : payrollObjects)
|
||||
{
|
||||
auto employeeIterator = employees.find(payrollPair.second->getEmployeeId());
|
||||
if (employeeIterator == employees.end())
|
||||
{
|
||||
throw std::runtime_error("Payroll Object not associated with an existing employee");
|
||||
}
|
||||
employeeIterator->second->setEmployeePayroll(payrollPair.second);
|
||||
}
|
||||
payrolls.insert(payrollObjects.begin(), payrollObjects.end());
|
||||
}
|
||||
|
||||
void PayslipManagementService::savePayrolls()
|
||||
{
|
||||
FileManager<Payroll> payrollFileManager(Config::File::PAYROLL_FILE);
|
||||
auto& payrolls = m_dataStore.getPayrolls();
|
||||
payrollFileManager.save(payrolls);
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include<stdexcept>
|
||||
#include"DataStore.h"
|
||||
|
||||
class PayslipManagementService
|
||||
{
|
||||
private:
|
||||
DataStore& m_dataStore;
|
||||
public:
|
||||
PayslipManagementService() : m_dataStore(DataStore::getInstance()) {};
|
||||
void updateSalary(const std::string&, double, double, double, double, double);
|
||||
void loadPayrolls();
|
||||
void savePayrolls();
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "AuthorizationHelper.h"
|
||||
@@ -0,0 +1,31 @@
|
||||
#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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace Enums {
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace Enums {
|
||||
GENERAL,
|
||||
IT,
|
||||
FINANCE,
|
||||
TAG,
|
||||
TALENT_ACQUISITION,
|
||||
HR,
|
||||
TEAM,
|
||||
ADMIN,
|
||||
@@ -89,4 +90,148 @@ 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::TALENT_ACQUISITION:
|
||||
return "TALENT_ACQUISITION";
|
||||
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 == "TALENT_ACQUISITION")
|
||||
{
|
||||
return EmployeeType::TALENT_ACQUISITION;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace util
|
||||
|
||||
inline void pressEnter()
|
||||
{
|
||||
std::cout << std::endl;
|
||||
system("pause");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace util
|
||||
{
|
||||
int extractNumber(const std::string&);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
#include "Validator.h"
|
||||
#include "Employee.h"
|
||||
#include "ApplicationConfig.h"
|
||||
|
||||
bool util::isPhoneNumberValid(const std::string& phoneNumber) {
|
||||
@@ -18,7 +18,10 @@ bool util::isPhoneNumberValid(const std::string& phoneNumber) {
|
||||
|
||||
bool util::isEmailValid(const std::string& email) {
|
||||
size_t index = email.find('@');
|
||||
if (index == std::string::npos) return false;
|
||||
if (index == std::string::npos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (email.find('@', index + 1) != std::string::npos)
|
||||
{
|
||||
return false;
|
||||
@@ -69,3 +72,54 @@ bool util::isPasswordValid(const std::string& password)
|
||||
}
|
||||
return hasUpper && hasLower && hasDigit && hasSpecial;
|
||||
}
|
||||
|
||||
bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map<std::string, std::shared_ptr<Employee>> & employees)
|
||||
{
|
||||
for (const auto& employeePair : employees)
|
||||
{
|
||||
const auto& employee = employeePair.second;
|
||||
if (employee->getEmployeeType() == employeeType && employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util::isEmailDuplicate(const std::string& email, const std::map<std::string, std::shared_ptr<Employee>>& employees)
|
||||
{
|
||||
for (const auto& employeePair : employees)
|
||||
{
|
||||
const auto& employee = employeePair.second;
|
||||
if (employee->getEmployeeEmail() == email)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util::isPhoneDuplicate(const std::string& phone, const std::map<std::string, std::shared_ptr<Employee>>& employees)
|
||||
{
|
||||
for (const auto& employeePair : employees)
|
||||
{
|
||||
const auto& employee = employeePair.second;
|
||||
if (employee->getEmployeePhone() == phone)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util::isPhoneDuplicate(const std::string& phone, const std::vector<std::shared_ptr<const Employee>>& employees)
|
||||
{
|
||||
for (const auto& employee : employees)
|
||||
{
|
||||
if (employee->getEmployeePhone() == phone)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
#pragma once
|
||||
#include<string>
|
||||
#include<map>
|
||||
#include<memory>
|
||||
#include<vector>
|
||||
#include<algorithm>
|
||||
#include<cctype>
|
||||
#include "Enums.h"
|
||||
|
||||
class Employee;
|
||||
|
||||
namespace util
|
||||
{
|
||||
bool isPhoneNumberValid(const std::string&);
|
||||
bool isEmailValid(const std::string&);
|
||||
bool isPasswordValid(const std::string&);
|
||||
bool hasActiveEmployeeOfType(Enums::EmployeeType, const std::map<std::string, std::shared_ptr<Employee>>&);
|
||||
bool isEmailDuplicate(const std::string&, const std::map<std::string, std::shared_ptr<Employee>>&);
|
||||
bool isPhoneDuplicate(const std::string&, const std::map<std::string, std::shared_ptr<Employee>>&);
|
||||
bool isPhoneDuplicate(const std::string&, const std::vector<std::shared_ptr<const Employee>>&);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "AdminMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void AdminMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void AdminMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - HR Management System\n1. Create HRManager\n2. Create Employee\n3. View Employee\n4. Deactivate Employee\n5. Logout\nEnter your Choice: ";
|
||||
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -31,22 +32,23 @@ bool AdminMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
/*case 1:
|
||||
m_zenvyController.createHRManager();
|
||||
case 1:
|
||||
createEmployee(m_zenvyController);
|
||||
break;
|
||||
case 2:
|
||||
m_zenvyController.createEmployee();
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
case 3:
|
||||
m_zenvyController.viewEmployee();
|
||||
deactivateEmployee(m_zenvyController);
|
||||
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,7 +1,9 @@
|
||||
#include <iostream>
|
||||
#include<iomanip>
|
||||
#include "EmployeeMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void EmployeeMenu::run()
|
||||
{
|
||||
@@ -12,7 +14,7 @@ void EmployeeMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
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: ";
|
||||
std::cout << "Employee Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. Raise Ticket\n5. View Ticket\n6. View Ticket History\n7. View Employees\n8. Search Employee\n9. View Team Members\n10. Book Meeting Room\n11. View Booking History\n12. View Notification\n13. View Announcements\n14. Update Profile\n15. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -31,7 +33,8 @@ bool EmployeeMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
/*case 1:
|
||||
/*
|
||||
case 1:
|
||||
m_zenvyController.applyLeave();
|
||||
break;
|
||||
case 2:
|
||||
@@ -48,11 +51,11 @@ bool EmployeeMenu::handleOperation(int choice)
|
||||
break;
|
||||
case 6:
|
||||
m_zenvyController.viewTicketHistory();
|
||||
break;
|
||||
break;*/
|
||||
case 7:
|
||||
m_zenvyController.viewEmployees();
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
case 8:
|
||||
/*case 8:
|
||||
m_zenvyController.searchEmployee();
|
||||
break;
|
||||
case 9:
|
||||
@@ -71,9 +74,13 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "FinanceExecutiveMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void FinanceExecutiveMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void FinanceExecutiveMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Generate Payslip\n10. Update Payroll\n11. Logout\nEnter your Choice: ";
|
||||
std::cout << "Finance Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Generate Payslip\n10. Update Payroll\n11. Update Profile\n12. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -27,44 +28,74 @@ void FinanceExecutiveMenu::run()
|
||||
}
|
||||
}
|
||||
|
||||
void FinanceExecutiveMenu::updatePayroll()
|
||||
{
|
||||
std::string employeeId;
|
||||
double basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution;
|
||||
employeeId = selectEmployeeId(m_zenvyController->getEmployees());
|
||||
util::clear();
|
||||
if (employeeId != "") {
|
||||
std::cout << "Enter the New Basic Salary: ";
|
||||
util::read(basicSalary);
|
||||
std::cout << "Enter the New House Rent Allowance: ";
|
||||
util::read(houseRentAllowance);
|
||||
std::cout << "Enter the New Food Allowance: ";
|
||||
util::read(foodAllowance);
|
||||
std::cout << "Enter the New EmployeePFContribution: ";
|
||||
util::read(employeePFContribution);
|
||||
std::cout << "Enter the New EmployerPFContribution: ";
|
||||
util::read(employerPFContribution);
|
||||
m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
|
||||
std::cout << "Payroll Updated";
|
||||
util::pressEnter();
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("Unexpected error occured");
|
||||
}
|
||||
}
|
||||
|
||||
bool FinanceExecutiveMenu::handleOperation(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
/*case 1:
|
||||
m_zenvyController.applyLeave();
|
||||
break;
|
||||
case 2:
|
||||
m_zenvyController.viewPayslip();
|
||||
break;
|
||||
case 3:
|
||||
m_zenvyController.viewPayslipHistory();
|
||||
break;
|
||||
//case 1:
|
||||
// m_zenvyController.applyLeave();
|
||||
// break;
|
||||
//case 2:
|
||||
// m_zenvyController.viewPayslip();
|
||||
// break;
|
||||
//case 3:
|
||||
// m_zenvyController.viewPayslipHistory();
|
||||
// break;
|
||||
case 4:
|
||||
m_zenvyController.viewEmployees();
|
||||
break;
|
||||
case 5:
|
||||
m_zenvyController.searchEmployee();
|
||||
break;
|
||||
case 6:
|
||||
m_zenvyController.viewNotifications();
|
||||
break;
|
||||
case 7:
|
||||
m_zenvyController.viewAnnouncements();
|
||||
break;
|
||||
case 8:
|
||||
m_zenvyController.resolveTicket();
|
||||
break;
|
||||
case 9:
|
||||
m_zenvyController.generatePayslip();
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
//case 5:
|
||||
// m_zenvyController.searchEmployee();
|
||||
// break;
|
||||
//case 6:
|
||||
// m_zenvyController.viewNotifications();
|
||||
// break;
|
||||
//case 7:
|
||||
// m_zenvyController.viewAnnouncements();
|
||||
// break;
|
||||
//case 8:
|
||||
// m_zenvyController.resolveTicket();
|
||||
// break;
|
||||
//case 9:
|
||||
// m_zenvyController.generatePayslip();
|
||||
// break;
|
||||
case 10:
|
||||
m_zenvyController.updatePayroll();
|
||||
break;*/
|
||||
updatePayroll();
|
||||
break;
|
||||
case 11:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 12:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
util::pressEnter();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
#include<memory>
|
||||
#include<iostream>
|
||||
#include<stdexcept>
|
||||
#include <iomanip>
|
||||
#include"ZenvyController.h"
|
||||
|
||||
class FinanceExecutiveMenu
|
||||
@@ -10,5 +13,6 @@ public:
|
||||
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {};
|
||||
void run();
|
||||
bool handleOperation(int);
|
||||
void updatePayroll();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "HRManagerMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void HRManagerMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void HRManagerMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Register CandidateAsEmployee\n12. Logout\nEnter your Choice: ";
|
||||
std::cout << "HR Manager Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Register CandidateAsEmployee\n12. Update Profile\n13. Deactivate Employee\n14. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -40,9 +41,9 @@ bool HRManagerMenu::handleOperation(int choice)
|
||||
//case 3:
|
||||
// m_zenvyController.viewPayslipHistory();
|
||||
// break;
|
||||
//case 4:
|
||||
// m_zenvyController.viewEmployees();
|
||||
// break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
//case 5:
|
||||
// m_zenvyController.searchEmployee();
|
||||
// break;
|
||||
@@ -52,9 +53,9 @@ bool HRManagerMenu::handleOperation(int choice)
|
||||
//case 7:
|
||||
// m_zenvyController.viewAnnouncements();
|
||||
// break;
|
||||
//case 8:
|
||||
// m_zenvyController.createEmployee();
|
||||
// break;
|
||||
case 8:
|
||||
createEmployee(m_zenvyController);
|
||||
break;
|
||||
//case 9:
|
||||
// m_zenvyController.regularizeAttenance();
|
||||
// break;
|
||||
@@ -65,9 +66,16 @@ bool HRManagerMenu::handleOperation(int choice)
|
||||
// m_zenvyController.registercandidateAsEmployee();
|
||||
// break;
|
||||
case 12:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 13:
|
||||
deactivateEmployee(m_zenvyController);
|
||||
break;
|
||||
case 14:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
util::pressEnter();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "ITExecutiveMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void ITExecutiveMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void ITExecutiveMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Logout\nEnter your Choice: ";
|
||||
std::cout << "IT Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Resolve Ticket\n9. Update Profile\n10. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -39,11 +40,11 @@ bool ITExecutiveMenu::handleOperation(int choice)
|
||||
break;
|
||||
case 3:
|
||||
m_zenvyController.viewPayslipHistory();
|
||||
break;
|
||||
break;*/
|
||||
case 4:
|
||||
m_zenvyController.viewEmployees();
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
case 5:
|
||||
/*case 5:
|
||||
m_zenvyController.searchEmployee();
|
||||
break;
|
||||
case 6:
|
||||
@@ -56,9 +57,13 @@ bool ITExecutiveMenu::handleOperation(int choice)
|
||||
m_zenvyController.resolveTicket();
|
||||
break;*/
|
||||
case 9:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 10:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
util::pressEnter();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
#include <stdexcept>
|
||||
#include "MenuHelper.h"
|
||||
|
||||
static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
static const std::map<Enums::EmployeeType, std::vector<Enums::EmployeeType>> employeeTypeOptions = {
|
||||
{ Enums::EmployeeType::ADMIN, {
|
||||
Enums::EmployeeType::HR,
|
||||
Enums::EmployeeType::IT,
|
||||
Enums::EmployeeType::TEAM,
|
||||
Enums::EmployeeType::FINANCE,
|
||||
Enums::EmployeeType::TALENT_ACQUISITION,
|
||||
Enums::EmployeeType::GENERAL
|
||||
}},
|
||||
{ Enums::EmployeeType::HR, {
|
||||
Enums::EmployeeType::IT,
|
||||
Enums::EmployeeType::TEAM,
|
||||
Enums::EmployeeType::FINANCE,
|
||||
Enums::EmployeeType::TALENT_ACQUISITION,
|
||||
Enums::EmployeeType::GENERAL
|
||||
}}
|
||||
};
|
||||
static const std::map<Enums::EmployeeType, std::string> labels = {
|
||||
{ Enums::EmployeeType::HR, "HR Employee" },
|
||||
{ Enums::EmployeeType::IT, "IT Executive" },
|
||||
{ Enums::EmployeeType::TEAM, "Team Executive" },
|
||||
{ Enums::EmployeeType::FINANCE, "Finance Executive" },
|
||||
{ Enums::EmployeeType::TALENT_ACQUISITION, "Talent Executive" },
|
||||
{ Enums::EmployeeType::GENERAL, "General Employee" }
|
||||
};
|
||||
auto it = employeeTypeOptions.find(employeeType);
|
||||
if (it == employeeTypeOptions.end())
|
||||
{
|
||||
throw std::runtime_error("You do not have the authority to create a new Employee!");
|
||||
}
|
||||
const auto& options = it->second;
|
||||
std::cout << "Select Employee Type\n";
|
||||
for (int index = 0; index < options.size(); ++index)
|
||||
{
|
||||
std::cout << index + 1 << ". " << labels.at(options[index]) << "\n";
|
||||
}
|
||||
std::cout << "Enter Choice: ";
|
||||
util::read(choice);
|
||||
if (choice >= 1 && choice <= options.size())
|
||||
{
|
||||
return options[choice - 1];
|
||||
}
|
||||
return Enums::EmployeeType::INVALID;
|
||||
}
|
||||
|
||||
static Enums::EmployeeDesignation getEmployeeDesignation()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Select Employee Designation"
|
||||
"\n1. SENIOR"
|
||||
"\n2. JUNIOR"
|
||||
"\nEnter Choice: ";
|
||||
util::read(choice);
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
return Enums::EmployeeDesignation::SENIOR;
|
||||
case 2:
|
||||
return Enums::EmployeeDesignation::JUNIOR;
|
||||
default:
|
||||
return Enums::EmployeeDesignation::INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void createEmployee(std::shared_ptr<ZenvyController> controller)
|
||||
{
|
||||
auto currentEmployee = controller->getCurrentEmployee();
|
||||
Enums::EmployeeType employeeType = getEmployeeType(currentEmployee->getEmployeeType());
|
||||
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
|
||||
std::string name, email, phone;
|
||||
switch (employeeType)
|
||||
{
|
||||
case Enums::EmployeeType::INVALID:
|
||||
std::cout << "Invalid Choice";
|
||||
util::pressEnter();
|
||||
return;
|
||||
case Enums::EmployeeType::GENERAL:
|
||||
employeeDesignation = getEmployeeDesignation();
|
||||
if (employeeDesignation == Enums::EmployeeDesignation::INVALID)
|
||||
{
|
||||
std::cout << "Invalid Choice";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
std::cout << "Enter Name: ";
|
||||
util::read(name);
|
||||
std::cout << "Enter Email: ";
|
||||
util::read(email);
|
||||
std::cout << "Enter Phone: ";
|
||||
util::read(phone);
|
||||
controller->createEmployee(employeeType, employeeDesignation, email, name, phone);
|
||||
std::cout << "\nCreated Employee Successfully.";
|
||||
util::pressEnter();
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "Employee.h"
|
||||
#include "ZenvyController.h"
|
||||
#include "MenuHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "Validator.h"
|
||||
#include "Enums.h"
|
||||
|
||||
void createEmployee(std::shared_ptr<ZenvyController> controller);
|
||||
|
||||
inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
{
|
||||
int choice;
|
||||
std::string name, phone;
|
||||
name = m_zenvyController->getCurrentEmployee()->getEmployeeName();
|
||||
phone = m_zenvyController->getCurrentEmployee()->getEmployeePhone();
|
||||
while (true)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Please choose the information you want to update:\n"
|
||||
"1. Name\n"
|
||||
"2. Phone Number\n"
|
||||
"3. Exit\n"
|
||||
"Enter your choice: ";
|
||||
util::read(choice);
|
||||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
std::cout << "Enter your updated Name: ";
|
||||
util::read(name);
|
||||
m_zenvyController->updateProfile(name, phone);
|
||||
std::cout << "Profile Updated Successfully\n";
|
||||
util::pressEnter();
|
||||
break;
|
||||
case 2:
|
||||
std::cout << "Enter your updated phone Number: ";
|
||||
util::read(phone);
|
||||
if (!util::isPhoneNumberValid(phone))
|
||||
{
|
||||
std::cout << "Error: Invalid Phone Number";
|
||||
util::pressEnter();
|
||||
}
|
||||
if (util::isPhoneDuplicate(phone, m_zenvyController->getEmployees()))
|
||||
{
|
||||
std::cout << "Error: Duplicate Phone Number!";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
m_zenvyController->updateProfile(name, phone);
|
||||
std::cout << "Profile Updated Successfully\n";
|
||||
util::pressEnter();
|
||||
break;
|
||||
case 3:
|
||||
return;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>> allEmployees)
|
||||
{
|
||||
int choice;
|
||||
std::map<int, std::shared_ptr<const Employee>> employeeList;
|
||||
int index = 0;
|
||||
util::clear();
|
||||
std::cout << "Select the Employee\n";
|
||||
for (auto& currentEmployee : allEmployees)
|
||||
{
|
||||
if (currentEmployee->getEmployeeType() == Enums::EmployeeType::ADMIN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
employeeList[++index] = currentEmployee;
|
||||
}
|
||||
std::cout << std::left
|
||||
<< std::setw(10) << "Index"
|
||||
<< std::setw(15) << "Employee ID"
|
||||
<< std::setw(20) << "Name"
|
||||
<< std::setw(20) << "Employee Type" << std::endl;
|
||||
for (const auto& employee : employeeList)
|
||||
{
|
||||
std::cout << std::left << std::setw(10) << employee.first
|
||||
<< std::setw(15) << employee.second->getId()
|
||||
<< std::setw(20) << employee.second->getEmployeeName()
|
||||
<< std::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType())
|
||||
<< std::endl;
|
||||
}
|
||||
std::cout << "Enter the Index: ";
|
||||
util::read(choice);
|
||||
auto employeeIterator = employeeList.find(choice);
|
||||
if (employeeIterator != employeeList.end())
|
||||
{
|
||||
return (employeeIterator->second->getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Invalid Index");
|
||||
}
|
||||
}
|
||||
|
||||
inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controller)
|
||||
{
|
||||
if(controller->deactivateEmployee(selectEmployeeId(controller->getEmployees())))
|
||||
{
|
||||
std::cout << "Employee deactivated successfully\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Employee not found\n";
|
||||
util::pressEnter();
|
||||
}
|
||||
}
|
||||
|
||||
inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
|
||||
{
|
||||
util::clear();
|
||||
std::cout << "Employee List\n";
|
||||
auto employees = m_zenvyController->getEmployees();
|
||||
if (employees.empty())
|
||||
{
|
||||
std::cout << "No employees found\n";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
std::cout << std::left
|
||||
<< std::setw(15) << "Employee ID"
|
||||
<< std::setw(25) << "Name"
|
||||
<< std::setw(25) << "Role"
|
||||
<< std::setw(25) << "Email"
|
||||
<< std::setw(15) << "Phone"
|
||||
<< std::setw(10) << "TeamId"
|
||||
<< std::endl;
|
||||
for (const auto& iterator : employees)
|
||||
{
|
||||
std::cout << std::left
|
||||
<< std::setw(15) << iterator->getId()
|
||||
<< std::setw(25) << iterator->getEmployeeName()
|
||||
<< std::setw(25) << Enums::getEmployeeTypeString(iterator->getEmployeeType())
|
||||
<< std::setw(25) << iterator->getEmployeeEmail()
|
||||
<< std::setw(15) << iterator->getEmployeePhone()
|
||||
<< std::setw(10) << iterator->getEmployeeTeamId()
|
||||
<< std::endl;
|
||||
}
|
||||
util::pressEnter();
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "TalentExecutiveMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void TalentExecutiveMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void TalentExecutiveMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create New Job\n9. View Job Opening\n10. Add Candidate\n11. UpdateCandidate Status\n12. View Shortlisted Candidate\n13. Logout\nEnter your Choice: ";
|
||||
std::cout << "Talent Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create New Job\n9. View Job Opening\n10. Add Candidate\n11. UpdateCandidate Status\n12. View Shortlisted Candidate\n13. Update Profile\n14. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -40,9 +41,9 @@ bool TalentExecutiveMenu::handleOperation(int choice)
|
||||
//case 3:
|
||||
// m_zenvyController.viewPayslipHistory();
|
||||
// break;
|
||||
//case 4:
|
||||
// m_zenvyController.viewEmployees();
|
||||
// break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
//case 5:
|
||||
// m_zenvyController.searchEmployee();
|
||||
// break;
|
||||
@@ -68,9 +69,13 @@ bool TalentExecutiveMenu::handleOperation(int choice)
|
||||
// m_zenvyController.viewShortlistedCandidates();
|
||||
// break;
|
||||
case 13:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 14:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
util::pressEnter();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "TeamExecutiveMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void TeamExecutiveMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void TeamExecutiveMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
std::cout << "Zenvy - The HR Management System\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Team\n9. Update Team\n10. Remove Team\n11. Assign Employee\n12. Unassign Employee\n13. View Teams\n14. Logout\nEnter your Choice: ";
|
||||
std::cout << "Team Executive Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Team\n9. Update Team\n10. Remove Team\n11. Assign Employee\n12. Unassign Employee\n13. View Teams\n14. Update Profile\n15. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -40,9 +41,9 @@ bool TeamExecutiveMenu::handleOperation(int choice)
|
||||
//case 3:
|
||||
// m_zenvyController.viewPayslipHistory();
|
||||
// break;
|
||||
//case 4:
|
||||
// m_zenvyController.viewEmployees();
|
||||
// break;
|
||||
case 4:
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
//case 5:
|
||||
// m_zenvyController.searchEmployee();
|
||||
// break;
|
||||
@@ -71,9 +72,13 @@ bool TeamExecutiveMenu::handleOperation(int choice)
|
||||
// m_zenvyController.viewTeams();
|
||||
// break;
|
||||
case 14:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 15:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
util::pressEnter();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "TeamLeadMenu.h"
|
||||
#include"InputHelper.h"
|
||||
#include"OutputHelper.h"
|
||||
#include "InputHelper.h"
|
||||
#include "OutputHelper.h"
|
||||
#include "MenuHelper.h"
|
||||
|
||||
void TeamLeadMenu::run()
|
||||
{
|
||||
@@ -12,7 +13,7 @@ void TeamLeadMenu::run()
|
||||
{
|
||||
int choice;
|
||||
util::clear();
|
||||
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\n4. Regularize Attendance\n15. Update Leave Request\n16. Logout\nEnter your Choice: ";
|
||||
std::cout << "Team Lead 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\n4. Regularize Attendance\n15. Update Leave Request\n16. Update Profile\n17. Logout\nEnter your Choice: ";
|
||||
util::read(choice);
|
||||
if (!handleOperation(choice))
|
||||
{
|
||||
@@ -48,11 +49,11 @@ bool TeamLeadMenu::handleOperation(int choice)
|
||||
break;
|
||||
case 6:
|
||||
m_zenvyController.viewTicketHistory();
|
||||
break;
|
||||
break;*/
|
||||
case 7:
|
||||
m_zenvyController.viewEmployees();
|
||||
viewEmployees(m_zenvyController);
|
||||
break;
|
||||
case 8:
|
||||
/*case 8:
|
||||
m_zenvyController.searchEmployee();
|
||||
break;
|
||||
case 9:
|
||||
@@ -77,9 +78,13 @@ bool TeamLeadMenu::handleOperation(int choice)
|
||||
m_zenvyController.updateLeaveRequest();
|
||||
break;*/
|
||||
case 16:
|
||||
updateProfile(m_zenvyController);
|
||||
break;
|
||||
case 17:
|
||||
return false;
|
||||
default:
|
||||
std::cout << "Enter a valid choice!" << std::endl;
|
||||
util::pressEnter();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,15 @@
|
||||
void UserInterface::run()
|
||||
{
|
||||
bool isMenuActive = true;
|
||||
try
|
||||
{
|
||||
m_controller->loadStates();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cout << "Exception: " << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
while (isMenuActive)
|
||||
{
|
||||
try
|
||||
@@ -38,6 +47,15 @@ void UserInterface::run()
|
||||
util::pressEnter();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
m_controller->persistStates();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cout << "Exception: " << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool UserInterface::handleOperation(int choice)
|
||||
@@ -94,7 +112,7 @@ void UserInterface::login()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "\nInvalid Password";
|
||||
std::cout << "Error: Invalid Password\n";
|
||||
util::pressEnter();
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +151,7 @@ void UserInterface::login()
|
||||
menu.run();
|
||||
break;
|
||||
}
|
||||
case Enums::EmployeeType::TAG:
|
||||
case Enums::EmployeeType::TALENT_ACQUISITION:
|
||||
{
|
||||
TalentExecutiveMenu menu;
|
||||
menu.run();
|
||||
|
||||
Reference in New Issue
Block a user