<?php
namespace App\Controller;
use App\Entity\Company;
use App\Entity\EmployeeReview;
use App\Entity\Employees\Employee;
use App\Entity\Employees\EmployeePosition;
use App\Entity\Location;
use App\Entity\QuadSettings;
use App\Repository\UserPermissionRepository;
use App\Service\Dashboard\PanelDataService;
use App\Service\Dashboard\PieDataService;
use App\Service\DashboardStatsService;
use App\Service\PeriodService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
#[Route(path: '/')]
class DashboardController extends AbstractController
{
/**
* @var EmployeeReview[]
*/
private $allReviews;
/**
* @var Location[]
*/
private $locations;
private $colorSets = [
1 => ['#ffffff', '#b5b2b5', '#7f7a7f', '#534f55', '#2f2c33', '#040707'],
2 => ['#fddb00', '#b89d31', '#816f34', '#544a2f', '#2f2a25', '#040707'],
3 => ['#f7941e', '#b6702e', '#82532f', '#573b2c', '#312423', '#040707'],
4 => ['#4060ac', '#3d5087', '#344067', '#292f4b', '#1b1e31', '#040707'],
];
private $quads = [];
/**
* @var Security
*/
private $security;
/**
* @var PieDataService
*/
private $pieDataService;
/**
* @var PeriodService
*/
private $periodService;
/**
* @var EntityManagerInterface
*/
private $em;
/**
* @var DashboardStatsService
*/
private $dashboardStats;
/**
* @var PanelDataService
*/
private $panelDataService;
/**
* DashboardController constructor.
*/
public function __construct(Security $security, PieDataService $pieDataService, PeriodService $periodService, EntityManagerInterface $em, DashboardStatsService $dashboardStats, PanelDataService $panelDataService)
{
$this->security = $security;
$this->pieDataService = $pieDataService;
$this->periodService = $periodService;
/** @var QuadSettings[] $quadSettings */
$quadSettings = $em->getRepository(QuadSettings::class)->findAll();
/** @var QuadSettings $quadSetting */
foreach ($quadSettings as $quadSetting) {
$this->quads[$quadSetting->getPositionNumber()] = $quadSetting->getName();
}
$this->em = $em;
$this->dashboardStats = $dashboardStats;
$this->panelDataService = $panelDataService;
}
/**
* @param Request $request
* @return Response
* @throws \Exception
*/
#[Route(path: '/review', name: 'review_test', methods: ['GET', 'POST'])]
public function review(Request $request): Response
{
$companyInfo = $this->getCompanyInfo();
$company = $companyInfo;
return $this->render('dashboard/review.html.twig', [
'company' => $company,
]);
}
/**
* @param UserPermissionRepository $permissionRepository
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/', name: 'home')]
public function index(UserPermissionRepository $permissionRepository): Response
{
$dashboardPermissions = $permissionRepository->findBy(['permission_user' => $this->security->getUser()]);
$rootNode = $this->determineRootNode($dashboardPermissions);
if ($rootNode) {
switch ($rootNode->getEntityType()) {
case 'company':
return $this->getCompanyLevelData($this->dashboardStats);
break;
case 'location':
return $this->locationRootData($rootNode->getEntityId()->toString());
break;
case 'employee':
return $this->employeeRootData($rootNode->getEntityId()->toString());
break;
}
}
return $this->redirect('/admin');
}
private function determineRootNode(array $permissions)
{
$nodeOrder = [
'company',
'location',
'department',
'employee',
];
foreach ($nodeOrder as $nodeType) {
foreach ($permissions as $permission) {
if ($permission->getEntityType() == $nodeType) {
return $permission;
}
}
}
}
/**
* @param Request $request
* @param DashboardStatsService $dashboardStats
* @param int $chartIndex
*
* @return Response
*/
#[Route(path: '/dashboard/period-chart/company/{chartIndex}')]
public function getCompanyPeriodChart(Request $request, DashboardStatsService $dashboardStats, int $chartIndex): Response
{
$totalScores = $dashboardStats->getTotalStats();
if (count($totalScores) > $this->periodService->getPeriodsToShow()) {
$sliceOffset = $this->periodService->getPeriodsToShow() * -1;
$totalScores = array_slice($totalScores, $sliceOffset);
}
$periodKeys = array_keys($totalScores);
$currentPeriodKey = $periodKeys[$chartIndex];
$currentValues = $totalScores[$currentPeriodKey];
$this->fillSkillGroupSettings();
$scores = [];
$scoreTotal = $currentValues['total_avg'];
foreach ($this->quads as $i => $name) {
$scores[$i] = [
'name' => $name,
'score' => $currentValues['quad'.$i.'_avg'],
];
}
$scores[5] = ['name' => 'Growth Opportunity', 'score' => 100 - $scoreTotal];
return $this->render('dashboard-stimulus/partials/_entity_score_period_donut.html.twig', [
'reviewPeriod' => $currentPeriodKey,
'scores' => $scores,
'scoreTotal' => $scoreTotal,
'colorSets' => $this->colorSets,
'reviewDirection' => 'up', // TODO: make this correct
'skillGroupNames' => $this->quads,
'currentScore' => $scoreTotal,
]
);
}
/**
* @param Request $request
* @param DashboardStatsService $dashboardStats
* @param int $chartIndex
*
* @return Response
*/
#[Route(path: '/dashboard/period-chart/location/{locationId}/{chartIndex}')]
public function getLocationPeriodChart(Request $request, DashboardStatsService $dashboardStats, string $locationId, int $chartIndex): Response
{
$totalScores = $dashboardStats->getLocationTotalStats($locationId);
$totalScores = current($totalScores);
if (count($totalScores) > $this->periodService->getPeriodsToShow()) {
$sliceOffset = $this->periodService->getPeriodsToShow() * -1;
$totalScores = array_slice($totalScores, $sliceOffset);
}
$periodKeys = array_keys($totalScores);
$currentPeriodKey = $periodKeys[$chartIndex];
$currentValues = $totalScores[$currentPeriodKey];
$this->fillSkillGroupSettings();
$scores = [];
$scoreTotal = $currentValues['total_avg'];
foreach ($this->quads as $i => $name) {
$scores[$i] = [
'name' => $name,
'score' => $currentValues['quad'.$i.'_avg'],
];
}
$scores[5] = ['name' => 'Growth Opportunity', 'score' => 100 - $scoreTotal];
return $this->render('dashboard-stimulus/partials/_entity_score_period_donut.html.twig', [
'reviewPeriod' => $currentPeriodKey,
'scores' => $scores,
'scoreTotal' => $scoreTotal,
'colorSets' => $this->colorSets,
'reviewDirection' => 'up', // TODO: make this correct
'skillGroupNames' => $this->quads,
'currentScore' => $scoreTotal,
]
);
}
private function getCompanyLevelData(DashboardStatsService $dashboardStats)
{
$periods = $this->getPeriods();
$this->fillSkillGroupSettings();
$currentPeriod = end($periods);
$previousPeriod = prev($periods);
reset($periods);
$company = $this->getCompanyInfo();
$companyStats = $dashboardStats->getTotalStats();
$locationStats = $dashboardStats->getLocationTotalStats();
$currentPeriodStats = end($companyStats);
$previousPeriodStats = prev($companyStats);
$currentPieData = $this->pieDataService->calculateSkillGroupPieDataFromStatsArray($currentPeriodStats, $this->quads);
$previousPieData = $this->pieDataService->calculateSkillGroupPieDataFromStatsArray($previousPeriodStats, $this->quads);
$totalScores = [];
foreach ($companyStats as $period => $stats) {
$period = substr($period, 2);
$totalScores[$period] = $stats['total_avg'];
}
if (count($totalScores) > $this->periodService->getPeriodsToShow()) {
$sliceOffset = $this->periodService->getPeriodsToShow() * -1;
$totalScores = array_slice($totalScores, $sliceOffset);
}
$locations = $this->getLocations();
$locationMap = [];
foreach ($locations as $location) {
$locationMap[$location->getId()->toString()] = $location;
}
$locationTotals = [];
$locationTrends = [];
foreach ($locationStats as $locationId => $periodStats) {
$locationTotals[$locationId] = [
'prevTotals' => 0,
'totals' => 0,
'skillGroups' => [],
'info' => $locationMap[$locationId],
'prevDiff' => 0,
];
if (count($periodStats)) {
$lastQuarter = end($periodStats);
$locationTotals[$locationId]['skillGroups'] = [
1 => $lastQuarter['quad1_avg'],
2 => $lastQuarter['quad2_avg'],
3 => $lastQuarter['quad3_avg'],
4 => $lastQuarter['quad4_avg'],
];
$locationTotals[$locationId]['totals'] = $lastQuarter['total_avg'];
}
if (count($periodStats) > 1) {
$prevQuarter = prev($periodStats);
$locationTotals[$locationId]['prevTotals'] = $prevQuarter['total_avg'];
$locationTotals[$locationId]['prevDiff'] = $locationTotals[$locationId]['totals'] - $locationTotals[$locationId]['prevTotals'];
}
$locationTrends[$locationId] = [];
foreach ($periodStats as $period => $stats) {
$locationTrends[$locationId][$period] = $stats['total_avg'];
}
}
return $this->render('dashboard-stimulus/index.html.twig', [
'controller_name' => 'DashboardController',
'totalScores' => $totalScores,
'periods' => $periods,
'company' => $company,
'entity' => $company,
'locations' => $locations,
'pieData' => $currentPieData,
'previousPieData' => $previousPieData,
'locationScores' => $locationTotals,
'locationTrends' => $locationTrends,
'skillGroupNames' => $this->quads,
'entityId' => $company->getId()->toString(),
'childScores' => $locationTotals,
'childTrends' => $locationTrends,
'entityType' => 'company',
'childType' => 'location',
'isRoot' => true,
]);
}
private function skillGroupPieData(array $reviews = null, $single = false, $period = null)
{
if (is_null($reviews)) {
$reviews = $this->getReviews();
}
if (is_null($period)) {
$periods = $this->getPeriods();
$period = array_pop($periods);
}
$pieData = $this->pieDataService->calculateSkillGroupPieDataFromReviews($reviews, $single, $period, $this->quads);
return $pieData;
}
/**
* @param Request $request
* @param string $reviewId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
#[Route(path: '/dashboard/review-data/{reviewId}')]
public function getReviewData(Request $request, string $reviewId): Response
{
$company = $this->getCompanyInfo();
$this->fillSkillGroupSettings();
/** @var EmployeeReview $review */
$review = $this->getDoctrine()->getRepository(EmployeeReview::class)->findOneBy(['id' => $reviewId]);
$positionVersion = $review->getPositionVersion();
$settings = json_decode($positionVersion->getSettings(), true);
$employeeId = $review->getEmployee()->getId()->toString();
$currentScore = $request->query->get('currentScore');
$previousScore = $request->query->get('previousScore');
$previousReviewId = $request->query->get('previousReviewId');
$reviewDirection = '';
if ($previousScore != 'null' && $currentScore > $previousScore) {
$reviewDirection = 'up';
} elseif ($previousScore > $currentScore) {
$reviewDirection = 'down';
}
$scores = [];
$scoreTotal = 0;
$goalTotal = 0;
foreach ($settings['positionQuads'] as $skillGroup) {
$num = $skillGroup['quadSetting']['positionNumber'];
$scores[$num] = [
'name' => $skillGroup['quadSetting']['name'],
'score' => $review->getQuadScore($num),
];
$scoreTotal += $review->getQuadScore($num);
}
$scores[5] = [
'name' => 'Growth Opportunity',
'score' => 100 - $scoreTotal,
];
return $this->render('dashboard-stimulus/partials/_review-preview-panel.html.twig', [
'positionName' => $review->getPosition()->getName(),
'reviewQuarter' => $review->getReviewQuarter(),
'reviewDate' => $review->getReviewDate(),
'scores' => $scores,
'scoreTotal' => $scoreTotal,
'reviewId' => $reviewId,
'colorSets' => $this->colorSets,
'company' => $company,
'reviewDirection' => $reviewDirection,
'skillGroupNames' => $this->quads,
'employeeId' => $employeeId,
'employeeName' => $review->getEmployee()->getDisplayName(),
'currentScore' => $currentScore,
'previousScore' => $previousScore,
'previousReviewId' => $previousReviewId,
]);
}
private function locationRootData($locationId)
{
$locationData = $this->getLocationPanelData($locationId, $this->dashboardStats);
return $this->render('dashboard/index-location.html.twig', $locationData);
}
/**
* @param Request $request
* @param string $locationId
* @param DashboardStatsService $dashboardStatsService
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/dashboard/location-aggregate/{locationId}')]
public function getLocationAggregateData(Request $request, string $locationId, DashboardStatsService $dashboardStatsService): Response
{
$locationData = $this->getLocationPanelData($locationId, $dashboardStatsService);
return $this->render('dashboard-stimulus/partials/_panel.html.twig', $locationData);
}
/**
* @return array
*/
private function getLocationPanelData(string $locationId, DashboardStatsService $dashboardStatsService)
{
$this->fillSkillGroupSettings();
$company = $this->getCompanyInfo();
$reviews = [];
/** @var Location $location */
$location = $this->getDoctrine()->getRepository(Location::class)->findBy(['id' => $locationId])[0];
$employees = $this->getDoctrine()->getRepository(Employee::class)->findBy(['location' => $locationId]);
uasort($employees, function (Employee $a, Employee $b) {
return $a->getDisplayName() <=> $b->getDisplayName();
});
$dashboardStatsTotalScores = $dashboardStatsService->getLocationTotalStats($locationId);
$dashboardStatsEmployeeScores = $dashboardStatsService->getLocationEmployeeTotalStats($locationId);
$totalScores = [];
$scores = [];
if (isset($dashboardStatsTotalScores[$locationId])) {
$scores = $this->pruneStatPeriods($dashboardStatsTotalScores[$locationId]);
foreach ($scores as $key => $data) {
$key = substr($key, 2);
$totalScores[$key] = $data['total_avg'];
}
}
$periods = array_keys($totalScores);
$currentPeriodStats = end($scores);
$previousPeriodStats = prev($scores);
$employeeScoreData = $this->compileEmployeeStatLines($dashboardStatsEmployeeScores, $employees);
return [
'totalScores' => $totalScores,
'pieData' => $this->pieDataService->calculateSkillGroupPieDataFromStatsArray($currentPeriodStats, $this->quads),
'previousPieData' => $this->pieDataService->calculateSkillGroupPieDataFromStatsArray($previousPeriodStats, $this->quads),
'location' => $location,
'periods' => $periods,
'employeeScores' => $employeeScoreData['employeeTotals'],
'employeeTrends' => $employeeScoreData['employeeTrends'],
'company' => $company,
'employees' => $employees,
'skillGroupNames' => $this->quads,
'entity' => $location,
'childScores' => $employeeScoreData['employeeTotals'],
'childTrends' => $employeeScoreData['employeeTrends'],
'entityId' => $location->getId()->toString(),
'childType' => 'employee',
'entityType' => 'location',
];
}
private function compileEmployeeStatLines(array $scores, array $employees)
{
$periods = $this->getPeriods();
reset($periods);
uasort($employees, function (Employee $a, Employee $b) {
return $a->getDisplayName() <=> $b->getDisplayName();
});
$employeeTotals = [];
$employeeTrends = [];
foreach ($employees as $employee) {
$employeeTotals[$employee->getId()->toString()] = [
'totals' => null,
'prevTotal' => null,
'prevDiff' => null,
'skillGroups' => [],
'info' => $employee,
];
}
foreach ($employeeTotals as $employeeId => $blank) {
$prunedScores = $this->pruneStatPeriods($scores[$employeeId]);
$latestReview = end($prunedScores);
$total = $latestReview['total_avg'];
if (count($prunedScores) > 1) {
$previousReview = prev($prunedScores);
$prevTotal = $previousReview['total_avg'];
$prevDiff = $total - $prevTotal;
} else {
$previousReview = null;
$prevTotal = null;
$prevDiff = null;
}
$totals = [
'totals' => $total,
'prevTotal' => $prevTotal,
'prevDiff' => round($prevDiff, 1),
'skillGroups' => [
$this->quads[1] => $latestReview['quad1_avg'],
$this->quads[2] => $latestReview['quad2_avg'],
$this->quads[3] => $latestReview['quad3_avg'],
$this->quads[4] => $latestReview['quad4_avg'],
],
];
$employeeTotals[$employeeId] = array_merge($employeeTotals[$employeeId], $totals);
foreach ($prunedScores as $score) {
$employeeTrends[$employeeId][$score['review_period']] = $score['total_avg'];
}
}
return [
'employeeTotals' => $employeeTotals,
'employeeTrends' => $employeeTrends,
];
}
protected function employeeRootData(string $employeeId)
{
$employeeData = $this->getEmployeePanelData($employeeId);
$employeeData['companyInfo'] = $this->getCompanyInfo();
$employeeData['skillGroupNames'] = $this->quads;
return $this->render('dashboard-stimulus/index.html.twig', $employeeData);
}
/**
* @param Request $request
* @param string $employeeId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
#[Route(path: '/dashboard/employee-aggregate/{employeeId}')]
public function getEmployeeAggregateData(Request $request, string $employeeId): Response
{
$employeeData = $this->getEmployeePanelData($employeeId);
return $this->render('dashboard-stimulus/partials/_panel.html.twig', $employeeData);
}
private function getEmployeePanelData(string $employeeId)
{
$this->fillSkillGroupSettings();
$reviews = [];
/** @var Employee $employee */
$employee = $this->getDoctrine()->getRepository(Employee::class)->findBy(['id' => $employeeId])[0];
$employeePositions = $this->getDoctrine()->getRepository(EmployeePosition::class)->findBy(['employee' => $employee]);
/** @var EmployeeReview[] $reviewList */
$reviewList = [];
$reviews = $this->getDoctrine()->getRepository(EmployeeReview::class)->findBy(['employee' => $employee]);
foreach ($reviews as $review) {
$reviewEmployeeId = $review->getEmployee()->getId()->toString();
if ($employeeId == $reviewEmployeeId) {
$reviewPeriodKey = $this->getReviewPeriodKey($review);
$reviewPeriodKey = substr($reviewPeriodKey, 2);
$reviews[$reviewPeriodKey] = $review;
$reviewList[$reviewPeriodKey] = $review->getId();
}
}
ksort($reviews);
$lastReview = end($reviews);
$prevReview = null;
if (count($reviews) > 1) {
$prevReview = prev($reviews);
}
$skillScores = [];
$lastReviewData = [];
if ($lastReview) {
foreach ($lastReview->getEmployeeReviewsSkillScores() as $score) {
if (!isset($skillScores[$score->getPositionQuadSkillId()])) {
$skillScores[$score->getPositionQuadSkillId()] = [
'score' => 0,
];
}
$skillScores[$score->getPositionQuadSkillId()]['score'] += $score->getScore();
}
$lastReviewSettings = json_decode($lastReview->getPositionVersion()->getSettings(), true);
foreach ($lastReviewSettings['positionQuads'] as $positionSkillGroup) {
$skillGroup = [
'id' => $positionSkillGroup['id'],
'name' => $positionSkillGroup['quadSetting']['name'],
'positionNumber' => $positionSkillGroup['quadSetting']['positionNumber'],
'skills' => [],
];
foreach ($positionSkillGroup['positionQuadSkills'] as $skill) {
$skillGroup['skills'][$skill['id']] = [
'id' => $skill['id'],
'title' => $skill['nameOverride'],
'description' => $skill['definitionOverride'],
'positionNumber' => $skill['positionNumber'],
'score' => $skillScores[$skill['id']]['score'],
];
}
$lastReviewData['skillGroups'][$skillGroup['id']] = $skillGroup;
$lastReviewData['id'] = $lastReview->getId();
}
}
$totalScores = array_fill_keys($this->getPeriods(), '');
$totalScores = array_merge($totalScores, $this->getTotalScores($reviews));
ksort($totalScores);
foreach ($totalScores as $period => $score) {
if ($score == '') {
unset($totalScores[$period]);
}
}
$periods = array_keys($totalScores);
$currentPeriod = end($periods);
$previousPeriod = prev($periods);
reset($periods);
$newTotalScores = [];
foreach ($totalScores as $period => $score) {
$period = substr($period, 2);
$newTotalScores[$period] = $score;
}
$totalScores = $newTotalScores;
$employeeStats = $this->dashboardStats->getEmployeeTotalStats($employeeId);
return [
'totalScores' => $totalScores,
'pieData' => $this->skillGroupPieData($reviews, true, $currentPeriod),
'previousPieData' => $this->skillGroupPieData($reviews, true, $previousPeriod),
'employee' => $employee,
'periods' => $periods,
'lastReview' => $lastReviewData,
'reviewList' => $reviewList,
'companyInfo' => $this->getCompanyInfo(),
'skillGroupNames' => $this->quads,
'position' => $employeePositions[0]->getPosition(),
'entity' => $employee,
'entityId' => $employee->getId()->toString(),
'entityType' => 'employee',
'location' => $employee->getLocation(),
'employeeStats' => $employeeStats,
'locations' => $this->getLocations(),
];
}
protected function getTotalScores(array $allReviews = null)
{
if (is_null($allReviews)) {
$allReviews = $this->getReviews();
}
$totals = [];
foreach ($allReviews as $review) {
$periodKey = $this->getReviewPeriodKey($review);
$reviewTotal = 0;
foreach ($review->getQuadTotals()['positionQuads'] as $score) {
$reviewTotal += $score['scoreTotal'];
}
if (!isset($totals[$periodKey])) {
$totals[$periodKey] = [];
}
$totals[$periodKey][] = $reviewTotal;
}
$periodTotals = [];
foreach ($totals as $qKey => $scores) {
$periodTotals[$qKey] = (array_sum($scores) / count($scores));
}
ksort($periodTotals);
if (count($periodTotals) > $this->periodService->getPeriodsToShow()) {
$sliceOffset = $this->periodService->getPeriodsToShow() * -1;
$periodTotals = array_slice($periodTotals, $sliceOffset);
}
return $periodTotals;
}
protected function getSkillGroupTotalScores(array $allReviews = null, string $skillGroupId)
{
if (is_null($allReviews)) {
$allReviews = $this->getReviews();
}
$totals = [];
foreach ($allReviews as $review) {
$reviewQuarter = ceil($review->getReviewDate()->format('n') / 3);
$qKey = $review->getReviewDate()->format('y').'Q'.$reviewQuarter;
$reviewTotal = 0;
foreach ($review->getQuadTotals()['positionQuads'] as $score) {
if ($score['id'] !== $skillGroupId) {
continue;
}
$reviewTotal += $score['scoreTotal'];
}
if (!isset($totals[$qKey])) {
$totals[$qKey] = [];
}
$totals[$qKey][] = $reviewTotal;
}
$periodTotals = [];
foreach ($totals as $qKey => $scores) {
$periodTotals[$qKey] = (array_sum($scores) / count($scores));
}
ksort($periodTotals);
while (count($periodTotals) > $this->periodService->getPeriodsToShow()) {
array_shift($periodTotals);
}
return $periodTotals;
}
/**
* @return EmployeeReview[]
*/
protected function getReviews()
{
/* @var EmployeeReview[] $allReviews */
if (!$this->allReviews) {
$allReviews = $this->getDoctrine()->getRepository(EmployeeReview::class)->findAll();
$this->allReviews = $allReviews;
}
return $this->allReviews;
}
protected function getPeriods()
{
return $this->periodService->getPeriods();
}
protected function getReviewPeriodKey(EmployeeReview $review): string
{
return $this->periodService->getPeriodKey($review->getReviewDate());
}
protected function getLocations()
{
if (!$this->locations) {
$locations = $this->getDoctrine()->getRepository(Location::class)->findAll();
$this->locations = $locations;
}
return $this->locations;
}
protected function getCompanyInfo()
{
$companyInfo = $this->getDoctrine()->getRepository(Company::class)->findAll();
if (isset($companyInfo[0])) {
$company = $companyInfo[0];
} else {
$company = null;
}
return $company;
}
protected function fillSkillGroupSettings()
{
$skillGroupSettings = $this->getDoctrine()->getRepository(QuadSettings::class)->findAll();
if (count($skillGroupSettings)) {
$this->quads = [];
/** @var QuadSettings $skillGroupSetting */
foreach ($skillGroupSettings as $skillGroupSetting) {
$this->quads[$skillGroupSetting->getPositionNumber()] = $skillGroupSetting->getName();
}
}
}
protected function pruneStatPeriods($data)
{
if (count($data) > $this->periodService->getPeriodsToShow()) {
$sliceOffset = $this->periodService->getPeriodsToShow() * -1;
$data = array_slice($data, $sliceOffset);
}
return $data;
}
/**
* @param Request $request
* @param string $employeeId
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
#[Route(path: '/profile/employee/{employeeId}', name: 'employee_profile')]
public function getEmployeeProfile(Request $request, string $employeeId): Response
{
$employeeData = $this->getEmployeePanelData($employeeId);
$employeeData['company'] = $this->getCompanyInfo();
$employeeData['locations'] = $this->getLocations();
$employeeData['skillGroupNames'] = $this->quads;
$employeeData['isRoot'] = 1;
$employee = $this->getDoctrine()->getRepository(Employee::class)->findOneBy(['id' => $employeeId]);
$employeeData['employee'] = $employee;
$employeeData['employeeMenu'] = 1;
$employeeData['employeeId'] = $employeeId;
return $this->render('dashboard-stimulus/index.html.twig', $employeeData);
}
}