Merge branch 'feature-employee-management' into feature-employee-management-emp011

This commit is contained in:
2026-04-16 14:47:25 +05:30
24 changed files with 318 additions and 60 deletions
@@ -13,7 +13,7 @@ void AdminMenu::run()
{
int choice;
util::clear();
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Logout\nEnter your Choice: ";
std::cout << "Admin Menu\n1. Create User\n2. View Employees\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Update Designation \n7. Add Shortlisted Candidate As Employee\n8. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
@@ -48,6 +48,12 @@ bool AdminMenu::handleOperation(int choice)
updateProfile(m_zenvyController);
break;
case 6:
updateDesignation(m_zenvyController);
break;
case 7:
addShortlistedCandidateAsEmployee(m_zenvyController);
break;
case 8:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
@@ -33,24 +33,12 @@ bool EmployeeMenu::handleOperation(int choice)
{
switch (choice)
{
/*case 1:
m_zenvyController.applyLeave();
break;
case 2:
m_zenvyController.viewPayslip();
break;*/
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
/*case 4 :
m_zenvyController.raiseTicket();
break;
case 5 :
m_zenvyController.viewTicket();
break;
case 6:
m_zenvyController.viewTicketHistory();
break;*/
case 7:
viewEmployees(m_zenvyController);
break;
@@ -65,6 +65,9 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
@@ -13,7 +13,7 @@ void HRManagerMenu::run()
{
int choice;
util::clear();
std::cout << "HR Manager Menu\n1. Apply Leave\n2. View Payslip\n3. View Payslip History\n4. View Employees\n5. Search Employee\n6. View Notification\n7. View Announcements\n8. Create Employee\n9. Regularize Attendance\n10. Update Leave Request\n11. Register CandidateAsEmployee\n12. Update Profile\n13. Deactivate Employee\n14. View Profile\n15. 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. Update Profile\n12. Deactivate Employee\n13. View Profile\n14. Update Designation\n15. Add Shortlisted Candidate as Employee\n16. Logout\nEnter your Choice: ";
util::read(choice);
if (!handleOperation(choice))
{
@@ -32,6 +32,9 @@ bool HRManagerMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
@@ -44,16 +47,22 @@ bool HRManagerMenu::handleOperation(int choice)
case 8:
createEmployee(m_zenvyController);
break;
case 12:
case 11:
updateProfile(m_zenvyController);
break;
case 13:
case 12:
deactivateEmployee(m_zenvyController);
break;
case 14:
case 13:
viewProfile(m_zenvyController);
break;
case 14:
updateDesignation(m_zenvyController);
break;
case 15:
addShortlistedCandidateAsEmployee(m_zenvyController);
break;
case 16:
return false;
default:
std::cout << "Enter a valid choice!" << std::endl;
@@ -32,6 +32,9 @@ bool ITExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
@@ -30,12 +30,12 @@ static Enums::EmployeeType getEmployeeType(Enums::EmployeeType employeeType)
{ Enums::EmployeeType::TALENT_ACQUISITION, "Talent Executive" },
{ Enums::EmployeeType::GENERAL, "General Employee" }
};
auto it = employeeTypeOptions.find(employeeType);
if (it == employeeTypeOptions.end())
auto employeeOptionsIterator = employeeTypeOptions.find(employeeType);
if (employeeOptionsIterator == employeeTypeOptions.end())
{
throw std::runtime_error("You do not have the authority to create a new Employee!");
}
const auto& options = it->second;
const auto& options = employeeOptionsIterator->second;
std::cout << "Select Employee Type\n";
for (int index = 0; index < options.size(); ++index)
{
@@ -102,3 +102,101 @@ void createEmployee(std::shared_ptr<ZenvyController> controller)
std::cout << "\nCreated Employee Successfully.";
util::pressEnter();
}
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController)
{
std::string selectedEmployeeId = selectEmployeeId(m_zenvyController->getEmployees(Enums::EmployeeType::GENERAL));
if (selectedEmployeeId.empty())
{
return;
}
Enums::EmployeeDesignation designation = getEmployeeDesignation();
if (m_zenvyController->updateDesignation(selectedEmployeeId, designation))
{
std::cout << "Assigned Employee Role Successfully\n";
util::pressEnter();
}
else
{
std::cout << "Employee not found\n";
util::pressEnter();
}
}
void displayCandidateDetails(const std::vector<std::shared_ptr<Candidate>>& shorlistedCandidates)
{
util::clear();
std::cout << std::left
<< std::setw(10) << "Index"
<< std::setw(10) << "ID"
<< std::setw(20) << "Name"
<< std::setw(15) << "Phone"
<< std::setw(15) << "Qualification"
<< std::setw(10) << "Status"
<< std::endl;
int index = 0;
for (auto& candidate : shorlistedCandidates)
{
std::cout << std::left
<< std::setw(10) << ++index
<< std::setw(10) << candidate->getCandidateId()
<< std::setw(20) << candidate->getCandidateName()
<< std::setw(15) << candidate->getCandidatePhone()
<< std::setw(15) << candidate->getCandidateQualification()
<< std::setw(10) << Enums::getCandidateStatusString(candidate->getCandidateStatus())
<< std::endl;
}
}
void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& controller)
{
int index;
std::string name, email, phone;
util::clear();
std::vector<std::shared_ptr<Candidate>> shortlistedCandidates = controller->getShorlistedCandidates();
if (shortlistedCandidates.empty())
{
std::cout << "No candidates Found!";
util::pressEnter();
return;
}
displayCandidateDetails(shortlistedCandidates);
std::cout << "Enter the Index: ";
util::read(index);
auto currentEmployee = controller->getCurrentEmployee();
Enums::EmployeeType employeeType;
Enums::EmployeeDesignation employeeDesignation = Enums::EmployeeDesignation::INVALID;
if (index > 0 && index <= shortlistedCandidates.size())
{
employeeType = getEmployeeType(currentEmployee->getEmployeeType());
std::shared_ptr<Candidate> candidate = shortlistedCandidates[index - 1];
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 email: ";
util::read(email);
name = candidate->getCandidateName();
phone = candidate->getCandidatePhone();
controller->createEmployee(employeeType, employeeDesignation, email, name, phone);
candidate->setCandidateStatus(Enums::CandidateStatus::HIRED);
std::cout << "\nCreated Employee Successfully.";
util::pressEnter();
}
else
{
throw std::runtime_error("Enter a valid Index.");
}
}
+82 -26
View File
@@ -16,6 +16,7 @@
#include "Validator.h"
void createEmployee(std::shared_ptr<ZenvyController> controller);
void updateDesignation(std::shared_ptr<ZenvyController> m_zenvyController);
inline void viewPayslipHistory(std::shared_ptr<ZenvyController> controller)
{
@@ -87,6 +88,9 @@ inline void viewProfile(std::shared_ptr<ZenvyController> controller)
}
}
void displayCandidateDetails(const std::vector<std::shared_ptr<const Candidate>>& shorlistedCandidates);
void addShortlistedCandidateAsEmployee(const std::shared_ptr<ZenvyController>& controller);
inline void updateProfile(std::shared_ptr<ZenvyController> m_zenvyController)
{
int choice;
@@ -163,14 +167,28 @@ inline std::string selectEmployeeId(std::vector<std::shared_ptr<const Employee>>
<< std::setw(10) << "Index"
<< std::setw(15) << "Employee ID"
<< std::setw(20) << "Name"
<< std::setw(20) << "Employee Type" << std::endl;
<< std::setw(20) << "Employee Type"
<< std::setw(20) << "Employee Designation" << std::endl;
for (const auto& employee : employeeList)
{
std::cout << std::left << std::setw(10) << employee.first
auto generalEmployee = std::dynamic_pointer_cast<const GeneralEmployee>(employee.second);
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::setw(20) << Enums::getEmployeeTypeString(employee.second->getEmployeeType());
if (generalEmployee)
{
std::cout << std::left
<< std::setw(20) << Enums::getEmployeeDesignationString(generalEmployee->getDesignation())
<< std::endl;
}
else
{
std::cout << std::left
<< std::setw(20) << "NULL"
<< std::endl;
}
}
std::cout << "Enter the Index: ";
util::read(choice);
@@ -192,7 +210,7 @@ inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controlle
{
return;
}
if(controller->deactivateEmployee(selectedEmployeeId))
if (controller->deactivateEmployee(selectedEmployeeId))
{
std::cout << "Employee deactivated successfully\n";
util::pressEnter();
@@ -237,15 +255,15 @@ inline void viewEmployees(std::shared_ptr<ZenvyController> m_zenvyController)
util::pressEnter();
}
inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
inline void searchEmployee(std::shared_ptr<ZenvyController> m_zenvyController)
{
std::string name;
util::clear();
std::cout << "Enter Employee Name: ";
util::read(name);
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
if (!(searchResults.second).empty())
{
std::string name;
util::clear();
std::cout << "Enter Employee Name: ";
util::read(name);
std::pair<Enums::EmployeeType, std::vector<std::shared_ptr<const Employee>>> searchResults = m_zenvyController->searchEmployee(name);
if (!(searchResults.second).empty())
{
std::cout << std::left
<< std::setw(10) << "ID"
<< std::setw(20) << "Name"
@@ -267,10 +285,10 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
<< std::setw(15) << "HouseRentAllowance";
}
std::cout << std::endl;
for (const auto& employee : searchResults.second)
{
if (employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
{
for (const auto& employee : searchResults.second)
{
if (employee->getEmployeeAccountStatus() == Enums::AccountStatus::ACTIVE)
{
std::cout << std::left
<< std::setw(10) << employee->getId()
<< std::setw(20) << employee->getEmployeeName()
@@ -286,8 +304,8 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
{
std::cout << std::setw(15) << employee->getEmployeeTeamId();
}
if (searchResults.first == Enums::EmployeeType::FINANCE
|| searchResults.first == Enums::EmployeeType::HR
if (searchResults.first == Enums::EmployeeType::FINANCE
|| searchResults.first == Enums::EmployeeType::HR
|| searchResults.first == Enums::EmployeeType::ADMIN)
{
std::cout << std::left
@@ -299,12 +317,50 @@ inline void searchEmployee(std::shared_ptr<ZenvyController>& m_zenvyController)
<< std::setw(15) << employee->getPayroll()->getHouseRentAllowance();
}
std::cout << std::endl;
}
}
}
else
{
std::cout << "No Employee found with this name" << std::endl;
}
}
}
}
else
{
std::cout << "No Employee found with this name" << std::endl;
}
util::pressEnter();
}
inline void viewPayslip(std::shared_ptr<ZenvyController> controller)
{
int year, month;
util::clear();
std::cout << "Enter the year: ";
util::read(year);
std::cout << "Enter the month: ";
util::read(month);
auto employee = controller->getCurrentEmployee();
if (!employee)
{
std::cout << "No authenticated employee.\n";
util::pressEnter();
return;
}
auto result = controller->getPayslipForMonth(employee->getId(), year, month);
auto payroll = result.first;
auto payslip = result.second;
if (payroll && payslip)
{
util::clear();
std::cout << "Payslip for " << employee->getEmployeeName() << " (" << year << "-" << std::setw(2) << std::setfill('0') << month << ")\n\n";
std::cout << "Basic Salary : " << payroll->getBasicSalary() << "\n";
std::cout << "House Rent Allowance : " << payroll->getHouseRentAllowance() << "\n";
std::cout << "Food Allowance : " << payroll->getFoodAllowance() << "\n";
std::cout << "Employee PF Contribution : " << payroll->getEmployeePFContribution() << "\n";
std::cout << "Employer PF Contribution : " << payroll->getEmployerPFContribution() << "\n";
std::cout << "----------------------------------------\n";
std::cout << "Net Salary (after deductions): " << payslip->getSalary() << "\n";
std::cout << "Generated on: " << payslip->getTimestamp().toString() << "\n";
}
else
{
std::cout << "Payslip not available for " << year << "-" << month << ".\n";
}
util::pressEnter();
}
@@ -32,6 +32,9 @@ bool TalentExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
@@ -32,6 +32,9 @@ bool TeamExecutiveMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;
@@ -32,6 +32,9 @@ bool TeamLeadMenu::handleOperation(int choice)
{
switch (choice)
{
case 2:
viewPayslip(m_zenvyController);
break;
case 3:
viewPayslipHistory(m_zenvyController);
break;