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 22/** 23 * @var CPartial $this 24 */ 25 26$table = (new CTableInfo()) 27 ->setHeader([ 28 ($data['source'] === 'scheduledreport-form') 29 ? (new CColHeader((new CCheckBox('all_scheduledreports')) 30 ->onClick("checkAll('".$data['source']."', 'all_scheduledreports', 'reportids');") 31 ))->addClass(ZBX_STYLE_CELL_WIDTH) 32 : null, 33 ($data['source'] === 'scheduledreport-form') 34 ? make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder'], 35 (new CUrl('zabbix.php')) 36 ->setArgument('action', 'scheduledreport.list') 37 ->getUrl() 38 ) 39 : [[_('Name'), (new CSpan())->addClass(ZBX_STYLE_ARROW_UP)]], 40 _('Owner'), 41 _('Repeats'), 42 _('Period'), 43 _('Last sent'), 44 _('Status'), 45 _('Info') 46 ]); 47 48$cycles = [ 49 ZBX_REPORT_CYCLE_DAILY => _('Daily'), 50 ZBX_REPORT_CYCLE_WEEKLY => _('Weekly'), 51 ZBX_REPORT_CYCLE_MONTHLY => _('Monthly'), 52 ZBX_REPORT_CYCLE_YEARLY => _('Yearly') 53]; 54 55$periods = [ 56 ZBX_REPORT_PERIOD_DAY => _('Previous day'), 57 ZBX_REPORT_PERIOD_WEEK => _('Previous week'), 58 ZBX_REPORT_PERIOD_MONTH => _('Previous month'), 59 ZBX_REPORT_PERIOD_YEAR => _('Previous year') 60]; 61 62$now = time(); 63 64foreach ($data['reports'] as $report) { 65 $name = new CLink($report['name'], (new CUrl('zabbix.php')) 66 ->setArgument('action', 'scheduledreport.edit') 67 ->setArgument('reportid', $report['reportid']) 68 ); 69 70 $info_icons = []; 71 72 if (($report['state'] == ZBX_REPORT_STATE_ERROR || $report['state'] == ZBX_REPORT_STATE_SUCCESS_INFO) 73 && $report['info'] !== '') { 74 $info_icons[] = ($report['state'] == ZBX_REPORT_STATE_ERROR) 75 ? makeErrorIcon($report['info']) 76 : makeWarningIcon($report['info']); 77 } 78 79 if ($report['status'] == ZBX_REPORT_STATUS_DISABLED) { 80 $status_name = _('Disabled'); 81 $status_class = ZBX_STYLE_RED; 82 } 83 else { 84 $status_name = _('Enabled'); 85 $status_class = ZBX_STYLE_GREEN; 86 87 if ($report['active_till'] !== '') { 88 $active_till = (DateTime::createFromFormat(ZBX_DATE, $report['active_till'], new DateTimeZone('UTC'))) 89 ->setTime(23, 59, 59); 90 91 if ($active_till->getTimestamp() < $now) { 92 $status_name = _('Expired'); 93 $status_class = ZBX_STYLE_GREY; 94 95 $info_icons[] = makeWarningIcon(_s('Expired on %1$s.', $active_till->format(DATE_FORMAT))); 96 } 97 } 98 } 99 100 $status = ($data['source'] === 'scheduledreport-form' && $data['allowed_edit']) 101 ? (new CLink($status_name, (new CUrl('zabbix.php')) 102 ->setArgument('action', ($report['status'] == ZBX_REPORT_STATUS_DISABLED) 103 ? 'scheduledreport.enable' 104 : 'scheduledreport.disable' 105 ) 106 ->setArgument('reportids', [$report['reportid']]) 107 ->getUrl() 108 )) 109 ->addClass(ZBX_STYLE_LINK_ACTION) 110 ->addSID() 111 : new CSpan($status_name); 112 $status->addClass($status_class); 113 114 $table->addRow([ 115 ($data['source'] === 'scheduledreport-form') 116 ? new CCheckBox('reportids['.$report['reportid'].']', $report['reportid']) 117 : null, 118 (new CCol($name))->addClass(ZBX_STYLE_WORDBREAK), 119 $report['owner'], 120 $cycles[$report['cycle']], 121 $periods[$report['period']], 122 zbx_date2str(DATE_TIME_FORMAT, $report['lastsent']), 123 $status, 124 makeInformationList($info_icons) 125 ]); 126} 127 128$table->show(); 129