diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:46:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:46:47 +0000 |
commit | 4ada86876033fa171e2896d7e3d3c5645d8062db (patch) | |
tree | f0d1fee61877df200ccfb1c0af58a39cd551fb46 /application/controllers/TestController.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-reporting-6f6e52922af9d5e1985f6f512f8f7f5144b36ae1.tar.xz icingaweb2-module-reporting-6f6e52922af9d5e1985f6f512f8f7f5144b36ae1.zip |
Adding upstream version 0.10.0.upstream/0.10.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers/TestController.php')
-rw-r--r-- | application/controllers/TestController.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/application/controllers/TestController.php b/application/controllers/TestController.php new file mode 100644 index 0000000..f666085 --- /dev/null +++ b/application/controllers/TestController.php @@ -0,0 +1,47 @@ +<?php +// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2 + +namespace Icinga\Module\Reporting\Controllers; + +use Icinga\Module\Reporting\Database; +use Icinga\Module\Reporting\Timeframe; +use Icinga\Module\Reporting\Web\Controller; +use ipl\Html\Table; +use ipl\Sql\Select; + +class TestController extends Controller +{ + use Database; + + public function timeframesAction() + { + $select = (new Select()) + ->from('timeframe') + ->columns('*'); + + $table = new Table(); + + $table->getAttributes()->add('class', 'common-table'); + + $table->getHeader()->add(Table::row(['Name', 'Title', 'Start', 'End'], null, 'th')); + + foreach ($this->getDb()->select($select) as $row) { + $timeframe = (new Timeframe()) + ->setName($row->name) + ->setTitle($row->title) + ->setStart($row->start) + ->setEnd($row->end); + + $table->getBody()->add(Table::row([ + $timeframe->getName(), + $timeframe->getTitle(), + $timeframe->getTimerange()->getStart()->format('Y-m-d H:i:s'), + $timeframe->getTimerange()->getEnd()->format('Y-m-d H:i:s') + ])); + } + + $this->addTitleTab('Timeframes'); + + $this->addContent($table); + } +} |