new user-year reporting and data-type chooser (#3155)

This commit is contained in:
Kevin Papst
2022-02-16 12:18:04 +01:00
committed by GitHub
parent 1852d71974
commit 85a63c4b78
58 changed files with 1862 additions and 683 deletions

View File

@@ -11,11 +11,9 @@ namespace App\Reporting;
abstract class AbstractUserList
{
/**
* @var \DateTime
*/
private $date;
private $decimal = false;
private $sumType = 'duration';
public function getDate(): ?\DateTime
{
@@ -36,4 +34,18 @@ abstract class AbstractUserList
{
$this->decimal = $decimal;
}
public function getSumType(): string
{
return $this->sumType;
}
public function setSumType(string $sumType): void
{
if (!\in_array($sumType, ['duration', 'rate', 'internalRate'])) {
throw new \InvalidArgumentException('Unknown sum type');
}
$this->sumType = $sumType;
}
}

View File

@@ -11,38 +11,17 @@ namespace App\Reporting;
use App\Entity\User;
abstract class DateByUser
abstract class DateByUser extends AbstractUserList
{
/**
* @var User
*/
private $user;
/**
* @var \DateTime
*/
private $date;
public function getUser(): ?User
{
return $this->user;
}
public function setUser(User $user): self
public function setUser(User $user): void
{
$this->user = $user;
return $this;
}
public function getDate(): ?\DateTime
{
return $this->date;
}
public function setDate(\DateTime $date): self
{
$this->date = $date;
return $this;
}
}

View File

@@ -10,6 +10,7 @@
namespace App\Reporting;
use App\Form\Type\MonthPickerType;
use App\Form\Type\ReportSumType;
use App\Form\Type\UserType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -41,6 +42,7 @@ class MonthByUserForm extends AbstractType
if ($options['include_user']) {
$builder->add('user', UserType::class, ['width' => false]);
}
$builder->add('sumType', ReportSumType::class);
}
/**

View File

@@ -10,6 +10,7 @@
namespace App\Reporting;
use App\Form\Type\MonthPickerType;
use App\Form\Type\ReportSumType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -36,6 +37,7 @@ class MonthlyUserListForm extends AbstractType
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
]);
$builder->add('sumType', ReportSumType::class);
}
/**

View File

@@ -44,6 +44,7 @@ final class ReportingService
if ($this->security->isGranted('view_reporting')) {
$event->addReport(new Report('week_by_user', 'report_user_week', 'report_user_week', 'user'));
$event->addReport(new Report('month_by_user', 'report_user_month', 'report_user_month', 'user'));
$event->addReport(new Report('year_by_user', 'report_user_year', 'report_user_year', 'user'));
if ($this->security->isGranted('view_other_reporting') && $this->security->isGranted('view_other_timesheet')) {
$event->addReport(new Report('weekly_users_list', 'report_weekly_users', 'report_weekly_users', 'users'));
$event->addReport(new Report('monthly_users_list', 'report_monthly_users', 'report_monthly_users', 'users'));

View File

@@ -9,6 +9,7 @@
namespace App\Reporting;
use App\Form\Type\ReportSumType;
use App\Form\Type\UserType;
use App\Form\Type\WeekPickerType;
use Symfony\Component\Form\AbstractType;
@@ -41,6 +42,7 @@ class WeekByUserForm extends AbstractType
if ($options['include_user']) {
$builder->add('user', UserType::class, ['width' => false]);
}
$builder->add('sumType', ReportSumType::class);
}
/**

View File

@@ -9,6 +9,7 @@
namespace App\Reporting;
use App\Form\Type\ReportSumType;
use App\Form\Type\WeekPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -36,6 +37,7 @@ class WeeklyUserListForm extends AbstractType
'view_timezone' => $options['timezone'],
'start_date' => $options['start_date'],
]);
$builder->add('sumType', ReportSumType::class);
}
/**

View 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
{
}

View 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',
]);
}
}

View File

@@ -9,6 +9,7 @@
namespace App\Reporting;
use App\Form\Type\ReportSumType;
use App\Form\Type\YearPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -37,6 +38,7 @@ class YearlyUserListForm extends AbstractType
'start_date' => $options['start_date'],
'show_range' => true,
]);
$builder->add('sumType', ReportSumType::class);
}
/**