From 49747c4dcaeaa74df72897e85c8bc5c8799778ce Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 5 Jun 2017 23:45:29 +0200 Subject: [PATCH] IcingaHostTemplateChoiceTable: table for choices (still need to commit the related migration, sorry) --- .../tables/IcingaHostTemplateChoiceTable.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 application/tables/IcingaHostTemplateChoiceTable.php diff --git a/application/tables/IcingaHostTemplateChoiceTable.php b/application/tables/IcingaHostTemplateChoiceTable.php new file mode 100644 index 00000000..8b234fa3 --- /dev/null +++ b/application/tables/IcingaHostTemplateChoiceTable.php @@ -0,0 +1,54 @@ +view(); + return [ + 'name' => $view->translate('Name'), + 'templates' => $view->translate('Choices'), + ]; + } + + public function getColumns() + { + return [ + 'id' => 'hc.id', + 'name' => 'hc.object_name', + 'templates' => 'GROUP_CONCAT(t.object_name)' + ]; + } + + protected function getActionUrl($row) + { + return $this->url('director/hosttemplatechoice', array('name' => $row->name)); + } + + protected function getUnfilteredQuery() + { + $query = $this->db()->select()->from( + ['hc' => 'icinga_host_template_choice'], + [] + )->joinLeft( + ['t' => 'icinga_host'], + 't.template_choice_id = hc.id', + [] + )->order('hc.object_name')->group('hc.id'); + + return $query; + } + + public function getBaseQuery() + { + return $this->getUnfilteredQuery(); + } +}