Example #1
0
 public function get($caption_l = S_IN, $caption_r = S_OTHER)
 {
     $grp_tab = new CTable();
     $grp_tab->addOption('name', $this->name);
     $grp_tab->addOption('id', $this->name);
     $grp_tab->setCellSpacing(0);
     $grp_tab->setCellPadding(0);
     if (!is_null($caption_l) || !is_null($caption_r)) {
         $grp_tab->addRow(array($caption_l, SPACE, $caption_r));
     }
     $add_btn = new CButton('add', ' « ');
     //S_ADD);//
     $add_btn->setType('button');
     $add_btn->setAction('javascript: moveListBoxSelectedItem("' . $this->form->GetName() . '","' . $this->varname . '","' . $this->id_r . '","' . $this->id_l . '","add");');
     $rmv_btn = new CButton('remove', ' » ');
     //S_REMOVE);//
     $rmv_btn->setType('button');
     $rmv_btn->setAction('javascript: moveListBoxSelectedItem("' . $this->form->GetName() . '","' . $this->varname . '","' . $this->id_l . '","' . $this->id_r . '","rmv");');
     $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox));
     return $grp_tab;
 }
Example #2
0
$fs_icon = new CDiv(SPACE, 'fullscreen');
$fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
$fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';"));
//-------
$left_tab = new CTable();
$left_tab->setCellPadding(3);
$left_tab->setCellSpacing(3);
$left_tab->addOption('border', 0);
$left_tab->addRow(create_hat(S_EVENT . SPACE . S_SOURCE . SPACE . S_DETAILS, make_trigger_details($_REQUEST['triggerid'], $trigger_data), null, 'hat_triggerdetails'));
$left_tab->addRow(create_hat(S_EVENT_DETAILS, make_event_details($_REQUEST['eventid']), null, 'hat_eventdetails'));
$right_tab = new CTable();
$right_tab->setCellPadding(3);
$right_tab->setCellSpacing(3);
$right_tab->addOption('border', 0);
$right_tab->addRow(create_hat(S_ACKNOWLEDGES, make_acktab_by_eventid($_REQUEST['eventid']), null, 'hat_eventack', get_profile('web.tr_events.hats.hat_eventack.state', 1)));
$right_tab->addRow(create_hat(S_MESSAGE_ACTIONS, get_action_msgs_for_event($_REQUEST['eventid']), null, 'hat_eventactionmsgs', get_profile('web.tr_events.hats.hat_eventactionmsgs.state', 1)));
$right_tab->addRow(create_hat(S_COMMAND_ACTIONS, get_action_cmds_for_event($_REQUEST['eventid']), null, 'hat_eventactioncmds', get_profile('web.tr_events.hats.hat_eventactioncmds.state', 1)));
$right_tab->addRow(create_hat(S_EVENTS . SPACE . S_LIST . SPACE . '[' . S_LAST . ' 20]', make_small_eventlist($_REQUEST['triggerid'], $trigger_data), null, 'hat_eventlist', get_profile('web.tr_events.hats.hat_eventlist.state', 1)));
$td_l = new CCol($left_tab);
$td_l->addOption('valign', 'top');
$td_r = new CCol($right_tab);
$td_r->addOption('valign', 'top');
$outer_table = new CTable();
$outer_table->addOption('border', 0);
$outer_table->setCellPadding(1);
$outer_table->setCellSpacing(1);
$outer_table->addRow(array($td_l, $td_r));
$p_elements[] = $outer_table;
$latest_hat = create_hat($text, $p_elements, array($fs_icon), 'hat_tr_events', get_profile('web.tr_events.hats.hat_tr_events.state', 1));
$latest_hat->show();
include_once 'include/page_footer.php';
Example #3
0
     $frmMaintenance->addVar('maintenanceid', $_REQUEST['maintenanceid']);
 }
 $left_tab = new CTable();
 $left_tab->setCellPadding(3);
 $left_tab->setCellSpacing(3);
 $left_tab->addOption('border', 0);
 $left_tab->addRow(create_hat(S_MAINTENANCE, get_maintenance_form(), null, 'hat_maintenance'));
 $left_tab->addRow(create_hat(S_MAINTENANCE_PERIODS, get_maintenance_periods(), null, 'hat_timeperiods'));
 if (isset($_REQUEST['new_timeperiod'])) {
     $new_timeperiod = $_REQUEST['new_timeperiod'];
     $left_tab->addRow(create_hat(is_array($new_timeperiod) && isset($new_timeperiod['id']) ? S_EDIT_MAINTENANCE_PERIOD : S_NEW_MAINTENANCE_PERIOD, get_timeperiod_form(), null, 'hat_new_timeperiod'));
 }
 $right_tab = new CTable();
 $right_tab->setCellPadding(3);
 $right_tab->setCellSpacing(3);
 $right_tab->addOption('border', 0);
 $right_tab->addRow(create_hat(S_HOSTS_IN_MAINTENANCE, get_maintenance_hosts_form($frmMaintenance), null, 'hat_host_link'));
 $right_tab->addRow(create_hat(S_GROUPS_IN_MAINTENANCE, get_maintenance_groups_form($frmMaintenance), null, 'hat_group_link'));
 $td_l = new CCol($left_tab);
 $td_l->addOption('valign', 'top');
 $td_r = new CCol($right_tab);
 $td_r->addOption('valign', 'top');
 $outer_table = new CTable();
 $outer_table->addOption('border', 0);
 $outer_table->setCellPadding(1);
 $outer_table->setCellSpacing(1);
 $outer_table->addRow(array($td_l, $td_r));
 $frmMaintenance->additem($outer_table);
 show_messages();
 $frmMaintenance->show();
 //			insert_maintenance_form();
Example #4
0
 $color = get_request('color', '009900');
 $report_timesince = get_request('report_timesince', time() - 86400);
 $report_timetill = get_request('report_timetill', time());
 $frmPd->addVar('config', $config);
 $frmPd->addVar('report_timesince', $report_timesince);
 $frmPd->addVar('report_timetill', $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', S_DEFAULT), S_CAPTION), new CTextBox('caption', $caption, 10));
 //		$frmPd->addRow(S_CAPTION, new CTextBox('caption',$caption,10));
 //*
 $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 = new CTable(null, 'calendar');
 $reporttimetab->addOption('width', '10%');
 $reporttimetab->setCellPadding(0);
 $reporttimetab->setCellSpacing(0);
 $reporttimetab->addRow(array(S_FROM, 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));
 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");');
 $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(S_TILL, 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_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
 $frmPd->addRow(S_PERIOD, $reporttimetab);
 //*/
 if ($config != 1) {
     $frmPd->addRow(S_COLOR, new CColor('color', $color));
 } else {
     $frmPd->addVar('color', $color);
 }
 $frmPd->addItemToBottomRow(new CButton('save', isset($_REQUEST['period_id']) ? S_UPDATE : S_ADD));
Example #5
0
function create_filter($col_l, $col_r, $items, $id = 'zbx_filter', $state = 1)
{
    if (isset($_REQUEST['print'])) {
        $state = 0;
    }
    $table = new CTable();
    $table->addOption('width', '100%');
    $table->setCellPadding(0);
    $table->setCellSpacing(0);
    $table->addOption('border', 0);
    $icon = new CDiv(SPACE, $state ? 'filteropened' : 'filterclosed');
    $icon->addAction('onclick', new CScript("javascript: change_filter_state(this,'" . $id . "');"));
    $icon->addOption('title', S_MAXIMIZE . '/' . S_MINIMIZE);
    $icon->addAction('id', 'filter_icon');
    $td_icon = new CCol($icon);
    $td_icon->addOption('valign', 'bottom');
    $icons_row = array($td_icon, SPACE);
    $icons_row[] = $col_l;
    $icon_tab = new CTable();
    $icon_tab->setCellSpacing(0);
    $icon_tab->setCellPadding(0);
    $icon_tab->addRow($icons_row);
    $table->addRow(get_thin_table_header($icon_tab, $col_r));
    $div = new CDiv($items);
    $div->addOption('id', $id);
    if (!$state) {
        $div->addOption('style', 'display: none;');
    }
    $tab = new CTable();
    $tab->addRow($div);
    //		$table->addRow($tab);
    $table->addRow($div);
    return $table;
}
Example #6
0
function show_messages($bool = TRUE, $okmsg = NULL, $errmsg = NULL)
{
    global $page, $ZBX_MESSAGES;
    if (!defined('PAGE_HEADER_LOADED')) {
        return;
    }
    if (!isset($page["type"])) {
        $page["type"] = PAGE_TYPE_HTML;
    }
    $message = array();
    $width = 0;
    $height = 0;
    $img_space = null;
    if (!$bool && !is_null($errmsg)) {
        $msg = 'ERROR: ' . $errmsg;
    } else {
        if ($bool && !is_null($okmsg)) {
            $msg = $okmsg;
        }
    }
    if (isset($msg)) {
        switch ($page['type']) {
            case PAGE_TYPE_IMAGE:
                array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2));
                $width = max($width, ImageFontWidth(2) * strlen($msg) + 1);
                $height += imagefontheight(2) + 1;
                break;
            case PAGE_TYPE_XML:
                echo htmlspecialchars($msg) . "\n";
                break;
            case PAGE_TYPE_HTML:
            default:
                $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr');
                $msg_tab->setCellPadding(0);
                $msg_tab->setCellSpacing(0);
                $msg_col = new CCol(bold($msg), 'msg_main msg');
                $msg_col->addOption('id', 'page_msg');
                $msg_details = SPACE;
                if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
                    $msg_details = new CDiv(array(S_DETAILS), 'pointer');
                    $msg_details->addAction('onclick', new CScript("javascript: ShowHide('msg_messages', IE?'block':'table');"));
                    $msg_details->addOption('title', S_MAXIMIZE . '/' . S_MINIMIZE);
                }
                $msg_tab->addRow(array(new CCol($msg_details, 'clr'), $msg_col));
                $msg_tab->Show();
                $img_space = new CImg('images/general/tree/zero.gif', 'space', '100', '2');
                break;
        }
    }
    if (isset($ZBX_MESSAGES)) {
        if ($page['type'] == PAGE_TYPE_IMAGE) {
            $msg_font = 2;
            foreach ($ZBX_MESSAGES as $msg) {
                if ($msg['type'] == 'error') {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font));
                } else {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font));
                }
                $width = max($width, imagefontwidth($msg_font) * strlen($msg['message']) + 1);
                $height += imagefontheight($msg_font) + 1;
            }
        } else {
            if ($page['type'] == PAGE_TYPE_XML) {
                foreach ($ZBX_MESSAGES as $msg) {
                    echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n";
                }
            } else {
                $lst_error = new CList(null, 'messages');
                foreach ($ZBX_MESSAGES as $msg) {
                    $lst_error->addItem($msg['message'], $msg['type']);
                    $bool = $bool && 'error' != strtolower($msg['type']);
                }
                //message scroll if needed
                $msg_show = 6;
                $msg_count = count($ZBX_MESSAGES);
                if ($msg_count > $msg_show) {
                    $msg_count = $msg_show;
                    $msg_count = $msg_count * 16;
                    $lst_error->addOption('style', 'height: ' . $msg_count . 'px;');
                }
                $tab = new CTable(null, $bool ? 'msgok' : 'msgerr');
                $tab->setCellPadding(0);
                $tab->setCellSpacing(0);
                $tab->addOption('id', 'msg_messages');
                $tab->addOption('style', 'width: 100%;');
                if (isset($msg_tab) && $bool) {
                    $tab->addOption('style', 'display: none;');
                }
                $tab->addRow(new CCol($lst_error, 'msg'));
                $tab->Show();
                //---
            }
        }
        $ZBX_MESSAGES = null;
    }
    if (!is_null($img_space)) {
        print unpack_object($img_space);
    }
    if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) {
        $width += 2;
        $height += 2;
        $canvas = imagecreate($width, $height);
        imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255));
        foreach ($message as $id => $msg) {
            $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0);
            $message[$id]['h'] = imagefontheight($msg['font']);
            imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']));
            $previd = $id;
        }
        imageOut($canvas);
        imagedestroy($canvas);
    }
}
Example #7
0
function insert_map_link_form()
{
    $frmCnct = new CFormTable('New connector', 'sysmap.php');
    $frmCnct->SetHelp('web.sysmap.connector.php');
    $frmCnct->addVar('sysmapid', $_REQUEST['sysmapid']);
    if (isset($_REQUEST['linkid']) && !isset($_REQUEST['form_refresh'])) {
        $frmCnct->addVar('linkid', $_REQUEST['linkid']);
        $db_links = DBselect('SELECT * FROM sysmaps_links WHERE linkid=' . $_REQUEST['linkid']);
        $db_link = DBfetch($db_links);
        $selementid1 = $db_link['selementid1'];
        $selementid2 = $db_link['selementid2'];
        $triggers = array();
        $drawtype = $db_link['drawtype'];
        $color = $db_link['color'];
        $res = DBselect('SELECT * FROM sysmaps_link_triggers WHERE linkid=' . $_REQUEST['linkid']);
        while ($rows = DBfetch($res)) {
            $triggers[] = $rows;
        }
    } else {
        if (isset($_REQUEST['linkid'])) {
            $frmCnct->addVar('linkid', $_REQUEST['linkid']);
        }
        $selementid1 = get_request('selementid1', 0);
        $selementid2 = get_request('selementid2', 0);
        $triggers = get_request('triggers', array());
        $drawtype = get_request('drawtype', 0);
        $color = get_request('color', 0);
    }
    /* START comboboxes preparations */
    $cmbElements1 = new CComboBox('selementid1', $selementid1);
    $cmbElements2 = new CComboBox('selementid2', $selementid2);
    $db_selements = DBselect('SELECT selementid,label,elementid,elementtype ' . ' FROM sysmaps_elements ' . ' WHERE sysmapid=' . $_REQUEST['sysmapid']);
    while ($db_selement = DBfetch($db_selements)) {
        $label = $db_selement['label'];
        if ($db_selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) {
            $db_host = get_host_by_hostid($db_selement['elementid']);
            $label .= ':' . $db_host['host'];
        } else {
            if ($db_selement['elementtype'] == SYSMAP_ELEMENT_TYPE_MAP) {
                $db_map = get_sysmap_by_sysmapid($db_selement['elementid']);
                $label .= ':' . $db_map['name'];
            } else {
                if ($db_selement['elementtype'] == SYSMAP_ELEMENT_TYPE_TRIGGER) {
                    if ($db_selement['elementid'] > 0) {
                        $label .= ':' . expand_trigger_description($db_selement['elementid']);
                    }
                } else {
                    if ($db_selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST_GROUP) {
                        if ($db_selement['elementid'] > 0) {
                            $db_group = DBfetch(DBselect('SELECT name FROM groups WHERE groupid=' . $db_selement['elementid']));
                            $label .= ':' . $db_group['name'];
                        }
                    }
                }
            }
        }
        $cmbElements1->addItem($db_selement['selementid'], $label);
        $cmbElements2->addItem($db_selement['selementid'], $label);
    }
    $cmbType = new CComboBox('drawtype', $drawtype);
    foreach (map_link_drawtypes() as $i) {
        $value = map_link_drawtype2str($i);
        $cmbType->addItem($i, $value);
    }
    /* END preparation */
    $frmCnct->addRow(S_ELEMENT_1, $cmbElements1);
    $frmCnct->addRow(S_ELEMENT_2, $cmbElements2);
    //trigger links
    foreach ($triggers as $id => $trigger) {
        if (isset($trigger['triggerid'])) {
            $triggers[$id]['description'] = expand_trigger_description($trigger['triggerid']);
        }
    }
    $table = new CTable();
    $table->SetClass('tableinfo');
    $table->setOddRowClass('even_row');
    $table->setEvenRowClass('even_row');
    $table->options['cellpadding'] = 3;
    $table->options['cellspacing'] = 1;
    $table->headerClass = 'header';
    $table->footerClass = 'footer';
    $table->SetHeader(array(new CCheckBox('all_triggers', null, "CheckAll('" . $frmCnct->GetName() . "','all_triggers','triggers');"), S_TRIGGERS, S_TYPE, S_COLOR));
    $table->addOption('id', 'link_triggers');
    foreach ($triggers as $id => $trigger) {
        if (!isset($trigger['triggerid'])) {
            continue;
        }
        $colorbox = new CSpan(SPACE . SPACE . SPACE);
        $colorbox->addOption('style', 'text-decoration: none; outline-color: black; outline-style: solid; outline-width: 1px; background-color: #' . $trigger['color'] . ';');
        $table->addRow(array(array(new CCheckBox('triggers[' . $trigger['triggerid'] . '][triggerid]', null, null, $trigger['triggerid']), new CVar('triggers[' . $trigger['triggerid'] . '][triggerid]', $trigger['triggerid'])), array(new CLink($trigger['description'], "javascript: openWinCentered('popup_link_tr.php?form=1&dstfrm=" . $frmCnct->GetName() . "&triggerid=" . $trigger['triggerid'] . url_param('linkid') . "','ZBX_Link_Indicator',560,260,'scrollbars=1, toolbar=0, menubar=0, resizable=0');"), new CVar('triggers[' . $trigger['triggerid'] . '][description]', $trigger['description'])), array(map_link_drawtype2str($trigger['drawtype']), new CVar('triggers[' . $trigger['triggerid'] . '][drawtype]', $trigger['drawtype'])), array($colorbox, new CVar('triggers[' . $trigger['triggerid'] . '][color]', $trigger['color']))));
    }
    $btnadd = new CButton('btn1', S_ADD, "javascript: openWinCentered('popup_link_tr.php?form=1&dstfrm=" . $frmCnct->GetName() . url_param('linkid') . "','ZBX_Link_Indicator',560,180,'scrollbars=1, toolbar=0, menubar=0, resizable=0');", 'T');
    $btnRemove = new CButton('btn1', S_REMOVE, "javascript: remove_childs('" . $frmCnct->GetName() . "','triggers','tr');", 'T');
    $btnadd->SetType('button');
    $frmCnct->addRow(S_LINK_STATUS_INDICATORS, array($table, BR(), $btnadd, $btnRemove));
    //----------
    $frmCnct->addRow(S_TYPE . ' (' . S_OK_BIG . ')', $cmbType);
    $frmCnct->addRow(S_COLOR . ' (' . S_OK_BIG . ')', new CColor('color', $color));
    $frmCnct->addItemToBottomRow(new CButton("save_link", S_SAVE));
    if (isset($_REQUEST["linkid"])) {
        $frmCnct->addItemToBottomRow(SPACE);
        $frmCnct->addItemToBottomRow(new CButtonDelete("Delete link?", url_param("linkid") . url_param("sysmapid")));
    }
    $frmCnct->addItemToBottomRow(SPACE);
    $frmCnct->addItemToBottomRow(new CButtonCancel(url_param("sysmapid")));
    $frmCnct->Show();
}
Example #8
0
function bar_report_form3()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY);
    $config = get_request('config', 1);
    $title = get_request('title', 'Report 2');
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $sorttype = get_request('sorttype', 0);
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', time() - 86400);
    $report_timetill = get_request('report_timetill', time());
    $captions = get_request('captions', array());
    $items = get_request('items', array());
    $hostids = get_request('hostids', array());
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(S_REPORTS, null, 'get');
    //,'events.php?report_set=1','POST',null,'sform');
    $reportForm->addOption('name', 'zbx_report');
    $reportForm->addOption('id', 'zbx_report');
    //	$reportForm->setMethod('post');
    if (isset($_REQUEST['report_show']) && !empty($items)) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', $report_timesince > 0 ? $report_timesince : '');
    $reportForm->addVar('report_timetill', $report_timetill > 0 ? $report_timetill : '');
    //	$reportForm->addVar('items',$items); 				//params are set later!!
    //	$reportForm->addVar('periods',$periods);
    $reportForm->addRow(S_TITLE, new CTextBox('title', $title, 40));
    $reportForm->addRow(S_X . SPACE . S_LABEL, new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(S_Y . SPACE . S_LABEL, new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(S_LEGEND, new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    // GROUPS
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', null, 10);
    $sql_from = '';
    $sql_where = 'AND ' . DBcondition('g.groupid', $groupids);
    $sql = 'SELECT DISTINCT g.groupid, g.name ' . ' FROM hosts h, hosts_groups hg, groups g ' . $sql_from . ' WHERE hg.groupid=g.groupid' . ' AND h.hostid=hg.hostid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . $sql_where . ' ORDER BY g.name';
    //SDI($sql);
    $db_groups = DBselect($sql);
    while ($group = DBfetch($db_groups)) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name'], true);
    }
    $sql = 'SELECT DISTINCT g.* ' . ' FROM hosts h, hosts_groups hg, groups g ' . ' WHERE hg.groupid=g.groupid' . ' AND h.hostid=hg.hostid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND ' . DBcondition('g.groupid', $groupids, true) . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' ORDER BY g.name';
    $db_groups = DBselect($sql);
    while ($group = DBfetch($db_groups)) {
        $group_tb->addItem($group['groupid'], $group['name'], false);
    }
    $reportForm->addRow(S_GROUPS, $group_tb->Get(S_SELECTED_GROUPS, S_OTHER . SPACE . S_GROUPS));
    // ----------
    // HOSTS
    //	validate_group(PERM_READ_ONLY,array('real_hosts'),'web.last.conf.groupid');
    $cmbGroups = new CComboBox('groupid', get_request('groupid', 0), 'submit()');
    $cmbGroups->addItem(0, S_ALL_S);
    $sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g,hosts_groups hg,hosts h ' . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND g.groupid=hg.groupid ' . ' AND h.hostid=hg.hostid' . ' AND h.status IN (' . HOST_STATUS_MONITORED . ') ' . ' ORDER BY g.name';
    $result = DBselect($sql);
    while ($row = DBfetch($result)) {
        $cmbGroups->addItem($row['groupid'], $row['name']);
    }
    $td_groups = new CCol(array(S_GROUP, SPACE, $cmbGroups));
    $td_groups->addOption('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', null, 10);
    $sql_from = '';
    $sql_where = 'AND ' . DBcondition('h.hostid', $hostids);
    $sql = 'SELECT DISTINCT h.hostid, h.host ' . ' FROM hosts h ' . $sql_from . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . $sql_where . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' ORDER BY h.host';
    $db_hosts = DBselect($sql);
    while ($host = DBfetch($db_hosts)) {
        $hostids[$host['hostid']] = $host['hostid'];
        $host_tb->addItem($host['hostid'], $host['host'], true);
    }
    $sql_from = '';
    $sql_where = '';
    if (isset($_REQUEST['groupid']) && $_REQUEST['groupid'] > 0) {
        $sql_from .= ', hosts_groups hg ';
        $sql_where .= ' AND hg.groupid=' . $_REQUEST['groupid'] . ' AND h.hostid=hg.hostid ';
    }
    $sql = 'SELECT DISTINCT h.* ' . ' FROM hosts h ' . $sql_from . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND ' . DBcondition('h.hostid', $hostids, true) . ' AND h.status IN (' . HOST_STATUS_MONITORED . ') ' . $sql_where . ' ORDER BY h.host';
    $db_hosts = DBselect($sql);
    while ($host = DBfetch($db_hosts)) {
        $host_tb->addItem($host['hostid'], $host['host'], false);
    }
    $reportForm->addRow(S_HOSTS, $host_tb->Get(S_SELECTED_HOSTS, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups)));
    // ----------
    //*/
    // PERIOD
    $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 = new CTable(null, 'calendar');
    $reporttimetab->addOption('width', '10%');
    $reporttimetab->setCellPadding(0);
    $reporttimetab->setCellSpacing(0);
    $reporttimetab->addRow(array(S_FROM, 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));
    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");');
    $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(S_TILL, 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_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
    zbx_add_post_js('addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
    $reportForm->addRow(S_PERIOD, $reporttimetab);
    //-----------
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, S_HOURLY);
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY);
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY);
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY);
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, S_YEARLY);
    $reportForm->addRow(S_SCALE, $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, S_HOURLY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, S_YEARLY);
    $reportForm->addRow(S_AVERAGE_BY, $avgcmb);
    // ITEMS
    $itemid = 0;
    $description = '';
    if (count($items) && $items[0]['itemid'] > 0) {
        $itemid = $items[0]['itemid'];
        $description = get_item_by_itemid($itemid);
        $description = item_description($description);
    }
    $reportForm->addVar('items[0][itemid]', $itemid);
    $txtCondVal = new CTextBox('items[0][description]', $description, 50, 'yes');
    $btnSelect = new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $reportForm->GetName() . "&dstfld1=items[0][itemid]&dstfld2=items[0][description]&" . "srctbl=items&srcfld1=itemid&srcfld2=description&monitored_hosts=1');", 'T');
    $reportForm->addRow(S_ITEM, array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, S_PALETTE . ' #1');
    $paletteCmb->addItem(1, S_PALETTE . ' #2');
    $paletteCmb->addItem(2, S_PALETTE . ' #3');
    $paletteCmb->addItem(3, S_PALETTE . ' #4');
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, S_MIDDLE);
    $paletteTypeCmb->addItem(1, S_DARKEN);
    $paletteTypeCmb->addItem(2, S_BRIGHTEN);
    $reportForm->addRow(S_PALETTE, array($paletteCmb, $paletteTypeCmb));
    //--------------
    $reportForm->addItemToBottomRow(new CButton('report_show', S_SHOW));
    $reset = new CButton('reset', S_RESET);
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
Example #9
0
    $url = '?elementid=' . $elementid . ($_REQUEST['fullscreen'] ? '' : '&fullscreen=1');
    $url .= url_param('groupid') . url_param('hostid');
    $fs_icon = new CDiv(SPACE, 'fullscreen');
    $fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
    $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';"));
}
$menu = array();
$submenu = array();
// js menu arrays
make_refresh_menu('mainpage', 'hat_slides', get_profile('web.slides.rf_rate.hat_slides', 30), array('elementid' => $elementid), $menu, $submenu);
insert_js('var page_menu=' . zbx_jsvalue($menu) . ";\n" . 'var page_submenu=' . zbx_jsvalue($submenu) . ";\n");
// --------------
$tab = new CTable();
$tab->setCellPadding(0);
$tab->setCellSpacing(0);
$tab->addOption('border', 0);
$tab->addOption('width', '100%');
// Refresh tab
$refresh_tab = array(array('id' => 'hat_slides', 'frequency' => get_profile('web.slides.rf_rate.hat_slides', 30), 'url' => 'slides.php?elementid=' . $elementid . url_param('stime') . url_param('period') . url_param('groupid') . url_param('hostid'), 'params' => array('lastupdate' => time())));
add_doll_objects($refresh_tab);
$refresh_icon = new CDiv(SPACE, 'iconmenu');
$refresh_icon->addAction('onclick', 'javascript: create_page_menu(event,"hat_slides");');
$refresh_icon->addOption('title', S_MENU);
if (isset($elementid)) {
    $effectiveperiod = navigation_bar_calc();
    if (2 != $_REQUEST['fullscreen']) {
        $stime = time() - 31536000;
        // ~1year
        $bstime = time() - $effectiveperiod;
        if (isset($_REQUEST['stime'])) {
            $bstime = $_REQUEST['stime'];
Example #10
0
} else {
    if (isset($_REQUEST['hostid'])) {
        /************************* FILTER *************************/
        /***********************************************************/
        $filterForm = new CFormTable(S_FILTER);
        //,'events.php?filter_set=1','POST',null,'sform');
        $filterForm->AddOption('name', 'zbx_filter');
        $filterForm->AddOption('id', 'zbx_filter');
        //		$filterForm->SetMethod('post');
        $filterForm->addVar('filter_timesince', $_REQUEST['filter_timesince'] > 0 ? $_REQUEST['filter_timesince'] : '');
        $filterForm->addVar('filter_timetill', $_REQUEST['filter_timetill'] > 0 ? $_REQUEST['filter_timetill'] : '');
        //*
        $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);");
        $filtertimetab = new CTable(null, 'calendar');
        $filtertimetab->addOption('width', '10%');
        $filtertimetab->setCellPadding(0);
        $filtertimetab->setCellSpacing(0);
        $filtertimetab->addRow(array(S_FROM, new CNumericBox('filter_since_day', $_REQUEST['filter_timesince'] > 0 ? date('d', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_month', $_REQUEST['filter_timesince'] > 0 ? date('m', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_year', $_REQUEST['filter_timesince'] > 0 ? date('Y', $_REQUEST['filter_timesince']) : '', 4), SPACE, new CNumericBox('filter_since_hour', $_REQUEST['filter_timesince'] > 0 ? date('H', $_REQUEST['filter_timesince']) : '', 2), ':', new CNumericBox('filter_since_minute', $_REQUEST['filter_timesince'] > 0 ? date('i', $_REQUEST['filter_timesince']) : '', 2), $clndr_icon));
        zbx_add_post_js('create_calendar(null,' . '["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],' . '"avail_report_since",' . '"filter_timesince");');
        $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);");
        $filtertimetab->AddRow(array(S_TILL, new CNumericBox('filter_till_day', $_REQUEST['filter_timetill'] > 0 ? date('d', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_month', $_REQUEST['filter_timetill'] > 0 ? date('m', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_year', $_REQUEST['filter_timetill'] > 0 ? date('Y', $_REQUEST['filter_timetill']) : '', 4), SPACE, new CNumericBox('filter_till_hour', $_REQUEST['filter_timetill'] > 0 ? date('H', $_REQUEST['filter_timetill']) : '', 2), ':', new CNumericBox('filter_till_minute', $_REQUEST['filter_timetill'] > 0 ? date('i', $_REQUEST['filter_timetill']) : '', 2), $clndr_icon));
        zbx_add_post_js('create_calendar(null,' . '["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],' . '"avail_report_till",' . '"filter_timetill");');
        zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),"click",CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
        $filterForm->addRow(S_PERIOD, $filtertimetab);
        //*/
        $filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER));
        $reset = new CButton("filter_rst", S_RESET);
        $reset->SetType('button');
        $reset->SetAction('javascript: var url = new Curl(location.href); url.setArgument("filter_rst",1); location.href = url.getUrl();');
        $filterForm->addItemToBottomRow($reset);
Example #11
0
 private function makeRow($id)
 {
     $table = new CTable();
     $table->setCellSpacing(0);
     $table->setCellPadding(0);
     $table->addOption('border', '0');
     $table->addOption('height', '100%');
     $tr = $this->makeSImgStr($id);
     $td = new CCol($this->tree[$id]['caption']);
     $td->addOption('style', 'height: 100%; vertical-align: top; white-space: normal; padding-right: 10px; padding-left: 2px;');
     $tr->addItem($td);
     $table->addRow($tr);
     $tr = new CRow();
     $tr->addItem($table);
     $tr->addOption('id', 'id_' . $id);
     $tr->addOption('style', $this->tree[$id]['parentid'] != '0' ? 'display: none;' : '');
     foreach ($this->fields as $key => $value) {
         $td = new CCol($this->tree[$id][$value]);
         $td->addOption('style', ' padding-right: 10px; padding-left: 2px;');
         $tr->addItem($td);
     }
     return $tr;
 }
Example #12
0
 $cb = new CButton('select_parent', S_CHANGE);
 $cb->SetType('button');
 $cb->SetAction("javascript: openWinCentered('services_form.php?pservices=1" . url_param('serviceid') . "','ZBX_Services_List',740,420,'scrollbars=1, toolbar=0, menubar=0, resizable=1, dialog=0');");
 $frmService->AddRow('Parent Service', array($ctb, $cb));
 //----------
 //child links
 $table = new CTable();
 $table->setClass('tableinfo');
 $table->setOddRowClass('even_row');
 $table->setEvenRowClass('even_row');
 $table->options['cellpadding'] = 3;
 $table->options['cellspacing'] = 1;
 $table->headerClass = 'header';
 $table->footerClass = 'footer';
 $table->setHeader(array(new CCheckBox('all_child_services', null, "check_childs('" . $frmService->GetName() . "','childs','all_child_services');"), S_SERVICES, S_SOFT, S_TRIGGER));
 $table->addOption('id', 'service_childs');
 foreach ($childs as $id => $child) {
     $prefix = null;
     $trigger = '-';
     $description = new CLink($child['name'], 'services_form.php?sform=1&serviceid=' . $child['serviceid'], 'action');
     if (isset($child['triggerid']) && !empty($child['triggerid'])) {
         $trigger = expand_trigger_description($child['triggerid']);
     }
     $table->AddRow(array(array(new CCheckBox('childs_to_del[' . $child['serviceid'] . '][serviceid]', null, null, $child['serviceid']), new CVar('childs[' . $child['serviceid'] . '][serviceid]', $child['serviceid'])), array($description, new CVar('childs[' . $child['serviceid'] . '][name]', $child['name'])), new CCheckBox('childs[' . $child['serviceid'] . '][soft]', isset($child['soft']) && !empty($child['soft']) ? 'checked' : 'no', null, isset($child['soft']) && !empty($child['soft']) ? 1 : 0), array($trigger, new CVar('childs[' . $child['serviceid'] . '][triggerid]', isset($child['triggerid']) ? $child['triggerid'] : ''))));
 }
 $cb = new CButton('add_child_service', S_ADD);
 $cb->SetType('button');
 $cb->SetAction("javascript: openWinCentered('services_form.php?cservices=1" . url_param('serviceid') . "','ZBX_Services_List',640,520,'scrollbars=1, toolbar=0, menubar=0, resizable=0');");
 $cb2 = new CButton('del_child_service', S_REMOVE);
 $cb2->SetType('button');
 $cb2->SetAction("javascript: remove_childs('" . $frmService->GetName() . "','childs_to_del','tr');");
Example #13
0
         $node_form = new CForm();
         $node_form->addItem(array(new CSpan(S_CURRENT_NODE, 'textcolorstyles'), $lst_nodes));
         unset($lst_nodes);
         if (!defined('ZBX_DISABLE_SUBNODES')) {
             global $ZBX_WITH_SUBNODES;
             $cmd_show_subnodes = new CComboBox('show_subnodes', !empty($ZBX_WITH_SUBNODES) ? 1 : 0, 'submit()');
             $cmd_show_subnodes->addItem(0, S_CURRENT_NODE_ONLY);
             $cmd_show_subnodes->addItem(1, S_WITH_SUBNODES);
             $node_form->addItem(array(SPACE, new CSpan(S_SHOW, 'textcolorstyles'), $cmd_show_subnodes));
         }
     }
 }
 $table = new CTable();
 $table->setCellSpacing(0);
 $table->setCellPadding(0);
 $table->addOption('style', 'width: 100%;');
 $r_col = new CCol($node_form);
 $r_col->AddOption('align', 'right');
 //		$r_col->AddOption('style','text-align: right;');
 $table->addRow(array($menu_table, $r_col));
 $page_menu = new CDiv();
 $page_menu->addoption('id', 'mmenu');
 $page_menu->addItem($table);
 $menu_selected = false;
 foreach ($sub_menus as $label => $sub_menu) {
     $sub_menu_table = new CTable(NULL, 'sub_menu');
     $sub_menu_table->setCellSpacing(0);
     $sub_menu_table->setCellPadding(5);
     $sub_menu_row = array();
     foreach ($sub_menu as $id => $sub_page) {
         if (empty($sub_page['menu_text'])) {
Example #14
0
function get_screen($screenid, $editmode, $effectiveperiod = NULL)
{
    global $USER_DETAILS;
    if (!screen_accessible($screenid, $editmode == 1 ? PERM_READ_WRITE : PERM_READ_ONLY)) {
        access_deny();
    }
    if (is_null($effectiveperiod)) {
        $effectiveperiod = ZBX_MIN_PERIOD;
    }
    $result = DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid=' . $screenid);
    $row = DBfetch($result);
    if (!$row) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    for ($r = 0; $r < $row['vsize']; $r++) {
        for ($c = 0; $c < $row['hsize']; $c++) {
            if (isset($skip_field[$r][$c])) {
                continue;
            }
            $sql = 'SELECT * FROM screens_items WHERE screenid=' . $screenid . ' AND x=' . $c . ' AND y=' . $r;
            $iresult = DBSelect($sql);
            $irow = DBfetch($iresult);
            if ($irow) {
                $colspan = $irow['colspan'];
                $rowspan = $irow['rowspan'];
            } else {
                $colspan = 0;
                $rowspan = 0;
            }
            for ($i = 0; $i < $rowspan || $i == 0; $i++) {
                for ($j = 0; $j < $colspan || $j == 0; $j++) {
                    if ($i != 0 || $j != 0) {
                        $skip_field[$r + $i][$c + $j] = 1;
                    }
                }
            }
        }
    }
    $table = new CTable(new CLink('No rows in screen ' . $row['name'], 'screenconf.php?config=0&form=update&screenid=' . $screenid), $editmode == 0 || $editmode == 2 ? 'screen_view' : 'screen_edit');
    $table->addOption('id', 'iframe');
    if ($editmode == 1) {
        $add_col_link = 'screenedit.php?config=1&screenid=' . $screenid . '&add_col=';
        $new_cols = array(new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        for ($c = 0; $c < $row['hsize'] + 1; $c++) {
            array_push($new_cols, new Ccol(new Clink(new Cimg('images/general/closed.gif'), $add_col_link . $c)));
        }
        $table->addRow($new_cols);
    }
    $empty_screen_col = array();
    for ($r = 0; $r < $row['vsize']; $r++) {
        $new_cols = array();
        $empty_screen_row = true;
        if ($editmode == 1) {
            $add_row_link = 'screenedit.php?config=1&screenid=' . $screenid . '&add_row=';
            array_push($new_cols, new Ccol(new Clink(new Cimg('images/general/closed.gif'), $add_row_link . $r)));
        }
        for ($c = 0; $c < $row['hsize']; $c++) {
            $item = array();
            if (isset($skip_field[$r][$c])) {
                continue;
            }
            $item_form = false;
            $iresult = DBSelect('SELECT * FROM screens_items WHERE screenid=' . $screenid . ' AND x=' . $c . ' AND y=' . $r);
            $irow = DBfetch($iresult);
            if ($irow) {
                $screenitemid = $irow['screenitemid'];
                $resourcetype = $irow['resourcetype'];
                $resourceid = $irow['resourceid'];
                $width = $irow['width'];
                $height = $irow['height'];
                $colspan = $irow['colspan'];
                $rowspan = $irow['rowspan'];
                $elements = $irow['elements'];
                $valign = $irow['valign'];
                $halign = $irow['halign'];
                $style = $irow['style'];
                $url = $irow['url'];
                $dynamic = $irow['dynamic'];
            } else {
                $screenitemid = 0;
                $resourcetype = 0;
                $resourceid = 0;
                $width = 0;
                $height = 0;
                $colspan = 0;
                $rowspan = 0;
                $elements = 0;
                $valign = VALIGN_DEFAULT;
                $halign = HALIGN_DEFAULT;
                $style = 0;
                $url = '';
                $dynamic = 0;
            }
            if ($screenitemid > 0) {
                $empty_screen_row = false;
                $empty_screen_col[$c] = 1;
            }
            if ($editmode == 1 && $screenitemid != 0) {
                $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&screenitemid=' . $screenitemid . "#form');";
                $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitemid . '#form';
            } else {
                if ($editmode == 1 && $screenitemid == 0) {
                    $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&x=' . $c . '&y=' . $r . "#form');";
                    $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r . '#form';
                } else {
                    $action = NULL;
                }
            }
            if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r) {
                // click on empty field
                $item = get_screen_item_form();
                $item_form = true;
            } else {
                if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitemid) == 0) {
                    // click on element
                    $item = get_screen_item_form();
                    $item_form = true;
                } else {
                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_GRAPH) {
                        if ($editmode == 0) {
                            $action = 'charts.php?graphid=' . $resourceid . url_param('period') . url_param('stime');
                        }
                        $graphid = null;
                        $graphtype = GRAPH_TYPE_NORMAL;
                        $yaxis = 0;
                        // GRAPH & ZOOM features
                        $sql = 'SELECT MAX(g.graphid) as graphid, MAX(g.graphtype) as graphtype, MIN(gi.yaxisside) as yaxissidel, MAX(gi.yaxisside) as yaxissider,' . ' MAX(g.show_legend) as legend, MAX(g.show_3d) as show3d ' . ' FROM graphs g, graphs_items gi ' . ' WHERE g.graphid=' . $resourceid . ' AND gi.graphid=g.graphid ';
                        $res = DBselect($sql);
                        while ($graph = DBfetch($res)) {
                            $graphid = $graph['graphid'];
                            $graphtype = $graph['graphtype'];
                            $yaxis = $graph['yaxissider'];
                            $yaxis = $graph['yaxissidel'] == $yaxis ? $yaxis : 2;
                            $legend = $graph['legend'];
                            $graph3d = $graph['show3d'];
                        }
                        if ($yaxis == 2) {
                            $shiftXleft = 60;
                            $shiftXright = 60;
                        } else {
                            if ($yaxis == 0) {
                                $shiftXleft = 60;
                                $shiftXright = 20;
                            } else {
                                $shiftXleft = 10;
                                $shiftXright = 60;
                            }
                        }
                        //-------------
                        // Host feature
                        if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                            $def_items = array();
                            $di_res = get_graphitems_by_graphid($resourceid);
                            while ($gitem = DBfetch($di_res)) {
                                $def_items[] = $gitem;
                            }
                            $url = '';
                            if ($new_items = get_same_graphitems_for_host($def_items, $_REQUEST['hostid'])) {
                                $url .= make_url_from_gitems($new_items);
                            }
                            $url = make_url_from_graphid($resourceid, false) . $url;
                        }
                        //-------------
                        $default = false;
                        if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart6.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $g_img = new CImg($url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime') . '&legend=' . $legend . '&graph3d=' . $graph3d);
                        } else {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart2.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                            $g_img = new CImg($url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime'));
                            $g_img->addOption('id', $dom_graph_id);
                            if (!is_null($graphid) && $editmode != 1) {
                                insert_js('	A_SBOX["' . $dom_graph_id . '"] = new Object;' . 'A_SBOX["' . $dom_graph_id . '"].shiftT = 17;' . 'A_SBOX["' . $dom_graph_id . '"].shiftL = ' . $shiftXleft . ';');
                                if (isset($_REQUEST['stime'])) {
                                    $stime = $_REQUEST['stime'];
                                    $stime = mktime(substr($stime, 8, 2), substr($stime, 10, 2), 0, substr($stime, 4, 2), substr($stime, 6, 2), substr($stime, 0, 4));
                                } else {
                                    $stime = 'null';
                                }
                                global $page;
                                if ($page['type'] == PAGE_TYPE_HTML) {
                                    zbx_add_post_js('graph_zoom_init("' . $dom_graph_id . '",' . $stime . ',' . $effectiveperiod . ',' . $width . ',' . $height . ', false);');
                                } else {
                                    $g_img->addOption('onload', 'javascript: graph_zoom_init("' . $dom_graph_id . '",' . $stime . ',' . $effectiveperiod . ',' . $width . ',' . $height . ', false);');
                                    //								insert_js('graph_zoom_init("'.$dom_graph_id.'",'.$stime.','.$effectiveperiod.','.$width.','.$height.', false);');
                                }
                            }
                        }
                        if ($default && $editmode == 0) {
                            $item = new CLink($g_img, $action);
                        } else {
                            $item =& $g_img;
                        }
                    } else {
                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
                            if ($editmode == 0) {
                                $action = "history.php?action=showgraph&itemid={$resourceid}" . url_param("period") . url_param("inc") . url_param("dec");
                            }
                            // Host feature
                            if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                    $resourceid = $newitemid;
                                } else {
                                    $resourceid = '';
                                }
                            }
                            //-------------
                            $url = empty($resourceid) ? 'chart3.php?' : "chart.php?itemid={$resourceid}&";
                            $item = new CLink(new CImg($url . "width={$width}&height={$height}" . "&period={$effectiveperiod}" . url_param("stime")), $action);
                        } else {
                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_MAP) {
                                $image_map = new CImg("map.php?noedit=1&sysmapid={$resourceid}" . "&width={$width}&height={$height}");
                                if ($editmode == 0) {
                                    $action_map = get_action_map_by_sysmapid($resourceid);
                                    $image_map->SetMap($action_map->GetName());
                                    $item = array($action_map, $image_map);
                                } else {
                                    $item = $image_map;
                                    //						$item = new CLink($image_map, $action);
                                }
                            } else {
                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                                    // Host feature
                                    if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                        if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                            $resourceid = $newitemid;
                                        } else {
                                            $resourceid = 0;
                                        }
                                    }
                                    //-------------
                                    $item = array(get_screen_plaintext($resourceid, $elements, $style));
                                    if ($editmode == 1) {
                                        array_push($item, new CLink(S_CHANGE, $action));
                                    }
                                } else {
                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_STATUS_OF_TRIGGERS) {
                                        $params = array();
                                        $params['groupid'] = get_request('tr_groupid', get_profile('web.screens.tr_groupid', 0));
                                        $params['hostid'] = get_request('tr_hostid', get_profile('web.screens.tr_hostid', 0));
                                        $params['limit'] = $elements;
                                        update_profile('web.screens.tr_groupid', $params['groupid'], PROFILE_TYPE_ID);
                                        update_profile('web.screens.tr_hostid', $params['hostid'], PROFILE_TYPE_ID);
                                        $tr_form = new CForm();
                                        $cmbGroup = new CComboBox('tr_groupid', $params['groupid'], 'submit()');
                                        $cmbHosts = new CComboBox('tr_hostid', $params['hostid'], 'submit()');
                                        $cmbGroup->addItem(0, S_ALL_SMALL);
                                        $cmbHosts->addItem(0, S_ALL_SMALL);
                                        $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY);
                                        $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY);
                                        $available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
                                        $sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g, hosts_groups hg, hosts h ' . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND hg.groupid=g.groupid ' . ' AND h.hostid=hg.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND EXISTS(SELECT i.itemid FROM items i WHERE i.status=' . ITEM_STATUS_ACTIVE . ' AND i.hostid=h.hostid ) ' . ' ORDER BY g.name';
                                        $tresult = DBselect($sql);
                                        while ($tr_row = DBfetch($tresult)) {
                                            $cmbGroup->addItem($tr_row['groupid'], get_node_name_by_elid($tr_row['groupid']) . $tr_row['name']);
                                        }
                                        $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                        $sql_from = '';
                                        $sql_where = '';
                                        if ($params['groupid'] > 0) {
                                            $sql_from .= ',hosts_groups hg ';
                                            $sql_where .= ' AND hg.hostid=h.hostid AND hg.groupid=' . $params['groupid'];
                                        }
                                        $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h, items i, functions f, triggers t ' . $sql_from . ' WHERE h.status=' . HOST_STATUS_MONITORED . $sql_where . ' AND h.hostid=i.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY h.host';
                                        $tresult = DBselect($sql);
                                        while ($tr_row = DBfetch($tresult)) {
                                            $cmbHosts->addItem($tr_row['hostid'], get_node_name_by_elid($tr_row['hostid']) . $tr_row['host']);
                                        }
                                        $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                        $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, date('[H:i:s]', time())), $tr_form));
                                        //*/
                                        //					$item = array();
                                        $item[] = make_latest_issues($params);
                                        if ($editmode == 1) {
                                            array_push($item, new CLink(S_CHANGE, $action));
                                        }
                                    } else {
                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SYSTEM_STATUS) {
                                            $item = array(get_table_header(array(S_SYSTEM_STATUSBIG, SPACE, date('[H:i:s]', time()))));
                                            $item[] = make_system_summary();
                                            if ($editmode == 1) {
                                                array_push($item, new CLink(S_CHANGE, $action));
                                            }
                                        } else {
                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTS_INFO) {
                                                $item = array(new CHostsInfo($resourceid, $style));
                                                if ($editmode == 1) {
                                                    array_push($item, new CLink(S_CHANGE, $action));
                                                }
                                            } else {
                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                                    $item = new CTriggersInfo($style);
                                                    if ($resourceid > 0) {
                                                        $item->set_host_group($resourceid);
                                                    }
                                                    $item = array($item);
                                                    if ($editmode == 1) {
                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                    }
                                                } else {
                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SERVER_INFO) {
                                                        //					$item = array(get_table_header(S_STATUS_OF_ZABBIX_BIG),make_status_of_zbx());
                                                        $item = array(new CServerInfo());
                                                        if ($editmode == 1) {
                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                        }
                                                    } else {
                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_CLOCK) {
                                                            $item = new CFlashClock($width, $height, $style, $action);
                                                        } else {
                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SCREEN) {
                                                                $item = array(get_screen($resourceid, 2, $effectiveperiod));
                                                                if ($editmode == 1) {
                                                                    array_push($item, new CLink(S_CHANGE, $action));
                                                                }
                                                            } else {
                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_OVERVIEW) {
                                                                    $hostids = array();
                                                                    $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                    while ($tmp_host = DBfetch($res)) {
                                                                        $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                    }
                                                                    $item = array(get_triggers_overview($hostids, $style));
                                                                    if ($editmode == 1) {
                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                    }
                                                                } else {
                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_DATA_OVERVIEW) {
                                                                        $hostids = array();
                                                                        $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                        while ($tmp_host = DBfetch($res)) {
                                                                            $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                        }
                                                                        $item = array(get_items_data_overview($hostids, $style));
                                                                        if ($editmode == 1) {
                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                        }
                                                                    } else {
                                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_URL) {
                                                                            $item = array(new CIFrame($url, $width, $height, "auto"));
                                                                            if ($editmode == 1) {
                                                                                array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                            }
                                                                        } else {
                                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_ACTIONS) {
                                                                                $item = array(get_history_of_actions(0, $elements));
                                                                                if ($editmode == 1) {
                                                                                    array_push($item, new CLink(S_CHANGE, $action));
                                                                                }
                                                                            } else {
                                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_EVENTS) {
                                                                                    $item = array(get_history_of_triggers_events(0, $elements));
                                                                                    if ($editmode == 1) {
                                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                                    }
                                                                                } else {
                                                                                    $item = array(SPACE);
                                                                                    if ($editmode == 1) {
                                                                                        array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $str_halign = 'def';
            if ($halign == HALIGN_CENTER) {
                $str_halign = 'cntr';
            }
            if ($halign == HALIGN_LEFT) {
                $str_halign = 'left';
            }
            if ($halign == HALIGN_RIGHT) {
                $str_halign = 'right';
            }
            $str_valign = 'def';
            if ($valign == VALIGN_MIDDLE) {
                $str_valign = 'mdl';
            }
            if ($valign == VALIGN_TOP) {
                $str_valign = 'top';
            }
            if ($valign == VALIGN_BOTTOM) {
                $str_valign = 'bttm';
            }
            if ($editmode == 1 && !$item_form) {
                $item = new CDiv($item, 'draggable');
                $item->addOption('id', 'position_' . $r . '_' . $c);
                if ($editmode == 1) {
                    $item->addOption('onclick', 'javascript: ' . $onclick_action);
                }
            }
            $new_col = new CCol($item, $str_halign . '_' . $str_valign);
            if ($colspan) {
                $new_col->SetColSpan($colspan);
            }
            if ($rowspan) {
                $new_col->SetRowSpan($rowspan);
            }
            array_push($new_cols, $new_col);
        }
        if ($editmode == 1) {
            $rmv_icon = new Cimg('images/general/opened.gif');
            if ($empty_screen_row) {
                $rmv_row_link = 'javascript: location.href = ' . "'screenedit.php?config=1&screenid=" . $screenid . '&rmv_row=' . $r . "';";
            } else {
                $rmv_row_link = "javascript: if(Confirm('This screen-row is not empty. Delete it?')){" . " location.href = 'screenedit.php?config=1&screenid=" . $screenid . "&rmv_row=" . $r . "';}";
            }
            $rmv_icon->addAction('onclick', $rmv_row_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        $table->AddRow(new CRow($new_cols));
    }
    if ($editmode == 1) {
        $add_row_link = 'screenedit.php?config=1&screenid=' . $screenid . '&add_row=';
        $new_cols = array(new Ccol(new Clink(new Cimg('images/general/closed.gif'), $add_row_link . $row['vsize'])));
        for ($c = 0; $c < $row['hsize']; $c++) {
            $rmv_icon = new Cimg('images/general/opened.gif');
            if (isset($empty_screen_col[$c])) {
                $rmv_col_link = "javascript: if(Confirm('This screen-column is not empty. Delete it?')){" . " location.href = 'screenedit.php?config=1&screenid=" . $screenid . "&rmv_col=" . $c . "';}";
            } else {
                $rmv_col_link = "javascript: location.href = 'screenedit.php?config=1&screenid=" . $screenid . "&rmv_col=" . $c . "';";
            }
            $rmv_icon->addAction('onclick', $rmv_col_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        array_push($new_cols, new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        $table->addRow($new_cols);
    }
    return $table;
}
Example #15
0
$rep_tab->addOption('border', 0);
// --------------
switch ($config) {
    case 1:
        $rep_form = bar_report_form();
        break;
    case 2:
        $rep_form = bar_report_form2();
        break;
    case 3:
        $rep_form = bar_report_form3();
        break;
    default:
        $rep_form = bar_report_form();
}
$form = create_filter(S_REPORTS, NULL, $rep_form, 'report_form', get_profile('web.report6.filter.state', 1));
$form->Show();
if (isset($_REQUEST['report_show'])) {
    $src = 'chart_bar.php?config=' . $_REQUEST['config'] . url_param('title') . url_param('xlabel') . url_param('ylabel') . url_param('scaletype') . url_param('avgperiod') . url_param('showlegend') . url_param('sorttype') . url_param('report_timesince') . url_param('report_timetill') . url_param('periods') . url_param('items') . url_param('hostids') . url_param('groupids') . url_param('palette') . url_param('palettetype');
    $rep_tab->addRow(create_hat(S_REPORT, new CImg($src, 'report'), null, 'hat_report', get_profile('web.report6.hats.hat_report.state', 1)));
}
$outer_table = new CTable();
$outer_table->addOption('border', 0);
$outer_table->addOption('width', '100%');
$outer_table->setCellPadding(1);
$outer_table->setCellSpacing(1);
$tmp_row = new CRow($rep_tab);
$tmp_row->addOption('align', 'center');
$outer_table->addRow($tmp_row);
$outer_table->Show();
include_once 'include/page_footer.php';
Example #16
0
function show_history($itemid, $from, $stime, $period)
{
    //$till=date(S_DATE_FORMAT_YMDHMS,time(NULL)-$from*3600);
    //show_table_header(S_TILL.SPACE.$till.' ( '.zbx_date2age($stime,$stime+$period).' )');
    $td = new CCol(get_js_sizeable_graph('graph', 'chart.php?itemid=' . $itemid . url_param($from, false, 'from') . url_param($stime, false, 'stime') . url_param($period, false, 'period')));
    $td->addOption('align', 'center');
    $tr = new CRow($td);
    $tr->addOption('bgcolor', '#dddddd');
    $table = new CTable();
    $table->addOption('width', '100%');
    $table->addOption('bgcolor', '#cccccc');
    $table->addOption('cellspacing', '1');
    $table->addOption('cellpadding', '3');
    $table->addRow($tr);
    $table->show();
}