Merged PR 924: UserStory EMP007 View Employees

Related work items: #952
This commit is contained in:
Tinu Johnson
2026-04-13 13:27:22 +05:30
committed by Joel Thomas
12 changed files with 122 additions and 62 deletions
@@ -109,11 +109,11 @@ std::string Payroll::serialize() const
std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record) std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
{ {
std::string id, employeeId; std::string id, employeeId;
std::string basicSalaryStr, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString; std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString;
std::istringstream serializedPayroll(record); std::istringstream serializedPayroll(record);
std::getline(serializedPayroll, id, ','); std::getline(serializedPayroll, id, ',');
std::getline(serializedPayroll, employeeId, ','); std::getline(serializedPayroll, employeeId, ',');
std::getline(serializedPayroll, basicSalaryStr, ','); std::getline(serializedPayroll, basicSalaryString, ',');
std::getline(serializedPayroll, houseRentAllowanceString, ','); std::getline(serializedPayroll, houseRentAllowanceString, ',');
std::getline(serializedPayroll, foodAllowanceString, ','); std::getline(serializedPayroll, foodAllowanceString, ',');
std::getline(serializedPayroll, employeePFString, ','); std::getline(serializedPayroll, employeePFString, ',');
@@ -121,7 +121,7 @@ std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record)
try try
{ {
double basicSalary = std::stod(basicSalaryStr); double basicSalary = std::stod(basicSalaryString);
double houseRentAllowance = std::stod(houseRentAllowanceString); double houseRentAllowance = std::stod(houseRentAllowanceString);
double foodAllowance = std::stod(foodAllowanceString); double foodAllowance = std::stod(foodAllowanceString);
double employeePFContribution = std::stod(employeePFString); double employeePFContribution = std::stod(employeePFString);
@@ -162,48 +162,76 @@ namespace Enums {
inline AccountStatus getAccountStatus(const std::string& input) inline AccountStatus getAccountStatus(const std::string& input)
{ {
if (input == "ACTIVE") if (input == "ACTIVE")
{
return AccountStatus::ACTIVE; return AccountStatus::ACTIVE;
}
if (input == "INACTIVE") if (input == "INACTIVE")
{
return AccountStatus::INACTIVE; return AccountStatus::INACTIVE;
}
return AccountStatus::INACTIVE; return AccountStatus::INACTIVE;
} }
inline EmployeeType getEmployeeType(const std::string& input) inline EmployeeType getEmployeeType(const std::string& input)
{ {
if (input == "GENERAL") if (input == "GENERAL")
{
return EmployeeType::GENERAL; return EmployeeType::GENERAL;
}
if (input == "IT") if (input == "IT")
{
return EmployeeType::IT; return EmployeeType::IT;
}
if (input == "FINANCE") if (input == "FINANCE")
{
return EmployeeType::FINANCE; return EmployeeType::FINANCE;
}
if (input == "TALENT_ACQUISITION") if (input == "TALENT_ACQUISITION")
{
return EmployeeType::TALENT_ACQUISITION; return EmployeeType::TALENT_ACQUISITION;
}
if (input == "HR") if (input == "HR")
{
return EmployeeType::HR; return EmployeeType::HR;
}
if (input == "TEAM") if (input == "TEAM")
{
return EmployeeType::TEAM; return EmployeeType::TEAM;
}
if (input == "ADMIN") if (input == "ADMIN")
{
return EmployeeType::ADMIN; return EmployeeType::ADMIN;
}
return EmployeeType::INVALID; return EmployeeType::INVALID;
} }
inline TeamStatus getTeamStatus(const std::string& str) inline TeamStatus getTeamStatus(const std::string& str)
{ {
if (str == "IN_TEAM") if (str == "IN_TEAM")
{
return TeamStatus::IN_TEAM; return TeamStatus::IN_TEAM;
}
if (str == "NOT_IN_TEAM") if (str == "NOT_IN_TEAM")
{
return TeamStatus::NOT_IN_TEAM; return TeamStatus::NOT_IN_TEAM;
}
return TeamStatus::NOT_IN_TEAM; return TeamStatus::NOT_IN_TEAM;
} }
inline EmployeeDesignation getEmployeeDesignation(const std::string& input) inline EmployeeDesignation getEmployeeDesignation(const std::string& input)
{ {
if (input == "JUNIOR") if (input == "JUNIOR")
{
return EmployeeDesignation::JUNIOR; return EmployeeDesignation::JUNIOR;
}
if (input == "SENIOR") if (input == "SENIOR")
{
return EmployeeDesignation::SENIOR; return EmployeeDesignation::SENIOR;
}
if (input == "TEAM_LEAD") if (input == "TEAM_LEAD")
{
return EmployeeDesignation::TEAM_LEAD; return EmployeeDesignation::TEAM_LEAD;
}
return EmployeeDesignation::INVALID; return EmployeeDesignation::INVALID;
} }
} }
@@ -18,7 +18,10 @@ bool util::isPhoneNumberValid(const std::string& phoneNumber) {
bool util::isEmailValid(const std::string& email) { bool util::isEmailValid(const std::string& email) {
size_t index = email.find('@'); size_t index = email.find('@');
if (index == std::string::npos) return false; if (index == std::string::npos)
{
return false;
}
if (email.find('@', index + 1) != std::string::npos) if (email.find('@', index + 1) != std::string::npos)
{ {
return false; return false;
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include "AdminMenu.h" #include "AdminMenu.h"
#include "InputHelper.h" #include"InputHelper.h"
#include "OutputHelper.h" #include"OutputHelper.h"
#include "MenuHelper.h" #include "MenuHelper.h"
void AdminMenu::run() void AdminMenu::run()
@@ -13,7 +13,7 @@ void AdminMenu::run()
{ {
int choice; int choice;
util::clear(); util::clear();
std::cout << "Admin Menu\n1. Create User\n2. View Employee\n3. Deactivate Employee\n4. Search Employee\n5. Update Profile\n6. Logout\nEnter your Choice: "; std::cout << "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); util::read(choice);
if (!handleOperation(choice)) if (!handleOperation(choice))
{ {
@@ -35,9 +35,9 @@ bool AdminMenu::handleOperation(int choice)
case 1: case 1:
createEmployee(m_zenvyController); createEmployee(m_zenvyController);
break; break;
/*case 2: case 2:
m_zenvyController.viewEmployee(); viewEmployees(m_zenvyController);
break;*/ break;
case 3: case 3:
deactivateEmployee(m_zenvyController); deactivateEmployee(m_zenvyController);
break; break;
@@ -1,4 +1,5 @@
#include <iostream> #include <iostream>
#include<iomanip>
#include "EmployeeMenu.h" #include "EmployeeMenu.h"
#include "InputHelper.h" #include "InputHelper.h"
#include "OutputHelper.h" #include "OutputHelper.h"
@@ -50,11 +51,11 @@ bool EmployeeMenu::handleOperation(int choice)
break; break;
case 6: case 6:
m_zenvyController.viewTicketHistory(); m_zenvyController.viewTicketHistory();
break; break;*/
case 7: case 7:
viewEmployees(); viewEmployees(m_zenvyController);
break; break;
case 8: /*case 8:
m_zenvyController.searchEmployee(); m_zenvyController.searchEmployee();
break; break;
case 9: case 9:
@@ -83,6 +84,3 @@ bool EmployeeMenu::handleOperation(int choice)
} }
return true; return true;
} }
@@ -43,7 +43,7 @@ void FinanceExecutiveMenu::updatePayroll()
util::read(foodAllowance); util::read(foodAllowance);
std::cout << "Enter the New EmployeePFContribution: "; std::cout << "Enter the New EmployeePFContribution: ";
util::read(employeePFContribution); util::read(employeePFContribution);
std::cout << "Enter the New EmplyerPFContribution: "; std::cout << "Enter the New EmployerPFContribution: ";
util::read(employerPFContribution); util::read(employerPFContribution);
m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution); m_zenvyController->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution);
std::cout << "Payroll Updated"; std::cout << "Payroll Updated";
@@ -67,9 +67,9 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
//case 3: //case 3:
// m_zenvyController.viewPayslipHistory(); // m_zenvyController.viewPayslipHistory();
// break; // break;
//case 4: case 4:
// m_zenvyController.viewEmployees(); viewEmployees(m_zenvyController);
// break; break;
//case 5: //case 5:
// m_zenvyController.searchEmployee(); // m_zenvyController.searchEmployee();
// break; // break;
@@ -99,5 +99,3 @@ bool FinanceExecutiveMenu::handleOperation(int choice)
} }
return true; return true;
} }
@@ -32,39 +32,39 @@ bool HRManagerMenu::handleOperation(int choice)
{ {
switch (choice) switch (choice)
{ {
/*case 1: //case 1:
m_zenvyController.applyLeave(); // m_zenvyController.applyLeave();
break; // break;
case 2: //case 2:
m_zenvyController.viewPayslip(); // m_zenvyController.viewPayslip();
break; // break;
case 3: //case 3:
m_zenvyController.viewPayslipHistory(); // m_zenvyController.viewPayslipHistory();
break; // break;
case 4: case 4:
m_zenvyController.viewEmployees(); viewEmployees(m_zenvyController);
break; break;
case 5: //case 5:
m_zenvyController.searchEmployee(); // m_zenvyController.searchEmployee();
break; // break;
case 6: //case 6:
m_zenvyController.viewNotifications(); // m_zenvyController.viewNotifications();
break; // break;
case 7: //case 7:
m_zenvyController.viewAnnouncements(); // m_zenvyController.viewAnnouncements();
break;*/ // break;
case 8: case 8:
createEmployee(m_zenvyController); createEmployee(m_zenvyController);
break; break;
/*case 9: //case 9:
m_zenvyController.regularizeAttenance(); // m_zenvyController.regularizeAttenance();
break; // break;
case 10: //case 10:
m_zenvyController.updateLeaveRequest(); // m_zenvyController.updateLeaveRequest();
break; // break;
case 11: //case 11:
m_zenvyController.registercandidateAsEmployee(); // m_zenvyController.registercandidateAsEmployee();
break;*/ // break;
case 12: case 12:
updateProfile(m_zenvyController); updateProfile(m_zenvyController);
break; break;
@@ -40,11 +40,11 @@ bool ITExecutiveMenu::handleOperation(int choice)
break; break;
case 3: case 3:
m_zenvyController.viewPayslipHistory(); m_zenvyController.viewPayslipHistory();
break; break;*/
case 4: case 4:
m_zenvyController.viewEmployees(); viewEmployees(m_zenvyController);
break; break;
case 5: /*case 5:
m_zenvyController.searchEmployee(); m_zenvyController.searchEmployee();
break; break;
case 6: case 6:
@@ -119,3 +119,36 @@ inline void deactivateEmployee(const std::shared_ptr<ZenvyController>& controlle
util::pressEnter(); 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();
}
@@ -41,9 +41,9 @@ bool TalentExecutiveMenu::handleOperation(int choice)
//case 3: //case 3:
// m_zenvyController.viewPayslipHistory(); // m_zenvyController.viewPayslipHistory();
// break; // break;
//case 4: case 4:
// m_zenvyController.viewEmployees(); viewEmployees(m_zenvyController);
// break; break;
//case 5: //case 5:
// m_zenvyController.searchEmployee(); // m_zenvyController.searchEmployee();
// break; // break;
@@ -41,9 +41,9 @@ bool TeamExecutiveMenu::handleOperation(int choice)
//case 3: //case 3:
// m_zenvyController.viewPayslipHistory(); // m_zenvyController.viewPayslipHistory();
// break; // break;
//case 4: case 4:
// m_zenvyController.viewEmployees(); viewEmployees(m_zenvyController);
// break; break;
//case 5: //case 5:
// m_zenvyController.searchEmployee(); // m_zenvyController.searchEmployee();
// break; // break;
@@ -49,11 +49,11 @@ bool TeamLeadMenu::handleOperation(int choice)
break; break;
case 6: case 6:
m_zenvyController.viewTicketHistory(); m_zenvyController.viewTicketHistory();
break; break;*/
case 7: case 7:
m_zenvyController.viewEmployees(); viewEmployees(m_zenvyController);
break; break;
case 8: /*case 8:
m_zenvyController.searchEmployee(); m_zenvyController.searchEmployee();
break; break;
case 9: case 9: