Weekly reporting view (#1892)

This commit is contained in:
Kevin Papst
2020-08-16 12:20:33 +02:00
committed by Kevin Papst
parent 34a1e07824
commit ed4b82f4b1
39 changed files with 1130 additions and 248 deletions

View File

@@ -230,34 +230,36 @@ class DateExtensions extends AbstractExtension
return $date->format($this->timeFormat);
}
public function monthName(\DateTime $dateTime): string
/**
* @see https://framework.zend.com/manual/1.12/en/zend.date.constants.html#zend.date.constants.selfdefinedformats
* @see http://userguide.icu-project.org/formatparse/datetime
*
* @param DateTime $dateTime
* @param string $format
* @return string
*/
private function formatIntl(\DateTime $dateTime, string $format): string
{
// @see http://userguide.icu-project.org/formatparse/datetime
$formatter = new \IntlDateFormatter(
$this->locale,
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
$dateTime->getTimezone()->getName(),
\IntlDateFormatter::GREGORIAN,
'LLLL'
$format
);
return $formatter->format($dateTime);
}
public function monthName(\DateTime $dateTime, bool $withYear = false): string
{
return $this->formatIntl($dateTime, ($withYear ? 'LLLL yyyy' : 'LLLL'));
}
public function dayName(\DateTime $dateTime, bool $short = false): string
{
// @see http://userguide.icu-project.org/formatparse/datetime
$formatter = new \IntlDateFormatter(
$this->locale,
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
$dateTime->getTimezone()->getName(),
\IntlDateFormatter::GREGORIAN,
$short ? 'EE' : 'EEEE'
);
return $formatter->format($dateTime);
return $this->formatIntl($dateTime, ($short ? 'EE' : 'EEEE'));
}
/**

View File

@@ -10,6 +10,10 @@
namespace App\Twig;
use App\Constants;
use App\Entity\Activity;
use App\Entity\Customer;
use App\Entity\EntityWithMetaFields;
use App\Entity\Project;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
@@ -27,6 +31,7 @@ class Extensions extends AbstractExtension
return [
new TwigFilter('docu_link', [$this, 'documentationLink']),
new TwigFilter('multiline_indent', [$this, 'multilineIndent']),
new TwigFilter('color', [$this, 'color']),
];
}
@@ -40,6 +45,34 @@ class Extensions extends AbstractExtension
];
}
public function color(EntityWithMetaFields $entity): ?string
{
if ($entity instanceof Activity) {
if (!empty($entity->getColor())) {
return $entity->getColor();
}
if (null !== $entity->getProject()) {
$entity = $entity->getProject();
}
}
if ($entity instanceof Project) {
if (!empty($entity->getColor())) {
return $entity->getColor();
}
$entity = $entity->getCustomer();
}
if ($entity instanceof Customer) {
if (!empty($entity->getColor())) {
return $entity->getColor();
}
}
return null;
}
/**
* @param object $object
* @return null|string

View File

@@ -54,6 +54,7 @@ final class ReportingExtension extends AbstractExtension
$event = new ReportingEvent($user);
if ($this->security->isGranted('view_reporting')) {
$event->addReport(new Report('week_by_user', 'report_user_week', 'report_user_week'));
$event->addReport(new Report('month_by_user', 'report_user_month', 'report_user_month'));
if ($this->security->isGranted('view_other_timesheet')) {
$event->addReport(new Report('monthly_users_list', 'report_monthly_users', 'report_monthly_users'));