Пример #1
0
function newComboFilterArray($array, $name, $value)
{
    $cmbRange = new CComboBox($name, $value, 'javascript: submit();');
    $cmbRange->additem('', 'Selecione...');
    foreach ($array as $k => $v) {
        $cmbRange->additem($k, $v);
    }
    return $cmbRange;
}
Пример #2
0
function newComboAPI($Data, $keyField, $showField, $selected_value, $name, $reloadScript = 'javascript: submit();', $fristBlank = true)
{
    $cmbRange = new CComboBox($name, $selected_value, $reloadScript);
    if ($fristBlank == true) {
        $cmbRange->additem("0", "");
    }
    for ($i = 0; $i < count($Data); $i++) {
        $cmbRange->additem($Data[$i][$keyField], $Data[$i][$showField]);
    }
    return $cmbRange;
}
Пример #3
0
/***********************************************************/
$filterForm = new CFormTable(null, null, 'get');
//,'tr_status.php?filter_set=1','POST',null,'sform');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterForm->addVar('fullscreen', $_REQUEST['fullscreen']);
$filterForm->addVar('groupid', $_REQUEST['groupid']);
$filterForm->addVar('hostid', $_REQUEST['hostid']);
$tr_select = new CComboBox('show_triggers', $show_triggers);
$tr_select->addItem(TRIGGERS_OPTION_ALL, S_ANY);
$tr_select->additem(TRIGGERS_OPTION_ONLYTRUE, S_PROBLEM);
$filterForm->addRow(S_TRIGGERS_STATUS, $tr_select);
if ($config['event_ack_enable']) {
    $cb_ack_status = new CComboBox('ack_status', $ack_status);
    $cb_ack_status->addItem(ZBX_ACK_STS_ANY, S_ANY);
    $cb_ack_status->additem(ZBX_ACK_STS_WITH_UNACK, S_WITH_UNACKNOWLEDGED_EVENTS);
    $cb_ack_status->additem(ZBX_ACK_STS_WITH_LAST_UNACK, S_WITH_LAST_EVENT_UNACKNOWLEDGED);
    $filterForm->addRow(S_ACKNOWLEDGE_STATUS, $cb_ack_status);
}
$ev_select = new CComboBox('show_events', $_REQUEST['show_events']);
$ev_select->addItem(EVENTS_OPTION_NOEVENT, S_HIDE_ALL);
$ev_select->addItem(EVENTS_OPTION_ALL, S_SHOW_ALL . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')');
if ($config['event_ack_enable']) {
    $ev_select->addItem(EVENTS_OPTION_NOT_ACK, S_SHOW_UNACKNOWLEDGED . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')');
}
$filterForm->addRow(S_EVENTS, $ev_select);
$severity_select = new CComboBox('show_severity', $show_severity);
$cb_items = array(-1 => S_ALL_S, TRIGGER_SEVERITY_NOT_CLASSIFIED => S_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION => S_INFORMATION, TRIGGER_SEVERITY_WARNING => S_WARNING, TRIGGER_SEVERITY_AVERAGE => S_AVERAGE, TRIGGER_SEVERITY_HIGH => S_HIGH, TRIGGER_SEVERITY_DISASTER => S_DISASTER);
$severity_select->addItems($cb_items);
$filterForm->addRow(S_MIN_SEVERITY, $severity_select);
$action = 'javascrip: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()';
Пример #4
0
$options = array('groups' => array('real_hosts' => 1), 'groupid' => get_request('groupid', null));
$pageFilter = new CPageFilter($options);
$_REQUEST['groupid'] = $pageFilter->groupid;
$_REQUEST['hostid'] = get_request('hostid', 0);
// permission check, imo should be remuved in future.
if ($_REQUEST['hostid'] > 0) {
    $res = CHost::get(array('real_hosts' => 1, 'hostids' => $_REQUEST['hostid']));
    if (empty($res)) {
        access_deny();
    }
}
$_REQUEST['prof_type'] = get_request('prof_type', 0);
$hostprof_wdgt = new CWidget();
$profile_form = new CForm(null, 'get');
$cmbProf = new CComboBox('prof_type', $_REQUEST['prof_type'], 'javascript: submit();');
$cmbProf->additem(0, S_NORMAL);
$cmbProf->additem(1, S_EXTENDED);
$profile_form->addItem(array(SPACE . S_HOST_PROFILES . SPACE, $cmbProf));
$hostprof_wdgt->addPageHeader(S_HOST_PROFILES_BIG, $profile_form);
if ($_REQUEST['hostid'] > 0) {
    if ($_REQUEST['prof_type']) {
        $hostprof_wdgt->addItem(insert_host_profile_ext_form());
    } else {
        $hostprof_wdgt->addItem(insert_host_profile_form());
    }
} else {
    $sortfield = getPageSortField('host');
    $sortorder = getPageSortOrder();
    $options = array('extendoutput' => 1, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'select_profile' => 1, 'select_groups' => 1, 'limit' => $config['search_limit'] + 1);
    if ($pageFilter->groupsSelected) {
        if ($pageFilter->groupid > 0) {
Пример #5
0
$tr_info = array(S_TRIGGERS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $tr_numrows, SPACE . SPACE . SPACE . S_UPDATED . ': ', new CSpan(date(S_DATE_FORMAT_YMDHMS), 'info'));
$trigg_wdgt->addHeader(S_STATUS_OF_TRIGGERS_BIG, array($mute_icon, $fs_icon));
$trigg_wdgt->addHeader($tr_info, $r_form);
/************************* FILTER **************************/
/***********************************************************/
$filterForm = new CFormTable();
//,'tr_status.php?filter_set=1','POST',null,'sform');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterForm->setMethod('post');
$filterForm->addVar('fullscreen', $_REQUEST['fullscreen']);
$filterForm->addVar('groupid', $_REQUEST['groupid']);
$filterForm->addVar('hostid', $_REQUEST['hostid']);
$tr_select = new CComboBox('show_triggers', $show_triggers, 'javasctipt: submit();');
if (TRIGGERS_OPTION_ONLYTRUE) {
    $tr_select->additem(TRIGGERS_OPTION_ONLYTRUE, S_SHOW_ONLY_PROBLEMS);
}
if (TRIGGERS_OPTION_ALL) {
    $tr_select->addItem(TRIGGERS_OPTION_ALL, S_SHOW_ALL);
}
if (TRIGGERS_OPTION_NOFALSEFORB && $config['event_ack_enable']) {
    $tr_select->addItem(TRIGGERS_OPTION_NOFALSEFORB, S_SHOW_NOFALSEFORB);
}
$ev_select = new CComboBox('show_events', $show_events, 'javasctipt: submit();');
if (EVENTS_OPTION_NOEVENT) {
    $ev_select->addItem(EVENTS_OPTION_NOEVENT, S_HIDE_ALL);
}
if (EVENTS_OPTION_ALL) {
    $ev_select->addItem(EVENTS_OPTION_ALL, S_SHOW_ALL . SPACE . '(' . $config['event_expire'] . SPACE . ($config['event_expire'] > 1 ? S_DAYS : S_DAY) . ')');
}
if (EVENTS_OPTION_NOT_ACK && $config['event_ack_enable']) {
Пример #6
0
function insert_trigger_form()
{
    global $USER_DETAILS;
    $frmTrig = new CFormTable(S_TRIGGER, "triggers.php");
    $frmTrig->SetHelp("config_triggers.php");
    if ($_REQUEST['hostid'] > 0) {
        $frmTrig->addVar("hostid", $_REQUEST['hostid']);
    }
    $dep_el = array();
    $dependencies = get_request("dependencies", array());
    $limited = null;
    if (isset($_REQUEST["triggerid"])) {
        $frmTrig->addVar("triggerid", $_REQUEST["triggerid"]);
        $trigger = get_trigger_by_triggerid($_REQUEST["triggerid"]);
        $frmTrig->SetTitle(S_TRIGGER . ' "' . htmlspecialchars($trigger["description"]) . '"');
        $limited = $trigger['templateid'] ? 'yes' : null;
    }
    $expression = get_request("expression", "");
    $description = get_request("description", "");
    $type = get_request('type', 0);
    $priority = get_request("priority", 0);
    $status = get_request("status", 0);
    $comments = get_request("comments", "");
    $url = get_request("url", "");
    if (isset($_REQUEST["triggerid"]) && !isset($_REQUEST["form_refresh"]) || isset($limited)) {
        $description = $trigger["description"];
        $expression = explode_exp($trigger["expression"], 0);
        if (!isset($limited) || !isset($_REQUEST["form_refresh"])) {
            $type = $trigger['type'];
            $priority = $trigger["priority"];
            $status = $trigger["status"];
            $comments = $trigger["comments"];
            $url = $trigger["url"];
            $trigs = DBselect('SELECT t.triggerid,t.description,t.expression ' . ' FROM triggers t,trigger_depends d ' . ' WHERE t.triggerid=d.triggerid_up ' . ' AND d.triggerid_down=' . $_REQUEST['triggerid']);
            while ($trig = DBfetch($trigs)) {
                if (uint_in_array($trig["triggerid"], $dependencies)) {
                    continue;
                }
                array_push($dependencies, $trig["triggerid"]);
            }
        }
    }
    $frmTrig->addRow(S_NAME, new CTextBox("description", $description, 90, $limited));
    $frmTrig->addRow(S_EXPRESSION, array(new CTextBox("expression", $expression, 75, $limited), $limited ? null : new CButton('insert', S_INSERT, "return PopUp('popup_trexpr.php?dstfrm=" . $frmTrig->GetName() . "&dstfld1=expression&srctbl=expression" . "&srcfld1=expression&expression=' + escape(getSelectedText(this.form.elements['expression'])),700,200);")));
    /* dependencies */
    foreach ($dependencies as $val) {
        array_push($dep_el, array(new CCheckBox("rem_dependence[]", 'no', null, strval($val)), expand_trigger_description($val)), BR());
        $frmTrig->addVar("dependencies[]", strval($val));
    }
    if (count($dep_el) == 0) {
        array_push($dep_el, S_NO_DEPENDENCES_DEFINED);
    } else {
        array_push($dep_el, new CButton('del_dependence', 'delete selected'));
    }
    $frmTrig->addRow(S_THE_TRIGGER_DEPENDS_ON, $dep_el);
    /* end dependencies */
    /* new dependence */
    //		$frmTrig->addVar('new_dependence','0');
    //		$txtCondVal = new CTextBox('trigger','',75,'yes');
    $btnSelect = new CButton('btn1', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmTrig->GetName() . "&dstfld1=new_dependence[]&srctbl=triggers&multiselect=1&dstact=add_dependence&objname=triggers&srcfld1=1" . "',750,450);", 'T');
    $frmTrig->addRow(S_NEW_DEPENDENCY, $btnSelect, 'new');
    /* end new dependence */
    $type_select = new CComboBox('type');
    $type_select->additem(TRIGGER_MULT_EVENT_DISABLED, S_NORMAL, $type == TRIGGER_MULT_EVENT_ENABLED ? 'no' : 'yes');
    $type_select->additem(TRIGGER_MULT_EVENT_ENABLED, S_NORMAL . SPACE . '+' . SPACE . S_MULTIPLE_TRUE_EVENTS, $type == TRIGGER_MULT_EVENT_ENABLED ? 'yes' : 'no');
    $frmTrig->addRow(S_EVENT_GENERATION, $type_select);
    $cmbPrior = new CComboBox("priority", $priority);
    for ($i = 0; $i <= 5; $i++) {
        $cmbPrior->addItem($i, get_severity_description($i));
    }
    $frmTrig->addRow(S_SEVERITY, $cmbPrior);
    $frmTrig->addRow(S_COMMENTS, new CTextArea("comments", $comments, 90, 7));
    $frmTrig->addRow(S_URL, new CTextBox("url", $url, 90));
    $frmTrig->addRow(S_DISABLED, new CCheckBox("status", $status));
    $frmTrig->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["triggerid"])) {
        $frmTrig->addItemToBottomRow(SPACE);
        $frmTrig->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmTrig->addItemToBottomRow(SPACE);
        if (!$limited) {
            $frmTrig->addItemToBottomRow(new CButtonDelete("Delete trigger?", url_param("form") . url_param('groupid') . url_param("hostid") . url_param("triggerid")));
        }
    }
    $frmTrig->addItemToBottomRow(SPACE);
    $frmTrig->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid")));
    $frmTrig->Show();
}
Пример #7
0
$filter_table->addRow($footer_col);
$filter_form->addItem($filter_table);
//    $filter_form->addVar('report_timesince', date('YmdHis', $report_timesince));
//    $filter_form->addVar('report_timetill', date('YmdHis', $report_timetill));
$hostprof_wdgt->addFlicker($filter_form, true);
// FIM Formulario de Filtro =========================================================
insert_js($script);
$numrows = new CDiv();
$numrows->setAttribute('name', 'numrows');
$report = array();
$hostprof_wdgt->addHeader($numrows);
$r_form = new CForm();
// Combo com os formatos de exibição ---------------------------------------
$cmbFormato = new CComboBox('formato', $formato, 'javascript: submit();');
$cmbFormato->additem('html', 'HTML');
$cmbFormato->additem('csv', 'CSV');
// Combo com as opções de relatorios possiveis -----------------------------
$cmbMenus = new CComboBox('submenu', $subMenu, 'javascript: submit();');
//    var_dump (zbxeSubMenus ('submenu_05'));
foreach (zbxeSubMenus('sub_report') as $row) {
    $cmbMenus->additem($row['url'], $row['label']);
}
$r_form->addItem(array(array(bold(_zeT('Formatting')), ': '), array($cmbFormato)));
$r_form->addItem(array(array(bold(_zeT('Report')), ': '), array($cmbMenus)));
$hostprof_wdgt->addPageHeader(_zeT('Zabbix-Extras Reports'));
$hostprof_wdgt->addHeader(_('Report'), $r_form);
//    $hostprof_wdgt->addItem(BR());
$paging = getPagingLine($report);
//$hostprof_wdgt->addItem($table);
$hostprof_wdgt->show();
include_once 'include/page_footer.php';
Пример #8
0
 * Filter
 */
$filterForm = new CFormTable(null, null, 'get');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterForm->addVar('fullscreen', $_REQUEST['fullscreen']);
$filterForm->addVar('groupid', $_REQUEST['groupid']);
$filterForm->addVar('hostid', $_REQUEST['hostid']);
$statusComboBox = new CComboBox('show_triggers', $showTriggers);
$statusComboBox->addItem(TRIGGERS_OPTION_ALL, _('Any'));
$statusComboBox->additem(TRIGGERS_OPTION_ONLYTRUE, _('Problem'));
$filterForm->addRow(_('Triggers status'), $statusComboBox);
if ($config['event_ack_enable']) {
    $ackStatusComboBox = new CComboBox('ack_status', $ackStatus);
    $ackStatusComboBox->addItem(ZBX_ACK_STS_ANY, _('Any'));
    $ackStatusComboBox->additem(ZBX_ACK_STS_WITH_UNACK, _('With unacknowledged events'));
    $ackStatusComboBox->additem(ZBX_ACK_STS_WITH_LAST_UNACK, _('With last event unacknowledged'));
    $filterForm->addRow(_('Acknowledge status'), $ackStatusComboBox);
}
$eventsComboBox = new CComboBox('show_events', $_REQUEST['show_events']);
$eventsComboBox->addItem(EVENTS_OPTION_NOEVENT, _('Hide all'));
$eventsComboBox->addItem(EVENTS_OPTION_ALL, _('Show all') . ' (' . $config['event_expire'] . ' ' . ($config['event_expire'] > 1 ? _('Days') : _('Day')) . ')');
if ($config['event_ack_enable']) {
    $eventsComboBox->addItem(EVENTS_OPTION_NOT_ACK, _('Show unacknowledged') . ' (' . $config['event_expire'] . ' ' . ($config['event_expire'] > 1 ? _('Days') : _('Day')) . ')');
}
$filterForm->addRow(_('Events'), $eventsComboBox);
$severityComboBox = new CComboBox('show_severity', $showSeverity);
$severityComboBox->addItems(array(TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER)));
$filterForm->addRow(_('Minimum trigger severity'), $severityComboBox);
$statusChangeDays = new CNumericBox('status_change_days', $_REQUEST['status_change_days'], 3, false, false, false);
if (!$_REQUEST['status_change']) {
Пример #9
0
$cmbAgregation = new CComboBox('agregation', get_request('agregation', 0), 'javascript: submit();');
if ($completo) {
    $intervalDesc = array('', _zeT('Day'), _zeT('Week'), _zeT('Month'), _zeT('Year'));
    $intervalFactor = array(0, 1, 7, 30, 365);
    $intervalFactor2 = array(0, '+1 days', '+1 week', '+1 months', '+1 years');
    $sourceAgregator = array('hu.value_max', 'hu.value_min', 'hu.value_avg');
    //		$sourceAgregator 	= array ('AVG(hu.value_max)','AVG(hu.value_min)','AVG(hu.value_avg)');
    $intervalMask = array('', '%d/%m/%Y', '%U', '%m/%Y', '%Y');
    $intervalMask2 = array('', 'd/m/Y', 'W (d/m/Y)', 'm/Y', 'Y');
    $intervalMaskSort = array('', '%Y%m%d', '%Y%U', '%Y%m', '%Y');
    for ($i = 0; $i < count($intervalDesc); $i++) {
        $cmbTimeSource->additem($i, $intervalDesc[$i]);
        $cmbTimeProjection->additem($i, $intervalDesc[$i]);
    }
    $completo = $timeShiftSource > 0 && $timeShiftProjection > 0;
    $cmbAgregation->additem(0, _zeT('Max'));
    $cmbAgregation->additem(1, _zeT('Min'));
    $cmbAgregation->additem(2, _zeT('Avg'));
}
/*----------- Filtro por período ---------------*/
$reporttimetab = new CTable(null, 'calendar');
$clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
$clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); ' . 'pos.top+=10; pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
$reporttimetab->addRow(array(_('From'), array(new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2)), $clndr_icon));
$clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); ' . 'pos.top+=10; pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
$reporttimetab->addRow(array(_('Till'), array(new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2)), $clndr_icon));
zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");');
zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
$reporttimetab2 = new CTable(null, 'calendar');
$reporttimetab2->addRow(array(array(bold(_zeT('Analysis')), ': '), array($cmbTimeSource, $cmbAgregation)));
$reporttimetab2->addRow(array(array(bold(_zeT('Projection')), ': '), array($cmbTimeProjection, array(bold(_zeT('Amount')), ': '), new CTextBox('num_projection', get_request('num_projection', 7), 2))));
Пример #10
0
/***********************************************************/
$filterForm = new CFormTable(null, null, 'get');
//,'tr_status.php?filter_set=1','POST',null,'sform');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
$filterForm->addVar('fullscreen', $_REQUEST['fullscreen']);
$filterForm->addVar('groupid', $_REQUEST['groupid']);
$filterForm->addVar('hostid', $_REQUEST['hostid']);
$tr_select = new CComboBox('show_triggers', $show_triggers);
$tr_select->addItem(TRIGGERS_OPTION_ALL, _('Any'));
$tr_select->additem(TRIGGERS_OPTION_ONLYTRUE, _('Problem'));
$filterForm->addRow(_('Triggers status'), $tr_select);
if ($config['event_ack_enable']) {
    $cb_ack_status = new CComboBox('ack_status', $ack_status);
    $cb_ack_status->addItem(ZBX_ACK_STS_ANY, _('Any'));
    $cb_ack_status->additem(ZBX_ACK_STS_WITH_UNACK, _('With unacknowledged events'));
    $cb_ack_status->additem(ZBX_ACK_STS_WITH_LAST_UNACK, _('With last event unacknowledged'));
    $filterForm->addRow(_('Acknowledge status'), $cb_ack_status);
}
$ev_select = new CComboBox('show_events', $_REQUEST['show_events']);
$ev_select->addItem(EVENTS_OPTION_NOEVENT, _('Hide all'));
$ev_select->addItem(EVENTS_OPTION_ALL, _('Show all') . ' (' . $config['event_expire'] . ' ' . ($config['event_expire'] > 1 ? _('Days') : _('Day')) . ')');
if ($config['event_ack_enable']) {
    $ev_select->addItem(EVENTS_OPTION_NOT_ACK, _('Show unacknowledged') . ' (' . $config['event_expire'] . ' ' . ($config['event_expire'] > 1 ? _('Days') : _('Day')) . ')');
}
$filterForm->addRow(_('Events'), $ev_select);
$severity_select = new CComboBox('show_severity', $show_severity);
$cb_items = array(-1 => _('All'), TRIGGER_SEVERITY_NOT_CLASSIFIED => getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), TRIGGER_SEVERITY_INFORMATION => getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), TRIGGER_SEVERITY_WARNING => getSeverityCaption(TRIGGER_SEVERITY_WARNING), TRIGGER_SEVERITY_AVERAGE => getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), TRIGGER_SEVERITY_HIGH => getSeverityCaption(TRIGGER_SEVERITY_HIGH), TRIGGER_SEVERITY_DISASTER => getSeverityCaption(TRIGGER_SEVERITY_DISASTER));
$severity_select->addItems($cb_items);
$filterForm->addRow(_('Min severity'), $severity_select);
$action = 'javascript: this.checked ? $("status_change_days").enable() : $("status_change_days").disable()';
Пример #11
0
function insert_trigger_form()
{
    $frmTrig = new CFormTable(S_TRIGGER, 'triggers.php');
    $frmTrig->setHelp('config_triggers.php');
    //		if(isset($_REQUEST['hostid'])){
    //			$frmTrig->addVar('hostid',$_REQUEST['hostid']);
    //		}
    $dep_el = array();
    $dependencies = get_request('dependencies', array());
    $limited = null;
    if (isset($_REQUEST['triggerid'])) {
        $frmTrig->addVar('triggerid', $_REQUEST['triggerid']);
        $trigger = get_trigger_by_triggerid($_REQUEST['triggerid']);
        $caption = array();
        $trigid = $_REQUEST['triggerid'];
        do {
            $sql = 'SELECT t.triggerid, t.templateid, h.host' . ' FROM triggers t, functions f, items i, hosts h' . ' WHERE t.triggerid=' . $trigid . ' AND h.hostid=i.hostid' . ' AND i.itemid=f.itemid' . ' AND f.triggerid=t.triggerid';
            $trig = DBfetch(DBselect($sql));
            if ($_REQUEST['triggerid'] != $trigid) {
                $caption[] = ' : ';
                $caption[] = new CLink($trig['host'], 'triggers.php?form=update&triggerid=' . $trig['triggerid'], 'highlight underline');
            }
            $trigid = $trig['templateid'];
        } while ($trigid != 0);
        $caption[] = S_TRIGGER . ' "';
        $caption = array_reverse($caption);
        $caption[] = htmlspecialchars($trigger['description']);
        $caption[] = '"';
        $frmTrig->setTitle($caption);
        $limited = $trigger['templateid'] ? 'yes' : null;
    }
    $expression = get_request('expression', '');
    $description = get_request('description', '');
    $type = get_request('type', 0);
    $priority = get_request('priority', 0);
    $status = get_request('status', 0);
    $comments = get_request('comments', '');
    $url = get_request('url', '');
    $expr_temp = get_request('expr_temp', '');
    $input_method = get_request('input_method', IM_ESTABLISHED);
    if (isset($_REQUEST['triggerid']) && !isset($_REQUEST['form_refresh']) || isset($limited)) {
        $description = $trigger['description'];
        $expression = explode_exp($trigger['expression'], 0);
        if (!isset($limited) || !isset($_REQUEST['form_refresh'])) {
            $type = $trigger['type'];
            $priority = $trigger['priority'];
            $status = $trigger['status'];
            $comments = $trigger['comments'];
            $url = $trigger['url'];
            $trigs = DBselect('SELECT t.triggerid,t.description,t.expression ' . ' FROM triggers t,trigger_depends d ' . ' WHERE t.triggerid=d.triggerid_up ' . ' AND d.triggerid_down=' . $_REQUEST['triggerid']);
            while ($trig = DBfetch($trigs)) {
                if (uint_in_array($trig['triggerid'], $dependencies)) {
                    continue;
                }
                array_push($dependencies, $trig['triggerid']);
            }
        }
    }
    $frmTrig->addRow(S_NAME, new CTextBox('description', $description, 90, $limited));
    if ($input_method == IM_TREE) {
        $alz = analyze_expression($expression);
        if ($alz !== false) {
            list($outline, $eHTMLTree) = $alz;
            if (isset($_REQUEST['expr_action']) && $eHTMLTree != null) {
                $new_expr = remake_expression($expression, $_REQUEST['expr_target_single'], $_REQUEST['expr_action'], $expr_temp);
                if ($new_expr !== false) {
                    $expression = $new_expr;
                    $alz = analyze_expression($expression);
                    if ($alz !== false) {
                        list($outline, $eHTMLTree) = $alz;
                    } else {
                        show_messages(false, '', S_EXPRESSION_SYNTAX_ERROR);
                    }
                    $expr_temp = '';
                } else {
                    show_messages(false, '', S_EXPRESSION_SYNTAX_ERROR);
                }
            }
            $frmTrig->addVar('expression', $expression);
            $exprfname = 'expr_temp';
            $exprtxt = new CTextBox($exprfname, $expr_temp, 65, 'yes');
            $macrobtn = new CButton('insert_macro', S_INSERT_MACRO, 'return call_ins_macro_menu(event);');
            //disabling button, if this trigger is templated
            if ($limited == 'yes') {
                $macrobtn->setAttribute('disabled', 'disabled');
            }
            $exprparam = "this.form.elements['{$exprfname}'].value";
        } else {
            show_messages(false, '', S_EXPRESSION_SYNTAX_ERROR);
            $input_method = IM_ESTABLISHED;
        }
    }
    if ($input_method != IM_TREE) {
        $exprfname = 'expression';
        $exprtxt = new CTextBox($exprfname, $expression, 75, $limited);
        $exprparam = "getSelectedText(this.form.elements['{$exprfname}'])";
    }
    $add_expr_button = new CButton('insert', $input_method == IM_TREE ? S_EDIT : S_ADD, "return PopUp('popup_trexpr.php?dstfrm=" . $frmTrig->getName() . "&dstfld1={$exprfname}&srctbl=expression" . "&srcfld1=expression&expression=' + escape({$exprparam}),1000,700);");
    //disabling button, if this trigger is templated
    if ($limited == 'yes') {
        $add_expr_button->setAttribute('disabled', 'disabled');
    }
    $row = array($exprtxt, $add_expr_button);
    if (isset($macrobtn)) {
        array_push($row, $macrobtn);
    }
    if ($input_method == IM_TREE) {
        array_push($row, BR());
        if (empty($outline)) {
            $tmpbtn = new CButton('add_expression', S_ADD, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
        } else {
            $tmpbtn = new CButton('and_expression', S_AND_BIG, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
            $tmpbtn = new CButton('or_expression', S_OR_BIG, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
            $tmpbtn = new CButton('replace_expression', S_REPLACE, "");
            if ($limited == 'yes') {
                $tmpbtn->setAttribute('disabled', 'disabled');
            }
            array_push($row, $tmpbtn);
        }
    }
    $frmTrig->addVar('input_method', $input_method);
    $frmTrig->addVar('toggle_input_method', '');
    $exprtitle = array(S_EXPRESSION);
    if ($input_method != IM_FORCED) {
        $btn_im = new CSpan(S_TOGGLE_INPUT_METHOD, 'link');
        $btn_im->setAttribute('onclick', 'javascript: ' . "document.getElementById('toggle_input_method').value=1;" . "document.getElementById('input_method').value=" . ($input_method == IM_TREE ? IM_ESTABLISHED : IM_TREE) . ';' . "document.forms['" . $frmTrig->getName() . "'].submit();");
        $exprtitle[] = array(SPACE, '(', $btn_im, ')');
    }
    $frmTrig->addRow($exprtitle, $row);
    if ($input_method == IM_TREE) {
        $exp_table = new CTable();
        $exp_table->setClass('tableinfo');
        $exp_table->setAttribute('id', 'exp_list');
        $exp_table->setOddRowClass('even_row');
        $exp_table->setEvenRowClass('even_row');
        $exp_table->setHeader(array($limited == 'yes' ? null : S_TARGET, S_EXPRESSION, S_EXPRESSION_PART_ERROR, $limited == 'yes' ? null : S_DELETE));
        $allowedTesting = true;
        if ($eHTMLTree != null) {
            foreach ($eHTMLTree as $i => $e) {
                if ($limited != 'yes') {
                    $del_url = new CSpan(S_DELETE, 'link');
                    $del_url->setAttribute('onclick', 'javascript: if(confirm("' . S_DELETE_EXPRESSION_Q . '")) {' . ' delete_expression(\'' . $e['id'] . '\');' . ' document.forms["config_triggers.php"].submit(); ' . '}');
                    $tgt_chk = new CCheckbox('expr_target_single', $i == 0 ? 'yes' : 'no', 'check_target(this);', $e['id']);
                } else {
                    $tgt_chk = null;
                }
                if (!isset($e['expression']['levelErrors'])) {
                    $errorImg = new CImg('images/general/ok_icon.png', 'expression_no_errors');
                    $errorImg->setHint(S_EXPRESSION_PART_NO_ERROR, '', '', false);
                } else {
                    $allowedTesting = false;
                    $errorImg = new CImg('images/general/error_icon.png', 'expression_errors');
                    $errorTexts = array();
                    if (is_array($e['expression']['levelErrors'])) {
                        foreach ($e['expression']['levelErrors'] as $expVal => $errTxt) {
                            if (count($errorTexts) > 0) {
                                array_push($errorTexts, BR());
                            }
                            array_push($errorTexts, $expVal, ':', $errTxt);
                        }
                    }
                    $errorImg->setHint($errorTexts, '', 'left', false);
                }
                //if it is a templated trigger
                if ($limited == 'yes') {
                    //make all links inside inactive
                    for ($i = 0; $i < count($e['list']); $i++) {
                        if (gettype($e['list'][$i]) == 'object' && get_class($e['list'][$i]) == 'CSpan' && $e['list'][$i]->getAttribute('class') == 'link') {
                            $e['list'][$i]->setClass('');
                            $e['list'][$i]->setAttribute('onclick', '');
                        }
                    }
                }
                $errorCell = new CCol($errorImg, 'center');
                $row = new CRow(array($tgt_chk, $e['list'], $errorCell, isset($del_url) ? $del_url : null));
                $exp_table->addRow($row);
            }
        } else {
            $allowedTesting = false;
            $outline = '';
        }
        $frmTrig->addVar('remove_expression', '');
        $btn_test = new CButton('test_expression', S_TEST, "openWinCentered(" . "'tr_testexpr.php?expression=' + encodeURIComponent(this.form.elements['expression'].value)" . ",'ExpressionTest'" . ",850,400" . ",'titlebar=no, resizable=yes, scrollbars=yes');" . "return false;");
        if (!isset($allowedTesting) || !$allowedTesting) {
            $btn_test->setAttribute('disabled', 'disabled');
        }
        if (empty($outline)) {
            $btn_test->setAttribute('disabled', 'yes');
        }
        //SDI($outline);
        $wrapOutline = new CSpan(array($outline));
        $wrapOutline->addStyle('white-space: pre;');
        $frmTrig->addRow(SPACE, array($wrapOutline, BR(), BR(), $exp_table, $btn_test));
    }
    // dependencies
    foreach ($dependencies as $val) {
        array_push($dep_el, array(new CCheckBox('rem_dependence[' . $val . ']', 'no', null, strval($val)), expand_trigger_description($val)), BR());
        $frmTrig->addVar('dependencies[]', strval($val));
    }
    if (count($dep_el) == 0) {
        array_push($dep_el, S_NO_DEPENDENCES_DEFINED);
    } else {
        array_push($dep_el, new CButton('del_dependence', S_DELETE_SELECTED));
    }
    $frmTrig->addRow(S_THE_TRIGGER_DEPENDS_ON, $dep_el);
    /* end dependencies */
    /* new dependency */
    //		$frmTrig->addVar('new_dependence','0');
    //		$txtCondVal = new CTextBox('trigger','',75,'yes');
    $btnSelect = new CButton('btn1', S_ADD, "return PopUp('popup.php?srctbl=triggers" . '&srcfld1=triggerid' . '&reference=deptrigger' . '&multiselect=1' . "',1000,700);", 'T');
    $frmTrig->addRow(S_NEW_DEPENDENCY, $btnSelect, 'new');
    // end new dependency
    $type_select = new CComboBox('type');
    $type_select->additem(TRIGGER_MULT_EVENT_DISABLED, S_NORMAL, $type == TRIGGER_MULT_EVENT_ENABLED ? 'no' : 'yes');
    $type_select->additem(TRIGGER_MULT_EVENT_ENABLED, S_NORMAL . SPACE . '+' . SPACE . S_MULTIPLE_PROBLEM_EVENTS, $type == TRIGGER_MULT_EVENT_ENABLED ? 'yes' : 'no');
    $frmTrig->addRow(S_EVENT_GENERATION, $type_select);
    $cmbPrior = new CComboBox('priority', $priority);
    for ($i = 0; $i <= 5; $i++) {
        $cmbPrior->addItem($i, get_severity_description($i));
    }
    $frmTrig->addRow(S_SEVERITY, $cmbPrior);
    $frmTrig->addRow(S_COMMENTS, new CTextArea("comments", $comments, 90, 7));
    $frmTrig->addRow(S_URL, new CTextBox("url", $url, 90));
    $frmTrig->addRow(S_DISABLED, new CCheckBox("status", $status));
    $frmTrig->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["triggerid"])) {
        $frmTrig->addItemToBottomRow(SPACE);
        $frmTrig->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmTrig->addItemToBottomRow(SPACE);
        if (!$limited) {
            $frmTrig->addItemToBottomRow(new CButtonDelete(S_DELETE_TRIGGER_Q, url_param("form") . url_param('groupid') . url_param("hostid") . url_param("triggerid")));
        }
    }
    $frmTrig->addItemToBottomRow(SPACE);
    $frmTrig->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid")));
    $jsmenu = new CPUMenu(null, 170);
    $jsmenu->InsertJavaScript();
    $script = "function addPopupValues(list){\n\t\t\t\t\t\tif(!isset('object', list)) return false;\n\n\t\t\t\t\t\tif(list.object == 'deptrigger'){\n\t\t\t\t\t\t\tfor(var i=0; i < list.values.length; i++){\n\t\t\t\t\t\t\t\tcreate_var('" . $frmTrig->getName() . "', 'new_dependence['+i+']', list.values[i], false);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcreate_var('" . $frmTrig->getName() . "','add_dependence', 1, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}";
    insert_js($script);
    return $frmTrig;
}
Пример #12
0
$descItem = "";
while ($row_extra = DBfetch($result)) {
    $descricao = $row_extra['name'];
    if (strpos($descricao, "\$") !== false) {
        $tmp = explode("[", $row_extra['key_']);
        $tmp = explode(",", str_replace("]", "", $tmp[1]));
        for ($i = 0; $i < count($tmp); $i++) {
            $descricao = str_replace("\$" . ($i + 1), $tmp[$i], $descricao);
        }
    }
    $descItem = $row_extra['id'] == $itemid ? $descricao : $descItem;
    $cmbItems->additem($row_extra['id'], $descricao);
}
// Combo com os formatos de exibição
$cmbReportType = new CComboBox('reportType', $reportType, 'javascript: submit();');
$cmbReportType->additem('html', 'HTML');
$cmbReportType->additem('csv', 'CSV');
$tituloGrafico = valorCampo('select name as id from hosts where hostid = ' . $hostid, 'id') . " - " . $descItem;
// FIM Combos de filtro =========================================================
$hostprof_wdgt->addHeader($titulo, array());
$filter_table = new CTable('', 'filter_config');
$filter_table->setAttribute('border', 0);
$filter_table->setAttribute('width', '100%');
// Idenfifica se o padrão foi informado para pesquisar ==========================================
$completo = $keyStandard !== '';
/*----------- Implementa o Filtro ---------------*/
$filter_table->addItem(new CDiv(_('Wizard'), 'thin_header'));
// Search standard
$filter_table->addRow(array(array(bold(_('Group')), ': ', $cmbGroups), array(bold(_('Host')), ': ', $cmbHosts), exibeConteudo($hostid > 0, array(bold(_('Application')), ': ', $cmbApplications)), exibeConteudo($applicationid > 0, array(bold(_('Item')), ': ', $cmbItems)), array()));
$filter_table2 = new CTable('', 'filter_config');
// Place to run the search