diff --git a/src/Controller/Reporting/AbstractUserReportController.php b/src/Controller/Reporting/AbstractUserReportController.php new file mode 100644 index 00000000..071d9ee9 --- /dev/null +++ b/src/Controller/Reporting/AbstractUserReportController.php @@ -0,0 +1,121 @@ +statisticService = $statisticService; + $this->projectRepository = $projectRepository; + $this->activityRepository = $activityRepository; + } + + protected function canSelectUser(): bool + { + // also found in App\EventSubscriber\Actions\UserSubscriber + if (!$this->isGranted('view_other_timesheet') || !$this->isGranted('view_other_reporting')) { + return false; + } + + return true; + } + + protected function getStatisticDataRaw(DateTime $begin, DateTime $end, User $user): array + { + return $this->statisticService->getDailyStatisticsGrouped($begin, $end, [$user]); + } + + protected function createStatisticModel(DateTime $begin, DateTime $end, User $user): DateStatisticInterface + { + return new DailyStatistic($begin, $end, $user); + } + + protected function prepareReport(DateTime $begin, DateTime $end, User $user): array + { + $data = $this->getStatisticDataRaw($begin, $end, $user); + + $data = array_pop($data); + $projectIds = []; + $activityIds = []; + + foreach ($data as $projectId => $projectValues) { + $projectIds[$projectId] = $projectId; + $dailyProjectStatistic = $this->createStatisticModel($begin, $end, $user); + foreach ($projectValues['activities'] as $activityId => $activityValues) { + $activityIds[$activityId] = $activityId; + if (!isset($data[$projectId]['duration'])) { + $data[$projectId]['duration'] = 0; + } + if (!isset($data[$projectId]['rate'])) { + $data[$projectId]['rate'] = 0.0; + } + if (!isset($data[$projectId]['internalRate'])) { + $data[$projectId]['internalRate'] = 0.0; + } + if (!isset($data[$projectId]['activities'][$activityId]['duration'])) { + $data[$projectId]['activities'][$activityId]['duration'] = 0; + } + if (!isset($data[$projectId]['activities'][$activityId]['rate'])) { + $data[$projectId]['activities'][$activityId]['rate'] = 0.0; + } + if (!isset($data[$projectId]['activities'][$activityId]['internalRate'])) { + $data[$projectId]['activities'][$activityId]['internalRate'] = 0.0; + } + /** @var StatisticDate $date */ + foreach ($activityValues['data']->getData() as $date) { + $statisticDate = $dailyProjectStatistic->getByDateTime($date->getDate()); + $statisticDate->setTotalDuration($statisticDate->getTotalDuration() + $date->getTotalDuration()); + $statisticDate->setTotalRate($statisticDate->getTotalRate() + $date->getTotalRate()); + $statisticDate->setTotalInternalRate($statisticDate->getTotalInternalRate() + $date->getTotalInternalRate()); + $data[$projectId]['duration'] = $data[$projectId]['duration'] + $date->getTotalDuration(); + $data[$projectId]['rate'] = $data[$projectId]['rate'] + $date->getTotalRate(); + $data[$projectId]['internalRate'] = $data[$projectId]['internalRate'] + $date->getTotalInternalRate(); + $data[$projectId]['activities'][$activityId]['duration'] = $data[$projectId]['activities'][$activityId]['duration'] + $date->getTotalDuration(); + $data[$projectId]['activities'][$activityId]['rate'] = $data[$projectId]['activities'][$activityId]['rate'] + $date->getTotalRate(); + $data[$projectId]['activities'][$activityId]['internalRate'] = $data[$projectId]['activities'][$activityId]['internalRate'] + $date->getTotalInternalRate(); + } + } + $data[$projectId]['data'] = $dailyProjectStatistic; + } + + $activities = $this->activityRepository->findByIds($activityIds); + foreach ($activities as $activity) { + $activityIds[$activity->getId()] = $activity; + } + + foreach ($data as $projectId => $projectValues) { + foreach ($projectValues['activities'] as $activityId => $activityValues) { + $data[$projectId]['activities'][$activityId]['activity'] = $activityIds[$activityId]; + } + } + + $projects = $this->projectRepository->findByIds($projectIds); + foreach ($projects as $project) { + $data[$project->getId()]['project'] = $project; + } + + return $data; + } +} diff --git a/src/Controller/Reporting/ReportByUserController.php b/src/Controller/Reporting/ReportByUserController.php deleted file mode 100644 index 4275528e..00000000 --- a/src/Controller/Reporting/ReportByUserController.php +++ /dev/null @@ -1,243 +0,0 @@ -statisticService = $statisticService; - $this->projectRepository = $projectRepository; - $this->activityRepository = $activityRepository; - } - - private function canSelectUser(): bool - { - // also found in App\EventSubscriber\Actions\UserSubscriber - if (!$this->isGranted('view_other_timesheet') || !$this->isGranted('view_other_reporting')) { - return false; - } - - return true; - } - - /** - * @Route(path="/month_by_user", name="report_user_month", methods={"GET","POST"}) - * - * @param Request $request - * @return Response - * @throws Exception - */ - public function monthByUser(Request $request): Response - { - $currentUser = $this->getUser(); - $dateTimeFactory = $this->getDateTimeFactory($currentUser); - $canChangeUser = $this->canSelectUser(); - - $values = new MonthByUser(); - $values->setUser($currentUser); - $values->setDate($dateTimeFactory->getStartOfMonth()); - - $form = $this->createForm(MonthByUserForm::class, $values, [ - 'include_user' => $canChangeUser, - 'timezone' => $dateTimeFactory->getTimezone()->getName(), - 'start_date' => $values->getDate(), - ]); - - $form->submit($request->query->all(), false); - - if ($values->getUser() === null) { - $values->setUser($currentUser); - } - - if ($currentUser !== $values->getUser() && !$canChangeUser) { - throw new AccessDeniedException('User is not allowed to see other users timesheet'); - } - - if ($values->getDate() === null) { - $values->setDate($dateTimeFactory->getStartOfMonth()); - } - - $start = $values->getDate(); - $start->modify('first day of 00:00:00'); - - $end = clone $start; - $end->modify('last day of 23:59:59'); - - $selectedUser = $values->getUser(); - - $previousMonth = clone $start; - $previousMonth->modify('-1 month'); - - $nextMonth = clone $start; - $nextMonth->modify('+1 month'); - - $data = $this->prepareReport($start, $end, $selectedUser); - - return $this->render('reporting/report_by_user.html.twig', [ - 'report_title' => 'report_user_month', - 'box_id' => 'user-month-reporting-box', - 'form' => $form->createView(), - 'rows' => $data, - 'days' => new DailyStatistic($start, $end, $selectedUser), - 'user' => $selectedUser, - 'current' => $start, - 'next' => $nextMonth, - 'previous' => $previousMonth, - ]); - } - - /** - * @Route(path="/week_by_user", name="report_user_week", methods={"GET","POST"}) - * - * @param Request $request - * @return Response - * @throws Exception - */ - public function weekByUser(Request $request): Response - { - $currentUser = $this->getUser(); - $dateTimeFactory = $this->getDateTimeFactory($currentUser); - $canChangeUser = $this->canSelectUser(); - - $values = new WeekByUser(); - $values->setUser($currentUser); - $values->setDate($dateTimeFactory->getStartOfWeek()); - - $form = $this->createForm(WeekByUserForm::class, $values, [ - 'include_user' => $canChangeUser, - 'timezone' => $dateTimeFactory->getTimezone()->getName(), - 'start_date' => $values->getDate(), - ]); - - $form->submit($request->query->all(), false); - - if ($values->getUser() === null) { - $values->setUser($currentUser); - } - - if ($currentUser !== $values->getUser() && !$canChangeUser) { - throw new AccessDeniedException('User is not allowed to see other users timesheet'); - } - - if ($values->getDate() === null) { - $values->setDate($dateTimeFactory->getStartOfWeek()); - } - - $start = $dateTimeFactory->getStartOfWeek($values->getDate()); - $end = $dateTimeFactory->getEndOfWeek($values->getDate()); - $selectedUser = $values->getUser(); - - $previous = clone $start; - $previous->modify('-1 week'); - - $next = clone $start; - $next->modify('+1 week'); - - $data = $this->prepareReport($start, $end, $selectedUser); - - return $this->render('reporting/report_by_user.html.twig', [ - 'report_title' => 'report_user_week', - 'box_id' => 'user-week-reporting-box', - 'form' => $form->createView(), - 'days' => new DailyStatistic($start, $end, $selectedUser), - 'rows' => $data, - 'user' => $selectedUser, - 'current' => $start, - 'next' => $next, - 'previous' => $previous, - ]); - } - - private function prepareReport(DateTime $begin, DateTime $end, User $user): array - { - $data = $this->statisticService->getDailyStatisticsGrouped($begin, $end, [$user]); - - $data = array_pop($data); - $projectIds = []; - $activityIds = []; - - foreach ($data as $projectId => $projectValues) { - $projectIds[$projectId] = $projectId; - $dailyProjectStatistic = new DailyStatistic($begin, $end, $user); - foreach ($projectValues['activities'] as $activityId => $activityValues) { - $activityIds[$activityId] = $activityId; - if (!isset($data[$projectId]['duration'])) { - $data[$projectId]['duration'] = 0; - } - if (!isset($data[$projectId]['rate'])) { - $data[$projectId]['rate'] = 0.0; - } - if (!isset($data[$projectId]['activities'][$activityId]['duration'])) { - $data[$projectId]['activities'][$activityId]['duration'] = 0; - } - if (!isset($data[$projectId]['activities'][$activityId]['rate'])) { - $data[$projectId]['activities'][$activityId]['rate'] = 0.0; - } - /** @var StatisticDate $day */ - foreach ($activityValues['days']->getDays() as $day) { - $statDay = $dailyProjectStatistic->getDayByDateTime($day->getDate()); - $statDay->setTotalDuration($statDay->getTotalDuration() + $day->getDuration()); - $statDay->setTotalRate($statDay->getTotalRate() + $day->getRate()); - $data[$projectId]['duration'] = $data[$projectId]['duration'] + $day->getDuration(); - $data[$projectId]['rate'] = $data[$projectId]['rate'] + $day->getRate(); - $data[$projectId]['activities'][$activityId]['duration'] = $data[$projectId]['activities'][$activityId]['duration'] + $day->getDuration(); - $data[$projectId]['activities'][$activityId]['rate'] = $data[$projectId]['activities'][$activityId]['rate'] + $day->getRate(); - } - } - $data[$projectId]['days'] = $dailyProjectStatistic; - } - - $activities = $this->activityRepository->findByIds($activityIds); - foreach ($activities as $activity) { - $activityIds[$activity->getId()] = $activity; - } - - foreach ($data as $projectId => $projectValues) { - foreach ($projectValues['activities'] as $activityId => $activityValues) { - $data[$projectId]['activities'][$activityId]['activity'] = $activityIds[$activityId]; - } - } - - $projects = $this->projectRepository->findByIds($projectIds); - foreach ($projects as $project) { - $data[$project->getId()]['project'] = $project; - } - - return $data; - } -} diff --git a/src/Controller/Reporting/ReportUsersMonthController.php b/src/Controller/Reporting/ReportUsersMonthController.php index a90cf0ca..55275568 100644 --- a/src/Controller/Reporting/ReportUsersMonthController.php +++ b/src/Controller/Reporting/ReportUsersMonthController.php @@ -25,13 +25,13 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; /** - * @Route(path="/reporting") + * @Route(path="/reporting/users") * @Security("is_granted('view_reporting') and is_granted('view_other_reporting') and is_granted('view_other_timesheet')") */ final class ReportUsersMonthController extends AbstractController { /** - * @Route(path="/monthly_users_list", name="report_monthly_users", methods={"GET","POST"}) + * @Route(path="/month", name="report_monthly_users", methods={"GET","POST"}) */ public function report(Request $request, TimesheetStatisticService $statisticService, UserRepository $userRepository): Response { @@ -42,7 +42,7 @@ final class ReportUsersMonthController extends AbstractController } /** - * @Route(path="/export/monthly_users_list", name="report_monthly_users_export", methods={"GET","POST"}) + * @Route(path="/month_export", name="report_monthly_users_export", methods={"GET","POST"}) */ public function export(Request $request, TimesheetStatisticService $statisticService, UserRepository $userRepository): Response { @@ -53,7 +53,7 @@ final class ReportUsersMonthController extends AbstractController $reader = new Html(); $spreadsheet = $reader->loadFromString($content); - $writer = new BinaryFileResponseWriter(new XlsxWriter(), 'kimai-export-users-weekly'); + $writer = new BinaryFileResponseWriter(new XlsxWriter(), 'kimai-export-users-monthly'); return $writer->getFileResponse($spreadsheet); } @@ -110,6 +110,8 @@ final class ReportUsersMonthController extends AbstractController } return [ + 'period_attribute' => 'days', + 'dataType' => $values->getSumType(), 'report_title' => 'report_monthly_users', 'box_id' => 'monthly-user-list-reporting-box', 'export_route' => 'report_monthly_users_export', diff --git a/src/Controller/Reporting/ReportUsersWeekController.php b/src/Controller/Reporting/ReportUsersWeekController.php index 54f4bc5a..6d208db1 100644 --- a/src/Controller/Reporting/ReportUsersWeekController.php +++ b/src/Controller/Reporting/ReportUsersWeekController.php @@ -25,13 +25,13 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; /** - * @Route(path="/reporting") + * @Route(path="/reporting/users") * @Security("is_granted('view_reporting') and is_granted('view_other_reporting') and is_granted('view_other_timesheet')") */ final class ReportUsersWeekController extends AbstractController { /** - * @Route(path="/weekly_users_list", name="report_weekly_users", methods={"GET","POST"}) + * @Route(path="/week", name="report_weekly_users", methods={"GET","POST"}) */ public function report(Request $request, TimesheetStatisticService $statisticService, UserRepository $userRepository): Response { @@ -42,7 +42,7 @@ final class ReportUsersWeekController extends AbstractController } /** - * @Route(path="/export/weekly_users_list", name="report_weekly_users_export", methods={"GET","POST"}) + * @Route(path="/week_export", name="report_weekly_users_export", methods={"GET","POST"}) */ public function export(Request $request, TimesheetStatisticService $statisticService, UserRepository $userRepository): Response { @@ -107,6 +107,8 @@ final class ReportUsersWeekController extends AbstractController } return [ + 'period_attribute' => 'days', + 'dataType' => $values->getSumType(), 'report_title' => 'report_weekly_users', 'box_id' => 'weekly-user-list-reporting-box', 'export_route' => 'report_weekly_users_export', diff --git a/src/Controller/Reporting/ReportUsersYearController.php b/src/Controller/Reporting/ReportUsersYearController.php index 72afb7cb..5f311cba 100644 --- a/src/Controller/Reporting/ReportUsersYearController.php +++ b/src/Controller/Reporting/ReportUsersYearController.php @@ -27,13 +27,13 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; /** - * @Route(path="/reporting") + * @Route(path="/reporting/users") * @Security("is_granted('view_reporting') and is_granted('view_other_reporting') and is_granted('view_other_timesheet')") */ final class ReportUsersYearController extends AbstractController { /** - * @Route(path="/yearly_users_list", name="report_yearly_users", methods={"GET","POST"}) + * @Route(path="/year", name="report_yearly_users", methods={"GET","POST"}) * * @param Request $request * @return Response @@ -48,7 +48,7 @@ final class ReportUsersYearController extends AbstractController } /** - * @Route(path="/export/yearly_users_list", name="report_yearly_users_export", methods={"GET","POST"}) + * @Route(path="/year_export", name="report_yearly_users_export", methods={"GET","POST"}) * * @param Request $request * @return Response @@ -118,6 +118,9 @@ final class ReportUsersYearController extends AbstractController } return [ + 'query' => $values, + 'period_attribute' => 'months', + 'dataType' => $values->getSumType(), 'report_title' => 'report_yearly_users', 'box_id' => 'yearly-user-list-reporting-box', 'export_route' => 'report_yearly_users_export', diff --git a/src/Controller/Reporting/UserMonthController.php b/src/Controller/Reporting/UserMonthController.php new file mode 100644 index 00000000..efeb2dea --- /dev/null +++ b/src/Controller/Reporting/UserMonthController.php @@ -0,0 +1,101 @@ +render('reporting/report_by_user.html.twig', $this->getData($request)); + } + + private function getData(Request $request): array + { + $currentUser = $this->getUser(); + $dateTimeFactory = $this->getDateTimeFactory($currentUser); + $canChangeUser = $this->canSelectUser(); + + $values = new MonthByUser(); + $values->setUser($currentUser); + $values->setDate($dateTimeFactory->getStartOfMonth()); + + $form = $this->createForm(MonthByUserForm::class, $values, [ + 'include_user' => $canChangeUser, + 'timezone' => $dateTimeFactory->getTimezone()->getName(), + 'start_date' => $values->getDate(), + ]); + + $form->submit($request->query->all(), false); + + if ($values->getUser() === null) { + $values->setUser($currentUser); + } + + if ($currentUser !== $values->getUser() && !$canChangeUser) { + throw new AccessDeniedException('User is not allowed to see other users timesheet'); + } + + if ($values->getDate() === null) { + $values->setDate($dateTimeFactory->getStartOfMonth()); + } + + $start = $values->getDate(); + $start->modify('first day of 00:00:00'); + + $end = clone $start; + $end->modify('last day of 23:59:59'); + + $selectedUser = $values->getUser(); + + $previousMonth = clone $start; + $previousMonth->modify('-1 month'); + + $nextMonth = clone $start; + $nextMonth->modify('+1 month'); + + $data = $this->prepareReport($start, $end, $selectedUser); + + return [ + 'decimal' => $values->isDecimal(), + 'dataType' => $values->getSumType(), + 'report_title' => 'report_user_month', + 'box_id' => 'user-month-reporting-box', + 'form' => $form->createView(), + 'rows' => $data, + 'period' => new DailyStatistic($start, $end, $selectedUser), + 'user' => $selectedUser, + 'current' => $start, + 'next' => $nextMonth, + 'previous' => $previousMonth, + ]; + } +} diff --git a/src/Controller/Reporting/UserWeekController.php b/src/Controller/Reporting/UserWeekController.php new file mode 100644 index 00000000..776809d1 --- /dev/null +++ b/src/Controller/Reporting/UserWeekController.php @@ -0,0 +1,97 @@ +render('reporting/report_by_user.html.twig', $this->getData($request)); + } + + private function getData(Request $request): array + { + $currentUser = $this->getUser(); + $dateTimeFactory = $this->getDateTimeFactory($currentUser); + $canChangeUser = $this->canSelectUser(); + + $values = new WeekByUser(); + $values->setUser($currentUser); + $values->setDate($dateTimeFactory->getStartOfWeek()); + + $form = $this->createForm(WeekByUserForm::class, $values, [ + 'include_user' => $canChangeUser, + 'timezone' => $dateTimeFactory->getTimezone()->getName(), + 'start_date' => $values->getDate(), + ]); + + $form->submit($request->query->all(), false); + + if ($values->getUser() === null) { + $values->setUser($currentUser); + } + + if ($currentUser !== $values->getUser() && !$canChangeUser) { + throw new AccessDeniedException('User is not allowed to see other users timesheet'); + } + + if ($values->getDate() === null) { + $values->setDate($dateTimeFactory->getStartOfWeek()); + } + + $start = $dateTimeFactory->getStartOfWeek($values->getDate()); + $end = $dateTimeFactory->getEndOfWeek($values->getDate()); + $selectedUser = $values->getUser(); + + $previous = clone $start; + $previous->modify('-1 week'); + + $next = clone $start; + $next->modify('+1 week'); + + $data = $this->prepareReport($start, $end, $selectedUser); + + return [ + 'decimal' => $values->isDecimal(), + 'dataType' => $values->getSumType(), + 'report_title' => 'report_user_week', + 'box_id' => 'user-week-reporting-box', + 'form' => $form->createView(), + 'period' => new DailyStatistic($start, $end, $selectedUser), + 'rows' => $data, + 'user' => $selectedUser, + 'current' => $start, + 'next' => $next, + 'previous' => $previous, + ]; + } +} diff --git a/src/Controller/Reporting/UserYearController.php b/src/Controller/Reporting/UserYearController.php new file mode 100644 index 00000000..34ac25d9 --- /dev/null +++ b/src/Controller/Reporting/UserYearController.php @@ -0,0 +1,109 @@ +render('reporting/report_by_user_year.html.twig', $this->getData($request)); + } + + private function getData(Request $request): array + { + $currentUser = $this->getUser(); + $dateTimeFactory = $this->getDateTimeFactory($currentUser); + $canChangeUser = $this->canSelectUser(); + + $values = new YearByUser(); + $values->setUser($currentUser); + $values->setDate($dateTimeFactory->createStartOfYear()); + + $form = $this->createForm(YearByUserForm::class, $values, [ + 'include_user' => $canChangeUser, + 'timezone' => $dateTimeFactory->getTimezone()->getName(), + 'start_date' => $values->getDate(), + ]); + + $form->submit($request->query->all(), false); + + if ($values->getUser() === null) { + $values->setUser($currentUser); + } + + if ($currentUser !== $values->getUser() && !$canChangeUser) { + throw new AccessDeniedException('User is not allowed to see other users timesheet'); + } + + if ($values->getDate() === null) { + $values->setDate($dateTimeFactory->createStartOfYear()); + } + + $start = $dateTimeFactory->createStartOfYear($values->getDate()); + $end = $dateTimeFactory->createEndOfYear($values->getDate()); + $selectedUser = $values->getUser(); + + $previous = clone $start; + $previous->modify('-1 year'); + + $next = clone $start; + $next->modify('+1 year'); + + $data = $this->prepareReport($start, $end, $selectedUser); + + return [ + 'decimal' => $values->isDecimal(), + 'dataType' => $values->getSumType(), + 'report_title' => 'report_user_year', + 'box_id' => 'user-year-reporting-box', + 'form' => $form->createView(), + 'period' => new MonthlyStatistic($start, $end, $selectedUser), + 'rows' => $data, + 'user' => $selectedUser, + 'current' => $start, + 'next' => $next, + 'previous' => $previous, + ]; + } + + protected function getStatisticDataRaw(DateTime $begin, DateTime $end, User $user): array + { + return $this->statisticService->getMonthlyStatisticsGrouped($begin, $end, [$user]); + } + + protected function createStatisticModel(DateTime $begin, DateTime $end, User $user): DateStatisticInterface + { + return new MonthlyStatistic($begin, $end, $user); + } +} diff --git a/src/Form/Type/ReportSumType.php b/src/Form/Type/ReportSumType.php new file mode 100644 index 00000000..dfb6edb7 --- /dev/null +++ b/src/Form/Type/ReportSumType.php @@ -0,0 +1,57 @@ +authorizationChecker = $authorizationChecker; + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'required' => true, + 'multiple' => false, + 'expanded' => true, + ]); + + $resolver->setDefault('choices', function (Options $options) { + $choices = ['stats.durationTotal' => 'duration']; + + if ($this->authorizationChecker->isGranted('view_rate_other_timesheet')) { + $choices['stats.amountTotal'] = 'rate'; + $choices['label.rate_internal'] = 'internalRate'; + } + + return $choices; + }); + } + + /** + * {@inheritdoc} + */ + public function getParent() + { + return ChoiceType::class; + } +} diff --git a/src/Model/DailyStatistic.php b/src/Model/DailyStatistic.php index c423147a..399df003 100644 --- a/src/Model/DailyStatistic.php +++ b/src/Model/DailyStatistic.php @@ -14,7 +14,7 @@ use App\Model\Statistic\StatisticDate; use DateTime; use DateTimeInterface; -final class DailyStatistic +final class DailyStatistic implements DateStatisticInterface { /** * @var array @@ -61,11 +61,26 @@ final class DailyStatistic return array_values($this->days); } + /** + * For unified frontend access + * + * @return StatisticDate[] + */ + public function getData(): array + { + return $this->getDays(); + } + public function getDayByDateTime(\DateTimeInterface $date): ?StatisticDate { return $this->getDay($date->format('Y'), $date->format('m'), $date->format('d')); } + public function getByDateTime(\DateTimeInterface $date): ?StatisticDate + { + return $this->getDayByDateTime($date); + } + public function getDayByReportDate(string $date): ?StatisticDate { $this->setupDays(); diff --git a/src/Model/DateStatisticInterface.php b/src/Model/DateStatisticInterface.php new file mode 100644 index 00000000..ebb8fae4 --- /dev/null +++ b/src/Model/DateStatisticInterface.php @@ -0,0 +1,30 @@ +> @@ -107,6 +107,26 @@ final class MonthlyStatistic return $all; } + /** + * For unified frontend access + * + * @return StatisticDate[] + */ + public function getData(): array + { + return $this->getMonths(); + } + + public function getMonthByDateTime(DateTimeInterface $date): ?StatisticDate + { + return $this->getMonth($date->format('Y'), $date->format('m')); + } + + public function getByDateTime(DateTimeInterface $date): ?StatisticDate + { + return $this->getMonthByDateTime($date); + } + public function getMonth(string $year, string $month): ?StatisticDate { $this->setupYears(); diff --git a/src/Reporting/AbstractUserList.php b/src/Reporting/AbstractUserList.php index afd86551..57f47453 100644 --- a/src/Reporting/AbstractUserList.php +++ b/src/Reporting/AbstractUserList.php @@ -11,11 +11,9 @@ namespace App\Reporting; abstract class AbstractUserList { - /** - * @var \DateTime - */ private $date; private $decimal = false; + private $sumType = 'duration'; public function getDate(): ?\DateTime { @@ -36,4 +34,18 @@ abstract class AbstractUserList { $this->decimal = $decimal; } + + public function getSumType(): string + { + return $this->sumType; + } + + public function setSumType(string $sumType): void + { + if (!\in_array($sumType, ['duration', 'rate', 'internalRate'])) { + throw new \InvalidArgumentException('Unknown sum type'); + } + + $this->sumType = $sumType; + } } diff --git a/src/Reporting/DateByUser.php b/src/Reporting/DateByUser.php index 41ac9318..3e905345 100644 --- a/src/Reporting/DateByUser.php +++ b/src/Reporting/DateByUser.php @@ -11,38 +11,17 @@ namespace App\Reporting; use App\Entity\User; -abstract class DateByUser +abstract class DateByUser extends AbstractUserList { - /** - * @var User - */ private $user; - /** - * @var \DateTime - */ - private $date; public function getUser(): ?User { return $this->user; } - public function setUser(User $user): self + public function setUser(User $user): void { $this->user = $user; - - return $this; - } - - public function getDate(): ?\DateTime - { - return $this->date; - } - - public function setDate(\DateTime $date): self - { - $this->date = $date; - - return $this; } } diff --git a/src/Reporting/MonthByUserForm.php b/src/Reporting/MonthByUserForm.php index b52d64ed..c14f67b8 100644 --- a/src/Reporting/MonthByUserForm.php +++ b/src/Reporting/MonthByUserForm.php @@ -10,6 +10,7 @@ namespace App\Reporting; use App\Form\Type\MonthPickerType; +use App\Form\Type\ReportSumType; use App\Form\Type\UserType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -41,6 +42,7 @@ class MonthByUserForm extends AbstractType if ($options['include_user']) { $builder->add('user', UserType::class, ['width' => false]); } + $builder->add('sumType', ReportSumType::class); } /** diff --git a/src/Reporting/MonthlyUserListForm.php b/src/Reporting/MonthlyUserListForm.php index ed5c3524..722903b0 100644 --- a/src/Reporting/MonthlyUserListForm.php +++ b/src/Reporting/MonthlyUserListForm.php @@ -10,6 +10,7 @@ namespace App\Reporting; use App\Form\Type\MonthPickerType; +use App\Form\Type\ReportSumType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -36,6 +37,7 @@ class MonthlyUserListForm extends AbstractType 'view_timezone' => $options['timezone'], 'start_date' => $options['start_date'], ]); + $builder->add('sumType', ReportSumType::class); } /** diff --git a/src/Reporting/ReportingService.php b/src/Reporting/ReportingService.php index fd75fa26..f37ca5d8 100644 --- a/src/Reporting/ReportingService.php +++ b/src/Reporting/ReportingService.php @@ -44,6 +44,7 @@ final class ReportingService if ($this->security->isGranted('view_reporting')) { $event->addReport(new Report('week_by_user', 'report_user_week', 'report_user_week', 'user')); $event->addReport(new Report('month_by_user', 'report_user_month', 'report_user_month', 'user')); + $event->addReport(new Report('year_by_user', 'report_user_year', 'report_user_year', 'user')); if ($this->security->isGranted('view_other_reporting') && $this->security->isGranted('view_other_timesheet')) { $event->addReport(new Report('weekly_users_list', 'report_weekly_users', 'report_weekly_users', 'users')); $event->addReport(new Report('monthly_users_list', 'report_monthly_users', 'report_monthly_users', 'users')); diff --git a/src/Reporting/WeekByUserForm.php b/src/Reporting/WeekByUserForm.php index a8d90553..b8e8842f 100644 --- a/src/Reporting/WeekByUserForm.php +++ b/src/Reporting/WeekByUserForm.php @@ -9,6 +9,7 @@ namespace App\Reporting; +use App\Form\Type\ReportSumType; use App\Form\Type\UserType; use App\Form\Type\WeekPickerType; use Symfony\Component\Form\AbstractType; @@ -41,6 +42,7 @@ class WeekByUserForm extends AbstractType if ($options['include_user']) { $builder->add('user', UserType::class, ['width' => false]); } + $builder->add('sumType', ReportSumType::class); } /** diff --git a/src/Reporting/WeeklyUserListForm.php b/src/Reporting/WeeklyUserListForm.php index eb729f89..f5b57e28 100644 --- a/src/Reporting/WeeklyUserListForm.php +++ b/src/Reporting/WeeklyUserListForm.php @@ -9,6 +9,7 @@ namespace App\Reporting; +use App\Form\Type\ReportSumType; use App\Form\Type\WeekPickerType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -36,6 +37,7 @@ class WeeklyUserListForm extends AbstractType 'view_timezone' => $options['timezone'], 'start_date' => $options['start_date'], ]); + $builder->add('sumType', ReportSumType::class); } /** diff --git a/src/Reporting/YearByUser.php b/src/Reporting/YearByUser.php new file mode 100644 index 00000000..97366311 --- /dev/null +++ b/src/Reporting/YearByUser.php @@ -0,0 +1,14 @@ +add('date', YearPickerType::class, [ + 'model_timezone' => $options['timezone'], + 'view_timezone' => $options['timezone'], + 'start_date' => $options['start_date'], + ]); + + if ($options['include_user']) { + $builder->add('user', UserType::class, ['width' => false]); + } + $builder->add('sumType', ReportSumType::class); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => YearByUser::class, + 'timezone' => date_default_timezone_get(), + 'start_date' => new \DateTime(), + 'include_user' => false, + 'csrf_protection' => false, + 'method' => 'GET', + ]); + } +} diff --git a/src/Reporting/YearlyUserListForm.php b/src/Reporting/YearlyUserListForm.php index 9c59e3fc..35d7de0d 100644 --- a/src/Reporting/YearlyUserListForm.php +++ b/src/Reporting/YearlyUserListForm.php @@ -9,6 +9,7 @@ namespace App\Reporting; +use App\Form\Type\ReportSumType; use App\Form\Type\YearPickerType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; @@ -37,6 +38,7 @@ class YearlyUserListForm extends AbstractType 'start_date' => $options['start_date'], 'show_range' => true, ]); + $builder->add('sumType', ReportSumType::class); } /** diff --git a/src/Timesheet/DateTimeFactory.php b/src/Timesheet/DateTimeFactory.php index 3bc949ae..aef86f38 100644 --- a/src/Timesheet/DateTimeFactory.php +++ b/src/Timesheet/DateTimeFactory.php @@ -156,6 +156,19 @@ class DateTimeFactory return $date; } + public function createEndOfYear(?DateTime $date = null): DateTime + { + if (null === $date) { + $date = $this->createDateTime(); + } else { + $date = clone $date; + } + + $date->modify('last day of december 23:59:59'); + + return $date; + } + public function createStartOfFinancialYear(?string $financialYear = null): DateTime { $defaultDate = $this->createDateTime('01 january this year 00:00:00'); diff --git a/src/Timesheet/TimesheetStatisticService.php b/src/Timesheet/TimesheetStatisticService.php index 1fbef27d..bb0944cd 100644 --- a/src/Timesheet/TimesheetStatisticService.php +++ b/src/Timesheet/TimesheetStatisticService.php @@ -143,11 +143,11 @@ final class TimesheetStatisticService $stats[$uid][$pid] = ['project' => $pid, 'activities' => []]; } if (!isset($stats[$uid][$pid]['activities'][$aid])) { - $stats[$uid][$pid]['activities'][$aid] = ['activity' => $aid, 'days' => new DailyStatistic($begin, $end, $usersById[$uid])]; + $stats[$uid][$pid]['activities'][$aid] = ['activity' => $aid, 'data' => new DailyStatistic($begin, $end, $usersById[$uid])]; } /** @var DailyStatistic $days */ - $days = $stats[$uid][$pid]['activities'][$aid]['days']; + $days = $stats[$uid][$pid]['activities'][$aid]['data']; $day = $days->getDayByReportDate($row['date']); if ($day === null) { @@ -167,6 +167,85 @@ final class TimesheetStatisticService return $stats; } + /** + * @internal only for core development + * @param DateTime $begin + * @param DateTime $end + * @param User[] $users + * @return array + */ + public function getMonthlyStatisticsGrouped(DateTime $begin, DateTime $end, array $users): array + { + /** @var MonthlyStatistic[] $stats */ + $stats = []; + $usersById = []; + + foreach ($users as $user) { + $usersById[$user->getId()] = $user; + if (!isset($stats[$user->getId()])) { + $stats[$user->getId()] = []; + } + } + + $qb = $this->repository->createQueryBuilder('t'); + $qb + ->select('COALESCE(SUM(t.rate), 0.0) as rate') + ->addSelect('COALESCE(SUM(t.duration), 0) as duration') + ->addSelect('COALESCE(SUM(t.internalRate), 0) as internalRate') + ->addSelect('t.billable as billable') + ->addSelect('IDENTITY(t.user) as user') + ->addSelect('IDENTITY(t.project) as project') + ->addSelect('IDENTITY(t.activity) as activity') + ->addSelect('YEAR(t.date) as year') + ->addSelect('MONTH(t.date) as month') + ->where($qb->expr()->isNotNull('t.end')) + ->andWhere($qb->expr()->between('t.begin', ':begin', ':end')) + ->andWhere($qb->expr()->in('t.user', ':user')) + ->setParameter('begin', $begin) + ->setParameter('end', $end) + ->setParameter('user', $users) + ->groupBy('year') + ->addGroupBy('month') + ->addGroupBy('project') + ->addGroupBy('activity') + ->addGroupBy('user') + ->addGroupBy('billable') + ; + + $results = $qb->getQuery()->getResult(); + + foreach ($results as $row) { + $uid = $row['user']; + $pid = $row['project']; + $aid = $row['activity']; + if (!isset($stats[$uid][$pid])) { + $stats[$uid][$pid] = ['project' => $pid, 'activities' => []]; + } + if (!isset($stats[$uid][$pid]['activities'][$aid])) { + $stats[$uid][$pid]['activities'][$aid] = ['activity' => $aid, 'data' => new MonthlyStatistic($begin, $end, $usersById[$uid])]; + } + + /** @var MonthlyStatistic $months */ + $months = $stats[$uid][$pid]['activities'][$aid]['data']; + $month = $months->getMonth((string) $row['year'], (string) $row['month']); + + if ($month === null) { + // timezone differences + continue; + } + + $month->setTotalDuration($month->getTotalDuration() + (int) $row['duration']); + $month->setTotalRate($month->getTotalRate() + (float) $row['rate']); + $month->setTotalInternalRate($month->getTotalInternalRate() + (float) $row['internalRate']); + if ($row['billable']) { + $month->setBillableRate((float) $row['rate']); + $month->setBillableDuration((int) $row['duration']); + } + } + + return $stats; + } + public function findFirstRecordDate(User $user): ?DateTime { $result = $this->repository->createQueryBuilder('t') diff --git a/src/Twig/IconExtension.php b/src/Twig/IconExtension.php index 9106137b..92795c88 100644 --- a/src/Twig/IconExtension.php +++ b/src/Twig/IconExtension.php @@ -39,6 +39,7 @@ final class IconExtension extends AbstractExtension 'debug' => 'far fa-file-alt', 'delete' => 'far fa-trash-alt', 'details' => 'fas fa-info-circle', + 'display' => 'fas fa-layer-group', 'doctor' => 'fas fa-medkit', 'dot' => 'fas fa-circle', 'download' => 'fas fa-download', diff --git a/templates/reporting/report_by_user.html.twig b/templates/reporting/report_by_user.html.twig index 0fadb6c8..b34c4962 100644 --- a/templates/reporting/report_by_user.html.twig +++ b/templates/reporting/report_by_user.html.twig @@ -7,7 +7,7 @@ {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} {% import "macros/widgets.html.twig" as widgets %} {% block box_before %} - {{ form_start(form, {'attr': {'class': 'form-inline'}}) }} + {{ form_start(form, {'attr': {'class': 'form-inline', 'id': 'user-filter-form'}}) }} {% endblock %} {% block box_after %} {{ form_end(form) }} @@ -19,78 +19,35 @@ {{ widgets.username(user) }} {% endif %} {{ form_widget(form.date) }} + {% endblock %} {% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %} {% block box_body %} - {% set totals = {'totals': 0} %} - {% set columns = 2 %} - - - - - - {% for day in days.dateTimes %} - - {% set columns = columns + 1 %} - {% set totals = totals|merge({(day|report_date): 0}) %} - {% endfor %} - - - - {% set oldCustomer = null %} - {% for pid, project in rows|sort((a,b) => a.project.customer.id <=> b.project.customer.id) %} - {% if oldCustomer is null or oldCustomer != project.project.customer.id %} - {% set oldCustomer = project.project.customer.id %} - - - - {% endif %} - {% set totals = totals|merge({'totals': (totals['totals'] + project.duration)}) %} - - - - {% for day in project.days.days %} - - {% endfor %} - - {% for activity in project.activities %} - - - - {% for day in activity.days.days %} - - {% endfor %} - - {% endfor %} - {% endfor %} - - - - - - {% for day in days.dateTimes %} - - {% endfor %} - - -
   - {{ day|date_weekday }} -
{{ widgets.label_customer(project.project.customer) }}
- {{ widgets.label_project(project.project) }} - {{ project.duration|duration }} - {% if day.duration > 0 %} - {% set totals = totals|merge({(day.date|report_date): (totals[day.date|report_date] + day.duration)}) %} - {{ day.duration|duration }} - {% endif %} -
- {{ widgets.label_activity(activity.activity) }} - {{ activity.duration|duration }} - {% if day.duration > 0 %} - {{ day.duration|duration }} - {% endif %} -
{{ 'stats.durationTotal'|trans }}{{ totals['totals']|duration }} - {{ totals[day|report_date]|duration }} -
+ {% embed 'reporting/report_by_user_data.html.twig' %} + {% block period_name %} + + {{ column|date_weekday }} + + {% endblock %} + {% block column_classes_project -%} + {% if column.date is weekend %} weekend{% endif %}{% if column.date is today %} today{% endif %} + {%- endblock %} + {% block column_classes_activity -%} + {% if column.date is weekend %} weekend{% endif %}{% if column.date is today %} today{% endif %} + {%- endblock %} + {% block column_classes_total -%} + {% if column is weekend %} weekend{% endif %} + {%- endblock %} + {% endembed %} {% endblock %} {% endembed %} @@ -100,13 +57,8 @@ {{ parent() }} diff --git a/templates/reporting/report_by_user_data.html.twig b/templates/reporting/report_by_user_data.html.twig new file mode 100644 index 00000000..0eac4ca0 --- /dev/null +++ b/templates/reporting/report_by_user_data.html.twig @@ -0,0 +1,141 @@ +{% import "macros/widgets.html.twig" as widgets %} +{%- set absoluteDuration = 0 -%} +{%- set absoluteInternalRate = 0 -%} +{%- set absoluteRate = 0 -%} +{%- set totalsDuration = {} -%} +{%- set totalsInternalRate = {} -%} +{%- set totalsRate = {} -%} +{% if dataType == 'rate' %} + {% set dataTypeTitle = 'stats.amountTotal' %} +{% elseif dataType == 'internalRate' %} + {% set dataTypeTitle = 'label.rate_internal' %} +{% else %} + {% set dataTypeTitle = 'stats.durationTotal' %} +{% endif %} +{% set columns = 2 %} +{% set totalCurrency = false %} + + + + + + {% for column in period.dateTimes %} + {% block period_name %}{% endblock %} + {% set columns = columns + 1 %} + {% set dateKey = column|report_date %} + {% set totalsDuration = totalsDuration|merge({(dateKey): 0}) %} + {% set totalsInternalRate = totalsInternalRate|merge({(dateKey): 0}) %} + {% set totalsRate = totalsRate|merge({(dateKey): 0}) %} + {% endfor %} + + + + {% set oldCustomer = null %} + {% for project in rows|sort((a,b) => a.project.customer.id <=> b.project.customer.id) %} + {% set currency = project.project.customer.currency %} + {% if oldCustomer is null or oldCustomer != project.project.customer.id %} + {% set oldCustomer = project.project.customer.id %} + {% if totalCurrency is same as (false) %} + {% set totalCurrency = currency %} + {% elseif project.project.customer.currency != totalCurrency %} + {% set totalCurrency = null %} + {% endif %} + + + + {% endif %} + {% set absoluteDuration = absoluteDuration + project.duration %} + {% set absoluteInternalRate = absoluteInternalRate + project.internalRate %} + {% set absoluteRate = absoluteRate + project.rate %} + + + + {% for column in project.data.data %} + {% set dateKey = column.date|report_date %} + + {% endfor %} + + {% for activity in project.activities %} + + + + {% for column in activity.data.data %} + + {% endfor %} + + {% endfor %} + {% endfor %} + + {% if totalCurrency is same as (false) %} + {% set totalCurrency = null %} + {% endif %} + + + + + {% for column in period.dateTimes %} + {% set dateKey = column|report_date %} + + {% endfor %} + + +
 {{ dataTypeTitle|trans }}
{{ widgets.label_customer(project.project.customer) }}
+ {{ widgets.label_project(project.project) }} + + {% if dataType == 'rate' %} + {{ project.rate|money(currency) }} + {% elseif dataType == 'internalRate' %} + {{ project.internalRate|money(currency) }} + {% else %} + {{ project.duration|duration(decimal) }} + {% endif %} + + {% if column.duration > 0 or column.rate > 0 or column.internalRate > 0 %} + {% if dataType == 'rate' %} + {% set totalsRate = totalsRate|merge({(dateKey): (totalsRate[dateKey] + column.rate)}) %} + {{ column.rate|money(currency) }} + {% elseif dataType == 'internalRate' %} + {% set totalsInternalRate = totalsInternalRate|merge({(dateKey): (totalsInternalRate[dateKey] + column.internalRate)}) %} + {{ column.internalRate|money(currency) }} + {% else %} + {% set totalsDuration = totalsDuration|merge({(dateKey): (totalsDuration[dateKey] + column.duration)}) %} + {{ column.duration|duration(decimal) }} + {% endif %} + {% endif %} +
+ {{ widgets.label_activity(activity.activity) }} + + {% if dataType == 'rate' %} + {{ activity.rate|money(currency) }} + {% elseif dataType == 'internalRate' %} + {{ activity.internalRate|money(currency) }} + {% else %} + {{ activity.duration|duration(decimal) }} + {% endif %} + + {% if column.duration > 0 or column.rate > 0 or column.internalRate > 0 %} + {% if dataType == 'rate' %} + {{ column.rate|money(currency) }} + {% elseif dataType == 'internalRate' %} + {{ column.internalRate|money(currency) }} + {% else %} + {{ column.duration|duration(decimal) }} + {% endif %} + {% endif %} +
{{ dataTypeTitle|trans }} + {% if dataType == 'rate' %} + {{ absoluteRate|money(totalCurrency) }} + {% elseif dataType == 'internalRate' %} + {{ absoluteInternalRate|money(totalCurrency) }} + {% else %} + {{ absoluteDuration|duration(decimal) }} + {% endif %} + + {% if dataType == 'rate' %} + {{ totalsRate[dateKey]|money(totalCurrency) }} + {% elseif dataType == 'internalRate' %} + {{ totalsInternalRate[dateKey]|money(totalCurrency) }} + {% else %} + {{ totalsDuration[dateKey]|duration(decimal) }} + {% endif %} +
diff --git a/templates/reporting/report_by_user_year.html.twig b/templates/reporting/report_by_user_year.html.twig new file mode 100644 index 00000000..c2603eb1 --- /dev/null +++ b/templates/reporting/report_by_user_year.html.twig @@ -0,0 +1,62 @@ +{% extends 'reporting/layout.html.twig' %} + +{% block report_title %}{{ report_title|trans({}, 'reporting') }}{% endblock %} + +{% block report %} + + {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} + {% import "macros/widgets.html.twig" as widgets %} + {% block box_before %} + {{ form_start(form, {'attr': {'class': 'form-inline', 'id': 'user-filter-form'}}) }} + {% endblock %} + {% block box_after %} + {{ form_end(form) }} + {% endblock %} + {% block box_title %} + {% if form.user is defined %} + {{ form_row(form.user, {'label': false}) }} + {% else %} + {{ widgets.username(user) }} + {% endif %} + {{ form_widget(form.date) }} + + {% endblock %} + {% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %} + {% block box_body %} + {% embed 'reporting/report_by_user_data.html.twig' %} + {% block period_name %} + + + {{ column|month_name }}
+ {{ column|date_format('Y') }} +
+ + {% endblock %} + {% block column_classes_project %}{% endblock %} + {% block column_classes_activity %}{% endblock %} + {% block column_classes_total %}{% endblock %} + {% endembed %} + {% endblock %} + {% endembed %} + +{% endblock %} + +{% block javascripts %} + {{ parent() }} + +{% endblock %} diff --git a/templates/reporting/report_user_list.html.twig b/templates/reporting/report_user_list.html.twig index bfc208a3..4c867f57 100644 --- a/templates/reporting/report_user_list.html.twig +++ b/templates/reporting/report_user_list.html.twig @@ -5,25 +5,60 @@ {% block report %} {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} - {% import "macros/widgets.html.twig" as widgets %} + {% from "macros/widgets.html.twig" import nothing_found %} {% block box_before %} - {{ form_start(form, {'attr': {'class': 'form-inline'}}) }} + {{ form_start(form, {'attr': {'class': 'form-inline kimai-1.17', 'id': 'user-list-filter-form'}}) }} {% endblock %} {% block box_after %} {{ form_end(form) }} {% endblock %} {% block box_title %} {{ form_widget(form.date) }} - {% endblock %} - {% block box_tools %} - + {% if form.sumType.vars.choices|length > 1 %} +
+ + +
+ {% endif %} + {% endblock %} {% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %} {% block box_body %} {% if not hasData %} - {{ widgets.nothing_found() }} + {{ nothing_found() }} {% else %} - {% embed 'reporting/report_user_list_data.html.twig' %}{% endembed %} + {% embed 'reporting/user_list_period_data.html.twig' %} + {% block period_name %} + + {{ column|date_weekday }} + + {% endblock %} + {% block total_rate_user %} + {{ usersTotalRate|money }} + {% endblock %} + {% block total_internal_rate_user %} + {{ usersTotalInternalRate|money }} + {% endblock %} + {% block total_duration_user %} + {{ usersTotalDuration|duration(decimal) }} + {% endblock %} + {% block rate %} + {{ period.totalRate|money }} + {% endblock %} + {% block internal_rate %} + {{ period.totalInternalRate|money }} + {% endblock %} + {% block duration %} + {{ period.totalDuration|duration(decimal) }} + {% endblock %} + {% block period_cell_class %}{% if period.date is weekend %} weekend{% endif %}{% if period.date is today %} today{% endif %}{% endblock %} + {% endembed %} {% endif %} {% endblock %} {% endembed %} @@ -34,8 +69,8 @@ {{ parent() }} diff --git a/templates/reporting/report_user_list_data.html.twig b/templates/reporting/report_user_list_data.html.twig deleted file mode 100644 index becf8f34..00000000 --- a/templates/reporting/report_user_list_data.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{% set absoluteTotals = 0 %} -{% set totals = {} %} - - - - - - {% for day in stats.0.getDateTimes() %} - - {% set totals = totals|merge({(day|report_date): 0}) %} - {% endfor %} - - - - {% for userPeriod in stats %} - {% set usersTotalDuration = 0 %} - - - {% for period in userPeriod.days %} - {% if period.totalDuration > 0 %} - {% set usersTotalDuration = usersTotalDuration + period.totalDuration %} - {% set absoluteTotals = absoluteTotals + period.totalDuration %} - {% endif %} - {% set totals = totals|merge({(period.date|report_date): (totals[period.date|report_date] + period.totalDuration)}) %} - {% endfor %} - - {% for period in userPeriod.days %} - - {% endfor %} - - {% endfor %} - - - - - - {% for id, total in totals %} - - {% endfor %} - - -
 {{ 'stats.durationTotal'|trans }} - {% block period_name %} - {{ day|date_weekday }} - {% endblock %} -
- {% block user_column %} - {% from "macros/widgets.html.twig" import label_dot %} - {{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }} - {% endblock %} - - {% block total_duration_user %} - {{ usersTotalDuration|duration(decimal) }} - {% endblock %} - - {% if period.totalDuration > 0 %} - {% block duration %} - {{ period.totalDuration|duration(decimal) }} - {% endblock %} - {% endif %} -
{{ 'stats.durationTotal'|trans }} - {% block total_duration %} - {{ absoluteTotals|duration(decimal) }} - {% endblock %} - - {% block total_duration_period %} - {{ total|duration(decimal) }} - {% endblock %} -
diff --git a/templates/reporting/report_user_list_export.html.twig b/templates/reporting/report_user_list_export.html.twig index b1c51caf..604b8147 100644 --- a/templates/reporting/report_user_list_export.html.twig +++ b/templates/reporting/report_user_list_export.html.twig @@ -1,20 +1,46 @@ -{% embed 'reporting/report_user_list_data.html.twig' %} +{% embed 'reporting/user_list_period_data.html.twig' %} {% block user_column %} {{ userPeriod.user.displayName }} {% endblock %} {% block duration -%} =VALUE("{{ period.totalDuration|duration(true) }}") {%- endblock %} + {% block total_duration -%} + =VALUE("{{ absoluteDuration|duration(true) }}") + {%- endblock %} {% block total_duration_user -%} =VALUE("{{ usersTotalDuration|duration(true) }}") {%- endblock %} - {% block total_duration -%} - =VALUE("{{ absoluteTotals|duration(true) }}") - {%- endblock %} {% block total_duration_period -%} =VALUE("{{ total|duration(true) }}") {%- endblock %} + {% block rate %} + =VALUE("{{ period.totalRate|money }}") + {% endblock %} + {% block total_rate %} + =VALUE("{{ absoluteRate|money }}") + {% endblock %} + {% block total_rate_user %} + =VALUE("{{ usersTotalRate|money }}") + {% endblock %} + {% block total_rate_period %} + =VALUE("{{ total|money }}") + {% endblock %} + {% block internal_rate %} + =VALUE("{{ period.totalInternalRate|money }}") + {% endblock %} + {% block total_internal_rate %} + =VALUE("{{ absoluteInternalRate|money }}") + {% endblock %} + {% block total_internal_rate_user %} + =VALUE("{{ usersTotalInternalRate|money }}") + {% endblock %} + {% block total_internal_rate_period %} + =VALUE("{{ total|money }}") + {% endblock %} {% block period_name %} - {{ day|date_short }} + + {{ column|date_short }} + {% endblock %} {% endembed %} diff --git a/templates/reporting/report_user_list_monthly.html.twig b/templates/reporting/report_user_list_monthly.html.twig index 2b1076e2..34417250 100644 --- a/templates/reporting/report_user_list_monthly.html.twig +++ b/templates/reporting/report_user_list_monthly.html.twig @@ -5,25 +5,74 @@ {% block report %} {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} - {% from "macros/widgets.html.twig" import nothing_found, action_button %} + {% from "macros/widgets.html.twig" import nothing_found %} {% block box_before %} - {{ form_start(form, {'attr': {'class': 'form-inline form-reporting'}}) }} + {{ form_start(form, {'attr': {'class': 'form-inline form-reporting', 'id': 'user-list-filter-form'}}) }} {% endblock %} {% block box_after %} {{ form_end(form) }} {% endblock %} - {% block box_tools %} - - {% endblock %} {% block box_title %} {{ form_widget(form.date) }} + {% if form.sumType.vars.choices|length > 1 %} +
+ + +
+ {% endif %} + {% endblock %} {% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %} {% block box_body %} {% if not hasData %} {{ nothing_found() }} {% else %} - {% embed 'reporting/report_user_list_monthly_data.html.twig' %}{% endembed %} + {% embed 'reporting/user_list_period_data.html.twig' %} + {% block period_name %} + + + {{ column|month_name }}
+ {{ column|date_format('Y') }} +
+ + {% endblock %} + {% block total_rate_user %} + + {{ usersTotalRate|money }} + + {% endblock %} + {% block total_internal_rate_user %} + + {{ usersTotalInternalRate|money }} + + {% endblock %} + {% block total_duration_user %} + + {{ usersTotalDuration|duration(decimal) }} + + {% endblock %} + {% block rate %} + + {{ period.totalRate|money }} + + {% endblock %} + {% block internal_rate %} + + {{ period.totalInternalRate|money }} + + {% endblock %} + {% block duration %} + + {{ period.totalDuration|duration(decimal) }} + + {% endblock %} + {% endembed %} {% endif %} {% endblock %} {% endembed %} @@ -34,8 +83,8 @@ {{ parent() }} diff --git a/templates/reporting/report_user_list_monthly_data.html.twig b/templates/reporting/report_user_list_monthly_data.html.twig deleted file mode 100644 index 839a2565..00000000 --- a/templates/reporting/report_user_list_monthly_data.html.twig +++ /dev/null @@ -1,74 +0,0 @@ -{% set absoluteTotals = 0 %} -{% set totals = {} %} - - - - - - {% for month in stats.0.getDateTimes() %} - - {% set totals = totals|merge({(month|report_date): 0}) %} - {% endfor %} - - - - {% for userPeriod in stats|filter(row => row.user is not null) %} - {% set usersTotalDuration = 0 %} - - - {% for mid, period in userPeriod.months %} - {% if period.totalDuration > 0 %} - {% set usersTotalDuration = usersTotalDuration + period.totalDuration %} - {% set absoluteTotals = absoluteTotals + period.totalDuration %} - {% endif %} - {% endfor %} - - {% for mid, period in userPeriod.months %} - - {% endfor %} - - {% endfor %} - - - - - - {% for id, total in totals %} - - {% endfor %} - - -
 {{ 'stats.durationTotal'|trans }} - {% block period_name %} - - {{ month|month_name }}
- {{ month|date_format('Y') }} -
- {% endblock %} -
- {% block user_column %} - {% from "macros/widgets.html.twig" import label_dot %} - {{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }} - {% endblock %} - - {% block total_duration_user %} - {{ usersTotalDuration|duration(decimal) }} - {% endblock %} - - {% if period.totalDuration > 0 %} - {% block duration %} - - {{ period.totalDuration|duration(decimal) }} - - {% endblock %} - {% set totals = totals|merge({(period.date|report_date): (totals[period.date|report_date] + period.totalDuration)}) %} - {% endif %} -
{{ 'stats.durationTotal'|trans }} - {% block total_duration %} - {{ absoluteTotals|duration(decimal) }} - {% endblock %} - - {% block total_duration_period %} - {{ total|duration(decimal) }} - {% endblock %} -
diff --git a/templates/reporting/report_user_list_monthly_export.html.twig b/templates/reporting/report_user_list_monthly_export.html.twig index ddf226fa..3b9d3821 100644 --- a/templates/reporting/report_user_list_monthly_export.html.twig +++ b/templates/reporting/report_user_list_monthly_export.html.twig @@ -1,4 +1,4 @@ -{% embed 'reporting/report_user_list_monthly_data.html.twig' %} +{% embed 'reporting/user_list_period_data.html.twig' %} {% block user_column %} {{ userPeriod.user.displayName }} {% endblock %} @@ -9,12 +9,38 @@ =VALUE("{{ usersTotalDuration|duration(true) }}") {%- endblock %} {% block total_duration -%} - =VALUE("{{ absoluteTotals|duration(true) }}") + =VALUE("{{ absoluteDuration|duration(true) }}") {%- endblock %} {% block total_duration_period -%} =VALUE("{{ total|duration(true) }}") {%- endblock %} + {% block rate %} + =VALUE("{{ period.totalRate|money }}") + {% endblock %} + {% block total_rate %} + =VALUE("{{ absoluteRate|money }}") + {% endblock %} + {% block total_rate_user %} + =VALUE("{{ usersTotalRate|money }}") + {% endblock %} + {% block total_rate_period %} + =VALUE("{{ total|money }}") + {% endblock %} + {% block internal_rate %} + =VALUE("{{ period.totalInternalRate|money }}") + {% endblock %} + {% block total_internal_rate %} + =VALUE("{{ absoluteInternalRate|money }}") + {% endblock %} + {% block total_internal_rate_user %} + =VALUE("{{ usersTotalInternalRate|money }}") + {% endblock %} + {% block total_internal_rate_period %} + =VALUE("{{ total|money }}") + {% endblock %} {% block period_name %} - {{ month|month_name }} {{ month|date_format('Y') }} + + {{ column|month_name }} {{ column|date_format('Y') }} + {% endblock %} {% endembed %} diff --git a/templates/reporting/user_list_period_data.html.twig b/templates/reporting/user_list_period_data.html.twig new file mode 100644 index 00000000..2bc5fbbd --- /dev/null +++ b/templates/reporting/user_list_period_data.html.twig @@ -0,0 +1,128 @@ +{%- set absoluteDuration = 0 -%} +{%- set absoluteInternalRate = 0 -%} +{%- set absoluteRate = 0 -%} +{%- set totalsDuration = {} -%} +{%- set totalsInternalRate = {} -%} +{%- set totalsRate = {} -%} +{% if dataType == 'rate' %} + {% set dataTypeTitle = 'stats.amountTotal' %} +{% elseif dataType == 'internalRate' %} + {% set dataTypeTitle = 'label.rate_internal' %} +{% else %} + {% set dataTypeTitle = 'stats.durationTotal' %} +{% endif %} + + + + + + {% for column in stats.0.getDateTimes() %} + {% block period_name %}{% endblock %} + {% set columnKey = column|report_date %} + {% set totalsDuration = totalsDuration|merge({(columnKey): 0}) %} + {% set totalsInternalRate = totalsInternalRate|merge({(columnKey): 0}) %} + {% set totalsRate = totalsRate|merge({(columnKey): 0}) %} + {% endfor %} + + + + {% for userPeriod in stats|filter(row => row.user is not null) %} + {% set usersTotalDuration = 0 %} + {% set usersTotalInternalRate = 0 %} + {% set usersTotalRate = 0 %} + + + {% for period in attribute(userPeriod, period_attribute) %} + {% if period.totalDuration > 0 %} + {% set usersTotalDuration = usersTotalDuration + period.totalDuration %} + {% set absoluteDuration = absoluteDuration + period.totalDuration %} + {% endif %} + {% if period.totalInternalRate > 0 %} + {% set usersTotalInternalRate = usersTotalInternalRate + period.totalInternalRate %} + {% set absoluteInternalRate = absoluteInternalRate + period.totalInternalRate %} + {% endif %} + {% if period.totalRate > 0 %} + {% set usersTotalRate = usersTotalRate + period.totalRate %} + {% set absoluteRate = absoluteRate + period.totalRate %} + {% endif %} + {% set reportDateKey = period.date|report_date %} + {% set totalsDuration = totalsDuration|merge({(reportDateKey): (totalsDuration[reportDateKey] + period.totalDuration)}) %} + {% set totalsInternalRate = totalsInternalRate|merge({(reportDateKey): (totalsInternalRate[reportDateKey] + period.totalInternalRate)}) %} + {% set totalsRate = totalsRate|merge({(reportDateKey): (totalsRate[reportDateKey] + period.totalRate)}) %} + {% endfor %} + + {% for period in attribute(userPeriod, period_attribute) %} + + {% endfor %} + + {% endfor %} + + + + + + {% if dataType == 'rate' %} + {% for id, total in totalsRate %} + + {% endfor %} + {% elseif dataType == 'internalRate' %} + {% for id, total in totalsInternalRate %} + + {% endfor %} + {% else %} + {% for id, total in totalsDuration %} + + {% endfor %} + {% endif %} + + +
 {{ dataTypeTitle|trans }}
+ {% block user_column %} + {% from "macros/widgets.html.twig" import label_dot %} + {{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }} + {% endblock %} + + {% if dataType == 'rate' %} + {% block total_rate_user %}{% endblock %} + {% elseif dataType == 'internalRate' %} + {% block total_internal_rate_user %}{% endblock %} + {% else %} + {% block total_duration_user %}{% endblock %} + {% endif %} + + {% if period.totalDuration > 0 or period.totalRate > 0 or period.totalInternalRate > 0 %} + {% if dataType == 'rate' %} + {% block rate %}{% endblock %} + {% elseif dataType == 'internalRate' %} + {% block internal_rate %}{% endblock %} + {% else %} + {% block duration %}{% endblock %} + {% endif %} + {% endif %} +
{{ dataTypeTitle|trans }} + {% if dataType == 'rate' %} + {% block total_rate %} + {{ absoluteRate|money }} + {% endblock %} + {% elseif dataType == 'internalRate' %} + {% block total_internal_rate %} + {{ absoluteInternalRate|money }} + {% endblock %} + {% else %} + {% block total_duration %} + {{ absoluteDuration|duration(decimal) }} + {% endblock %} + {% endif %} + + {% block total_rate_period %} + {{ total|money }} + {% endblock %} + + {% block total_internal_rate_period %} + {{ total|money }} + {% endblock %} + + {% block total_duration_period %} + {{ total|duration(decimal) }} + {% endblock %} +
diff --git a/templates/user/stats.html.twig b/templates/user/stats.html.twig index 288c8307..e0e17c5a 100644 --- a/templates/user/stats.html.twig +++ b/templates/user/stats.html.twig @@ -27,7 +27,9 @@ {% endif %} {% set monthRoute = null %} - {%- if user.enabled and is_granted('view_reporting') and (app.user.id == user.id or is_granted('view_other_timesheet')) -%} + {% set canSeeReport = user.enabled and is_granted('view_reporting') and (app.user.id == user.id or is_granted('view_other_timesheet')) %} + + {%- if canSeeReport -%} {% set monthRoute = path('report_user_month', {'user': user.id, 'date': '__MONTH__'}) %} {% endif %} @@ -37,6 +39,11 @@ {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} {% import "macros/charts.html.twig" as charts %} {% block box_title %}{{ year }}{% endblock %} + {% block box_tools %} + {%- if canSeeReport -%} + + {% endif %} + {% endblock %} {% block box_body %} {% set dataset = [] %} {% for month in workMonths.year(year) %} diff --git a/tests/Controller/Reporting/AbstractUserPeriodControllerTest.php b/tests/Controller/Reporting/AbstractUserPeriodControllerTest.php new file mode 100644 index 00000000..a826145c --- /dev/null +++ b/tests/Controller/Reporting/AbstractUserPeriodControllerTest.php @@ -0,0 +1,75 @@ +setAmount(50); + $fixture->setAmountRunning(10); + $fixture->setUser($this->getUserByRole($role)); + $fixture->setStartDate(new \DateTime()); + $this->importFixture($fixture); + } + + abstract protected function getReportUrl(): string; + + abstract protected function getBoxId(): string; + + public function testIsSecure() + { + $this->assertUrlIsSecured($this->getReportUrl()); + } + + public function getTestData(): array + { + return [ + [4, 'duration', 'Working hours total'], + [4, 'rate', 'Total revenue'], + [4, 'internalRate', 'Internal rate'], + ]; + } + + /** + * @dataProvider getTestData + */ + public function testUserPeriodReport(int $user, string $dataType, string $title) + { + $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); + $this->importReportingFixture(User::ROLE_SUPER_ADMIN); + $this->assertAccessIsGranted($client, sprintf('%s?user=%s&date=12999119191&sumType=%s', $this->getReportUrl(), $user, $dataType)); + self::assertStringContainsString(sprintf('
attr('value')); + $cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]"); + self::assertEquals($title, $cell->text()); + } + + public function testUserPeriodReportAsTeamlead() + { + $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); + $this->importReportingFixture(User::ROLE_USER); + $this->assertAccessIsGranted($client, sprintf('%s?date=12999119191', $this->getReportUrl())); + self::assertStringContainsString(sprintf('
count()); + $cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]"); + self::assertEquals('Working hours total', $cell->text()); + } +} diff --git a/tests/Controller/Reporting/AbstractUsersPeriodControllerTest.php b/tests/Controller/Reporting/AbstractUsersPeriodControllerTest.php new file mode 100644 index 00000000..b79cd249 --- /dev/null +++ b/tests/Controller/Reporting/AbstractUsersPeriodControllerTest.php @@ -0,0 +1,95 @@ +setAmount(50); + $fixture->setAmountRunning(10); + $fixture->setUser($this->getUserByRole($role)); + $fixture->setStartDate(new \DateTime()); + $this->importFixture($fixture); + } + + abstract protected function getReportUrl(): string; + + abstract protected function getReportExportUrl(): string; + + abstract protected function getBoxId(): string; + + public function testIsSecure() + { + $this->assertUrlIsSecured($this->getReportUrl()); + } + + public function getTestData(): array + { + return [ + ['duration', 'Working hours total'], + ['rate', 'Total revenue'], + ['internalRate', 'Internal rate'], + ]; + } + + /** + * @dataProvider getTestData + */ + public function testUsersPeriodReport(string $dataType, string $title) + { + $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); + $this->importReportingFixture(User::ROLE_SUPER_ADMIN); + $this->assertAccessIsGranted($client, sprintf('%s?date=12999119191&sumType=%s', $this->getReportUrl(), $dataType)); + self::assertStringContainsString(sprintf('
text()); + } + + /** + * @dataProvider getTestData + */ + public function testUsersPeriodReportAsTeamlead(string $dataType, string $title) + { + $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); + $this->importReportingFixture(User::ROLE_TEAMLEAD); + $this->assertAccessIsGranted($client, sprintf('%s?date=12999119191&sumType=%s', $this->getReportUrl(), $dataType)); + self::assertStringContainsString(sprintf('
count()); + $cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]"); + self::assertEquals($title, $cell->text()); + } + + /** + * @dataProvider getTestData + */ + public function testUsersPeriodReportExport(string $dataType, string $title) + { + $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); + $this->importReportingFixture(User::ROLE_SUPER_ADMIN); + $this->request($client, sprintf('%s?date=12999119191&sumType=%s', $this->getReportExportUrl(), $dataType)); + $response = $client->getResponse(); + $this->assertTrue($response->isSuccessful()); + self::assertInstanceOf(BinaryFileResponse::class, $response); + self::assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type')); + self::assertStringContainsString('attachment; filename=kimai-export-users-', $response->headers->get('Content-Disposition')); + self::assertStringContainsString('.xlsx', $response->headers->get('Content-Disposition')); + } +} diff --git a/tests/Controller/Reporting/ReportByUserControllerTest.php b/tests/Controller/Reporting/ReportByUserControllerTest.php deleted file mode 100644 index fd796717..00000000 --- a/tests/Controller/Reporting/ReportByUserControllerTest.php +++ /dev/null @@ -1,60 +0,0 @@ -setAmount(50); - $fixture->setAmountRunning(10); - $fixture->setUser($this->getUserByRole($role)); - $fixture->setStartDate(new \DateTime()); - $this->importFixture($fixture); - } - - public function testWeekByUserIsSecure() - { - $this->assertUrlIsSecured('/reporting/week_by_user'); - } - - public function testMonthByUserIsSecure() - { - $this->assertUrlIsSecured('/reporting/month_by_user'); - } - - public function testUserWeekReport() - { - $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); - $this->importReportingFixture(User::ROLE_SUPER_ADMIN); - $this->assertAccessIsGranted($client, '/reporting/week_by_user?user=4&date=12999119191'); - self::assertStringContainsString('
attr('value')); - } - - public function testUserMonthReport() - { - $client = $this->getClientForAuthenticatedUser(User::ROLE_USER); - $this->importReportingFixture(User::ROLE_USER); - $this->assertAccessIsGranted($client, '/reporting/month_by_user?user=4&date=12999119191'); - self::assertStringContainsString('
count()); - } -} diff --git a/tests/Controller/Reporting/ReportUsersListControllerTest.php b/tests/Controller/Reporting/ReportUsersListControllerTest.php deleted file mode 100644 index 8da8a0df..00000000 --- a/tests/Controller/Reporting/ReportUsersListControllerTest.php +++ /dev/null @@ -1,90 +0,0 @@ -setAmount(50); - $fixture->setAmountRunning(10); - $fixture->setUser($this->getUserByRole($role)); - $fixture->setStartDate(new \DateTime()); - $this->importFixture($fixture); - } - - public function testYearlyListIsSecure() - { - $this->assertUrlIsSecured('/reporting/yearly_users_list'); - } - - public function testWeeklyListIsSecure() - { - $this->assertUrlIsSecured('/reporting/weekly_users_list'); - } - - public function testMonthlyListIsSecure() - { - $this->assertUrlIsSecured('/reporting/monthly_users_list'); - } - - public function testYearlyUsersListIsSecureForUserRole() - { - $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/reporting/yearly_users_list'); - } - - public function testWeeklyUsersListIsSecureForUserRole() - { - $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/reporting/weekly_users_list'); - } - - public function testMonthlyUsersListIsSecureForUserRole() - { - $this->assertUrlIsSecuredForRole(User::ROLE_USER, '/reporting/monthly_users_list'); - } - - public function testYearlyUsersReport() - { - $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); - $this->importReportingFixture(User::ROLE_TEAMLEAD); - $this->assertAccessIsGranted($client, '/reporting/yearly_users_list'); - self::assertStringContainsString('
count()); - } - - public function testWeeklyUsersReport() - { - $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); - $this->importReportingFixture(User::ROLE_TEAMLEAD); - $this->assertAccessIsGranted($client, '/reporting/weekly_users_list'); - self::assertStringContainsString('
count()); - } - - public function testMonthlyUsersReport() - { - $client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD); - $this->importReportingFixture(User::ROLE_TEAMLEAD); - $this->assertAccessIsGranted($client, '/reporting/monthly_users_list'); - self::assertStringContainsString('
count()); - } -} diff --git a/tests/Controller/Reporting/ReportUsersMonthControllerTest.php b/tests/Controller/Reporting/ReportUsersMonthControllerTest.php new file mode 100644 index 00000000..69b1196b --- /dev/null +++ b/tests/Controller/Reporting/ReportUsersMonthControllerTest.php @@ -0,0 +1,31 @@ +getClientForAuthenticatedUser(User::ROLE_USER); $this->request($client, '/reporting/'); - $this->assertIsRedirect($client, $this->createUrl('/reporting/week_by_user')); + $this->assertIsRedirect($client, $this->createUrl('/reporting/user/week')); $client->followRedirect(); self::assertStringContainsString('