133785dd3f
- Switched shared_ptr to raw pointers - Added cleanup logic in DataStore - Fixed Factory object creation - Updated function signatures to match changes - Small refactors and formatting fixes
101 lines
3.6 KiB
C++
101 lines
3.6 KiB
C++
/*
|
|
* File: Employee.h
|
|
* Description: The Employee class manages employee information and associated work records such as payroll, attendance, leaves, and payslips.
|
|
* Author: Trenser
|
|
* Created: 31-Mar-2026
|
|
*/
|
|
#pragma once
|
|
#include <string>
|
|
#include <map>
|
|
#include "Payslip.h"
|
|
#include "Attendance.h"
|
|
#include "Leave.h"
|
|
#include "Payroll.h"
|
|
#include "Enums.h"
|
|
#include "ApplicationConfig.h"
|
|
using payslipMap = std::map<std::string, Payslip*>;
|
|
using attendanceMap = std::map<int, std::map<std::string, Attendance*>>;
|
|
using leaveMap = std::map<std::string, Leave*>;
|
|
|
|
class Employee
|
|
{
|
|
protected:
|
|
static int m_uid;
|
|
std::string m_id;
|
|
std::string m_password;
|
|
std::string m_name;
|
|
std::string m_phone;
|
|
std::string m_email;
|
|
Enums::AccountStatus m_accountStatus;
|
|
Enums::TeamStatus m_teamStatus;
|
|
std::string m_teamId;
|
|
Payroll* m_payroll;
|
|
payslipMap m_payslips;
|
|
attendanceMap m_attendances;
|
|
leaveMap m_leaves;
|
|
Enums::EmployeeType m_employeeType;
|
|
public:
|
|
Employee()
|
|
: m_id("EMP" + std::to_string(++m_uid)),
|
|
m_password(Config::Authentication::DEFAULT_PASSWORD),
|
|
m_name(""),
|
|
m_phone(""),
|
|
m_email(""),
|
|
m_accountStatus(Enums::AccountStatus::ACTIVE),
|
|
m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM),
|
|
m_teamId(""),
|
|
m_payroll(nullptr),
|
|
m_employeeType(Enums::EmployeeType::GENERAL) {}
|
|
Employee(const std::string& name,
|
|
const std::string& phone,
|
|
const std::string& email,
|
|
Enums::EmployeeType employeeType,
|
|
Payroll* payroll)
|
|
: m_id("EMP" + std::to_string(++m_uid)),
|
|
m_password(Config::Authentication::DEFAULT_PASSWORD),
|
|
m_name(name),
|
|
m_phone(phone),
|
|
m_email(email),
|
|
m_accountStatus(Enums::AccountStatus::ACTIVE),
|
|
m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM),
|
|
m_teamId(""),
|
|
m_employeeType(employeeType),
|
|
m_payroll(payroll) {}
|
|
Employee(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;
|
|
const std::string& getEmployeeEmail() const;
|
|
Enums::AccountStatus getEmployeeAccountStatus() const;
|
|
Enums::TeamStatus getEmployeeTeamStatus() const;
|
|
const std::string& getEmployeeTeamId() const;
|
|
Payroll* getPayroll() const;
|
|
const payslipMap& getEmployeePayslips() const;
|
|
const attendanceMap& getEmployeeAttendances() const;
|
|
const leaveMap& getEmployeeLeaves() const;
|
|
void setEmployeeId(const std::string& id);
|
|
void setEmployeePassword(const std::string& password);
|
|
void setEmployeeName(const std::string& name);
|
|
void setEmployeePhone(const std::string& phone);
|
|
void setEmployeeAccountStatus(Enums::AccountStatus status);
|
|
void setEmployeeTeamStatus(Enums::TeamStatus status);
|
|
void setEmployeeTeamId(const std::string& teamId);
|
|
void setEmployeePayroll(Payroll* payroll);
|
|
void addPayslip(Payslip* payslip);
|
|
void addAttendance(Attendance* attendance);
|
|
void addLeave(Leave* leave);
|
|
Enums::EmployeeType getEmployeeType() const;
|
|
virtual std::string serialize() const;
|
|
static Employee* deserialize(const std::string&);
|
|
static std::string getHeaders();
|
|
virtual ~Employee() = default;
|
|
}; |