if (isset($hosts_linked_to[$host['hostid']])) {
        continue;
    }
    $host_tb->addItem($host['hostid'], $host['name']);
}
// select allowed selected hosts
$params = array('output' => array('hostid', 'name', 'flags'), 'hostids' => $hosts_linked_to, 'templated_hosts' => 1, 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL), 'preservekeys' => true);
$hostsAllowed = API::Host()->get($params);
order_result($hostsAllowed, 'name');
// select selected hosts including read only and add them
$hostsAll = API::Host()->get(array('output' => array('hostid', 'name', 'flags'), 'hostids' => $hosts_linked_to, 'templated_hosts' => true));
order_result($hostsAll, 'name');
foreach ($hostsAll as $host) {
    $host_tb->addItem($host['hostid'], $host['name'], true, isset($hostsAllowed[$host['hostid']]));
}
$templateList->addRow(_('Hosts / templates'), $host_tb->Get(_('In'), array(_('Other | group') . SPACE, $cmbGroups)));
// FULL CLONE {
if ($_REQUEST['form'] == 'full_clone') {
    // template applications
    $templateApps = API::Application()->get(array('hostids' => $templateid, 'inherited' => false, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
    if (!empty($templateApps)) {
        $applicationsList = array();
        foreach ($templateApps as $tplAppId => $templateApp) {
            $applicationsList[$tplAppId] = $templateApp['name'];
        }
        order_result($applicationsList);
        $listBox = new CListBox('applications', null, 8);
        $listBox->setAttribute('disabled', 'disabled');
        $listBox->addItems($applicationsList);
        $templateList->addRow(_('Applications'), $listBox);
    }
예제 #2
0
 // get hosts from selected twb_groupid combo
 $params = array('groupids' => $twb_groupid, 'templated_hosts' => 1, 'order' => 'host', 'editable' => 1, 'extendoutput' => 1);
 $db_hosts = CHost::get($params);
 foreach ($db_hosts as $hostid => $db_host) {
     // add all except selected hosts
     if (!isset($hosts[$hostid])) {
         $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $db_host['host']);
     }
 }
 // select selected hosts and add them
 $params = array('hostids' => $hosts, 'templated_hosts' => 1, 'order' => 'host', 'editable' => 1, 'extendoutput' => 1);
 $db_hosts = CHost::get($params);
 foreach ($db_hosts as $hostid => $db_host) {
     $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $db_host['host']);
 }
 $frmHostG->addRow(S_HOSTS, $cmbHosts->Get(S_HOSTS . SPACE . S_IN, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups)));
 $frmHostG->addItemToBottomRow(new CButton('save', S_SAVE));
 if ($groupid > 0) {
     $frmHostG->addItemToBottomRow(SPACE);
     $frmHostG->addItemToBottomRow(new CButton('clone', S_CLONE));
     $frmHostG->addItemToBottomRow(SPACE);
     $dltButton = new CButtonDelete('Delete selected group?', url_param('form') . url_param('config') . url_param('groupid'));
     $dlt_groups = getDeletableHostGroups($_REQUEST['groupid']);
     if (empty($dlt_groups)) {
         $dltButton->setAttribute('disabled', 'disabled');
     }
     $frmHostG->addItemToBottomRow($dltButton);
 }
 $frmHostG->addItemToBottomRow(SPACE);
 $frmHostG->addItemToBottomRow(new CButtonCancel(url_param('config')));
 $frmHostG->show();
예제 #3
0
function insert_template_form($available_hosts)
{
    $frm_title = S_TEMPLATE_LINKAGE;
    if ($_REQUEST['hostid'] > 0) {
        $template = get_host_by_hostid($_REQUEST['hostid']);
        $frm_title .= ' [' . $template['host'] . ']';
    }
    if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) {
        $name = $template['host'];
    } else {
        $name = get_request("tname", '');
    }
    $frmHostT = new CFormTable($frm_title, 'hosts.php');
    $frmHostT->setHelp('web.hosts.group.php');
    $frmHostT->addVar('config', get_request('config', 2));
    if ($_REQUEST['hostid'] > 0) {
        $frmHostT->addVar('hostid', $_REQUEST['hostid']);
    }
    $frmHostT->addRow(S_TEMPLATE, new CTextBox('tname', $name, 60, 'yes'));
    $hosts_in_tpl = array();
    $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h,hosts_templates ht' . ' WHERE ht.templateid=' . $_REQUEST['hostid'] . ' AND h.hostid=ht.hostid' . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ') ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY h.host';
    $db_hosts = DBselect($sql);
    while ($db_host = DBfetch($db_hosts)) {
        $hosts_in_tpl[$db_host['hostid']] = $db_host['hostid'];
    }
    $cmbHosts = new CTweenBox($frmHostT, 'hosts', $hosts_in_tpl, 6);
    $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h' . ' WHERE h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ') ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY h.host';
    $db_hosts = DBselect($sql);
    while ($db_host = DBfetch($db_hosts)) {
        $cmbHosts->addItem($db_host['hostid'], get_node_name_by_elid($db_host['hostid']) . $db_host['host']);
    }
    $frmHostT->addRow(S_HOSTS, $cmbHosts->Get(S_HOSTS . SPACE . S_IN, S_OTHER . SPACE . S_HOSTS));
    $frmHostT->addItemToBottomRow(new CButton('save', S_SAVE));
    $frmHostT->addItemToBottomRow(SPACE);
    $frmHostT->addItemToBottomRow(new CButtonCancel(url_param('config')));
    $frmHostT->Show();
}
예제 #4
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', S_REPORT . ' 3');
    $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', date('YmdHis', time() - 86400));
    $report_timetill = get_request('report_timetill', date('YmdHis'));
    $captions = get_request('captions', array());
    $items = get_request('items', array());
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    //,'events.php?report_set=1','POST',null,'sform');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('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', date('YmdHis', $report_timesince));
    $reportForm->addVar('report_timetill', date('YmdHis', $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', $groupids, 10);
    $options = array('real_hosts' => 1, 'output' => 'extend');
    $db_groups = CHostGroup::get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(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');
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, S_ALL_S);
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(S_GROUP, SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'host'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = CHost::get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'host');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['host']);
    }
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'host'), 'hostids' => $hostids);
    $db_hosts2 = CHost::get($options);
    order_result($db_hosts2, 'host');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['host']);
        }
    }
    $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->setAttribute('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;
}
예제 #5
0
        $cmbConnectBy->addItem(1, S_IP_ADDRESS);
        $frmHostG->addRow(S_CONNECT_TO, $cmbConnectBy);
        $frmHostG->addRow(S_PORT, new CNumericBox('port', $port, 5));
    } else {
        $frmHostG->addVar('dns', $dns);
        $frmHostG->addVar('ip', $ip);
        $frmHostG->addVar('useip', $useip);
        $frmHostG->addVar('port', $port);
    }
    $cmbHosts = new CTweenBox($frmHostG, 'hosts', $hosts);
    $sql = 'SELECT hostid, proxy_hostid, host ' . ' FROM hosts ' . ' WHERE status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBin_node('hostid') . ' ORDER BY host';
    $db_hosts = DBselect($sql);
    while ($db_host = DBfetch($db_hosts)) {
        $cmbHosts->addItem($db_host['hostid'], $db_host['host'], NULL, $db_host['proxy_hostid'] == 0 || $_REQUEST['hostid'] > 0 && $db_host['proxy_hostid'] == $_REQUEST['hostid']);
    }
    $frmHostG->addRow(S_HOSTS, $cmbHosts->Get(S_PROXY . SPACE . S_HOSTS, S_OTHER . SPACE . S_HOSTS));
    $frmHostG->addItemToBottomRow(new CButton('save', S_SAVE));
    if ($_REQUEST['hostid'] > 0) {
        $frmHostG->addItemToBottomRow(array(SPACE, new CButton('clone', S_CLONE), SPACE, new CButtonDelete(S_DELETE_SELECTED_PROXY_Q, url_param('form') . url_param('hostid')), SPACE));
    }
    $frmHostG->addItemToBottomRow(new CButtonCancel());
    $proxies_wdgt->addItem($frmHostG);
    $proxies_wdgt->show();
} else {
    $numrows = new CDiv();
    $numrows->setAttribute('name', 'numrows');
    $proxies_wdgt->addHeader(S_PROXIES_BIG);
    $proxies_wdgt->addHeader($numrows);
    $form = new CForm('proxies.php', 'get');
    $form->setName('hosts');
    $table = new CTableInfo(S_NO_PROXIES_DEFINED);
예제 #6
0
/**
 * Create report bar for for "Compare values for multiple periods"
 *
 * @return object $reportForm
 */
function valueComparisonFormForMultiplePeriods()
{
    $config = get_request('config', 1);
    $title = get_request('title', _('Report 3'));
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY));
    $report_timetill = get_request('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME));
    $itemId = get_request('itemid', 0);
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('id', 'zbx_report');
    if (isset($_REQUEST['report_show']) && $itemId) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', date(TIMESTAMP_FORMAT, $report_timesince));
    $reportForm->addVar('report_timetill', date(TIMESTAMP_FORMAT, $report_timetill));
    $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
    $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $options = array('real_hosts' => true, 'output' => 'extend');
    $db_groups = API::HostGroup()->get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, _('All'));
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => true, 'output' => array('hostid', 'name'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = API::Host()->get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'name');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['name']);
    }
    $options = array('real_hosts' => true, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
    $db_hosts2 = API::Host()->get($options);
    order_result($db_hosts2, 'name');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['name']);
        }
    }
    $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
    $reporttimetab = new CTable(null, 'calendar');
    $timeSinceRow = createDateSelector('report_timesince', $report_timesince, 'report_timetill');
    array_unshift($timeSinceRow, _('From'));
    $reporttimetab->addRow($timeSinceRow);
    $timeTillRow = createDateSelector('report_timetill', $report_timetill, 'report_timesince');
    array_unshift($timeTillRow, _('Till'));
    $reporttimetab->addRow($timeTillRow);
    $reportForm->addRow(_('Period'), $reporttimetab);
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Scale'), $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Average by'), $avgcmb);
    $itemName = '';
    if ($itemId) {
        $itemName = get_item_by_itemid($itemId);
        $itemName = itemName($itemName);
    }
    $itemidVar = new CVar('itemid', $itemId, 'itemid');
    $reportForm->addItem($itemidVar);
    $txtCondVal = new CTextBox('item_name', $itemName, 50, 'yes');
    $txtCondVal->setAttribute('id', 'item_name');
    $btnSelect = new CButton('btn1', _('Select'), 'return PopUp("popup.php?dstfrm=' . $reportForm->GetName() . '&dstfld1=itemid' . '&dstfld2=item_name' . '&srctbl=items' . '&srcfld1=itemid' . '&srcfld2=name' . '&monitored_hosts=1");', 'T');
    $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, _s('Palette #%1$s', 1));
    $paletteCmb->addItem(1, _s('Palette #%1$s', 2));
    $paletteCmb->addItem(2, _s('Palette #%1$s', 3));
    $paletteCmb->addItem(3, _s('Palette #%1$s', 4));
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, _('Middle'));
    $paletteTypeCmb->addItem(1, _('Darken'));
    $paletteTypeCmb->addItem(2, _('Brighten'));
    $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb));
    $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show')));
    $reset = new CButton('reset', _('Reset'));
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
예제 #7
0
    $tblHlink->addRow($host_tb->Get(S_IN . SPACE . S_MAINTENANCE, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups)));
    $right_tab->addRow(new CFormElement(S_HOSTS_IN_MAINTENANCE, $tblHlink));
    // }}} MAINTENANCE HOSTS
    // MAINTENANCE GROUPS {{{
    $tblGlink = new CTable(null, 'formElementTable');
    if (isset($_REQUEST['maintenanceid']) && !isset($_REQUEST['form_refresh'])) {
        $groupids = CHostGroup::get(array('maintenanceids' => $_REQUEST['maintenanceid'], 'real_hosts' => 1, 'output' => API_OUTPUT_SHORTEN, 'editable' => 1));
        $groupids = zbx_objectValues($groupids, 'groupid');
    } else {
        $groupids = get_request('groupids', array());
    }
    $group_tb = new CTweenBox($frmMaintenance, 'groupids', $groupids, 10);
    foreach ($all_groups as $group) {
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $tblGlink->addRow($group_tb->Get(S_IN . SPACE . S_MAINTENANCE, S_OTHER . SPACE . S_GROUPS));
    $right_tab->addRow(new CFormElement(S_GROUPS_IN_MAINTENANCE, $tblGlink));
    // }}} MAINTENANCE GROUPS
    $td_l = new CCol($left_tab);
    $td_l->setAttribute('valign', 'top');
    $td_r = new CCol($right_tab);
    $td_r->setAttribute('valign', 'top');
    $outer_table = new CTable();
    $outer_table->addRow(array($td_l, $td_r));
    $frmMaintenance->additem($outer_table);
    show_messages();
    $maintenance_wdgt->addItem($frmMaintenance);
} else {
    // Table HEADER
    $form = new CForm(null, 'get');
    $form->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB()));
예제 #8
0
function insert_template_link_form($available_hosts)
{
    global $USER_DETAILS;
    $frm_title = S_TEMPLATE_LINKAGE;
    if ($_REQUEST['hostid'] > 0) {
        $template = get_host_by_hostid($_REQUEST['hostid']);
        $frm_title .= ' [' . $template['host'] . ']';
    }
    if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) {
        $name = $template['host'];
    } else {
        $name = get_request("tname", '');
    }
    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE);
    $selected_grp = get_request('twb_groupid', 0);
    $selected_grp = isset($available_groups[$selected_grp]) ? $selected_grp : reset($available_groups);
    $cmbGroups = new CComboBox('twb_groupid', $selected_grp, 'submit()');
    //		$cmbGroups->addItem(0,S_ALL_S);
    $sql = 'SELECT DISTINCT g.groupid, g.name ' . ' FROM groups g, hosts_groups hg, hosts h ' . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=hg.groupid ' . ' AND h.hostid=hg.hostid' . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ') ' . ' ORDER BY g.name';
    $result = DBselect($sql);
    while ($row = DBfetch($result)) {
        $cmbGroups->addItem($row['groupid'], $row['name']);
    }
    $frmHostT = new CFormTable($frm_title, 'hosts.php');
    $frmHostT->setHelp('web.hosts.group.php');
    $frmHostT->addVar('config', get_request('config', 2));
    if ($_REQUEST['hostid'] > 0) {
        $frmHostT->addVar('hostid', $_REQUEST['hostid']);
    }
    $frmHostT->addRow(S_TEMPLATE, new CTextBox('tname', $name, 60, 'yes'));
    $hosts_in_tpl = array();
    $sql_where = '';
    if (isset($_REQUEST['form_refresh'])) {
        $saved_hosts = get_request('hosts', array());
        $hosts_in_tpl = array_intersect($available_hosts, $saved_hosts);
        $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h' . ' WHERE ' . DBcondition('h.hostid', $hosts_in_tpl) . ' ORDER BY h.host';
        $db_hosts = DBselect($sql);
        while ($db_host = DBfetch($db_hosts)) {
            $hosts_in_tpl[$db_host['hostid']] = $db_host['hostid'];
        }
    } else {
        $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h,hosts_templates ht' . ' WHERE (ht.templateid=' . $_REQUEST['hostid'] . ' AND h.hostid=ht.hostid' . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ') ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' )' . ' ORDER BY h.host';
        $db_hosts = DBselect($sql);
        while ($db_host = DBfetch($db_hosts)) {
            $hosts_in_tpl[$db_host['hostid']] = $db_host['hostid'];
        }
    }
    $cmbHosts = new CTweenBox($frmHostT, 'hosts', $hosts_in_tpl, 25);
    $sql = 'SELECT DISTINCT h.hostid,h.host ' . ' FROM hosts h, hosts_groups hg' . ' WHERE ( h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ') ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND hg.groupid=' . $selected_grp . ' AND h.hostid=hg.hostid)' . ' OR ' . DBcondition('h.hostid', $hosts_in_tpl) . ' ORDER BY h.host';
    $db_hosts = DBselect($sql);
    while ($db_host = DBfetch($db_hosts)) {
        $cmbHosts->addItem($db_host['hostid'], get_node_name_by_elid($db_host['hostid']) . $db_host['host']);
    }
    $frmHostT->addRow(S_HOSTS, $cmbHosts->Get(S_HOSTS . SPACE . S_IN, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups)));
    $frmHostT->addItemToBottomRow(new CButton('save', S_SAVE));
    $frmHostT->addItemToBottomRow(SPACE);
    $frmHostT->addItemToBottomRow(new CButtonCancel(url_param('config')));
    $frmHostT->show();
}
function bar_report_form3()
{
    $config = get_request('config', 1);
    $title = get_request('title', _('Report 3'));
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', date('YmdHis', time() - SEC_PER_DAY));
    $report_timetill = get_request('report_timetill', date('YmdHis'));
    $items = get_request('items', array());
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    //,'events.php?report_set=1','POST',null,'sform');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('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', date('YmdHis', $report_timesince));
    $reportForm->addVar('report_timetill', date('YmdHis', $report_timetill));
    //	$reportForm->addVar('items',$items); 				//params are set later!!
    //	$reportForm->addVar('periods',$periods);
    $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
    $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    // GROUPS
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $options = array('real_hosts' => 1, 'output' => 'extend');
    $db_groups = API::HostGroup()->get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
    // ----------
    // HOSTS
    //	validate_group(PERM_READ_ONLY,array('real_hosts'),'web.last.conf.groupid');
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, _('All'));
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'name'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = API::Host()->get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'name');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['name']);
    }
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
    $db_hosts2 = API::Host()->get($options);
    order_result($db_hosts2, 'name');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['name']);
        }
    }
    $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
    // ----------
    //*/
    // 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->setAttribute('width', '10%');
    $reporttimetab->setCellPadding(0);
    $reporttimetab->setCellSpacing(0);
    $reporttimetab->addRow(array(_('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(_('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(_('Period'), $reporttimetab);
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Scale'), $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Average by'), $avgcmb);
    // items
    $itemid = 0;
    $description = '';
    if (count($items) && $items[0]['itemid'] > 0) {
        $itemid = $items[0]['itemid'];
        $description = get_item_by_itemid($itemid);
        $description = itemName($description);
    }
    $itemidVar = new CVar('items[0][itemid]', $itemid, 'items_0_itemid');
    $reportForm->addItem($itemidVar);
    $txtCondVal = new CTextBox('items[0][description]', $description, 50, 'yes');
    $txtCondVal->setAttribute('id', 'items_0_description');
    $btnSelect = new CButton('btn1', _('Select'), "return PopUp('popup.php?dstfrm=" . $reportForm->GetName() . "&dstfld1=items_0_itemid&dstfld2=items_0_description&" . "srctbl=items&srcfld1=itemid&srcfld2=name&monitored_hosts=1');", 'T');
    $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, _s('Palette #%1$s', 1));
    $paletteCmb->addItem(1, _s('Palette #%1$s', 2));
    $paletteCmb->addItem(2, _s('Palette #%1$s', 3));
    $paletteCmb->addItem(3, _s('Palette #%1$s', 4));
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, _('Middle'));
    $paletteTypeCmb->addItem(1, _('Darken'));
    $paletteTypeCmb->addItem(2, _('Brighten'));
    $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb));
    $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show')));
    $reset = new CButton('reset', _('Reset'));
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
foreach ($data['hostsAllowedToAdd'] as $host) {
    if (bccomp($host['hostid'], $data['templateId']) == 0) {
        continue;
    }
    if (isset($data['hostIdsLinkedTo'][$host['hostid']])) {
        continue;
    }
    if (array_key_exists($host['hostid'], $data['linkedTemplates'])) {
        continue;
    }
    $hostsTB->addItem($host['hostid'], $host['name']);
}
foreach ($data['hostsAll'] as $host) {
    $hostsTB->addItem($host['hostid'], $host['name'], true, isset($data['hostsAllowed'][$host['hostid']]));
}
$templateList->addRow(_('Hosts / templates'), $hostsTB->Get(_('In'), [_('Other | group') . SPACE, $cmbGroups]));
$templateList->addRow(_('Description'), (new CTextArea('description', $this->data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
// FULL CLONE {
if ($data['form'] === 'full_clone') {
    // template applications
    $templateApps = API::Application()->get(['hostids' => $data['templateId'], 'inherited' => false, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true]);
    if (!empty($templateApps)) {
        $applicationsList = [];
        foreach ($templateApps as $tplAppId => $templateApp) {
            $applicationsList[$tplAppId] = $templateApp['name'];
        }
        order_result($applicationsList);
        $listBox = (new CListBox('applications', null, 8))->setAttribute('disabled', 'disabled')->addItems($applicationsList);
        $templateList->addRow(_('Applications'), $listBox);
    }
    // items
예제 #11
0
 order_result($db_hosts, 'host');
 foreach ($db_hosts as $hnum => $db_host) {
     if (isset($hosts_linked_to[$db_host['hostid']])) {
         continue;
     }
     // add all except selected hosts
     $host_tb->addItem($db_host['hostid'], $db_host['host']);
 }
 // select selected hosts and add them
 $params = array('hostids' => $hosts_linked_to, 'templated_hosts' => 1, 'editable' => 1, 'extendoutput' => 1);
 $db_hosts = CHost::get($params);
 order_result($db_hosts, 'host');
 foreach ($db_hosts as $hnum => $db_host) {
     $host_tb->addItem($db_host['hostid'], $db_host['host']);
 }
 $template_tbl->addRow(array(S_HOSTS . '|' . S_TEMPLATES, $host_tb->Get(S_IN, array(S_OTHER . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups))));
 // FORM ITEM : linked Template table
 $tpl_table = new CTable();
 $tpl_table->setCellPadding(0);
 $tpl_table->setCellSpacing(0);
 foreach ($templates as $tid => $tname) {
     $frmHost->addVar('templates[' . $tid . ']', $tname);
     $tpl_table->addRow(array($tname, new CButton('unlink[' . $tid . ']', S_UNLINK), isset($original_templates[$tid]) ? new CButton('unlink_and_clear[' . $tid . ']', S_UNLINK_AND_CLEAR) : SPACE));
 }
 $template_tbl->addRow(array(S_LINK_WITH_TEMPLATE, array($tpl_table, new CButton('add_template', S_ADD, 'return PopUp("popup.php?dstfrm=' . $frmHost->GetName() . '&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host&excludeids[' . $templateid . ']=' . $templateid . url_param($templates, false, "existed_templates") . '",450,450)', 'T'))));
 // FULL CLONE {
 if ($_REQUEST['form'] == 'full_clone') {
     // FORM ITEM : Template items
     $items_lbx = new CListBox('items', null, 8);
     $items_lbx->setAttribute('disabled', 'disabled');
     $options = array('editable' => 1, 'hostids' => $templateid, 'output' => API_OUTPUT_EXTEND);