1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21$widget = (new CWidget()) 22 ->setTitle(_('Maintenance periods')) 23 ->setControls((new CForm('get')) 24 ->cleanItems() 25 ->addItem((new CList()) 26 ->addItem([ 27 new CLabel(_('Group'), 'groupid'), 28 (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), 29 $this->data['pageFilter']->getGroupsCB() 30 ]) 31 ->addItem(new CSubmit('form', _('Create maintenance period'))) 32 )); 33 34// create form 35$maintenanceForm = (new CForm())->setName('maintenanceForm'); 36 37// create table 38$maintenanceTable = (new CTableInfo()) 39 ->setHeader([ 40 (new CColHeader( 41 (new CCheckBox('all_maintenances'))->onClick("checkAll('".$maintenanceForm->getName()."', 'all_maintenances', 'maintenanceids');") 42 ))->addClass(ZBX_STYLE_CELL_WIDTH), 43 make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), 44 make_sorting_header(_('Type'), 'maintenance_type', $this->data['sort'], $this->data['sortorder']), 45 make_sorting_header(_('Active since'), 'active_since', $this->data['sort'], $this->data['sortorder']), 46 make_sorting_header(_('Active till'), 'active_till', $this->data['sort'], $this->data['sortorder']), 47 _('State'), 48 _('Description') 49 ]); 50 51foreach ($this->data['maintenances'] as $maintenance) { 52 $maintenanceid = $maintenance['maintenanceid']; 53 54 switch ($maintenance['status']) { 55 case MAINTENANCE_STATUS_EXPIRED: 56 $maintenanceStatus = (new CSpan(_x('Expired', 'maintenance status')))->addClass(ZBX_STYLE_RED); 57 break; 58 case MAINTENANCE_STATUS_APPROACH: 59 $maintenanceStatus = (new CSpan(_x('Approaching', 'maintenance status')))->addClass(ZBX_STYLE_ORANGE); 60 break; 61 case MAINTENANCE_STATUS_ACTIVE: 62 $maintenanceStatus = (new CSpan(_x('Active', 'maintenance status')))->addClass(ZBX_STYLE_GREEN); 63 break; 64 } 65 66 $maintenanceTable->addRow([ 67 new CCheckBox('maintenanceids['.$maintenanceid.']', $maintenanceid), 68 new CLink($maintenance['name'], 'maintenance.php?form=update&maintenanceid='.$maintenanceid), 69 $maintenance['maintenance_type'] ? _('No data collection') : _('With data collection'), 70 zbx_date2str(DATE_TIME_FORMAT, $maintenance['active_since']), 71 zbx_date2str(DATE_TIME_FORMAT, $maintenance['active_till']), 72 $maintenanceStatus, 73 $maintenance['description'] 74 ]); 75} 76 77// append table to form 78$maintenanceForm->addItem([ 79 $maintenanceTable, 80 $this->data['paging'], 81 new CActionButtonList('action', 'maintenanceids', [ 82 'maintenance.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected maintenance periods?')] 83 ]) 84]); 85 86// append form to widget 87$widget->addItem($maintenanceForm); 88 89return $widget; 90