monthly budget, monthly report, unified report calculation (#2684)

This commit is contained in:
Kevin Papst
2021-08-06 18:38:41 +02:00
committed by GitHub
parent 21f785638c
commit cefd747e91
196 changed files with 5031 additions and 2167 deletions

View File

@@ -9,6 +9,7 @@
namespace App\Form;
use App\Form\Type\BudgetType;
use App\Form\Type\DurationType;
use App\Form\Type\MetaFieldsCollectionType;
use App\Form\Type\YesNoType;
@@ -38,6 +39,7 @@ trait EntityFormTrait
'icon' => 'clock',
'required' => false,
])
->add('budgetType', BudgetType::class)
;
}

View File

@@ -10,21 +10,21 @@
namespace App\Form\Extension;
use App\Entity\User;
use App\Security\CurrentUser;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
final class UserExtension extends AbstractTypeExtension
{
/**
* @var CurrentUser
* @var Security
*/
private $user;
private $security;
public function __construct(CurrentUser $user)
public function __construct(Security $security)
{
$this->user = $user;
$this->security = $security;
}
public static function getExtendedTypes(): iterable
@@ -37,6 +37,6 @@ final class UserExtension extends AbstractTypeExtension
$resolver->setDefined(['user']);
// null needs to be allowed, as there is no user for anonymous forms (like "forgot password" and "registration")
$resolver->setAllowedTypes('user', [User::class, 'null']);
$resolver->setDefault('user', $this->user->getUser());
$resolver->setDefault('user', $this->security->getUser());
}
}

View File

@@ -0,0 +1,42 @@
<?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\OptionsResolver;
/**
* Custom form field type to select the type of budget.
*/
class BudgetType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => 'label.budgetType',
'required' => false,
'choices' => [
'label.budgetType_month' => 'month',
],
]);
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return ChoiceType::class;
}
}

View File

@@ -9,7 +9,6 @@
namespace App\Form\Type;
use App\Utils\MomentFormatConverter;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormInterface;
@@ -48,7 +47,6 @@ final class MonthPickerType extends AbstractType
$view->vars['month'] = $date;
$view->vars['previousMonth'] = (clone $date)->modify('-1 month');
$view->vars['nextMonth'] = (clone $date)->modify('+1 month');
$view->vars['momentFormat'] = (new MomentFormatConverter())->convert($options['format']);
}
/**

View File

@@ -9,7 +9,6 @@
namespace App\Form\Type;
use App\Utils\MomentFormatConverter;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormInterface;
@@ -48,7 +47,6 @@ final class WeekPickerType extends AbstractType
$view->vars['week'] = $date;
$view->vars['previousWeek'] = (clone $date)->modify('-1 week');
$view->vars['nextWeek'] = (clone $date)->modify('+1 week');
$view->vars['momentFormat'] = (new MomentFormatConverter())->convert($options['format']);
}
/**