diff options
Diffstat (limited to 'library/Director/Web/Table/BasketTable.php')
-rw-r--r-- | library/Director/Web/Table/BasketTable.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/library/Director/Web/Table/BasketTable.php b/library/Director/Web/Table/BasketTable.php new file mode 100644 index 0000000..25e37e0 --- /dev/null +++ b/library/Director/Web/Table/BasketTable.php @@ -0,0 +1,50 @@ +<?php + +namespace Icinga\Module\Director\Web\Table; + +use gipfl\IcingaWeb2\Link; +use gipfl\IcingaWeb2\Table\ZfQueryBasedTable; + +class BasketTable extends ZfQueryBasedTable +{ + protected $searchColumns = [ + 'basket_name', + ]; + + public function renderRow($row) + { + $tr = $this::row([ + new Link( + $row->basket_name, + 'director/basket', + ['name' => $row->basket_name] + ), + $row->cnt_snapshots + ]); + + return $tr; + } + + public function getColumnsToBeRendered() + { + return [ + $this->translate('Basket'), + $this->translate('Snapshots'), + ]; + } + + public function prepareQuery() + { + return $this->db()->select()->from([ + 'b' => 'director_basket' + ], [ + 'b.uuid', + 'b.basket_name', + 'cnt_snapshots' => 'COUNT(bs.basket_uuid)', + ])->joinLeft( + ['bs' => 'director_basket_snapshot'], + 'bs.basket_uuid = b.uuid', + [] + )->group('b.uuid')->order('b.basket_name'); + } +} |