daily stats in timesheet (#552)

This commit is contained in:
Kevin Papst
2019-02-13 15:36:59 +01:00
committed by GitHub
parent fd60d5bb17
commit 2c6f57c7ce
13 changed files with 95 additions and 41 deletions

View File

@@ -75,6 +75,7 @@ class TimesheetController extends AbstractController
'query' => $query,
'showFilter' => $form->isSubmitted(),
'toolbarForm' => $form->createView(),
'showSummary' => $this->getUser()->getPreferenceValue('timesheet.daily_stats', false),
]);
}

View File

@@ -254,7 +254,7 @@ trait TimesheetControllerTrait
/**
* Get a user from the Security Token Storage.
*
* @return mixed
* @return User
* @throws \LogicException If SecurityBundle is not available
*/
abstract protected function getUser();

View File

@@ -77,13 +77,6 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
$enableHourlyRate = true;
}
/*
(new UserPreference())
->setName('timezone')
->setValue(date_default_timezone_get())
->setType(TimezoneType::class),
*/
return [
(new UserPreference())
->setName(UserPreference::HOURLY_RATE)
@@ -136,6 +129,11 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
->setName('login.initial_view')
->setValue(InitialViewType::DEFAULT_VIEW)
->setType(InitialViewType::class),
(new UserPreference())
->setName('timesheet.daily_stats')
->setValue(false)
->setType(CheckboxType::class),
];
}

View File

@@ -41,6 +41,10 @@ class Extensions extends \Twig_Extension
* @var NumberFormatter
*/
protected $numberFormatter;
/**
* @var NumberFormatter
*/
protected $moneyFormatter;
/**
* @var RequestStack
@@ -254,18 +258,15 @@ class Extensions extends \Twig_Extension
if ($this->locale !== $locale) {
$this->locale = $locale;
$this->numberFormatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
$this->numberFormatter = new NumberFormatter($locale, NumberFormatter::DECIMAL);
$this->moneyFormatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
}
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
$amount = round($amount, $fractionDigits);
$result = $this->numberFormatter->format($amount);
if (null !== $currency) {
$result = $this->numberFormatter->formatCurrency($amount, $currency);
return $this->moneyFormatter->formatCurrency($amount, $currency);
}
return $result;
return $this->numberFormatter->format($amount);
}
/**