new user-year reporting and data-type chooser (#3155)
This commit is contained in:
121
src/Controller/Reporting/AbstractUserReportController.php
Normal file
121
src/Controller/Reporting/AbstractUserReportController.php
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Controller\Reporting;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Model\DailyStatistic;
|
||||||
|
use App\Model\DateStatisticInterface;
|
||||||
|
use App\Model\Statistic\StatisticDate;
|
||||||
|
use App\Repository\ActivityRepository;
|
||||||
|
use App\Repository\ProjectRepository;
|
||||||
|
use App\Timesheet\TimesheetStatisticService;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
abstract class AbstractUserReportController extends AbstractController
|
||||||
|
{
|
||||||
|
protected $statisticService;
|
||||||
|
private $projectRepository;
|
||||||
|
private $activityRepository;
|
||||||
|
|
||||||
|
public function __construct(TimesheetStatisticService $statisticService, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,243 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Kimai time-tracking app.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Controller\Reporting;
|
|
||||||
|
|
||||||
use App\Controller\AbstractController;
|
|
||||||
use App\Entity\User;
|
|
||||||
use App\Model\DailyStatistic;
|
|
||||||
use App\Model\Statistic\StatisticDate;
|
|
||||||
use App\Reporting\MonthByUser;
|
|
||||||
use App\Reporting\MonthByUserForm;
|
|
||||||
use App\Reporting\WeekByUser;
|
|
||||||
use App\Reporting\WeekByUserForm;
|
|
||||||
use App\Repository\ActivityRepository;
|
|
||||||
use App\Repository\ProjectRepository;
|
|
||||||
use App\Timesheet\TimesheetStatisticService;
|
|
||||||
use DateTime;
|
|
||||||
use Exception;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(path="/reporting")
|
|
||||||
* @Security("is_granted('view_reporting')")
|
|
||||||
*/
|
|
||||||
final class ReportByUserController extends AbstractController
|
|
||||||
{
|
|
||||||
private $statisticService;
|
|
||||||
private $projectRepository;
|
|
||||||
private $activityRepository;
|
|
||||||
|
|
||||||
public function __construct(TimesheetStatisticService $statisticService, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
|
||||||
{
|
|
||||||
$this->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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,13 +25,13 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
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')")
|
* @Security("is_granted('view_reporting') and is_granted('view_other_reporting') and is_granted('view_other_timesheet')")
|
||||||
*/
|
*/
|
||||||
final class ReportUsersMonthController extends AbstractController
|
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
|
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
|
public function export(Request $request, TimesheetStatisticService $statisticService, UserRepository $userRepository): Response
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ final class ReportUsersMonthController extends AbstractController
|
|||||||
$reader = new Html();
|
$reader = new Html();
|
||||||
$spreadsheet = $reader->loadFromString($content);
|
$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);
|
return $writer->getFileResponse($spreadsheet);
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,8 @@ final class ReportUsersMonthController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'period_attribute' => 'days',
|
||||||
|
'dataType' => $values->getSumType(),
|
||||||
'report_title' => 'report_monthly_users',
|
'report_title' => 'report_monthly_users',
|
||||||
'box_id' => 'monthly-user-list-reporting-box',
|
'box_id' => 'monthly-user-list-reporting-box',
|
||||||
'export_route' => 'report_monthly_users_export',
|
'export_route' => 'report_monthly_users_export',
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
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')")
|
* @Security("is_granted('view_reporting') and is_granted('view_other_reporting') and is_granted('view_other_timesheet')")
|
||||||
*/
|
*/
|
||||||
final class ReportUsersWeekController extends AbstractController
|
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
|
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
|
public function export(Request $request, TimesheetStatisticService $statisticService, UserRepository $userRepository): Response
|
||||||
{
|
{
|
||||||
@@ -107,6 +107,8 @@ final class ReportUsersWeekController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'period_attribute' => 'days',
|
||||||
|
'dataType' => $values->getSumType(),
|
||||||
'report_title' => 'report_weekly_users',
|
'report_title' => 'report_weekly_users',
|
||||||
'box_id' => 'weekly-user-list-reporting-box',
|
'box_id' => 'weekly-user-list-reporting-box',
|
||||||
'export_route' => 'report_weekly_users_export',
|
'export_route' => 'report_weekly_users_export',
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
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')")
|
* @Security("is_granted('view_reporting') and is_granted('view_other_reporting') and is_granted('view_other_timesheet')")
|
||||||
*/
|
*/
|
||||||
final class ReportUsersYearController extends AbstractController
|
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
|
* @param Request $request
|
||||||
* @return Response
|
* @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
|
* @param Request $request
|
||||||
* @return Response
|
* @return Response
|
||||||
@@ -118,6 +118,9 @@ final class ReportUsersYearController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'query' => $values,
|
||||||
|
'period_attribute' => 'months',
|
||||||
|
'dataType' => $values->getSumType(),
|
||||||
'report_title' => 'report_yearly_users',
|
'report_title' => 'report_yearly_users',
|
||||||
'box_id' => 'yearly-user-list-reporting-box',
|
'box_id' => 'yearly-user-list-reporting-box',
|
||||||
'export_route' => 'report_yearly_users_export',
|
'export_route' => 'report_yearly_users_export',
|
||||||
|
|||||||
101
src/Controller/Reporting/UserMonthController.php
Normal file
101
src/Controller/Reporting/UserMonthController.php
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Controller\Reporting;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Model\DailyStatistic;
|
||||||
|
use App\Reporting\MonthByUser;
|
||||||
|
use App\Reporting\MonthByUserForm;
|
||||||
|
use Exception;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(path="/reporting/user")
|
||||||
|
* @Security("is_granted('view_reporting')")
|
||||||
|
*/
|
||||||
|
final class UserMonthController extends AbstractUserReportController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Route(path="/month", name="report_user_month", methods={"GET","POST"})
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function monthByUser(Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
97
src/Controller/Reporting/UserWeekController.php
Normal file
97
src/Controller/Reporting/UserWeekController.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Controller\Reporting;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Model\DailyStatistic;
|
||||||
|
use App\Reporting\WeekByUser;
|
||||||
|
use App\Reporting\WeekByUserForm;
|
||||||
|
use Exception;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(path="/reporting/user")
|
||||||
|
* @Security("is_granted('view_reporting')")
|
||||||
|
*/
|
||||||
|
final class UserWeekController extends AbstractUserReportController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Route(path="/week", name="report_user_week", methods={"GET","POST"})
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function weekByUser(Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
109
src/Controller/Reporting/UserYearController.php
Normal file
109
src/Controller/Reporting/UserYearController.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Controller\Reporting;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Model\DateStatisticInterface;
|
||||||
|
use App\Model\MonthlyStatistic;
|
||||||
|
use App\Reporting\YearByUser;
|
||||||
|
use App\Reporting\YearByUserForm;
|
||||||
|
use DateTime;
|
||||||
|
use Exception;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(path="/reporting/user")
|
||||||
|
* @Security("is_granted('view_reporting')")
|
||||||
|
*/
|
||||||
|
final class UserYearController extends AbstractUserReportController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Route(path="/year", name="report_user_year", methods={"GET","POST"})
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function yearByUser(Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
57
src/Form/Type/ReportSumType.php
Normal file
57
src/Form/Type/ReportSumType.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
|
|
||||||
|
class ReportSumType extends AbstractType
|
||||||
|
{
|
||||||
|
private $authorizationChecker;
|
||||||
|
|
||||||
|
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use App\Model\Statistic\StatisticDate;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|
||||||
final class DailyStatistic
|
final class DailyStatistic implements DateStatisticInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array<string, StatisticDate>
|
* @var array<string, StatisticDate>
|
||||||
@@ -61,11 +61,26 @@ final class DailyStatistic
|
|||||||
return array_values($this->days);
|
return array_values($this->days);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For unified frontend access
|
||||||
|
*
|
||||||
|
* @return StatisticDate[]
|
||||||
|
*/
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
return $this->getDays();
|
||||||
|
}
|
||||||
|
|
||||||
public function getDayByDateTime(\DateTimeInterface $date): ?StatisticDate
|
public function getDayByDateTime(\DateTimeInterface $date): ?StatisticDate
|
||||||
{
|
{
|
||||||
return $this->getDay($date->format('Y'), $date->format('m'), $date->format('d'));
|
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
|
public function getDayByReportDate(string $date): ?StatisticDate
|
||||||
{
|
{
|
||||||
$this->setupDays();
|
$this->setupDays();
|
||||||
|
|||||||
30
src/Model/DateStatisticInterface.php
Normal file
30
src/Model/DateStatisticInterface.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
use App\Model\Statistic\StatisticDate;
|
||||||
|
use DateTimeInterface;
|
||||||
|
|
||||||
|
interface DateStatisticInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* For unified frontend access
|
||||||
|
*
|
||||||
|
* @return StatisticDate[]
|
||||||
|
*/
|
||||||
|
public function getData(): array;
|
||||||
|
|
||||||
|
public function getByDateTime(DateTimeInterface $date): ?StatisticDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return DateTimeInterface[]
|
||||||
|
*/
|
||||||
|
public function getDateTimes(): array;
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use App\Model\Statistic\StatisticDate;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|
||||||
final class MonthlyStatistic
|
final class MonthlyStatistic implements DateStatisticInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array<string, array<int, StatisticDate>>
|
* @var array<string, array<int, StatisticDate>>
|
||||||
@@ -107,6 +107,26 @@ final class MonthlyStatistic
|
|||||||
return $all;
|
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
|
public function getMonth(string $year, string $month): ?StatisticDate
|
||||||
{
|
{
|
||||||
$this->setupYears();
|
$this->setupYears();
|
||||||
|
|||||||
@@ -11,11 +11,9 @@ namespace App\Reporting;
|
|||||||
|
|
||||||
abstract class AbstractUserList
|
abstract class AbstractUserList
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \DateTime
|
|
||||||
*/
|
|
||||||
private $date;
|
private $date;
|
||||||
private $decimal = false;
|
private $decimal = false;
|
||||||
|
private $sumType = 'duration';
|
||||||
|
|
||||||
public function getDate(): ?\DateTime
|
public function getDate(): ?\DateTime
|
||||||
{
|
{
|
||||||
@@ -36,4 +34,18 @@ abstract class AbstractUserList
|
|||||||
{
|
{
|
||||||
$this->decimal = $decimal;
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,38 +11,17 @@ namespace App\Reporting;
|
|||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
|
||||||
abstract class DateByUser
|
abstract class DateByUser extends AbstractUserList
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
private $user;
|
private $user;
|
||||||
/**
|
|
||||||
* @var \DateTime
|
|
||||||
*/
|
|
||||||
private $date;
|
|
||||||
|
|
||||||
public function getUser(): ?User
|
public function getUser(): ?User
|
||||||
{
|
{
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUser(User $user): self
|
public function setUser(User $user): void
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDate(): ?\DateTime
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDate(\DateTime $date): self
|
|
||||||
{
|
|
||||||
$this->date = $date;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
namespace App\Reporting;
|
namespace App\Reporting;
|
||||||
|
|
||||||
use App\Form\Type\MonthPickerType;
|
use App\Form\Type\MonthPickerType;
|
||||||
|
use App\Form\Type\ReportSumType;
|
||||||
use App\Form\Type\UserType;
|
use App\Form\Type\UserType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@@ -41,6 +42,7 @@ class MonthByUserForm extends AbstractType
|
|||||||
if ($options['include_user']) {
|
if ($options['include_user']) {
|
||||||
$builder->add('user', UserType::class, ['width' => false]);
|
$builder->add('user', UserType::class, ['width' => false]);
|
||||||
}
|
}
|
||||||
|
$builder->add('sumType', ReportSumType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
namespace App\Reporting;
|
namespace App\Reporting;
|
||||||
|
|
||||||
use App\Form\Type\MonthPickerType;
|
use App\Form\Type\MonthPickerType;
|
||||||
|
use App\Form\Type\ReportSumType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
@@ -36,6 +37,7 @@ class MonthlyUserListForm extends AbstractType
|
|||||||
'view_timezone' => $options['timezone'],
|
'view_timezone' => $options['timezone'],
|
||||||
'start_date' => $options['start_date'],
|
'start_date' => $options['start_date'],
|
||||||
]);
|
]);
|
||||||
|
$builder->add('sumType', ReportSumType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ final class ReportingService
|
|||||||
if ($this->security->isGranted('view_reporting')) {
|
if ($this->security->isGranted('view_reporting')) {
|
||||||
$event->addReport(new Report('week_by_user', 'report_user_week', 'report_user_week', 'user'));
|
$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('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')) {
|
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('weekly_users_list', 'report_weekly_users', 'report_weekly_users', 'users'));
|
||||||
$event->addReport(new Report('monthly_users_list', 'report_monthly_users', 'report_monthly_users', 'users'));
|
$event->addReport(new Report('monthly_users_list', 'report_monthly_users', 'report_monthly_users', 'users'));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Reporting;
|
namespace App\Reporting;
|
||||||
|
|
||||||
|
use App\Form\Type\ReportSumType;
|
||||||
use App\Form\Type\UserType;
|
use App\Form\Type\UserType;
|
||||||
use App\Form\Type\WeekPickerType;
|
use App\Form\Type\WeekPickerType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
@@ -41,6 +42,7 @@ class WeekByUserForm extends AbstractType
|
|||||||
if ($options['include_user']) {
|
if ($options['include_user']) {
|
||||||
$builder->add('user', UserType::class, ['width' => false]);
|
$builder->add('user', UserType::class, ['width' => false]);
|
||||||
}
|
}
|
||||||
|
$builder->add('sumType', ReportSumType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Reporting;
|
namespace App\Reporting;
|
||||||
|
|
||||||
|
use App\Form\Type\ReportSumType;
|
||||||
use App\Form\Type\WeekPickerType;
|
use App\Form\Type\WeekPickerType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@@ -36,6 +37,7 @@ class WeeklyUserListForm extends AbstractType
|
|||||||
'view_timezone' => $options['timezone'],
|
'view_timezone' => $options['timezone'],
|
||||||
'start_date' => $options['start_date'],
|
'start_date' => $options['start_date'],
|
||||||
]);
|
]);
|
||||||
|
$builder->add('sumType', ReportSumType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
14
src/Reporting/YearByUser.php
Normal file
14
src/Reporting/YearByUser.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Reporting;
|
||||||
|
|
||||||
|
final class YearByUser extends DateByUser
|
||||||
|
{
|
||||||
|
}
|
||||||
62
src/Reporting/YearByUserForm.php
Normal file
62
src/Reporting/YearByUserForm.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Reporting;
|
||||||
|
|
||||||
|
use App\Form\Type\ReportSumType;
|
||||||
|
use App\Form\Type\UserType;
|
||||||
|
use App\Form\Type\YearPickerType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class YearByUserForm extends AbstractType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Simplify cross-linking between pages by removing the block prefix.
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder->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',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace App\Reporting;
|
namespace App\Reporting;
|
||||||
|
|
||||||
|
use App\Form\Type\ReportSumType;
|
||||||
use App\Form\Type\YearPickerType;
|
use App\Form\Type\YearPickerType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@@ -37,6 +38,7 @@ class YearlyUserListForm extends AbstractType
|
|||||||
'start_date' => $options['start_date'],
|
'start_date' => $options['start_date'],
|
||||||
'show_range' => true,
|
'show_range' => true,
|
||||||
]);
|
]);
|
||||||
|
$builder->add('sumType', ReportSumType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -156,6 +156,19 @@ class DateTimeFactory
|
|||||||
return $date;
|
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
|
public function createStartOfFinancialYear(?string $financialYear = null): DateTime
|
||||||
{
|
{
|
||||||
$defaultDate = $this->createDateTime('01 january this year 00:00:00');
|
$defaultDate = $this->createDateTime('01 january this year 00:00:00');
|
||||||
|
|||||||
@@ -143,11 +143,11 @@ final class TimesheetStatisticService
|
|||||||
$stats[$uid][$pid] = ['project' => $pid, 'activities' => []];
|
$stats[$uid][$pid] = ['project' => $pid, 'activities' => []];
|
||||||
}
|
}
|
||||||
if (!isset($stats[$uid][$pid]['activities'][$aid])) {
|
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 */
|
/** @var DailyStatistic $days */
|
||||||
$days = $stats[$uid][$pid]['activities'][$aid]['days'];
|
$days = $stats[$uid][$pid]['activities'][$aid]['data'];
|
||||||
$day = $days->getDayByReportDate($row['date']);
|
$day = $days->getDayByReportDate($row['date']);
|
||||||
|
|
||||||
if ($day === null) {
|
if ($day === null) {
|
||||||
@@ -167,6 +167,85 @@ final class TimesheetStatisticService
|
|||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal only for core development
|
||||||
|
* @param DateTime $begin
|
||||||
|
* @param DateTime $end
|
||||||
|
* @param User[] $users
|
||||||
|
* @return array<int, MonthlyStatistic[]>
|
||||||
|
*/
|
||||||
|
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
|
public function findFirstRecordDate(User $user): ?DateTime
|
||||||
{
|
{
|
||||||
$result = $this->repository->createQueryBuilder('t')
|
$result = $this->repository->createQueryBuilder('t')
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ final class IconExtension extends AbstractExtension
|
|||||||
'debug' => 'far fa-file-alt',
|
'debug' => 'far fa-file-alt',
|
||||||
'delete' => 'far fa-trash-alt',
|
'delete' => 'far fa-trash-alt',
|
||||||
'details' => 'fas fa-info-circle',
|
'details' => 'fas fa-info-circle',
|
||||||
|
'display' => 'fas fa-layer-group',
|
||||||
'doctor' => 'fas fa-medkit',
|
'doctor' => 'fas fa-medkit',
|
||||||
'dot' => 'fas fa-circle',
|
'dot' => 'fas fa-circle',
|
||||||
'download' => 'fas fa-download',
|
'download' => 'fas fa-download',
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
|
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
|
||||||
{% import "macros/widgets.html.twig" as widgets %}
|
{% import "macros/widgets.html.twig" as widgets %}
|
||||||
{% block box_before %}
|
{% block box_before %}
|
||||||
{{ form_start(form, {'attr': {'class': 'form-inline'}}) }}
|
{{ form_start(form, {'attr': {'class': 'form-inline', 'id': 'user-filter-form'}}) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_after %}
|
{% block box_after %}
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
@@ -19,78 +19,35 @@
|
|||||||
{{ widgets.username(user) }}
|
{{ widgets.username(user) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ form_widget(form.date) }}
|
{{ form_widget(form.date) }}
|
||||||
|
<div class="btn-group"{% if form.sumType.vars.choices|length <= 1 %} style="display: none"{% endif %}>
|
||||||
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu checkbox-menu">
|
||||||
|
<li>
|
||||||
|
{{ form_widget(form.sumType) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
|
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
|
||||||
{% block box_body %}
|
{% block box_body %}
|
||||||
{% set totals = {'totals': 0} %}
|
{% embed 'reporting/report_by_user_data.html.twig' %}
|
||||||
{% set columns = 2 %}
|
{% block period_name %}
|
||||||
<table class="table table-bordered table-hover dataTable">
|
<th class="text-center text-nowrap{% if column is weekend %} weekend{% endif %}{% if column is today %} today{% endif %}">
|
||||||
<thead>
|
{{ column|date_weekday }}
|
||||||
<tr>
|
</th>
|
||||||
<th> </th>
|
{% endblock %}
|
||||||
<th> </th>
|
{% block column_classes_project -%}
|
||||||
{% for day in days.dateTimes %}
|
{% if column.date is weekend %} weekend{% endif %}{% if column.date is today %} today{% endif %}
|
||||||
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}{% if day is today %} today{% endif %}">
|
{%- endblock %}
|
||||||
{{ day|date_weekday }}
|
{% block column_classes_activity -%}
|
||||||
</th>
|
{% if column.date is weekend %} weekend{% endif %}{% if column.date is today %} today{% endif %}
|
||||||
{% set columns = columns + 1 %}
|
{%- endblock %}
|
||||||
{% set totals = totals|merge({(day|report_date): 0}) %}
|
{% block column_classes_total -%}
|
||||||
{% endfor %}
|
{% if column is weekend %} weekend{% endif %}
|
||||||
</tr>
|
{%- endblock %}
|
||||||
</thead>
|
{% endembed %}
|
||||||
<tbody>
|
|
||||||
{% 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 %}
|
|
||||||
<tr class="summary">
|
|
||||||
<td colspan="{{ columns }}">{{ widgets.label_customer(project.project.customer) }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% set totals = totals|merge({'totals': (totals['totals'] + project.duration)}) %}
|
|
||||||
<tr class="project">
|
|
||||||
<td class="text-nowrap">
|
|
||||||
<strong>{{ widgets.label_project(project.project) }}</strong>
|
|
||||||
</td>
|
|
||||||
<th class="text-nowrap text-center total">{{ project.duration|duration }}</th>
|
|
||||||
{% for day in project.days.days %}
|
|
||||||
<td class="text-nowrap text-center day-total{% if day.date is weekend %} weekend{% endif %}{% if day.date is today %} today{% endif %}">
|
|
||||||
{% if day.duration > 0 %}
|
|
||||||
{% set totals = totals|merge({(day.date|report_date): (totals[day.date|report_date] + day.duration)}) %}
|
|
||||||
<strong>{{ day.duration|duration }}</strong>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
{% for activity in project.activities %}
|
|
||||||
<tr class="activity">
|
|
||||||
<td class="text-nowrap">
|
|
||||||
{{ widgets.label_activity(activity.activity) }}
|
|
||||||
</td>
|
|
||||||
<th class="text-nowrap text-center total">{{ activity.duration|duration }}</th>
|
|
||||||
{% for day in activity.days.days %}
|
|
||||||
<td class="text-nowrap text-center day-total{% if day.date is weekend %} weekend{% endif %}{% if day.date is today %} today{% endif %}">
|
|
||||||
{% if day.duration > 0 %}
|
|
||||||
{{ day.duration|duration }}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr class="summary">
|
|
||||||
<td>{{ 'stats.durationTotal'|trans }}</td>
|
|
||||||
<td class="text-nowrap text-center total">{{ totals['totals']|duration }}</td>
|
|
||||||
{% for day in days.dateTimes %}
|
|
||||||
<td class="text-nowrap text-center day-total{% if day is weekend %} weekend{% endif %}">
|
|
||||||
{{ totals[day|report_date]|duration }}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
|
|
||||||
@@ -100,13 +57,8 @@
|
|||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.addEventListener('kimai.initialized', function() {
|
document.addEventListener('kimai.initialized', function() {
|
||||||
{% if form.user is defined %}
|
jQuery('#user-filter-form').on('change', function(ev) {
|
||||||
jQuery('#{{ form.user.vars.id }}').on('change', function(ev) {
|
jQuery(this).submit();
|
||||||
jQuery(this).closest('form').submit();
|
|
||||||
});
|
|
||||||
{% endif %}
|
|
||||||
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
|
|
||||||
jQuery(this).closest('form').submit();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
141
templates/reporting/report_by_user_data.html.twig
Normal file
141
templates/reporting/report_by_user_data.html.twig
Normal file
@@ -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 %}
|
||||||
|
<table class="table table-bordered table-hover dataTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th class="text-center reportDataTypeTitle">{{ dataTypeTitle|trans }}</th>
|
||||||
|
{% 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 %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% 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 %}
|
||||||
|
<tr class="summary">
|
||||||
|
<td colspan="{{ columns }}">{{ widgets.label_customer(project.project.customer) }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% set absoluteDuration = absoluteDuration + project.duration %}
|
||||||
|
{% set absoluteInternalRate = absoluteInternalRate + project.internalRate %}
|
||||||
|
{% set absoluteRate = absoluteRate + project.rate %}
|
||||||
|
<tr class="project">
|
||||||
|
<td class="text-nowrap">
|
||||||
|
<strong>{{ widgets.label_project(project.project) }}</strong>
|
||||||
|
</td>
|
||||||
|
<td class="text-nowrap text-center total">
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{{ project.rate|money(currency) }}
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{{ project.internalRate|money(currency) }}
|
||||||
|
{% else %}
|
||||||
|
{{ project.duration|duration(decimal) }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% for column in project.data.data %}
|
||||||
|
{% set dateKey = column.date|report_date %}
|
||||||
|
<td class="text-nowrap text-center day-total {% block column_classes_project %}{% endblock %}">
|
||||||
|
{% if column.duration > 0 or column.rate > 0 or column.internalRate > 0 %}
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{% set totalsRate = totalsRate|merge({(dateKey): (totalsRate[dateKey] + column.rate)}) %}
|
||||||
|
<strong>{{ column.rate|money(currency) }}</strong>
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{% set totalsInternalRate = totalsInternalRate|merge({(dateKey): (totalsInternalRate[dateKey] + column.internalRate)}) %}
|
||||||
|
<strong>{{ column.internalRate|money(currency) }}</strong>
|
||||||
|
{% else %}
|
||||||
|
{% set totalsDuration = totalsDuration|merge({(dateKey): (totalsDuration[dateKey] + column.duration)}) %}
|
||||||
|
<strong>{{ column.duration|duration(decimal) }}</strong>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
{% for activity in project.activities %}
|
||||||
|
<tr class="activity">
|
||||||
|
<td class="text-nowrap">
|
||||||
|
{{ widgets.label_activity(activity.activity) }}
|
||||||
|
</td>
|
||||||
|
<td class="text-nowrap text-center">
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{{ activity.rate|money(currency) }}
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{{ activity.internalRate|money(currency) }}
|
||||||
|
{% else %}
|
||||||
|
{{ activity.duration|duration(decimal) }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% for column in activity.data.data %}
|
||||||
|
<td class="text-nowrap text-center day-total {% block column_classes_activity %}{% endblock %}">
|
||||||
|
{% 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 %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
{% if totalCurrency is same as (false) %}
|
||||||
|
{% set totalCurrency = null %}
|
||||||
|
{% endif %}
|
||||||
|
<tfoot>
|
||||||
|
<tr class="summary">
|
||||||
|
<td>{{ dataTypeTitle|trans }}</td>
|
||||||
|
<td class="text-nowrap text-center total">
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{{ absoluteRate|money(totalCurrency) }}
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{{ absoluteInternalRate|money(totalCurrency) }}
|
||||||
|
{% else %}
|
||||||
|
{{ absoluteDuration|duration(decimal) }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% for column in period.dateTimes %}
|
||||||
|
{% set dateKey = column|report_date %}
|
||||||
|
<td class="text-nowrap text-center day-total {% block column_classes_total %}{% endblock %}">
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{{ totalsRate[dateKey]|money(totalCurrency) }}
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{{ totalsInternalRate[dateKey]|money(totalCurrency) }}
|
||||||
|
{% else %}
|
||||||
|
{{ totalsDuration[dateKey]|duration(decimal) }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
62
templates/reporting/report_by_user_year.html.twig
Normal file
62
templates/reporting/report_by_user_year.html.twig
Normal file
@@ -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) }}
|
||||||
|
<div class="btn-group"{% if form.sumType.vars.choices|length <= 1 %} style="display: none"{% endif %}>
|
||||||
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu checkbox-menu">
|
||||||
|
<li>
|
||||||
|
{{ form_widget(form.sumType) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% 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 %}
|
||||||
|
<th class="text-center text-nowrap">
|
||||||
|
<a href="{{ path('report_user_month', {'date': column|report_date, 'sumType': dataType, 'user': user.id}) }}">
|
||||||
|
{{ column|month_name }}<br>
|
||||||
|
{{ column|date_format('Y') }}
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
|
{% endblock %}
|
||||||
|
{% block column_classes_project %}{% endblock %}
|
||||||
|
{% block column_classes_activity %}{% endblock %}
|
||||||
|
{% block column_classes_total %}{% endblock %}
|
||||||
|
{% endembed %}
|
||||||
|
{% endblock %}
|
||||||
|
{% endembed %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascripts %}
|
||||||
|
{{ parent() }}
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.addEventListener('kimai.initialized', function() {
|
||||||
|
jQuery('#user-filter-form').on('change', function(ev) {
|
||||||
|
jQuery(this).submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -5,25 +5,60 @@
|
|||||||
{% block report %}
|
{% block report %}
|
||||||
|
|
||||||
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
|
{% 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 %}
|
{% 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 %}
|
{% endblock %}
|
||||||
{% block box_after %}
|
{% block box_after %}
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_title %}
|
{% block box_title %}
|
||||||
{{ form_widget(form.date) }}
|
{{ form_widget(form.date) }}
|
||||||
{% endblock %}
|
{% if form.sumType.vars.choices|length > 1 %}
|
||||||
{% block box_tools %}
|
<div class="btn-group">
|
||||||
<button class="btn btn-default btn-sm" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu checkbox-menu">
|
||||||
|
<li>
|
||||||
|
{{ form_widget(form.sumType) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<button class="btn btn-primary" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %}
|
{% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %}
|
||||||
{% block box_body %}
|
{% block box_body %}
|
||||||
{% if not hasData %}
|
{% if not hasData %}
|
||||||
{{ widgets.nothing_found() }}
|
{{ nothing_found() }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% embed 'reporting/report_user_list_data.html.twig' %}{% endembed %}
|
{% embed 'reporting/user_list_period_data.html.twig' %}
|
||||||
|
{% block period_name %}
|
||||||
|
<th class="text-center text-nowrap{% if column is weekend %} weekend{% endif %}{% if column is today %} today{% endif %}">
|
||||||
|
{{ column|date_weekday }}
|
||||||
|
</th>
|
||||||
|
{% endblock %}
|
||||||
|
{% block total_rate_user %}
|
||||||
|
<a href="{{ path(subReportRoute, {'sumType': dataType, 'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalRate|money }}</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block total_internal_rate_user %}
|
||||||
|
<a href="{{ path(subReportRoute, {'sumType': dataType, 'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalInternalRate|money }}</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block total_duration_user %}
|
||||||
|
<a href="{{ path(subReportRoute, {'sumType': dataType, 'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalDuration|duration(decimal) }}</a>
|
||||||
|
{% 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 %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
@@ -34,8 +69,8 @@
|
|||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.addEventListener('kimai.initialized', function() {
|
document.addEventListener('kimai.initialized', function() {
|
||||||
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
|
jQuery('#user-list-filter-form').on('change', function(ev) {
|
||||||
jQuery(this).closest('form').submit();
|
jQuery(this).submit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
{% set absoluteTotals = 0 %}
|
|
||||||
{% set totals = {} %}
|
|
||||||
<table class="table table-bordered table-hover dataTable">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th> </th>
|
|
||||||
<th class="text-center">{{ 'stats.durationTotal'|trans }}</th>
|
|
||||||
{% for day in stats.0.getDateTimes() %}
|
|
||||||
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}{% if day is today %} today{% endif %}">
|
|
||||||
{% block period_name %}
|
|
||||||
{{ day|date_weekday }}
|
|
||||||
{% endblock %}
|
|
||||||
</th>
|
|
||||||
{% set totals = totals|merge({(day|report_date): 0}) %}
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for userPeriod in stats %}
|
|
||||||
{% set usersTotalDuration = 0 %}
|
|
||||||
<tr class="user">
|
|
||||||
<td class="text-nowrap">
|
|
||||||
{% block user_column %}
|
|
||||||
{% from "macros/widgets.html.twig" import label_dot %}
|
|
||||||
{{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }}
|
|
||||||
{% endblock %}
|
|
||||||
</td>
|
|
||||||
{% 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 %}
|
|
||||||
<th class="text-nowrap text-center total">
|
|
||||||
{% block total_duration_user %}
|
|
||||||
<a href="{{ path(subReportRoute, {'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalDuration|duration(decimal) }}</a>
|
|
||||||
{% endblock %}
|
|
||||||
</th>
|
|
||||||
{% for period in userPeriod.days %}
|
|
||||||
<td class="text-nowrap text-center day-total{% if period.date is weekend %} weekend{% endif %}{% if period.date is today %} today{% endif %}">
|
|
||||||
{% if period.totalDuration > 0 %}
|
|
||||||
{% block duration %}
|
|
||||||
{{ period.totalDuration|duration(decimal) }}
|
|
||||||
{% endblock %}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr class="summary">
|
|
||||||
<td>{{ 'stats.durationTotal'|trans }}</td>
|
|
||||||
<td class="text-center text-nowrap">
|
|
||||||
{% block total_duration %}
|
|
||||||
{{ absoluteTotals|duration(decimal) }}
|
|
||||||
{% endblock %}
|
|
||||||
</td>
|
|
||||||
{% for id, total in totals %}
|
|
||||||
<td class="text-center text-nowrap">
|
|
||||||
{% block total_duration_period %}
|
|
||||||
{{ total|duration(decimal) }}
|
|
||||||
{% endblock %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
@@ -1,20 +1,46 @@
|
|||||||
{% embed 'reporting/report_user_list_data.html.twig' %}
|
{% embed 'reporting/user_list_period_data.html.twig' %}
|
||||||
{% block user_column %}
|
{% block user_column %}
|
||||||
{{ userPeriod.user.displayName }}
|
{{ userPeriod.user.displayName }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block duration -%}
|
{% block duration -%}
|
||||||
=VALUE("{{ period.totalDuration|duration(true) }}")
|
=VALUE("{{ period.totalDuration|duration(true) }}")
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
|
{% block total_duration -%}
|
||||||
|
=VALUE("{{ absoluteDuration|duration(true) }}")
|
||||||
|
{%- endblock %}
|
||||||
{% block total_duration_user -%}
|
{% block total_duration_user -%}
|
||||||
=VALUE("{{ usersTotalDuration|duration(true) }}")
|
=VALUE("{{ usersTotalDuration|duration(true) }}")
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
{% block total_duration -%}
|
|
||||||
=VALUE("{{ absoluteTotals|duration(true) }}")
|
|
||||||
{%- endblock %}
|
|
||||||
{% block total_duration_period -%}
|
{% block total_duration_period -%}
|
||||||
=VALUE("{{ total|duration(true) }}")
|
=VALUE("{{ total|duration(true) }}")
|
||||||
{%- endblock %}
|
{%- 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 %}
|
{% block period_name %}
|
||||||
{{ day|date_short }}
|
<th class="text-center text-nowrap">
|
||||||
|
{{ column|date_short }}
|
||||||
|
</th>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
|
|||||||
@@ -5,25 +5,74 @@
|
|||||||
{% block report %}
|
{% block report %}
|
||||||
|
|
||||||
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
|
{% 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 %}
|
{% 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 %}
|
{% endblock %}
|
||||||
{% block box_after %}
|
{% block box_after %}
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_tools %}
|
|
||||||
<button class="btn btn-default btn-sm" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
|
|
||||||
{% endblock %}
|
|
||||||
{% block box_title %}
|
{% block box_title %}
|
||||||
{{ form_widget(form.date) }}
|
{{ form_widget(form.date) }}
|
||||||
|
{% if form.sumType.vars.choices|length > 1 %}
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu checkbox-menu">
|
||||||
|
<li>
|
||||||
|
{{ form_widget(form.sumType) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<button class="btn btn-primary" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %}
|
{% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %}
|
||||||
{% block box_body %}
|
{% block box_body %}
|
||||||
{% if not hasData %}
|
{% if not hasData %}
|
||||||
{{ nothing_found() }}
|
{{ nothing_found() }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% embed 'reporting/report_user_list_monthly_data.html.twig' %}{% endembed %}
|
{% embed 'reporting/user_list_period_data.html.twig' %}
|
||||||
|
{% block period_name %}
|
||||||
|
<th class="text-center text-nowrap">
|
||||||
|
<a href="{{ path('report_monthly_users', {'date': column|report_date, 'sumType': dataType}) }}">
|
||||||
|
{{ column|month_name }}<br>
|
||||||
|
{{ column|date_format('Y') }}
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
|
{% endblock %}
|
||||||
|
{% block total_rate_user %}
|
||||||
|
<a href="{{ path('report_user_year', {'sumType': dataType, 'date': create_date(query.date.format('Y') ~'-01-01')|report_date, 'user': userPeriod.user.id}) }}">
|
||||||
|
{{ usersTotalRate|money }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block total_internal_rate_user %}
|
||||||
|
<a href="{{ path('report_user_year', {'sumType': dataType, 'date': create_date(query.date.format('Y') ~'-01-01')|report_date, 'user': userPeriod.user.id}) }}">
|
||||||
|
{{ usersTotalInternalRate|money }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block total_duration_user %}
|
||||||
|
<a href="{{ path('report_user_year', {'sumType': dataType, 'date': create_date(query.date.format('Y') ~'-01-01')|report_date, 'user': userPeriod.user.id}) }}">
|
||||||
|
{{ usersTotalDuration|duration(decimal) }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block rate %}
|
||||||
|
<a href="{{ path('report_user_month', {'sumType': dataType, 'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
|
||||||
|
{{ period.totalRate|money }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block internal_rate %}
|
||||||
|
<a href="{{ path('report_user_month', {'sumType': dataType, 'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
|
||||||
|
{{ period.totalInternalRate|money }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% block duration %}
|
||||||
|
<a href="{{ path('report_user_month', {'sumType': dataType, 'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
|
||||||
|
{{ period.totalDuration|duration(decimal) }}
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
|
{% endembed %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
@@ -34,8 +83,8 @@
|
|||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.addEventListener('kimai.initialized', function() {
|
document.addEventListener('kimai.initialized', function() {
|
||||||
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
|
jQuery('#user-list-filter-form').on('change', function(ev) {
|
||||||
jQuery(this).closest('form').submit();
|
jQuery(this).submit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
{% set absoluteTotals = 0 %}
|
|
||||||
{% set totals = {} %}
|
|
||||||
<table class="table table-bordered table-hover dataTable">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th> </th>
|
|
||||||
<th class="text-center">{{ 'stats.durationTotal'|trans }}</th>
|
|
||||||
{% for month in stats.0.getDateTimes() %}
|
|
||||||
<th class="text-center text-nowrap">
|
|
||||||
{% block period_name %}
|
|
||||||
<a href="{{ path('report_monthly_users', {'date': month|report_date}) }}">
|
|
||||||
{{ month|month_name }}<br>
|
|
||||||
{{ month|date_format('Y') }}
|
|
||||||
</a>
|
|
||||||
{% endblock %}
|
|
||||||
</th>
|
|
||||||
{% set totals = totals|merge({(month|report_date): 0}) %}
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for userPeriod in stats|filter(row => row.user is not null) %}
|
|
||||||
{% set usersTotalDuration = 0 %}
|
|
||||||
<tr class="user">
|
|
||||||
<td class="text-nowrap">
|
|
||||||
{% block user_column %}
|
|
||||||
{% from "macros/widgets.html.twig" import label_dot %}
|
|
||||||
{{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }}
|
|
||||||
{% endblock %}
|
|
||||||
</td>
|
|
||||||
{% for mid, period in userPeriod.months %}
|
|
||||||
{% if period.totalDuration > 0 %}
|
|
||||||
{% set usersTotalDuration = usersTotalDuration + period.totalDuration %}
|
|
||||||
{% set absoluteTotals = absoluteTotals + period.totalDuration %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
<th class="text-nowrap text-center total">
|
|
||||||
{% block total_duration_user %}
|
|
||||||
{{ usersTotalDuration|duration(decimal) }}
|
|
||||||
{% endblock %}
|
|
||||||
</th>
|
|
||||||
{% for mid, period in userPeriod.months %}
|
|
||||||
<td class="text-nowrap text-center day-total">
|
|
||||||
{% if period.totalDuration > 0 %}
|
|
||||||
{% block duration %}
|
|
||||||
<a href="{{ path('report_user_month', {'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
|
|
||||||
{{ period.totalDuration|duration(decimal) }}
|
|
||||||
</a>
|
|
||||||
{% endblock %}
|
|
||||||
{% set totals = totals|merge({(period.date|report_date): (totals[period.date|report_date] + period.totalDuration)}) %}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr class="summary">
|
|
||||||
<td>{{ 'stats.durationTotal'|trans }}</td>
|
|
||||||
<td class="text-center text-nowrap">
|
|
||||||
{% block total_duration %}
|
|
||||||
{{ absoluteTotals|duration(decimal) }}
|
|
||||||
{% endblock %}
|
|
||||||
</td>
|
|
||||||
{% for id, total in totals %}
|
|
||||||
<td class="text-center text-nowrap">
|
|
||||||
{% block total_duration_period %}
|
|
||||||
{{ total|duration(decimal) }}
|
|
||||||
{% endblock %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{% embed 'reporting/report_user_list_monthly_data.html.twig' %}
|
{% embed 'reporting/user_list_period_data.html.twig' %}
|
||||||
{% block user_column %}
|
{% block user_column %}
|
||||||
{{ userPeriod.user.displayName }}
|
{{ userPeriod.user.displayName }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -9,12 +9,38 @@
|
|||||||
=VALUE("{{ usersTotalDuration|duration(true) }}")
|
=VALUE("{{ usersTotalDuration|duration(true) }}")
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
{% block total_duration -%}
|
{% block total_duration -%}
|
||||||
=VALUE("{{ absoluteTotals|duration(true) }}")
|
=VALUE("{{ absoluteDuration|duration(true) }}")
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
{% block total_duration_period -%}
|
{% block total_duration_period -%}
|
||||||
=VALUE("{{ total|duration(true) }}")
|
=VALUE("{{ total|duration(true) }}")
|
||||||
{%- endblock %}
|
{%- 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 %}
|
{% block period_name %}
|
||||||
{{ month|month_name }} {{ month|date_format('Y') }}
|
<th class="text-center text-nowrap">
|
||||||
|
{{ column|month_name }} {{ column|date_format('Y') }}
|
||||||
|
</th>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
|
|||||||
128
templates/reporting/user_list_period_data.html.twig
Normal file
128
templates/reporting/user_list_period_data.html.twig
Normal file
@@ -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 %}
|
||||||
|
<table class="table table-bordered table-hover dataTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th class="text-center reportDataTypeTitle">{{ dataTypeTitle|trans }}</th>
|
||||||
|
{% 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 %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for userPeriod in stats|filter(row => row.user is not null) %}
|
||||||
|
{% set usersTotalDuration = 0 %}
|
||||||
|
{% set usersTotalInternalRate = 0 %}
|
||||||
|
{% set usersTotalRate = 0 %}
|
||||||
|
<tr class="user">
|
||||||
|
<td class="text-nowrap">
|
||||||
|
{% block user_column %}
|
||||||
|
{% from "macros/widgets.html.twig" import label_dot %}
|
||||||
|
{{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }}
|
||||||
|
{% endblock %}
|
||||||
|
</td>
|
||||||
|
{% 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 %}
|
||||||
|
<th class="text-nowrap text-center total">
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{% block total_rate_user %}{% endblock %}
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{% block total_internal_rate_user %}{% endblock %}
|
||||||
|
{% else %}
|
||||||
|
{% block total_duration_user %}{% endblock %}
|
||||||
|
{% endif %}
|
||||||
|
</th>
|
||||||
|
{% for period in attribute(userPeriod, period_attribute) %}
|
||||||
|
<td class="text-nowrap text-center day-total{% block period_cell_class %}{% endblock %}">
|
||||||
|
{% 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 %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr class="summary">
|
||||||
|
<td>{{ dataTypeTitle|trans }}</td>
|
||||||
|
<td class="text-center text-nowrap">
|
||||||
|
{% 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 %}
|
||||||
|
</td>
|
||||||
|
{% if dataType == 'rate' %}
|
||||||
|
{% for id, total in totalsRate %}
|
||||||
|
<td class="text-center text-nowrap">
|
||||||
|
{% block total_rate_period %}
|
||||||
|
{{ total|money }}
|
||||||
|
{% endblock %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% elseif dataType == 'internalRate' %}
|
||||||
|
{% for id, total in totalsInternalRate %}
|
||||||
|
<td class="text-center text-nowrap">
|
||||||
|
{% block total_internal_rate_period %}
|
||||||
|
{{ total|money }}
|
||||||
|
{% endblock %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for id, total in totalsDuration %}
|
||||||
|
<td class="text-center text-nowrap">
|
||||||
|
{% block total_duration_period %}
|
||||||
|
{{ total|duration(decimal) }}
|
||||||
|
{% endblock %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
@@ -27,7 +27,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% set monthRoute = null %}
|
{% 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__'}) %}
|
{% set monthRoute = path('report_user_month', {'user': user.id, 'date': '__MONTH__'}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -37,6 +39,11 @@
|
|||||||
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
|
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
|
||||||
{% import "macros/charts.html.twig" as charts %}
|
{% import "macros/charts.html.twig" as charts %}
|
||||||
{% block box_title %}{{ year }}{% endblock %}
|
{% block box_title %}{{ year }}{% endblock %}
|
||||||
|
{% block box_tools %}
|
||||||
|
{%- if canSeeReport -%}
|
||||||
|
<a class="btn btn-default btn-sm" href="{{ path('report_user_year', {'user': user.id, 'date': year ~ '-01-01'}) }}"><i class="{{ 'reporting'|icon }}"></i></a>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
{% block box_body %}
|
{% block box_body %}
|
||||||
{% set dataset = [] %}
|
{% set dataset = [] %}
|
||||||
{% for month in workMonths.year(year) %}
|
{% for month in workMonths.year(year) %}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Tests\Controller\ControllerBaseTest;
|
||||||
|
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
abstract class AbstractUserPeriodControllerTest extends ControllerBaseTest
|
||||||
|
{
|
||||||
|
protected function importReportingFixture(string $role)
|
||||||
|
{
|
||||||
|
$fixture = new TimesheetFixtures();
|
||||||
|
$fixture->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('<div class="box-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||||
|
$option = $client->getCrawler()->filterXPath("//select[@id='user']/option[@selected]");
|
||||||
|
self::assertEquals($user, $option->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('<div class="box-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||||
|
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
||||||
|
self::assertEquals(0, $select->count());
|
||||||
|
$cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]");
|
||||||
|
self::assertEquals('Working hours total', $cell->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Tests\Controller\ControllerBaseTest;
|
||||||
|
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
abstract class AbstractUsersPeriodControllerTest extends ControllerBaseTest
|
||||||
|
{
|
||||||
|
protected function importReportingFixture(string $role)
|
||||||
|
{
|
||||||
|
$fixture = new TimesheetFixtures();
|
||||||
|
$fixture->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('<div class="box-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||||
|
$cell = $client->getCrawler()->filterXPath("//th[contains(@class, 'reportDataTypeTitle')]");
|
||||||
|
self::assertEquals($title, $cell->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('<div class="box-body %s', $this->getBoxId()), $client->getResponse()->getContent());
|
||||||
|
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
||||||
|
self::assertEquals(0, $select->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'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Kimai time-tracking app.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Tests\Controller\Reporting;
|
|
||||||
|
|
||||||
use App\Entity\User;
|
|
||||||
use App\Tests\Controller\ControllerBaseTest;
|
|
||||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group integration
|
|
||||||
*/
|
|
||||||
class ReportByUserControllerTest extends ControllerBaseTest
|
|
||||||
{
|
|
||||||
protected function importReportingFixture(string $role)
|
|
||||||
{
|
|
||||||
$fixture = new TimesheetFixtures();
|
|
||||||
$fixture->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('<div class="box-body user-week-reporting-box', $client->getResponse()->getContent());
|
|
||||||
$option = $client->getCrawler()->filterXPath("//select[@id='user']/option[@selected]");
|
|
||||||
self::assertEquals(4, $option->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('<div class="box-body user-month-reporting-box', $client->getResponse()->getContent());
|
|
||||||
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
|
||||||
self::assertEquals(0, $select->count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Kimai time-tracking app.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Tests\Controller\Reporting;
|
|
||||||
|
|
||||||
use App\Entity\User;
|
|
||||||
use App\Tests\Controller\ControllerBaseTest;
|
|
||||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group integration
|
|
||||||
*/
|
|
||||||
class ReportUsersListControllerTest extends ControllerBaseTest
|
|
||||||
{
|
|
||||||
protected function importReportingFixture(string $role)
|
|
||||||
{
|
|
||||||
$fixture = new TimesheetFixtures();
|
|
||||||
$fixture->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('<div class="box-body yearly-user-list-reporting-box', $client->getResponse()->getContent());
|
|
||||||
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
|
||||||
self::assertEquals(0, $select->count());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testWeeklyUsersReport()
|
|
||||||
{
|
|
||||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
|
||||||
$this->importReportingFixture(User::ROLE_TEAMLEAD);
|
|
||||||
$this->assertAccessIsGranted($client, '/reporting/weekly_users_list');
|
|
||||||
self::assertStringContainsString('<div class="box-body weekly-user-list-reporting-box', $client->getResponse()->getContent());
|
|
||||||
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
|
||||||
self::assertEquals(0, $select->count());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMonthlyUsersReport()
|
|
||||||
{
|
|
||||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
|
|
||||||
$this->importReportingFixture(User::ROLE_TEAMLEAD);
|
|
||||||
$this->assertAccessIsGranted($client, '/reporting/monthly_users_list');
|
|
||||||
self::assertStringContainsString('<div class="box-body monthly-user-list-reporting-box', $client->getResponse()->getContent());
|
|
||||||
$select = $client->getCrawler()->filterXPath("//select[@id='user']");
|
|
||||||
self::assertEquals(0, $select->count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
class ReportUsersMonthControllerTest extends AbstractUsersPeriodControllerTest
|
||||||
|
{
|
||||||
|
protected function getReportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/users/month';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getReportExportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/users/month_export';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBoxId(): string
|
||||||
|
{
|
||||||
|
return 'monthly-user-list-reporting-box';
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Controller/Reporting/ReportUsersWeekControllerTest.php
Normal file
31
tests/Controller/Reporting/ReportUsersWeekControllerTest.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
class ReportUsersWeekControllerTest extends AbstractUsersPeriodControllerTest
|
||||||
|
{
|
||||||
|
protected function getReportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/users/week';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getReportExportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/users/week_export';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBoxId(): string
|
||||||
|
{
|
||||||
|
return 'weekly-user-list-reporting-box';
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Controller/Reporting/ReportUsersYearControllerTest.php
Normal file
31
tests/Controller/Reporting/ReportUsersYearControllerTest.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
class ReportUsersYearControllerTest extends AbstractUsersPeriodControllerTest
|
||||||
|
{
|
||||||
|
protected function getReportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/users/year';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getReportExportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/users/year_export';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBoxId(): string
|
||||||
|
{
|
||||||
|
return 'yearly-user-list-reporting-box';
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/Controller/Reporting/UserMonthControllerTest.php
Normal file
26
tests/Controller/Reporting/UserMonthControllerTest.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
class UserMonthControllerTest extends AbstractUserPeriodControllerTest
|
||||||
|
{
|
||||||
|
protected function getReportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/user/month';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBoxId(): string
|
||||||
|
{
|
||||||
|
return 'user-month-reporting-box';
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/Controller/Reporting/UserWeekControllerTest.php
Normal file
26
tests/Controller/Reporting/UserWeekControllerTest.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
class UserWeekControllerTest extends AbstractUserPeriodControllerTest
|
||||||
|
{
|
||||||
|
protected function getReportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/user/week';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBoxId(): string
|
||||||
|
{
|
||||||
|
return 'user-week-reporting-box';
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/Controller/Reporting/UserYearControllerTest.php
Normal file
26
tests/Controller/Reporting/UserYearControllerTest.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Controller\Reporting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
|
class UserYearControllerTest extends AbstractUserPeriodControllerTest
|
||||||
|
{
|
||||||
|
protected function getReportUrl(): string
|
||||||
|
{
|
||||||
|
return '/reporting/user/year';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getBoxId(): string
|
||||||
|
{
|
||||||
|
return 'user-year-reporting-box';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ class ReportingControllerTest extends ControllerBaseTest
|
|||||||
{
|
{
|
||||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
|
||||||
$this->request($client, '/reporting/');
|
$this->request($client, '/reporting/');
|
||||||
$this->assertIsRedirect($client, $this->createUrl('/reporting/week_by_user'));
|
$this->assertIsRedirect($client, $this->createUrl('/reporting/user/week'));
|
||||||
$client->followRedirect();
|
$client->followRedirect();
|
||||||
self::assertStringContainsString('<div class="box-body user-week-reporting-box', $client->getResponse()->getContent());
|
self::assertStringContainsString('<div class="box-body user-week-reporting-box', $client->getResponse()->getContent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,5 +104,10 @@ class MonthlyStatisticTest extends TestCase
|
|||||||
self::assertNull($sut->getMonth('2019', '12'));
|
self::assertNull($sut->getMonth('2019', '12'));
|
||||||
self::assertNull($sut->getMonth('2020', '1'));
|
self::assertNull($sut->getMonth('2020', '1'));
|
||||||
self::assertNull($sut->getMonth('2020', '01'));
|
self::assertNull($sut->getMonth('2020', '01'));
|
||||||
|
self::assertNull($sut->getMonthByDateTime(new \DateTime('2020-01-01')));
|
||||||
|
self::assertInstanceOf(StatisticDate::class, $sut->getMonthByDateTime(new \DateTime('2018-04-01')));
|
||||||
|
self::assertInstanceOf(StatisticDate::class, $sut->getByDateTime(new \DateTime('2018-04-01')));
|
||||||
|
|
||||||
|
self::assertSame($sut->getMonths(), $sut->getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use App\Reporting\DateByUser;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @covers \App\Reporting\AbstractUserList
|
||||||
* @covers \App\Reporting\DateByUser
|
* @covers \App\Reporting\DateByUser
|
||||||
*/
|
*/
|
||||||
abstract class AbstractDateByUserTest extends TestCase
|
abstract class AbstractDateByUserTest extends TestCase
|
||||||
@@ -25,6 +26,8 @@ abstract class AbstractDateByUserTest extends TestCase
|
|||||||
$sut = $this->createSut();
|
$sut = $this->createSut();
|
||||||
self::assertNull($sut->getDate());
|
self::assertNull($sut->getDate());
|
||||||
self::assertNull($sut->getUser());
|
self::assertNull($sut->getUser());
|
||||||
|
self::assertEquals('duration', $sut->getSumType());
|
||||||
|
self::assertFalse($sut->isDecimal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetter()
|
public function testSetter()
|
||||||
@@ -34,10 +37,32 @@ abstract class AbstractDateByUserTest extends TestCase
|
|||||||
$user->setAlias('sdfsdfdsdf');
|
$user->setAlias('sdfsdfdsdf');
|
||||||
|
|
||||||
$sut = $this->createSut();
|
$sut = $this->createSut();
|
||||||
self::assertInstanceOf(DateByUser::class, $sut->setDate($date));
|
$sut->setDate($date);
|
||||||
self::assertInstanceOf(DateByUser::class, $sut->setUser($user));
|
$sut->setUser($user);
|
||||||
|
|
||||||
self::assertSame($date, $sut->getDate());
|
self::assertSame($date, $sut->getDate());
|
||||||
self::assertSame($user, $sut->getUser());
|
self::assertSame($user, $sut->getUser());
|
||||||
|
|
||||||
|
$sut->setSumType('rate');
|
||||||
|
self::assertEquals('rate', $sut->getSumType());
|
||||||
|
|
||||||
|
$sut->setSumType('internalRate');
|
||||||
|
self::assertEquals('internalRate', $sut->getSumType());
|
||||||
|
|
||||||
|
$sut->setSumType('duration');
|
||||||
|
self::assertEquals('duration', $sut->getSumType());
|
||||||
|
|
||||||
|
$sut->setDecimal(true);
|
||||||
|
self::assertTrue($sut->isDecimal());
|
||||||
|
|
||||||
|
$sut->setDecimal(false);
|
||||||
|
self::assertFalse($sut->isDecimal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvalidSumType()
|
||||||
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
$sut = $this->createSut();
|
||||||
|
$sut->setSumType('DURation');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
61
tests/Reporting/AbstractUserListTest.php
Normal file
61
tests/Reporting/AbstractUserListTest.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Reporting;
|
||||||
|
|
||||||
|
use App\Reporting\AbstractUserList;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \App\Reporting\AbstractUserList
|
||||||
|
*/
|
||||||
|
abstract class AbstractUserListTest extends TestCase
|
||||||
|
{
|
||||||
|
abstract protected function createSut(): AbstractUserList;
|
||||||
|
|
||||||
|
public function testEmptyObject()
|
||||||
|
{
|
||||||
|
$sut = $this->createSut();
|
||||||
|
self::assertNull($sut->getDate());
|
||||||
|
self::assertEquals('duration', $sut->getSumType());
|
||||||
|
self::assertFalse($sut->isDecimal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetter()
|
||||||
|
{
|
||||||
|
$date = new \DateTime('2019-05-27');
|
||||||
|
|
||||||
|
$sut = $this->createSut();
|
||||||
|
$sut->setDate($date);
|
||||||
|
|
||||||
|
self::assertSame($date, $sut->getDate());
|
||||||
|
|
||||||
|
$sut->setSumType('rate');
|
||||||
|
self::assertEquals('rate', $sut->getSumType());
|
||||||
|
|
||||||
|
$sut->setSumType('internalRate');
|
||||||
|
self::assertEquals('internalRate', $sut->getSumType());
|
||||||
|
|
||||||
|
$sut->setSumType('duration');
|
||||||
|
self::assertEquals('duration', $sut->getSumType());
|
||||||
|
|
||||||
|
$sut->setDecimal(true);
|
||||||
|
self::assertTrue($sut->isDecimal());
|
||||||
|
|
||||||
|
$sut->setDecimal(false);
|
||||||
|
self::assertFalse($sut->isDecimal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInvalidSumType()
|
||||||
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
$sut = $this->createSut();
|
||||||
|
$sut->setSumType('DURation');
|
||||||
|
}
|
||||||
|
}
|
||||||
25
tests/Reporting/MonthlyUserListTest.php
Normal file
25
tests/Reporting/MonthlyUserListTest.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Reporting;
|
||||||
|
|
||||||
|
use App\Reporting\AbstractUserList;
|
||||||
|
use App\Reporting\MonthlyUserList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \App\Reporting\MonthlyUserList
|
||||||
|
* @covers \App\Reporting\AbstractUserList
|
||||||
|
*/
|
||||||
|
class MonthlyUserListTest extends AbstractUserListTest
|
||||||
|
{
|
||||||
|
protected function createSut(): AbstractUserList
|
||||||
|
{
|
||||||
|
return new MonthlyUserList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,6 @@ class ReportingServiceTest extends TestCase
|
|||||||
$sut = $this->getSut(true);
|
$sut = $this->getSut(true);
|
||||||
$reports = $sut->getAvailableReports(new User());
|
$reports = $sut->getAvailableReports(new User());
|
||||||
self::assertIsArray($reports);
|
self::assertIsArray($reports);
|
||||||
self::assertCount(9, $reports);
|
self::assertCount(10, $reports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
tests/Reporting/WeeklyUserListTest.php
Normal file
25
tests/Reporting/WeeklyUserListTest.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Reporting;
|
||||||
|
|
||||||
|
use App\Reporting\AbstractUserList;
|
||||||
|
use App\Reporting\WeeklyUserList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \App\Reporting\WeeklyUserList
|
||||||
|
* @covers \App\Reporting\AbstractUserList
|
||||||
|
*/
|
||||||
|
class WeeklyUserListTest extends AbstractUserListTest
|
||||||
|
{
|
||||||
|
protected function createSut(): AbstractUserList
|
||||||
|
{
|
||||||
|
return new WeeklyUserList();
|
||||||
|
}
|
||||||
|
}
|
||||||
25
tests/Reporting/YearByUserTest.php
Normal file
25
tests/Reporting/YearByUserTest.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Reporting;
|
||||||
|
|
||||||
|
use App\Reporting\DateByUser;
|
||||||
|
use App\Reporting\YearByUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \App\Reporting\YearByUser
|
||||||
|
* @covers \App\Reporting\DateByUser
|
||||||
|
*/
|
||||||
|
class YearByUserTest extends AbstractDateByUserTest
|
||||||
|
{
|
||||||
|
protected function createSut(): DateByUser
|
||||||
|
{
|
||||||
|
return new YearByUser();
|
||||||
|
}
|
||||||
|
}
|
||||||
25
tests/Reporting/YearlyUserListTest.php
Normal file
25
tests/Reporting/YearlyUserListTest.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests\Reporting;
|
||||||
|
|
||||||
|
use App\Reporting\AbstractUserList;
|
||||||
|
use App\Reporting\YearlyUserList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \App\Reporting\YearlyUserList
|
||||||
|
* @covers \App\Reporting\AbstractUserList
|
||||||
|
*/
|
||||||
|
class YearlyUserListTest extends AbstractUserListTest
|
||||||
|
{
|
||||||
|
protected function createSut(): AbstractUserList
|
||||||
|
{
|
||||||
|
return new YearlyUserList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -238,4 +238,25 @@ class DateTimeFactoryTest extends TestCase
|
|||||||
self::assertEquals('01', $year->format('d'));
|
self::assertEquals('01', $year->format('d'));
|
||||||
self::assertEquals('00:00:00', $year->format('H:i:s'));
|
self::assertEquals('00:00:00', $year->format('H:i:s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateEndOfYear()
|
||||||
|
{
|
||||||
|
$sut = $this->createDateTimeFactory(self::TEST_TIMEZONE);
|
||||||
|
|
||||||
|
$now = $sut->createDateTime();
|
||||||
|
$year = $sut->createEndOfYear();
|
||||||
|
self::assertEquals($now->format('Y'), $year->format('Y'));
|
||||||
|
self::assertEquals('12', $year->format('m'));
|
||||||
|
self::assertEquals('31', $year->format('d'));
|
||||||
|
self::assertEquals('23:59:59', $year->format('H:i:s'));
|
||||||
|
$now->setTime(23, 59, 59);
|
||||||
|
self::assertEquals($now->format('H:i:s'), $year->format('H:i:s'));
|
||||||
|
|
||||||
|
$begin = $sut->createDateTime('2017-12-31 23:59:59');
|
||||||
|
$year = $sut->createEndOfYear($begin);
|
||||||
|
self::assertEquals('2017', $year->format('Y'));
|
||||||
|
self::assertEquals('12', $year->format('m'));
|
||||||
|
self::assertEquals('31', $year->format('d'));
|
||||||
|
self::assertEquals('23:59:59', $year->format('H:i:s'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
<source>report_user_month</source>
|
<source>report_user_month</source>
|
||||||
<target>Monatsansicht für einen Benutzer</target>
|
<target>Monatsansicht für einen Benutzer</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="3JLmvfB" resname="report_user_year">
|
||||||
|
<source>report_user_year</source>
|
||||||
|
<target>Jahresansicht für einen Benutzer</target>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="q_A4AHD" resname="report_weekly_users">
|
<trans-unit id="q_A4AHD" resname="report_weekly_users">
|
||||||
<source>report_weekly_users</source>
|
<source>report_weekly_users</source>
|
||||||
<target>Wochenansicht für alle Benutzer</target>
|
<target>Wochenansicht für alle Benutzer</target>
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
<source>report_user_month</source>
|
<source>report_user_month</source>
|
||||||
<target>Monthly view for one user</target>
|
<target>Monthly view for one user</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="3JLmvfB" resname="report_user_year">
|
||||||
|
<source>report_user_year</source>
|
||||||
|
<target>Yearly view for one user</target>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="q_A4AHD" resname="report_weekly_users">
|
<trans-unit id="q_A4AHD" resname="report_weekly_users">
|
||||||
<source>report_weekly_users</source>
|
<source>report_weekly_users</source>
|
||||||
<target>Weekly view for all users</target>
|
<target>Weekly view for all users</target>
|
||||||
|
|||||||
Reference in New Issue
Block a user