function get_timeperiod_form() { $tblPeriod = new CTable(null, 'formElementTable'); // init new_timeperiod variable $new_timeperiod = getRequest('new_timeperiod', array()); $new = is_array($new_timeperiod); if (is_array($new_timeperiod)) { if (isset($new_timeperiod['id'])) { $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id'])); } if (isset($new_timeperiod['timeperiodid'])) { $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid'])); } } if (!is_array($new_timeperiod)) { $new_timeperiod = array(); $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME; } if (!isset($new_timeperiod['every'])) { $new_timeperiod['every'] = 1; } if (!isset($new_timeperiod['day'])) { $new_timeperiod['day'] = 1; } if (!isset($new_timeperiod['hour'])) { $new_timeperiod['hour'] = 12; } if (!isset($new_timeperiod['minute'])) { $new_timeperiod['minute'] = 0; } if (!isset($new_timeperiod['start_date'])) { $new_timeperiod['start_date'] = 0; } if (!isset($new_timeperiod['period_days'])) { $new_timeperiod['period_days'] = 0; } if (!isset($new_timeperiod['period_hours'])) { $new_timeperiod['period_hours'] = 1; } if (!isset($new_timeperiod['period_minutes'])) { $new_timeperiod['period_minutes'] = 0; } if (!isset($new_timeperiod['month_date_type'])) { $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day']; } // start time if (isset($new_timeperiod['start_time'])) { $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR); $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN); } // period if (isset($new_timeperiod['period'])) { $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY); $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR); $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN); } // daysofweek $dayofweek = ''; $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1'; if (isset($new_timeperiod['dayofweek'])) { $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true); } $new_timeperiod['dayofweek_mo'] = $dayofweek[0]; $new_timeperiod['dayofweek_tu'] = $dayofweek[1]; $new_timeperiod['dayofweek_we'] = $dayofweek[2]; $new_timeperiod['dayofweek_th'] = $dayofweek[3]; $new_timeperiod['dayofweek_fr'] = $dayofweek[4]; $new_timeperiod['dayofweek_sa'] = $dayofweek[5]; $new_timeperiod['dayofweek_su'] = $dayofweek[6]; // months $month = ''; $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_may']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1'; if (isset($new_timeperiod['month'])) { $month = zbx_num2bitstr($new_timeperiod['month'], true); } $new_timeperiod['month_jan'] = $month[0]; $new_timeperiod['month_feb'] = $month[1]; $new_timeperiod['month_mar'] = $month[2]; $new_timeperiod['month_apr'] = $month[3]; $new_timeperiod['month_may'] = $month[4]; $new_timeperiod['month_jun'] = $month[5]; $new_timeperiod['month_jul'] = $month[6]; $new_timeperiod['month_aug'] = $month[7]; $new_timeperiod['month_sep'] = $month[8]; $new_timeperiod['month_oct'] = $month[9]; $new_timeperiod['month_nov'] = $month[10]; $new_timeperiod['month_dec'] = $month[11]; $bit_dayofweek = strrev($dayofweek); $bit_month = strrev($month); $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()'); $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only')); $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily')); $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly')); $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly')); $tblPeriod->addRow(array(_('Period type'), $cmbType)); if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) { $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month))); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3))); } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) { $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month))); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2))); $tabDays = new CTable(); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday'))); $tblPeriod->addRow(array(_('Day of week'), $tabDays)); } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) { $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tabMonths = new CTable(); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December'))); $tblPeriod->addRow(array(_('Month'), $tabMonths)); $tblPeriod->addRow(array(_('Date'), array(new CRadioButton('new_timeperiod[month_date_type]', '0', null, null, !$new_timeperiod['month_date_type'], 'submit()'), _('Day'), SPACE, new CRadioButton('new_timeperiod[month_date_type]', '1', null, null, $new_timeperiod['month_date_type'], 'submit()'), _('Day of week')))); if ($new_timeperiod['month_date_type'] > 0) { $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']); $cmbCount->addItem(1, _('First')); $cmbCount->addItem(2, _('Second')); $cmbCount->addItem(3, _('Third')); $cmbCount->addItem(4, _('Fourth')); $cmbCount->addItem(5, _('Last')); $td = new CCol($cmbCount); $td->setColSpan(2); $tabDays = new CTable(); $tabDays->addRow($td); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday'))); $tblPeriod->addRow(array(_('Day of week'), $tabDays)); } else { $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2))); } } else { $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); if (isset($_REQUEST['add_timeperiod'])) { $date = array('y' => getRequest('new_timeperiod_start_date_year'), 'm' => getRequest('new_timeperiod_start_date_month'), 'd' => getRequest('new_timeperiod_start_date_day'), 'h' => getRequest('new_timeperiod_start_date_hour'), 'i' => getRequest('new_timeperiod_start_date_minute')); } else { $date = zbxDateToTime($new_timeperiod['start_date'] ? $new_timeperiod['start_date'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time())); } $tblPeriod->addRow(array(_('Date'), createDateSelector('new_timeperiod_start_date', $date))); } if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) { $tblPeriod->addRow(array(_('At (hour:minute)'), array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2)))); } $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours'], null, range(0, 23)); $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes'], null, range(0, 59)); $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, _('Hours') . SPACE . SPACE, $perMinutes, _('Minutes')))); return $tblPeriod; }
** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/js/reports.toptriggers.js.php'; $topTriggers = (new CWidget())->setTitle(_('100 busiest triggers')); $filterForm = (new CFilter('web.toptriggers.filter.state'))->addVar('filter_from', date(TIMESTAMP_FORMAT, $this->data['filter']['filter_from']))->addVar('filter_till', date(TIMESTAMP_FORMAT, $this->data['filter']['filter_till'])); $filterColumn1 = new CFormList(); $filterColumn2 = new CFormList(); $filterColumn2->addRow(_('From'), createDateSelector('filter_from', $this->data['filter']['filter_from'])); $filterColumn2->addRow(_('Till'), createDateSelector('filter_till', $this->data['filter']['filter_till'])); $filterColumn2->addRow(null, [new CHorList([(new CButton(null, _('Today')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_TODAY . ');')->addClass(ZBX_STYLE_BTN_LINK), (new CButton(null, _('Yesterday')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_YESTERDAY . ');')->addClass(ZBX_STYLE_BTN_LINK), (new CButton(null, _('Current week')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_CURRENT_WEEK . ');')->addClass(ZBX_STYLE_BTN_LINK), (new CButton(null, _('Current month')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_CURRENT_MONTH . ');')->addClass(ZBX_STYLE_BTN_LINK), (new CButton(null, _('Current year')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_CURRENT_YEAR . ');')->addClass(ZBX_STYLE_BTN_LINK)]), new CHorList([(new CButton(null, _('Last week')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_LAST_WEEK . ');')->addClass(ZBX_STYLE_BTN_LINK), (new CButton(null, _('Last month')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_LAST_MONTH . ');')->addClass(ZBX_STYLE_BTN_LINK), (new CButton(null, _('Last year')))->onClick('javascript: setPeriod(' . REPORT_PERIOD_LAST_YEAR . ');')->addClass(ZBX_STYLE_BTN_LINK)])]); $filterColumn1->addRow(_('Host groups'), (new CMultiSelect(['name' => 'groupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['multiSelectHostGroupData'], 'popup' => ['parameters' => 'srctbl=host_groups&dstfrm=' . $filterForm->getName() . '&dstfld1=groupids_' . '&srcfld1=groupid&multiselect=1']]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)); $filterColumn1->addRow(_('Hosts'), (new CMultiSelect(['name' => 'hostids[]', 'objectName' => 'hosts', 'data' => $this->data['multiSelectHostData'], 'popup' => ['parameters' => 'srctbl=hosts&dstfrm=' . $filterForm->getName() . '&dstfld1=hostids_&srcfld1=hostid' . '&real_hosts=1&multiselect=1']]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)); // severities $severity_columns = [0 => [], 1 => []]; for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) { $severity_columns[$severity % 2][] = new CLabel([(new CCheckBox('severities[' . $severity . ']'))->setChecked(in_array($severity, $this->data['filter']['severities'])), getSeverityName($severity, $this->data['config'])], 'severities[' . $severity . ']'); } $filterColumn1->addRow(_('Severity'), (new CTable())->addRow($severity_columns[0])->addRow($severity_columns[1])); $filterForm->addColumn($filterColumn1)->addColumn($filterColumn2); $topTriggers->addItem($filterForm); // table $table = (new CTableInfo())->setHeader([_('Host'), _('Trigger'), _('Severity'), _('Number of status changes')]); foreach ($this->data['triggers'] as $trigger) { foreach ($trigger['hosts'] as $host) {
foreach ($hosts as $host) { $hostsComboBox->addItem($host['hostid'], $host['name']); } $filterForm->addRow(_('Host'), $hostsComboBox); // trigger options if (!empty($_REQUEST['filter_groupid']) || !$config['dropdown_first_entry']) { $triggerOptions['groupids'] = $_REQUEST['filter_groupid']; } if (!empty($_REQUEST['filter_hostid']) && isset($hosts[$_REQUEST['filter_hostid']]) || !$config['dropdown_first_entry']) { $triggerOptions['hostids'] = $_REQUEST['filter_hostid']; } } // filter period $timeSinceRow = createDateSelector('filter_timesince', $_REQUEST['filter_timesince'], 'filter_timetill'); array_unshift($timeSinceRow, _('From')); $timeTillRow = createDateSelector('filter_timetill', $_REQUEST['filter_timetill'], 'filter_timesince'); array_unshift($timeTillRow, _('Till')); $filterPeriodTable = new CTable(null, 'calendar'); $filterPeriodTable->addRow($timeSinceRow); $filterPeriodTable->addRow($timeTillRow); $filterForm->addRow(_('Period'), $filterPeriodTable); // filter buttons $filterForm->addItemToBottomRow(new CSubmit('filter_set', _('Filter'))); $filterForm->addItemToBottomRow(new CSubmit('filter_rst', _('Reset'))); $reportWidget->addFlicker($filterForm, CProfile::get('web.avail_report.filter.state', 0)); /* * Triggers */ $triggerTable = new CTableInfo(_('No triggers found.')); $triggerTable->setHeader(array($_REQUEST['filter_hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? _('Host') : null, _('Name'), _('Problems'), _('Ok'), _('Graph'))); $triggers = API::Trigger()->get($triggerOptions);
// active till if (isset($_REQUEST['active_till'])) { $toYear = get_request('active_till_year'); $toMonth = get_request('active_till_month'); $toDay = get_request('active_till_day'); $toHours = get_request('active_till_hour'); $toMinutes = get_request('active_till_minute'); $toDate = array('y' => $toYear, 'm' => $toMonth, 'd' => $toDay, 'h' => $toHours, 'i' => $toMinutes); $activeTill = $toYear . $toMonth . $toDay . $toHours . $toMinutes; } else { $toDate = zbxDateToTime($this->data['active_till']); $activeTill = $this->data['active_till']; } $maintenanceForm->addVar('active_till', $activeTill); $maintenanceFormList->addRow(_('Active since'), createDateSelector('active_since', $fromDate, 'active_till')); $maintenanceFormList->addRow(_('Active till'), createDateSelector('active_till', $toDate, 'active_since')); $maintenanceFormList->addRow(_('Description'), new CTextArea('description', $this->data['description'])); /* * Maintenance period tab */ $maintenancePeriodFormList = new CFormList('maintenancePeriodFormList'); $maintenancePeriodTable = new CTable(_('No maintenance periods defined.'), 'formElementTable'); $maintenancePeriodTable->setHeader(array(_('Period type'), _('Schedule'), _('Period'), _('Action'))); foreach ($this->data['timeperiods'] as $id => $timeperiod) { $maintenancePeriodTable->addRow(array(new CCol(timeperiod_type2str($timeperiod['timeperiod_type']), 'nowrap'), new CCol(shedule2str($timeperiod), 'wraptext'), new CCol(zbx_date2age(0, $timeperiod['period']), 'nowrap'), new CCol(array(new CSubmit('edit_timeperiodid[' . $id . ']', _('Edit'), null, 'link_menu'), SPACE . SPACE, new CSubmit('del_timeperiodid[' . $id . ']', _('Remove'), null, 'link_menu')), 'nowrap'))); if (isset($timeperiod['timeperiodid'])) { $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiodid]', $timeperiod['timeperiodid']); } $maintenanceForm->addVar('timeperiods[' . $id . '][timeperiod_type]', $timeperiod['timeperiod_type']); $maintenanceForm->addVar('timeperiods[' . $id . '][every]', $timeperiod['every']); $maintenanceForm->addVar('timeperiods[' . $id . '][month]', $timeperiod['month']);
$toMinutes = getRequest('new_service_time_to_minute'); $toDate = array('y' => $toYear, 'm' => $toMonth, 'd' => $toDay, 'h' => $toHours, 'i' => $toMinutes); $serviceTimeTo = $toYear . $toMonth . $toDay . $toHours . $toMinutes; } else { $downtimeTill = date(TIMESTAMP_FORMAT_ZERO_TIME, time() + SEC_PER_DAY); $toDate = zbxDateToTime($downtimeTill); $serviceTimeTo = $downtimeTill; } $servicesForm->addVar('new_service_time[to]', $serviceTimeTo); // create calendar table $timeCalendarTable = new CTable(); $noteTextBox = new CTextBox('new_service_time[note]', '', ZBX_TEXTBOX_STANDARD_SIZE); $noteTextBox->setAttribute('placeholder', _('short description')); $timeCalendarTable->addRow(array(_('Note'), $noteTextBox)); $timeCalendarTable->addRow(array(_('From'), createDateSelector('new_service_time_from', $fromDate, 'new_service_time_to'))); $timeCalendarTable->addRow(array(_('Till'), createDateSelector('new_service_time_to', $toDate, 'new_service_time_from'))); $serviceTimeTable->addRow($timeCalendarTable); } else { $weekFromComboBox = new CComboBox('new_service_time[from_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['from_week'] : 0); $weekToComboBox = new CComboBox('new_service_time[to_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['to_week'] : 0); for ($dow = 0; $dow < 7; $dow++) { $weekFromComboBox->addItem($dow, getDayOfWeekCaption($dow)); $weekToComboBox->addItem($dow, getDayOfWeekCaption($dow)); } $timeFromHourTextBox = new CTextBox('new_service_time[from_hour]', isset($_REQUEST['new_service_time']['from_hour']) ? $_REQUEST['new_service_time']['from_hour'] : '', 2, false, 2); $timeFromHourTextBox->setAttribute('placeholder', _('hh')); $timeFromMinuteTextBox = new CTextBox('new_service_time[from_minute]', isset($_REQUEST['new_service_time']['from_minute']) ? $_REQUEST['new_service_time']['from_minute'] : '', 2, false, 2); $timeFromMinuteTextBox->setAttribute('placeholder', _('mm')); $timeToHourTextBox = new CTextBox('new_service_time[to_hour]', isset($_REQUEST['new_service_time']['to_hour']) ? $_REQUEST['new_service_time']['to_hour'] : '', 2, false, 2); $timeToHourTextBox->setAttribute('placeholder', _('hh')); $timeToMinuteTextBox = new CTextBox('new_service_time[to_minute]', isset($_REQUEST['new_service_time']['to_minute']) ? $_REQUEST['new_service_time']['to_minute'] : '', 2, false, 2);
/** * Create report bar for for "Compare values for multiple periods" * * @return object $reportForm */ function valueComparisonFormForMultiplePeriods() { $config = get_request('config', 1); $title = get_request('title', _('Report 3')); $xlabel = get_request('xlabel', ''); $ylabel = get_request('ylabel', ''); $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY); $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY); $report_timesince = get_request('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY)); $report_timetill = get_request('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME)); $itemId = get_request('itemid', 0); $hostids = get_request('hostids', array()); $hostids = zbx_toHash($hostids); $showlegend = get_request('showlegend', 0); $palette = get_request('palette', 0); $palettetype = get_request('palettetype', 0); $reportForm = new CFormTable(null, null, 'get'); $reportForm->setAttribute('name', 'zbx_report'); $reportForm->setAttribute('id', 'zbx_report'); if (isset($_REQUEST['report_show']) && $itemId) { $reportForm->addVar('report_show', 'show'); } $reportForm->addVar('config', $config); $reportForm->addVar('report_timesince', date(TIMESTAMP_FORMAT, $report_timesince)); $reportForm->addVar('report_timetill', date(TIMESTAMP_FORMAT, $report_timetill)); $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40)); $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40)); $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40)); $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1)); $reportForm->addVar('sortorder', 0); $groupids = get_request('groupids', array()); $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10); $options = array('real_hosts' => true, 'output' => 'extend'); $db_groups = API::HostGroup()->get($options); order_result($db_groups, 'name'); foreach ($db_groups as $gnum => $group) { $groupids[$group['groupid']] = $group['groupid']; $group_tb->addItem($group['groupid'], $group['name']); } $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups'))); $groupid = get_request('groupid', 0); $cmbGroups = new CComboBox('groupid', $groupid, 'submit()'); $cmbGroups->addItem(0, _('All')); foreach ($db_groups as $gnum => $group) { $cmbGroups->addItem($group['groupid'], $group['name']); } $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups)); $td_groups->setAttribute('style', 'text-align: right;'); $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10); $options = array('real_hosts' => true, 'output' => array('hostid', 'name')); if ($groupid > 0) { $options['groupids'] = $groupid; } $db_hosts = API::Host()->get($options); $db_hosts = zbx_toHash($db_hosts, 'hostid'); order_result($db_hosts, 'name'); foreach ($db_hosts as $hnum => $host) { $host_tb->addItem($host['hostid'], $host['name']); } $options = array('real_hosts' => true, 'output' => array('hostid', 'name'), 'hostids' => $hostids); $db_hosts2 = API::Host()->get($options); order_result($db_hosts2, 'name'); foreach ($db_hosts2 as $hnum => $host) { if (!isset($db_hosts[$host['hostid']])) { $host_tb->addItem($host['hostid'], $host['name']); } } $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups))); $reporttimetab = new CTable(null, 'calendar'); $timeSinceRow = createDateSelector('report_timesince', $report_timesince, 'report_timetill'); array_unshift($timeSinceRow, _('From')); $reporttimetab->addRow($timeSinceRow); $timeTillRow = createDateSelector('report_timetill', $report_timetill, 'report_timesince'); array_unshift($timeTillRow, _('Till')); $reporttimetab->addRow($timeTillRow); $reportForm->addRow(_('Period'), $reporttimetab); $scale = new CComboBox('scaletype', $scaletype); $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly')); $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily')); $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly')); $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly')); $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly')); $reportForm->addRow(_('Scale'), $scale); $avgcmb = new CComboBox('avgperiod', $avgperiod); $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly')); $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily')); $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly')); $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly')); $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly')); $reportForm->addRow(_('Average by'), $avgcmb); $itemName = ''; if ($itemId) { $itemName = get_item_by_itemid($itemId); $itemName = itemName($itemName); } $itemidVar = new CVar('itemid', $itemId, 'itemid'); $reportForm->addItem($itemidVar); $txtCondVal = new CTextBox('item_name', $itemName, 50, 'yes'); $txtCondVal->setAttribute('id', 'item_name'); $btnSelect = new CButton('btn1', _('Select'), 'return PopUp("popup.php?dstfrm=' . $reportForm->GetName() . '&dstfld1=itemid' . '&dstfld2=item_name' . '&srctbl=items' . '&srcfld1=itemid' . '&srcfld2=name' . '&monitored_hosts=1");', 'T'); $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect)); $paletteCmb = new CComboBox('palette', $palette); $paletteCmb->addItem(0, _s('Palette #%1$s', 1)); $paletteCmb->addItem(1, _s('Palette #%1$s', 2)); $paletteCmb->addItem(2, _s('Palette #%1$s', 3)); $paletteCmb->addItem(3, _s('Palette #%1$s', 4)); $paletteTypeCmb = new CComboBox('palettetype', $palettetype); $paletteTypeCmb->addItem(0, _('Middle')); $paletteTypeCmb->addItem(1, _('Darken')); $paletteTypeCmb->addItem(2, _('Brighten')); $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb)); $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show'))); $reset = new CButton('reset', _('Reset')); $reset->setType('reset'); $reportForm->addItemToBottomRow($reset); return $reportForm; }
$config = get_request('config', 1); $caption = get_request('caption', ''); $color = get_request('color', '009900'); $report_timesince = get_request('report_timesince', time() - SEC_PER_DAY); $report_timetill = get_request('report_timetill', time()); $frmPd->addVar('config', $config); $frmPd->addVar('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, $report_timesince)); $frmPd->addVar('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME, $report_timetill)); if (isset($_REQUEST['period_id'])) { $frmPd->addVar('period_id', $_REQUEST['period_id']); } $frmPd->addRow(array(new CVisibilityBox('caption_visible', !zbx_empty($caption), 'caption', _('Default')), _('Caption')), new CTextBox('caption', $caption, 42)); $reporttimetab = new CTable(null, 'calendar'); $timeSinceRow = createDateSelector('report_timesince', $report_timesince, 'report_timetill'); array_unshift($timeSinceRow, _('From')); $reporttimetab->addRow($timeSinceRow); $timeTillRow = createDateSelector('report_timetill', $report_timetill, 'report_timesince'); array_unshift($timeTillRow, _('Till')); $reporttimetab->addRow($timeTillRow); $frmPd->addRow(_('Period'), $reporttimetab); //*/ if ($config != 1) { $frmPd->addRow(_('Colour'), new CColor('color', $color)); } else { $frmPd->addVar('color', $color); } $frmPd->addItemToBottomRow(new CSubmit('save', isset($_REQUEST['period_id']) ? _('Update') : _('Add'))); $frmPd->addItemToBottomRow(new CButtonCancel(null, 'close_window();')); $frmPd->Show(); } require_once dirname(__FILE__) . '/include/page_footer.php';
$hosts = zbx_toHash($hosts, 'hostid'); foreach ($hosts as $host) { $hostsComboBox->addItem($host['hostid'], $host['name']); } $filterColumn1->addRow(_('Host'), $hostsComboBox); // trigger options if (!empty($_REQUEST['filter_groupid'])) { $triggerOptions['groupids'] = $_REQUEST['filter_groupid']; } if (!empty($_REQUEST['filter_hostid']) && isset($hosts[$_REQUEST['filter_hostid']])) { $triggerOptions['hostids'] = $_REQUEST['filter_hostid']; } } // filter period $filterColumn2->addRow(_('From'), createDateSelector('filter_timesince', $_REQUEST['filter_timesince'], 'filter_timetill')); $filterColumn2->addRow(_('To'), createDateSelector('filter_timetill', $_REQUEST['filter_timetill'], 'filter_timesince')); $filterForm->addColumn($filterColumn1); $filterForm->addColumn($filterColumn2); $reportWidget->addItem($filterForm); /* * Triggers */ $triggerTable = (new CTableInfo())->setHeader([$_REQUEST['filter_hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? _('Host') : null, _('Name'), _('Problems'), _('Ok'), _('Graph')]); $triggers = API::Trigger()->get($triggerOptions); CArrayHelper::sort($triggers, ['host', 'description']); $paging = getPagingLine($triggers, ZBX_SORT_UP, new CUrl('report2.php')); foreach ($triggers as $trigger) { $availability = calculateAvailability($trigger['triggerid'], getRequest('filter_timesince'), getRequest('filter_timetill')); $triggerTable->addRow([$_REQUEST['filter_hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? $trigger['hosts'][0]['name'] : null, new CLink($trigger['description'], 'events.php?filter_set=1&triggerid=' . $trigger['triggerid']), $availability['true'] == 0 ? '' : (new CSpan(sprintf('%.4f%%', $availability['true'])))->addClass(ZBX_STYLE_RED), $availability['false'] == 0 ? '' : (new CSpan(sprintf('%.4f%%', $availability['false'])))->addClass(ZBX_STYLE_GREEN), new CLink(_('Show'), 'report2.php?filter_groupid=' . $_REQUEST['filter_groupid'] . '&filter_hostid=' . $_REQUEST['filter_hostid'] . '&triggerid=' . $trigger['triggerid'])]); } $reportWidget->addItem([$triggerTable, $paging])->show();
// downtime till if (isset($_REQUEST['new_service_time']['to'])) { $toYear = getRequest('new_service_time_to_year'); $toMonth = getRequest('new_service_time_to_month'); $toDay = getRequest('new_service_time_to_day'); $toHours = getRequest('new_service_time_to_hour'); $toMinutes = getRequest('new_service_time_to_minute'); $toDate = ['y' => $toYear, 'm' => $toMonth, 'd' => $toDay, 'h' => $toHours, 'i' => $toMinutes]; $serviceTimeTo = $toYear . $toMonth . $toDay . $toHours . $toMinutes; } else { $downtimeTill = date(TIMESTAMP_FORMAT_ZERO_TIME, time() + SEC_PER_DAY); $toDate = zbxDateToTime($downtimeTill); $serviceTimeTo = $downtimeTill; } $servicesForm->addVar('new_service_time[to]', $serviceTimeTo); $serviceTimeTable->addRow([_('Note'), (new CTextBox('new_service_time[note]'))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('placeholder', _('short description'))])->addRow([_('From'), createDateSelector('new_service_time_from', $fromDate, 'new_service_time_to')])->addRow([_('Till'), createDateSelector('new_service_time_to', $toDate, 'new_service_time_from')]); } else { $weekFromComboBox = new CComboBox('new_service_time[from_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['from_week'] : 0); $weekToComboBox = new CComboBox('new_service_time[to_week]', isset($_REQUEST['new_service_time']['from_week']) ? $_REQUEST['new_service_time']['to_week'] : 0); for ($dow = 0; $dow < 7; $dow++) { $weekFromComboBox->addItem($dow, getDayOfWeekCaption($dow)); $weekToComboBox->addItem($dow, getDayOfWeekCaption($dow)); } $timeFromHourTextBox = (new CTextBox('new_service_time[from_hour]', isset($_REQUEST['new_service_time']['from_hour']) ? $_REQUEST['new_service_time']['from_hour'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('hh')); $timeFromMinuteTextBox = (new CTextBox('new_service_time[from_minute]', isset($_REQUEST['new_service_time']['from_minute']) ? $_REQUEST['new_service_time']['from_minute'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('mm')); $timeToHourTextBox = (new CTextBox('new_service_time[to_hour]', isset($_REQUEST['new_service_time']['to_hour']) ? $_REQUEST['new_service_time']['to_hour'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('hh')); $timeToMinuteTextBox = (new CTextBox('new_service_time[to_minute]', isset($_REQUEST['new_service_time']['to_minute']) ? $_REQUEST['new_service_time']['to_minute'] : '', false, 2))->setWidth(ZBX_TEXTAREA_2DIGITS_WIDTH)->setAttribute('placeholder', _('mm')); $serviceTimeTable->addRow([_('From'), [$weekFromComboBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), _('Time'), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeFromHourTextBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), ':', (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeFromMinuteTextBox]]); $serviceTimeTable->addRow([_('Till'), [$weekToComboBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), _('Time'), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeToHourTextBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), ':', (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $timeToMinuteTextBox]]); $servicesForm->addVar('new_service_time[note]', ''); }