-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73beaf8
commit a3e7d1e
Showing
7 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "DemoBundle" for Kimai. | ||
* All rights reserved by Kevin Papst (www.kevinpapst.de). | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace KimaiPlugin\DemoBundle\EventSubscriber; | ||
|
||
use App\Event\ReportingEvent; | ||
use App\Reporting\Report; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | ||
|
||
final class ReportingSubscriber implements EventSubscriberInterface | ||
{ | ||
public function __construct(private readonly AuthorizationCheckerInterface $security) | ||
{ | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
ReportingEvent::class => ['onReporting'], | ||
]; | ||
} | ||
|
||
public function onReporting(ReportingEvent $event): void | ||
{ | ||
$auth = $this->security; | ||
|
||
if (!$auth->isGranted('view_reporting')) { | ||
return; | ||
} | ||
|
||
$event->addReport(new Report('demo_report', 'demo_report', 'Demo Report', 'fas fa-snowman')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "DemoBundle" for Kimai. | ||
* All rights reserved by Kevin Papst (www.kevinpapst.de). | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace KimaiPlugin\DemoBundle\Report; | ||
|
||
use App\Form\Type\MonthPickerType; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @extends AbstractType<DemoReportQuery> | ||
*/ | ||
final class DemoReportForm extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder->add('month', MonthPickerType::class, [ | ||
'required' => true, | ||
'label' => false, | ||
'view_timezone' => $options['timezone'], | ||
'model_timezone' => $options['timezone'], | ||
]); | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'data_class' => DemoReportQuery::class, | ||
'timezone' => date_default_timezone_get(), | ||
'csrf_protection' => false, | ||
'method' => 'GET', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "DemoBundle" for Kimai. | ||
* All rights reserved by Kevin Papst (www.kevinpapst.de). | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace KimaiPlugin\DemoBundle\Report; | ||
|
||
final class DemoReportQuery | ||
{ | ||
public function __construct(private \DateTimeInterface $month) | ||
{ | ||
} | ||
|
||
public function getMonth(): \DateTimeInterface | ||
{ | ||
return $this->month; | ||
} | ||
|
||
public function setMonth(?\DateTime $month): void | ||
{ | ||
$this->month = $month; | ||
Check failure on line 26 in Report/DemoReportQuery.php GitHub Actions / Linting - PHP 8.1
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends 'reporting/layout.html.twig' %} | ||
|
||
{% block report_form_layout %} | ||
{{ form_widget(form.month, {'label': false}) }} | ||
{% endblock %} | ||
|
||
{% block report %} | ||
{% embed '@theme/embeds/card.html.twig' %} | ||
{% block box_body_class %}{{ box_id }} table-responsive m-0{% endblock %} | ||
{% block box_body %} | ||
{% if not hasData %} | ||
{% from "macros/widgets.html.twig" import nothing_found %} | ||
{{ nothing_found() }} | ||
{% else %} | ||
<p>Put your report data here</p> | ||
{% endif %} | ||
{% endblock %} | ||
{% endembed %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters