summaryrefslogtreecommitdiffstats
path: root/application/controllers/TimeframeController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers/TimeframeController.php')
-rw-r--r--application/controllers/TimeframeController.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/application/controllers/TimeframeController.php b/application/controllers/TimeframeController.php
new file mode 100644
index 0000000..ca67b0b
--- /dev/null
+++ b/application/controllers/TimeframeController.php
@@ -0,0 +1,47 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Timeframe;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\TimeframeForm;
+
+class TimeframeController extends Controller
+{
+ use Database;
+
+ /** @var Timeframe */
+ protected $timeframe;
+
+ public function init()
+ {
+ $this->timeframe = Timeframe::fromDb($this->params->getRequired('id'));
+ }
+
+ public function editAction()
+ {
+ $this->assertPermission('reporting/timeframes');
+ $this->addTitleTab($this->translate('Edit Time Frame'));
+
+ $values = [
+ 'name' => $this->timeframe->getName(),
+ 'start' => $this->timeframe->getStart(),
+ 'end' => $this->timeframe->getEnd()
+ ];
+
+
+ $form = (new TimeframeForm())
+ ->setId($this->timeframe->getId());
+
+ $form->populate($values);
+
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/timeframes');
+
+ $this->addContent($form);
+ }
+}