<?php declare(strict_types = 0);
class CControllerAvailabilityReportList extends CController {
protected function init(): void {
$this->disableCsrfValidation();
protected function checkInput(): bool {
'mode' => 'in '.AVAILABILITY_REPORT_BY_HOST.','.AVAILABILITY_REPORT_BY_TEMPLATE,
'filter_template_groups' => 'array_db hosts_groups.groupid',
'filter_templates' => 'array_db hosts.hostid',
'filter_triggers' => 'array_db triggers.triggerid',
'filter_host_groups' => 'array_db hosts_groups.groupid',
'filter_hosts' => 'array_db hosts.hostid',
$ret = $this->validateInput($fields) && $this->validateTimeSelectorPeriod();
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions(): bool {
return $this->checkAccess(CRoleHelper::UI_REPORTS_AVAILABILITY_REPORT);
protected function doAction(): void {
$report_mode = $this->getInput('mode',
CProfile::get('web.availabilityreport.filter.mode', AVAILABILITY_REPORT_BY_HOST)
$prefix = 'web.availabilityreport.filter.'.$report_mode;
CProfile::update('web.availabilityreport.filter.mode', $report_mode, PROFILE_TYPE_INT);
if ($this->hasInput('filter_set')) {
$this->updateProfiles($report_mode);
elseif ($this->hasInput('filter_rst')) {
$this->deleteProfiles($report_mode);
$timeselector_options = [
'profileIdx' => 'web.availabilityreport.filter',
'from' => $this->hasInput('from') ? $this->getInput('from') : null,
'to' => $this->hasInput('to') ? $this->getInput('to') : null
updateTimeSelectorPeriod($timeselector_options);
'timeline' => getTimeSelectorPeriod($timeselector_options),
'active_tab' => CProfile::get('web.availabilityreport.filter.active', 1),
'profileIdx' => 'web.availabilityreport.filter',
$data['filter'] = ($report_mode == AVAILABILITY_REPORT_BY_TEMPLATE)
'template_groups' => CProfile::getArray($prefix.'.template_groups',
$this->getInput('filter_template_groups', [])),
'templates' => CProfile::getArray($prefix.'.templates', $this->getInput('filter_templates', [])),
'triggers' => CProfile::getArray($prefix.'.triggers', $this->getInput('filter_hosts', [])),
'host_groups' => CProfile::getArray($prefix.'.host_groups', $this->getInput('filter_host_groups', []))
'host_groups' => CProfile::getArray($prefix.'.host_groups', $this->getInput('filter_host_groups', [])),