Example #1
0
 $template_tbl->addRow(array(S_GROUPS, $group_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS)));
 // FORM ITEM : new group text box [  ]
 $template_tbl->addRow(array(S_NEW_GROUP, new CTextBox('newgroup', $newgroup)));
 // FORM ITEM : linked Hosts tween box [  ] [  ]
 // $options = array('editable' => 1, 'extendoutput' => 1);
 // $twb_groups = CHostGroup::get($options);
 $twb_groupid = get_request('twb_groupid', 0);
 if ($twb_groupid == 0) {
     $gr = reset($all_groups);
     $twb_groupid = $gr['groupid'];
 }
 $cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
 foreach ($all_groups as $gnum => $group) {
     $cmbGroups->addItem($group['groupid'], $group['name']);
 }
 $host_tb = new CTweenBox($frmHost, 'hosts', $hosts_linked_to, 25);
 // get hosts from selected twb_groupid combo
 $params = array('groupids' => $twb_groupid, 'templated_hosts' => 1, 'editable' => 1, 'extendoutput' => 1);
 $db_hosts = CHost::get($params);
 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');
Example #2
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();
}
    $frmHost->addVar('groupid', $_REQUEST['groupid']);
}
// LLD rule link
if ($isDiscovered) {
    $hostList->addRow(_('Discovered by'), new CLink($dbHost['discoveryRule']['name'], 'host_prototypes.php?parent_discoveryid=' . $dbHost['discoveryRule']['itemid'], 'highlight underline weight_normal'));
}
$hostTB = new CTextBox('host', $host, ZBX_TEXTBOX_STANDARD_SIZE, $isDiscovered);
$hostTB->setAttribute('maxlength', 64);
$hostTB->setAttribute('autofocus', 'autofocus');
$hostList->addRow(_('Host name'), $hostTB);
$visiblenameTB = new CTextBox('visiblename', $visiblename, ZBX_TEXTBOX_STANDARD_SIZE, $isDiscovered);
$visiblenameTB->setAttribute('maxlength', 64);
$hostList->addRow(_('Visible name'), $visiblenameTB);
// groups for normal hosts
if (!$isDiscovered) {
    $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10);
    $all_groups = API::HostGroup()->get(array('editable' => true, 'output' => API_OUTPUT_EXTEND));
    order_result($all_groups, 'name');
    foreach ($all_groups as $group) {
        $grp_tb->addItem($group['groupid'], $group['name']);
    }
    $hostList->addRow(_('Groups'), $grp_tb->get(_('In groups'), _('Other groups')));
    $newgroupTB = new CTextBox('newgroup', $newgroup, ZBX_TEXTBOX_SMALL_SIZE);
    $newgroupTB->setAttribute('maxlength', 64);
    $tmp_label = _('New group');
    if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
        $tmp_label .= SPACE . _('(Only super admins can create groups)');
        $newgroupTB->setReadonly(true);
    }
    $hostList->addRow(SPACE, array(new CLabel($tmp_label, 'newgroup'), BR(), $newgroupTB), null, null, null, 'new');
} else {
Example #4
0
         }
     }
 }
 // select all possible groups
 $params = array('not_proxy_host' => 1, 'order' => 'name', 'editable' => 1, 'extendoutput' => 1);
 $db_groups = CHostGroup::get($params);
 $twb_groupid = get_request('twb_groupid', 0);
 if ($twb_groupid == 0) {
     $gr = reset($db_groups);
     $twb_groupid = $gr['groupid'];
 }
 $cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
 foreach ($db_groups as $groupid => $row) {
     $cmbGroups->addItem($groupid, $row['name']);
 }
 $cmbHosts = new CTweenBox($frmHostG, 'hosts', $hosts, 25);
 // 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']);
 }
if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
    $tmp_label .= SPACE . _('(Only super admins can create groups)');
    $newgroupTB->setReadonly(true);
}
$templateList->addRow(SPACE, array($tmp_label, BR(), $newgroupTB), null, null, 'new');
// FORM ITEM : linked Hosts tween box [  ] [  ]
$twb_groupid = get_request('twb_groupid', 0);
if ($twb_groupid == 0) {
    $gr = reset($groupsAllowed);
    $twb_groupid = $gr['groupid'];
}
$cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
foreach ($groupsAllowed as $group) {
    $cmbGroups->addItem($group['groupid'], $group['name']);
}
$host_tb = new CTweenBox($frmHost, 'hosts', $hosts_linked_to, 20);
// get hosts from selected twb_groupid combo
$params = array('groupids' => $twb_groupid, 'templated_hosts' => 1, 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL), 'preservekeys' => true);
$hostsAllowedToAdd = API::Host()->get($params);
order_result($hostsAllowedToAdd, 'name');
// add all except selected hosts
foreach ($hostsAllowedToAdd as $host) {
    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');
$hostGroupForm->addVar('form', $this->data['form']);
if (isset($this->data['groupid'])) {
    $hostGroupForm->addVar('groupid', $this->data['groupid']);
}
// create hostgroup form list
$hostGroupFormList = new CFormList('hostgroupFormList');
$nameTextBox = new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['groupid'] && $this->data['group']['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 64);
$nameTextBox->attr('autofocus', 'autofocus');
$hostGroupFormList->addRow(_('Group name'), $nameTextBox);
// append groups and hosts to form list
$groupsComboBox = new CComboBox('twb_groupid', $this->data['twb_groupid'], 'submit()');
$groupsComboBox->addItem('0', _('All'));
foreach ($this->data['db_groups'] as $group) {
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostsComboBox = new CTweenBox($hostGroupForm, 'hosts', $this->data['hosts'], 25);
foreach ($this->data['db_hosts'] as $host) {
    if (!isset($this->data['hosts'][$host['hostid']])) {
        $hostsComboBox->addItem($host['hostid'], $host['name']);
    }
}
foreach ($this->data['r_hosts'] as $host) {
    if ($host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostsComboBox->addItem($host['hostid'], $host['name']);
    } else {
        $hostsComboBox->addItem($host['hostid'], $host['name'], true, false);
    }
}
$hostGroupFormList->addRow(_('Hosts'), $hostsComboBox->get(_('Hosts in'), array(_('Other hosts | Group') . SPACE, $groupsComboBox)));
// append tabs to form
$hostGroupTab = new CTabView();
Example #7
0
$comboform->addVar('dstfrm', $dstfrm);
// create table header +
$cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
$cmbGroups->addItem(0, S_ALL_S);
$sql = 'SELECT usrgrpid, name FROM usrgrp WHERE ' . DBin_node('usrgrpid') . ' ORDER BY name';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
    $cmbGroups->addItem($row['usrgrpid'], $row['name']);
}
$comboform->addItem($cmbGroups);
show_table_header(S_USERS, $comboform);
// -
// create user twinbox +
$form = new CForm('users.php');
$form->addOption('id', 'users');
$user_tb = new CTweenBox($form, 'usersid', null, 10);
$from = '';
$where = '';
if ($groupid > 0) {
    $from = ', users_groups g ';
    $where = ' AND u.userid=g.userid AND g.usrgrpid=' . $groupid;
}
$sql = 'SELECT u.userid, u.alias FROM users u ' . $from . ' WHERE ' . DBin_node('u.userid') . $where . ' ORDER BY name';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
    $user_tb->addItem($row['userid'], $row['alias'], false);
}
$form->addItem($user_tb->get('asdasda', 'asdasdasdas'));
// -
$button = new CButton('select', S_SELECT, 'add_users("' . $dstfrm . '")');
$button->setType('button');
if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
    $tmp_label .= SPACE . _('(Only super admins can create groups)');
    $newgroupTB->setReadonly(true);
}
$templateList->addRow(SPACE, array($tmp_label, BR(), $newgroupTB), null, null, 'new');
// FORM ITEM : linked Hosts tween box [  ] [  ]
$twb_groupid = getRequest('twb_groupid', 0);
if ($twb_groupid == 0) {
    $gr = reset($all_groups);
    $twb_groupid = $gr['groupid'];
}
$cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
foreach ($all_groups as $gnum => $group) {
    $cmbGroups->addItem($group['groupid'], $group['name']);
}
$host_tb = new CTweenBox($frmHost, 'hosts', $hosts_linked_to, 20);
// get hosts from selected twb_groupid combo
$params = array('groupids' => $twb_groupid, 'templated_hosts' => 1, 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL));
$db_hosts = API::Host()->get($params);
order_result($db_hosts, 'name');
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['name']);
}
// select selected hosts and add them
$params = array('hostids' => $hosts_linked_to, 'templated_hosts' => 1, 'editable' => 1, 'output' => API_OUTPUT_EXTEND);
$db_hosts = API::Host()->get($params);
order_result($db_hosts, 'name');
Example #9
0
 if ($twb_groupid == -1) {
     $gr = reset($db_groups);
     $twb_groupid = $gr['groupid'];
 }
 //creating <select> with list of host groups
 $cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
 /**
  * Adding option 'All' to combobox list
  * @see ZBX-1425
  * @author Konstantin Buravcov
  */
 $cmbGroups->addItem('0', S_O_ALL);
 foreach ($db_groups as $row) {
     $cmbGroups->addItem($row['groupid'], $row['name']);
 }
 $cmbHosts = new CTweenBox($frmHostG, 'hosts', $hosts, 25);
 //if $twb_groupid is '0', we need to get all hosts, if not, hosts from given group
 if ($twb_groupid == 0) {
     //get all hosts from all groups
     $params = array('templated_hosts' => 1, 'sortfield' => 'host', 'editable' => 1, 'extendoutput' => 1);
 } else {
     // get hosts from selected twb_groupid combo
     $params = array('groupids' => $twb_groupid, 'templated_hosts' => 1, 'sortfield' => 'host', 'editable' => 1, 'extendoutput' => 1);
 }
 $db_hosts = CHost::get($params);
 foreach ($db_hosts as $num => $db_host) {
     // add all except selected hosts
     if (!isset($hosts[$db_host['hostid']])) {
         $cmbHosts->addItem($db_host['hostid'], $db_host['host']);
     }
 }
Example #10
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;
}
Example #12
0
function insert_host_form()
{
    global $USER_DETAILS;
    $host_groups = get_request('groups', array());
    if (isset($_REQUEST['groupid']) && $_REQUEST['groupid'] > 0 && empty($host_groups)) {
        array_push($host_groups, $_REQUEST['groupid']);
    }
    $newgroup = get_request('newgroup', '');
    $host = get_request('host', '');
    $port = get_request('port', CProfile::get('HOST_PORT', 10050));
    $status = get_request('status', HOST_STATUS_MONITORED);
    $useip = get_request('useip', 1);
    $dns = get_request('dns', '');
    $ip = get_request('ip', '0.0.0.0');
    $proxy_hostid = get_request('proxy_hostid', '');
    $useipmi = get_request('useipmi', 'no');
    $ipmi_ip = get_request('ipmi_ip', '');
    $ipmi_port = get_request('ipmi_port', 623);
    $ipmi_authtype = get_request('ipmi_authtype', -1);
    $ipmi_privilege = get_request('ipmi_privilege', 2);
    $ipmi_username = get_request('ipmi_username', '');
    $ipmi_password = get_request('ipmi_password', '');
    $useprofile = get_request('useprofile', 'no');
    $devicetype = get_request('devicetype', '');
    $name = get_request('name', '');
    $os = get_request('os', '');
    $serialno = get_request('serialno', '');
    $tag = get_request('tag', '');
    $macaddress = get_request('macaddress', '');
    $hardware = get_request('hardware', '');
    $software = get_request('software', '');
    $contact = get_request('contact', '');
    $location = get_request('location', '');
    $notes = get_request('notes', '');
    $_REQUEST['hostid'] = get_request('hostid', 0);
    // BEGIN: HOSTS PROFILE EXTENDED Section
    $useprofile_ext = get_request('useprofile_ext', 'no');
    $ext_host_profiles = get_request('ext_host_profiles', array());
    // END:   HOSTS PROFILE EXTENDED Section
    $templates = get_request('templates', array());
    $clear_templates = get_request('clear_templates', array());
    $frm_title = S_HOST;
    if ($_REQUEST['hostid'] > 0) {
        $db_host = get_host_by_hostid($_REQUEST['hostid']);
        $frm_title .= SPACE . ' [' . $db_host['host'] . ']';
        $original_templates = get_templates_by_hostid($_REQUEST['hostid']);
    } else {
        $original_templates = array();
    }
    if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) {
        $proxy_hostid = $db_host['proxy_hostid'];
        $host = $db_host['host'];
        $port = $db_host['port'];
        $status = $db_host['status'];
        $useip = $db_host['useip'];
        $useipmi = $db_host['useipmi'] ? 'yes' : 'no';
        $ip = $db_host['ip'];
        $dns = $db_host['dns'];
        $ipmi_ip = $db_host['ipmi_ip'];
        $ipmi_port = $db_host['ipmi_port'];
        $ipmi_authtype = $db_host['ipmi_authtype'];
        $ipmi_privilege = $db_host['ipmi_privilege'];
        $ipmi_username = $db_host['ipmi_username'];
        $ipmi_password = $db_host['ipmi_password'];
        // add groups
        $options = array('hostids' => $_REQUEST['hostid']);
        $host_groups = CHostGroup::get($options);
        $host_groups = zbx_objectValues($host_groups, 'groupid');
        // read profile
        $db_profiles = DBselect('SELECT * FROM hosts_profiles WHERE hostid=' . $_REQUEST['hostid']);
        $useprofile = 'no';
        $db_profile = DBfetch($db_profiles);
        if ($db_profile) {
            $useprofile = 'yes';
            $devicetype = $db_profile['devicetype'];
            $name = $db_profile['name'];
            $os = $db_profile['os'];
            $serialno = $db_profile['serialno'];
            $tag = $db_profile['tag'];
            $macaddress = $db_profile['macaddress'];
            $hardware = $db_profile['hardware'];
            $software = $db_profile['software'];
            $contact = $db_profile['contact'];
            $location = $db_profile['location'];
            $notes = $db_profile['notes'];
        }
        // BEGIN: HOSTS PROFILE EXTENDED Section
        $useprofile_ext = 'no';
        $db_profiles_alt = DBselect('SELECT * FROM hosts_profiles_ext WHERE hostid=' . $_REQUEST['hostid']);
        if ($ext_host_profiles = DBfetch($db_profiles_alt)) {
            $useprofile_ext = 'yes';
        } else {
            $ext_host_profiles = array();
        }
        // END:   HOSTS PROFILE EXTENDED Section
        $templates = $original_templates;
    }
    $ext_profiles_fields = array('device_alias' => S_DEVICE_ALIAS, 'device_type' => S_DEVICE_TYPE, 'device_chassis' => S_DEVICE_CHASSIS, 'device_os' => S_DEVICE_OS, 'device_os_short' => S_DEVICE_OS_SHORT, 'device_hw_arch' => S_DEVICE_HW_ARCH, 'device_serial' => S_DEVICE_SERIAL, 'device_model' => S_DEVICE_MODEL, 'device_tag' => S_DEVICE_TAG, 'device_vendor' => S_DEVICE_VENDOR, 'device_contract' => S_DEVICE_CONTRACT, 'device_who' => S_DEVICE_WHO, 'device_status' => S_DEVICE_STATUS, 'device_app_01' => S_DEVICE_APP_01, 'device_app_02' => S_DEVICE_APP_02, 'device_app_03' => S_DEVICE_APP_03, 'device_app_04' => S_DEVICE_APP_04, 'device_app_05' => S_DEVICE_APP_05, 'device_url_1' => S_DEVICE_URL_1, 'device_url_2' => S_DEVICE_URL_2, 'device_url_3' => S_DEVICE_URL_3, 'device_networks' => S_DEVICE_NETWORKS, 'device_notes' => S_DEVICE_NOTES, 'device_hardware' => S_DEVICE_HARDWARE, 'device_software' => S_DEVICE_SOFTWARE, 'ip_subnet_mask' => S_IP_SUBNET_MASK, 'ip_router' => S_IP_ROUTER, 'ip_macaddress' => S_IP_MACADDRESS, 'oob_ip' => S_OOB_IP, 'oob_subnet_mask' => S_OOB_SUBNET_MASK, 'oob_router' => S_OOB_ROUTER, 'date_hw_buy' => S_DATE_HW_BUY, 'date_hw_install' => S_DATE_HW_INSTALL, 'date_hw_expiry' => S_DATE_HW_EXPIRY, 'date_hw_decomm' => S_DATE_HW_DECOMM, 'site_street_1' => S_SITE_STREET_1, 'site_street_2' => S_SITE_STREET_2, 'site_street_3' => S_SITE_STREET_3, 'site_city' => S_SITE_CITY, 'site_state' => S_SITE_STATE, 'site_country' => S_SITE_COUNTRY, 'site_zip' => S_SITE_ZIP, 'site_rack' => S_SITE_RACK, 'site_notes' => S_SITE_NOTES, 'poc_1_name' => S_POC_1_NAME, 'poc_1_email' => S_POC_1_EMAIL, 'poc_1_phone_1' => S_POC_1_PHONE_1, 'poc_1_phone_2' => S_POC_1_PHONE_2, 'poc_1_cell' => S_POC_1_CELL, 'poc_1_screen' => S_POC_1_SCREEN, 'poc_1_notes' => S_POC_1_NOTES, 'poc_2_name' => S_POC_2_NAME, 'poc_2_email' => S_POC_2_EMAIL, 'poc_2_phone_1' => S_POC_2_PHONE_1, 'poc_2_phone_2' => S_POC_2_PHONE_2, 'poc_2_cell' => S_POC_2_CELL, 'poc_2_screen' => S_POC_2_SCREEN, 'poc_2_notes' => S_POC_2_NOTES);
    foreach ($ext_profiles_fields as $field => $caption) {
        if (!isset($ext_host_profiles[$field])) {
            $ext_host_profiles[$field] = '';
        }
    }
    $clear_templates = array_intersect($clear_templates, array_keys($original_templates));
    $clear_templates = array_diff($clear_templates, array_keys($templates));
    natcasesort($templates);
    $frmHost = new CForm('hosts.php', 'post');
    $frmHost->setName('web.hosts.host.php.');
    //		$frmHost->setHelp('web.hosts.host.php');
    //		$frmHost->addVar('config',get_request('config',0));
    $frmHost->addVar('form', get_request('form', 1));
    $from_rfr = get_request('form_refresh', 0);
    $frmHost->addVar('form_refresh', $from_rfr + 1);
    $frmHost->addVar('clear_templates', $clear_templates);
    // HOST WIDGET {
    $host_tbl = new CTable('', 'tablestripped');
    $host_tbl->setOddRowClass('form_odd_row');
    $host_tbl->setEvenRowClass('form_even_row');
    if ($_REQUEST['hostid'] > 0) {
        $frmHost->addVar('hostid', $_REQUEST['hostid']);
    }
    if ($_REQUEST['groupid'] > 0) {
        $frmHost->addVar('groupid', $_REQUEST['groupid']);
    }
    $host_tbl->addRow(array(S_NAME, new CTextBox('host', $host, 54)));
    $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10);
    $all_groups = CHostGroup::get(array('editable' => 1, 'extendoutput' => 1));
    order_result($all_groups, 'name');
    foreach ($all_groups as $group) {
        $grp_tb->addItem($group['groupid'], $group['name']);
    }
    $host_tbl->addRow(array(S_GROUPS, $grp_tb->get(S_IN_GROUPS, S_OTHER_GROUPS)));
    $host_tbl->addRow(array(S_NEW_GROUP, new CTextBox('newgroup', $newgroup)));
    // onchange does not work on some browsers: MacOS, KDE browser
    $host_tbl->addRow(array(S_DNS_NAME, new CTextBox('dns', $dns, '40')));
    if (defined('ZBX_HAVE_IPV6')) {
        $host_tbl->addRow(array(S_IP_ADDRESS, new CTextBox('ip', $ip, '39')));
    } else {
        $host_tbl->addRow(array(S_IP_ADDRESS, new CTextBox('ip', $ip, '15')));
    }
    $cmbConnectBy = new CComboBox('useip', $useip);
    $cmbConnectBy->addItem(0, S_DNS_NAME);
    $cmbConnectBy->addItem(1, S_IP_ADDRESS);
    $host_tbl->addRow(array(S_CONNECT_TO, $cmbConnectBy));
    $host_tbl->addRow(array(S_AGENT_PORT, new CNumericBox('port', $port, 5)));
    //Proxy
    $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid);
    $cmbProxy->addItem(0, S_NO_PROXY);
    $options = array('extendoutput' => 1);
    $db_proxies = CProxy::get($options);
    order_result($db_proxies, 'host');
    foreach ($db_proxies as $proxy) {
        $cmbProxy->addItem($proxy['proxyid'], $proxy['host']);
    }
    $host_tbl->addRow(array(S_MONITORED_BY_PROXY, $cmbProxy));
    //----------
    $cmbStatus = new CComboBox('status', $status);
    $cmbStatus->addItem(HOST_STATUS_MONITORED, S_MONITORED);
    $cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED);
    $host_tbl->addRow(array(S_STATUS, $cmbStatus));
    $host_tbl->addRow(array(S_USEIPMI, new CCheckBox('useipmi', $useipmi, 'submit()')));
    if ($useipmi == 'yes') {
        $host_tbl->addRow(array(S_IPMI_IP_ADDRESS, new CTextBox('ipmi_ip', $ipmi_ip, defined('ZBX_HAVE_IPV6') ? 39 : 15)));
        $host_tbl->addRow(array(S_IPMI_PORT, new CNumericBox('ipmi_port', $ipmi_port, 5)));
        $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_DEFAULT, S_AUTHTYPE_DEFAULT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_NONE, S_AUTHTYPE_NONE);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD2, S_AUTHTYPE_MD2);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD5, S_AUTHTYPE_MD5);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_STRAIGHT, S_AUTHTYPE_STRAIGHT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_OEM, S_AUTHTYPE_OEM);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_RMCP_PLUS, S_AUTHTYPE_RMCP_PLUS);
        $host_tbl->addRow(array(S_IPMI_AUTHTYPE, $cmbIPMIAuthtype));
        $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_CALLBACK, S_PRIVILEGE_CALLBACK);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_USER, S_PRIVILEGE_USER);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OPERATOR, S_PRIVILEGE_OPERATOR);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_ADMIN, S_PRIVILEGE_ADMIN);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OEM, S_PRIVILEGE_OEM);
        $host_tbl->addRow(array(S_IPMI_PRIVILEGE, $cmbIPMIPrivilege));
        $host_tbl->addRow(array(S_IPMI_USERNAME, new CTextBox('ipmi_username', $ipmi_username, 16)));
        $host_tbl->addRow(array(S_IPMI_PASSWORD, new CTextBox('ipmi_password', $ipmi_password, 20)));
    } else {
        $frmHost->addVar('ipmi_ip', $ipmi_ip);
        $frmHost->addVar('ipmi_port', $ipmi_port);
        $frmHost->addVar('ipmi_authtype', $ipmi_authtype);
        $frmHost->addVar('ipmi_privilege', $ipmi_privilege);
        $frmHost->addVar('ipmi_username', $ipmi_username);
        $frmHost->addVar('ipmi_password', $ipmi_password);
    }
    if ($_REQUEST['form'] == 'full_clone') {
        // Host items
        $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'output' => API_OUTPUT_EXTEND, 'webitems' => 1);
        $host_items = CItem::get($options);
        if (!empty($host_items)) {
            $items_lbx = new CListBox('items', null, 8);
            $items_lbx->setAttribute('disabled', 'disabled');
            order_result($host_items, 'description');
            foreach ($host_items as $hitem) {
                $items_lbx->addItem($hitem['itemid'], item_description($hitem));
            }
            $host_tbl->addRow(array(S_ITEMS, $items_lbx));
        }
        // Host triggers
        $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true);
        $host_triggers = CTrigger::get($options);
        if (!empty($host_triggers)) {
            $trig_lbx = new CListBox('triggers', null, 8);
            $trig_lbx->setAttribute('disabled', 'disabled');
            order_result($host_triggers, 'description');
            foreach ($host_triggers as $htrigger) {
                $trig_lbx->addItem($htrigger['triggerid'], $htrigger['description']);
            }
            $host_tbl->addRow(array(S_TRIGGERS, $trig_lbx));
        }
        // Host graphs
        $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'select_hosts' => API_OUTPUT_REFER, 'output' => API_OUTPUT_EXTEND);
        $host_graphs = CGraph::get($options);
        if (!empty($host_graphs)) {
            $graphs_lbx = new CListBox('graphs', null, 8);
            $graphs_lbx->setAttribute('disabled', 'disabled');
            order_result($host_graphs, 'name');
            foreach ($host_graphs as $hgraph) {
                if (count($hgraph['hosts']) > 1) {
                    continue;
                }
                $graphs_lbx->addItem($hgraph['graphid'], $hgraph['name']);
            }
            if ($graphs_lbx->ItemsCount() > 1) {
                $host_tbl->addRow(array(S_GRAPHS, $graphs_lbx));
            }
        }
    }
    $host_footer = array();
    $host_footer[] = new CButton('save', S_SAVE);
    if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') {
        array_push($host_footer, SPACE, new CButton('clone', S_CLONE), SPACE, new CButton('full_clone', S_FULL_CLONE), SPACE, new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param('form') . url_param('hostid') . url_param('groupid')));
    }
    array_push($host_footer, SPACE, new CButtonCancel(url_param('groupid')));
    $host_footer = new CCol($host_footer);
    $host_footer->setColSpan(2);
    $host_tbl->setFooter($host_footer);
    $host_wdgt = new CWidget();
    $host_wdgt->setClass('header');
    $host_wdgt->addHeader($frm_title);
    $host_wdgt->addItem($host_tbl);
    // } HOST WIDGET
    // TEMPLATES{
    $template_tbl = new CTableInfo(S_NO_TEMPLATES_LINKED, 'tablestripped');
    $template_tbl->setOddRowClass('form_odd_row');
    $template_tbl->setEvenRowClass('form_even_row');
    foreach ($templates as $id => $temp_name) {
        $frmHost->addVar('templates[' . $id . ']', $temp_name);
        $template_tbl->addRow(new CCol(array(new CCheckBox('templates_rem[' . $id . ']', 'no', null, $id), $temp_name)));
    }
    $footer = new CCol(array(new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->getName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T'), SPACE, new CButton('unlink', S_UNLINK), SPACE, new CButton('unlink_and_clear', S_UNLINK_AND_CLEAR)));
    //$footer->setColSpan(2);
    $template_tbl->setFooter($footer);
    $template_wdgt = new CWidget();
    $template_wdgt->setClass('header');
    $template_wdgt->addHeader(S_LINKED_TEMPLATES);
    $template_wdgt->addItem($template_tbl);
    // } TEMPLATES
    // MACROS WIDGET {
    $macros_wdgt = get_macros_widget($_REQUEST['hostid']);
    // } MACROS WIDGET
    // PROFILE WIDGET {
    $profile_tbl = new CTable('', 'tablestripped');
    $profile_tbl->setOddRowClass('form_odd_row');
    $profile_tbl->setEvenRowClass('form_even_row');
    $profile_tbl->addRow(array(S_USE_PROFILE, new CCheckBox('useprofile', $useprofile, 'submit()')));
    if ($useprofile == 'yes') {
        $profile_tbl->addRow(array(S_DEVICE_TYPE, new CTextBox('devicetype', $devicetype, 61)));
        $profile_tbl->addRow(array(S_NAME, new CTextBox('name', $name, 61)));
        $profile_tbl->addRow(array(S_OS, new CTextBox('os', $os, 61)));
        $profile_tbl->addRow(array(S_SERIALNO, new CTextBox('serialno', $serialno, 61)));
        $profile_tbl->addRow(array(S_TAG, new CTextBox('tag', $tag, 61)));
        $profile_tbl->addRow(array(S_MACADDRESS, new CTextBox('macaddress', $macaddress, 61)));
        $profile_tbl->addRow(array(S_HARDWARE, new CTextArea('hardware', $hardware, 60, 4)));
        $profile_tbl->addRow(array(S_SOFTWARE, new CTextArea('software', $software, 60, 4)));
        $profile_tbl->addRow(array(S_CONTACT, new CTextArea('contact', $contact, 60, 4)));
        $profile_tbl->addRow(array(S_LOCATION, new CTextArea('location', $location, 60, 4)));
        $profile_tbl->addRow(array(S_NOTES, new CTextArea('notes', $notes, 60, 4)));
    } else {
        $frmHost->addVar('devicetype', $devicetype);
        $frmHost->addVar('name', $name);
        $frmHost->addVar('os', $os);
        $frmHost->addVar('serialno', $serialno);
        $frmHost->addVar('tag', $tag);
        $frmHost->addVar('macaddress', $macaddress);
        $frmHost->addVar('hardware', $hardware);
        $frmHost->addVar('software', $software);
        $frmHost->addVar('contact', $contact);
        $frmHost->addVar('location', $location);
        $frmHost->addVar('notes', $notes);
    }
    $profile_wdgt = new CWidget();
    $profile_wdgt->setClass('header');
    $profile_wdgt->addHeader(S_PROFILE);
    $profile_wdgt->addItem($profile_tbl);
    // } PROFILE WIDGET
    // EXT PROFILE WIDGET {
    $ext_profile_tbl = new CTable('', 'tablestripped');
    $ext_profile_tbl->setOddRowClass('form_odd_row');
    $ext_profile_tbl->setEvenRowClass('form_even_row');
    $ext_profile_tbl->addRow(array(S_USE_EXTENDED_PROFILE, new CCheckBox('useprofile_ext', $useprofile_ext, 'submit()', 'yes')));
    foreach ($ext_profiles_fields as $prof_field => $caption) {
        if ($useprofile_ext == 'yes') {
            $ext_profile_tbl->addRow(array($caption, new CTextBox('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field], 40)));
        } else {
            $frmHost->addVar('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field]);
        }
    }
    $ext_profile_wdgt = new CWidget();
    $ext_profile_wdgt->setClass('header');
    $ext_profile_wdgt->addHeader(S_EXTENDED_HOST_PROFILE);
    $ext_profile_wdgt->addItem($ext_profile_tbl);
    // } EXT PROFILE WIDGET
    $left_table = new CTable();
    $left_table->setCellPadding(4);
    $left_table->setCellSpacing(4);
    $left_table->addRow($host_wdgt);
    $right_table = new CTable();
    $right_table->setCellPadding(4);
    $right_table->setCellSpacing(4);
    $right_table->addRow($template_wdgt);
    $right_table->addRow($macros_wdgt);
    $right_table->addRow($profile_wdgt);
    $right_table->addRow($ext_profile_wdgt);
    $td_l = new CCol($left_table);
    $td_l->setAttribute('valign', 'top');
    $td_r = new CCol($right_table);
    $td_r->setAttribute('valign', 'top');
    $outer_table = new CTable();
    $outer_table->addRow(array($td_l, $td_r));
    $frmHost->addItem($outer_table);
    return $frmHost;
}
}
$templateList->addRow(_('Groups'), $groupsTB->get(_('In groups'), _('Other groups')));
// FORM ITEM : new group text box [  ]
$new_group = (new CTextBox('newgroup', $newgroup))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('maxlength', 64);
$new_group_label = _('New group');
if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
    $new_group_label .= ' ' . _('(Only super admins can create groups)');
    $new_group->setReadonly(true);
}
$templateList->addRow(new CLabel($new_group_label, 'newgroup'), (new CSpan($new_group))->addClass(ZBX_STYLE_FORM_NEW_GROUP));
// FORM ITEM : linked Hosts tween box [  ] [  ]
$cmbGroups = new CComboBox('twb_groupid', $data['twb_groupid'], 'submit()');
foreach ($data['groupsAllowed'] as $group) {
    $cmbGroups->addItem($group['groupid'], $group['name']);
}
$hostsTB = new CTweenBox($frmHost, 'hosts', $data['hostIdsLinkedTo'], 20);
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']]));
}
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once dirname(__FILE__) . '/js/configuration.host.edit.js.php';
// create form
$hostForm = new CForm();
$hostForm->setName('hostForm');
$hostForm->addVar('go', 'massupdate');
foreach ($this->data['hosts'] as $hostid) {
    $hostForm->addVar('hosts[' . $hostid . ']', $hostid);
}
// create form list
$hostFormList = new CFormList('hostFormList');
// append groups to form list
$groupTweenBox = new CTweenBox($hostForm, 'groups', $this->data['groups'], 6);
foreach ($this->data['all_groups'] as $group) {
    $groupTweenBox->addItem($group['groupid'], $group['name']);
}
$hostFormList->addRow(array(_('Replace host groups'), SPACE, new CVisibilityBox('visible[groups]', isset($this->data['visible']['groups']), $groupTweenBox->getName(), _('Original'))), $groupTweenBox->get(_('In groups'), _('Other groups')));
$hostFormList->addRow(array(_('New host group'), SPACE, new CVisibilityBox('visible[newgroup]', isset($this->data['visible']['newgroup']), 'newgroup', _('Original'))), new CTextBox('newgroup', $this->data['newgroup'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 64), null, null, 'new');
// append proxy to form list
$proxyComboBox = new CComboBox('proxy_hostid', $this->data['proxy_hostid']);
$proxyComboBox->addItem(0, _('(no proxy)'));
foreach ($this->data['proxies'] as $proxie) {
    $proxyComboBox->addItem($proxie['hostid'], $proxie['host']);
}
$hostFormList->addRow(array(_('Monitored by proxy'), SPACE, new CVisibilityBox('visible[proxy_hostid]', isset($this->data['visible']['proxy_hostid']), 'proxy_hostid', _('Original'))), $proxyComboBox);
// append status to form list
$statusComboBox = new CComboBox('status', $this->data['status']);
$statusComboBox->addItem(HOST_STATUS_MONITORED, _('Monitored'));
}
// LLD rule link
if ($isDiscovered) {
    $hostList->addRow(_('Discovered by'), new CLink($dbHost['discoveryRule']['name'], 'host_prototypes.php?parent_discoveryid=' . $dbHost['discoveryRule']['itemid'], 'highlight underline weight_normal'));
}
$hostTB = new CTextBox('host', $host, ZBX_TEXTBOX_STANDARD_SIZE, $isDiscovered, 128);
$hostTB->setAttribute('autofocus', 'autofocus');
$hostList->addRow(_('Host name'), $hostTB);
$visiblenameTB = new CTextBox('visiblename', $visibleName, ZBX_TEXTBOX_STANDARD_SIZE, $isDiscovered, 128);
$hostList->addRow(_('Visible name'), $visiblenameTB);
// groups for normal hosts
if (!$isDiscovered) {
    if ($hostGroups) {
        $hostGroups = array_combine($hostGroups, $hostGroups);
    }
    $grp_tb = new CTweenBox($frmHost, 'groups', $hostGroups, 10);
    // get user allowed host groups and sort them by name
    $groupsAllowed = API::HostGroup()->get(array('editable' => true, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
    order_result($groupsAllowed, 'name');
    if (getRequest('form') === 'update') {
        // get other host groups that user has also read permissions and sort by name
        $all_groups = API::HostGroup()->get(array('output' => array('groupid', 'name'), 'preservekeys' => true));
        order_result($all_groups, 'name');
        // Add existing host groups to list and, depending on permissions show name as enabled or disabled
        $groupsInList = array();
        foreach ($all_groups as $group) {
            if (isset($hostGroups[$group['groupid']])) {
                $grp_tb->addItem($group['groupid'], $group['name'], true, isset($groupsAllowed[$group['groupid']]));
                $groupsInList[$group['groupid']] = true;
            }
        }
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
$this->includeJSfile('app/views/administration.proxy.edit.js.php');
$widget = (new CWidget())->setTitle(_('Proxies'));
$tabs = new CTabView();
if ($data['form_refresh'] == 0) {
    $tabs->setSelected(0);
}
$proxyForm = (new CForm())->setId('proxyForm')->addVar('proxyid', $data['proxyid'])->addVar('tls_accept', $data['tls_accept']);
if ($data['status'] == HOST_STATUS_PROXY_PASSIVE && array_key_exists('interfaceid', $data)) {
    $proxyForm->addVar('interfaceid', $data['interfaceid']);
}
$interfaceTable = (new CTable())->setHeader([_('IP address'), _('DNS name'), _('Connect to'), _('Port')])->addRow([(new CTextBox('ip', $data['ip'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_IP_WIDTH), (new CTextBox('dns', $data['dns'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_DNS_WIDTH), (new CRadioButtonList('useip', (int) $data['useip']))->addValue(_('IP'), INTERFACE_USE_IP)->addValue(_('DNS'), INTERFACE_USE_DNS)->setModern(true), (new CTextBox('port', $data['port'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_PORT_WIDTH)]);
// append hosts to form list
$hosts_tween_box = new CTweenBox($proxyForm, 'proxy_hostids', $data['proxy_hostids']);
foreach ($data['all_hosts'] as $host) {
    // show only normal hosts, and discovered hosts monitored by the current proxy
    // for new proxies display only normal hosts
    if ($host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL || $data['proxyid'] != 0 && bccomp($data['proxyid'], $host['proxy_hostid']) == 0) {
        $hosts_tween_box->addItem($host['hostid'], $host['name'], null, $host['proxy_hostid'] == 0 || bccomp($host['proxy_hostid'], $data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL);
    }
}
$proxy_form_list = (new CFormList('proxyFormList'))->addRow(_('Proxy name'), (new CTextBox('host', $data['host'], false, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))->addRow(_('Proxy mode'), new CComboBox('status', $data['status'], null, [HOST_STATUS_PROXY_ACTIVE => _('Active'), HOST_STATUS_PROXY_PASSIVE => _('Passive')]))->addRow(_('Interface'), (new CDiv($interfaceTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR))->addRow(_('Hosts'), $hosts_tween_box->get(_('Proxy hosts'), _('Other hosts')))->addRow(_('Description'), (new CTextArea('description', $data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
// append tabs to form
$proxyTab = (new CTabView())->addTab('proxyTab', _('Proxy'), $proxy_form_list);
// Encryption form list.
$encryption_form_list = (new CFormList('encryption'))->addRow(_('Connections to proxy'), (new CRadioButtonList('tls_connect', (int) $data['tls_connect']))->addValue(_('No encryption'), HOST_ENCRYPTION_NONE)->addValue(_('PSK'), HOST_ENCRYPTION_PSK)->addValue(_('Certificate'), HOST_ENCRYPTION_CERTIFICATE)->setModern(true))->addRow(_('Connections from proxy'), [new CLabel([new CCheckBox('tls_in_none'), _('No encryption')]), BR(), new CLabel([new CCheckBox('tls_in_psk'), _('PSK')]), BR(), new CLabel([new CCheckBox('tls_in_cert'), _('Certificate')])])->addRow(_('PSK identity'), (new CTextBox('tls_psk_identity', $data['tls_psk_identity'], false, 128))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('PSK'), (new CTextBox('tls_psk', $data['tls_psk'], false, 512))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('Issuer'), (new CTextBox('tls_issuer', $data['tls_issuer'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_x('Subject', 'encryption certificate'), (new CTextBox('tls_subject', $data['tls_subject'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH));
$tabs->addTab('proxyTab', _('Proxy'), $proxy_form_list);
$tabs->addTab('encryptionTab', _('Encryption'), $encryption_form_list);
// append buttons to form
if ($data['clone_hostid'] != 0) {
    $frmHost->addVar('clone_hostid', $data['clone_hostid']);
}
if ($data['groupid'] != 0) {
    $frmHost->addVar('groupid', $data['groupid']);
}
$hostList = new CFormList('hostlist');
// LLD rule link
if ($data['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
    $hostList->addRow(_('Discovered by'), new CLink($data['discoveryRule']['name'], 'host_prototypes.php?parent_discoveryid=' . $data['discoveryRule']['itemid']));
}
$hostList->addRow(_('Host name'), (new CTextBox('host', $data['host'], $data['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'));
$hostList->addRow(_('Visible name'), (new CTextBox('visiblename', $data['visiblename'], $data['flags'] == ZBX_FLAG_DISCOVERY_CREATED, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
if ($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED) {
    // groups for normal hosts
    $groupsTB = new CTweenBox($frmHost, 'groups', $data['groups'], 10);
    foreach ($data['groupsAll'] as $group) {
        if (in_array($group['groupid'], $data['groups'])) {
            $groupsTB->addItem($group['groupid'], $group['name'], null, array_key_exists($group['groupid'], $data['groupsAllowed']));
        } elseif (array_key_exists($group['groupid'], $data['groupsAllowed'])) {
            $groupsTB->addItem($group['groupid'], $group['name']);
        }
    }
    $hostList->addRow(_('Groups'), $groupsTB->get(_('In groups'), _('Other groups')));
    $new_group = (new CTextBox('newgroup', $data['newgroup']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('maxlength', 64);
    $new_group_label = _('New group');
    if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
        $new_group_label .= ' ' . _('(Only super admins can create groups)');
        $new_group->setReadonly(true);
    }
    $hostList->addRow(new CLabel($new_group_label, 'newgroup'), (new CSpan($new_group))->addClass(ZBX_STYLE_FORM_NEW_GROUP));
Example #18
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;
}
Example #19
0
 foreach ($hosts as $host) {
     $host_tb->addItem($host['hostid'], $host['host']);
 }
 $tblHlink = new CTable(null, 'formElementTable');
 $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);
if ($this->data['status'] == HOST_STATUS_PROXY_PASSIVE) {
    if (isset($this->data['interface']['interfaceid'])) {
        $proxyForm->addVar('interfaces[0][interfaceid]', $this->data['interface']['interfaceid']);
        $proxyForm->addVar('interfaces[0][hostid]', $this->data['interface']['hostid']);
    }
    $interfaceTable = new CTable(_('No interfaces defined.'), 'formElementTable');
    $interfaceTable->addRow(array(_('IP address'), _('DNS name'), _('Connect to'), _('Port')));
    $connectByComboBox = new CRadioButtonList('interfaces[0][useip]', $this->data['interface']['useip']);
    $connectByComboBox->addValue(_('IP'), 1);
    $connectByComboBox->addValue(_('DNS'), 0);
    $connectByComboBox->useJQueryStyle();
    $interfaceTable->addRow(array(new CTextBox('interfaces[0][ip]', $this->data['interface']['ip'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 39), new CTextBox('interfaces[0][dns]', $this->data['interface']['dns'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), $connectByComboBox, new CTextBox('interfaces[0][port]', $this->data['interface']['port'], 18, 'no', 64)));
    $proxyFormList->addRow(_('Interface'), new CDiv($interfaceTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
}
// append hosts to form list
$hostsTweenBox = new CTweenBox($proxyForm, 'hosts', $this->data['hosts']);
foreach ($this->data['dbHosts'] as $host) {
    $hostsTweenBox->addItem($host['hostid'], $host['name'], null, empty($host['proxy_hostid']) || !empty($this->data['proxyid']) && bccomp($host['proxy_hostid'], $this->data['proxyid']) == 0);
}
$proxyFormList->addRow(_('Hosts'), $hostsTweenBox->get(_('Proxy hosts'), _('Other hosts')));
// append tabs to form
$proxyTab = new CTabView();
$proxyTab->addTab('proxyTab', _('Proxy'), $proxyFormList);
$proxyForm->addItem($proxyTab);
// append buttons to form
if (!empty($this->data['proxyid'])) {
    $proxyForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete proxy?'), url_param('form') . url_param('proxyid')), new CButtonCancel())));
} else {
    $proxyForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CButtonCancel())));
}
// append form to widget
Example #21
0
            $frmHostG->addRow(S_IP_ADDRESS, new CTextBox('ip', $ip, '39'));
        } else {
            $frmHostG->addRow(S_IP_ADDRESS, new CTextBox('ip', $ip, '15'));
        }
        $cmbConnectBy = new CComboBox('useip', $useip);
        $cmbConnectBy->addItem(0, S_DNS_NAME);
        $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();
 * Hosts & groups tab
 */
$hostsAndGroupsFormList = new CFormList('hostsAndGroupsFormList');
$hostTweenBox = new CTweenBox($maintenanceForm, 'hostids', $this->data['hostids'], 10);
foreach ($this->data['hosts'] as $host) {
    $hostTweenBox->addItem($host['hostid'], $host['name']);
}
$groupsComboBox = new CComboBox('twb_groupid', $this->data['twb_groupid'], 'submit()');
foreach ($this->data['all_groups'] as $group) {
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostTable = new CTable(null, 'formElementTable');
$hostTable->addRow($hostTweenBox->get(_('In maintenance'), array(_('Other hosts | Group') . SPACE, $groupsComboBox)));
$hostsAndGroupsFormList->addRow(_('Hosts in maintenance'), $hostTable);
$groupTable = new CTable(null, 'formElementTable');
$groupTweenBox = new CTweenBox($maintenanceForm, 'groupids', $this->data['groupids'], 10);
foreach ($this->data['all_groups'] as $group) {
    $groupTweenBox->addItem($group['groupid'], $group['name']);
}
$groupTable->addRow($groupTweenBox->get(_('In maintenance'), _('Other groups')));
$hostsAndGroupsFormList->addRow(_('Groups in maintenance'), $groupTable);
// append tabs to form
$maintenanceTab = new CTabView();
if (!$this->data['form_refresh']) {
    $maintenanceTab->setSelected(0);
}
$maintenanceTab->addTab('maintenanceTab', _('Maintenance'), $maintenanceFormList);
$maintenanceTab->addTab('periodsTab', _('Periods'), $maintenancePeriodFormList);
$maintenanceTab->addTab('hostTab', _('Hosts & Groups'), $hostsAndGroupsFormList);
$maintenanceForm->addItem($maintenanceTab);
// append buttons to form
if ($USER_DETAILS['type'] != USER_TYPE_SUPER_ADMIN) {
    $tmp_label .= SPACE . _('(Only super admins can create groups)');
    $newgroupTB->setReadonly(true);
}
$templateList->addRow(array(new CLabel($tmp_label, 'newgroup'), BR(), $newgroupTB), null, null, null, 'new');
// FORM ITEM : linked Hosts tween box [  ] [  ]
$twb_groupid = get_request('twb_groupid', 0);
if ($twb_groupid == 0) {
    $gr = reset($all_groups);
    $twb_groupid = $gr['groupid'];
}
$cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
foreach ($all_groups as $gnum => $group) {
    $cmbGroups->addItem($group['groupid'], $group['name']);
}
$host_tb = new CTweenBox($frmHost, 'hosts', $hosts_linked_to, 20);
// get hosts from selected twb_groupid combo
$params = array('groupids' => $twb_groupid, 'templated_hosts' => 1, 'editable' => 1, 'output' => API_OUTPUT_EXTEND);
$db_hosts = API::Host()->get($params);
order_result($db_hosts, 'name');
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['name']);
}
// select selected hosts and add them
$params = array('hostids' => $hosts_linked_to, 'templated_hosts' => 1, 'editable' => 1, 'output' => API_OUTPUT_EXTEND);
$db_hosts = API::Host()->get($params);
order_result($db_hosts, 'name');
}
/*
 * User group tab
*/
$userGroupFormList = new CFormList('userGroupFormList');
$nameTextBox = new CTextBox('gname', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE);
$nameTextBox->attr('autofocus', 'autofocus');
$userGroupFormList->addRow(_('Group name'), $nameTextBox);
// append groups to form list
$groupsComboBox = new CComboBox('selusrgrp', $this->data['selected_usrgrp'], 'submit()');
$groupsComboBox->addItem(0, _('All'));
foreach ($this->data['usergroups'] as $group) {
    $groupsComboBox->addItem($group['usrgrpid'], $group['name']);
}
// append user tweenbox to form list
$usersTweenBox = new CTweenBox($userGroupForm, 'group_users', $this->data['group_users'], 10);
foreach ($this->data['users'] as $user) {
    $usersTweenBox->addItem($user['userid'], getUserFullname($user));
}
$userGroupFormList->addRow(_('Users'), $usersTweenBox->get(_('In group'), array(_('Other groups'), SPACE, $groupsComboBox)));
// append frontend and user status to from list
$isGranted = isset($data['usrgrpid']) ? granted2update_group($data['usrgrpid']) : true;
if ($isGranted) {
    $frontendComboBox = new CComboBox('gui_access', $this->data['gui_access']);
    $frontendComboBox->addItem(GROUP_GUI_ACCESS_SYSTEM, user_auth_type2str(GROUP_GUI_ACCESS_SYSTEM));
    $frontendComboBox->addItem(GROUP_GUI_ACCESS_INTERNAL, user_auth_type2str(GROUP_GUI_ACCESS_INTERNAL));
    $frontendComboBox->addItem(GROUP_GUI_ACCESS_DISABLED, user_auth_type2str(GROUP_GUI_ACCESS_DISABLED));
    $userGroupFormList->addRow(_('Frontend access'), $frontendComboBox);
    $userGroupFormList->addRow(_('Enabled'), new CCheckBox('users_status', $this->data['users_status'] ? isset($data['usrgrpid']) ? 0 : 1 : 1, null, 1));
    // invert user status 0 - enable, 1 - disable
} else {
Example #25
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;
}
if ($this->data['status'] == HOST_STATUS_PROXY_PASSIVE) {
    if (isset($this->data['interface']['interfaceid'])) {
        $proxyForm->addVar('interface[interfaceid]', $this->data['interface']['interfaceid']);
        $proxyForm->addVar('interface[hostid]', $this->data['interface']['hostid']);
    }
    $interfaceTable = new CTable(null, 'formElementTable');
    $interfaceTable->addRow(array(_('IP address'), _('DNS name'), _('Connect to'), _('Port')));
    $connectByComboBox = new CRadioButtonList('interface[useip]', $this->data['interface']['useip']);
    $connectByComboBox->addValue(_('IP'), 1);
    $connectByComboBox->addValue(_('DNS'), 0);
    $connectByComboBox->useJQueryStyle();
    $interfaceTable->addRow(array(new CTextBox('interface[ip]', $this->data['interface']['ip'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), new CTextBox('interface[dns]', $this->data['interface']['dns'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), $connectByComboBox, new CTextBox('interface[port]', $this->data['interface']['port'], 18, 'no', 64)));
    $proxyFormList->addRow(_('Interface'), new CDiv($interfaceTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
}
// append hosts to form list
$hostsTweenBox = new CTweenBox($proxyForm, 'hosts', $this->data['hosts']);
foreach ($this->data['dbHosts'] as $host) {
    // show only normal hosts, and discovered hosts monitored by the current proxy
    // for new proxies display only normal hosts
    if ($this->data['proxyid'] && idcmp($this->data['proxyid'], $host['proxy_hostid']) || $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostsTweenBox->addItem($host['hostid'], $host['name'], null, empty($host['proxy_hostid']) || !empty($this->data['proxyid']) && bccomp($host['proxy_hostid'], $this->data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL);
    }
}
$proxyFormList->addRow(_('Hosts'), $hostsTweenBox->get(_('Proxy hosts'), _('Other hosts')));
// append tabs to form
$proxyTab = new CTabView();
$proxyTab->addTab('proxyTab', _('Proxy'), $proxyFormList);
$proxyForm->addItem($proxyTab);
// append buttons to form
if (!empty($this->data['proxyid'])) {
    $proxyForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete proxy?'), url_param('form') . url_param('proxyid')), new CButtonCancel())));
Example #27
0
     $name = $proxy["host"];
     $db_hosts = DBselect('SELECT hostid ' . ' FROM hosts ' . ' WHERE status NOT IN (' . HOST_STATUS_DELETED . ') ' . ' AND proxy_hostid=' . $_REQUEST['hostid']);
     while ($db_host = DBfetch($db_hosts)) {
         array_push($hosts, $db_host['hostid']);
     }
 } else {
     $name = get_request("host", "");
 }
 $frmHostG = new CFormTable($frm_title, "proxies.php");
 $frmHostG->setHelp("web.proxy.php");
 $frmHostG->addVar("config", get_request("config", 5));
 if ($_REQUEST['hostid'] > 0) {
     $frmHostG->addVar("hostid", $_REQUEST['hostid']);
 }
 $frmHostG->addRow(S_PROXY_NAME, new CTextBox("host", $name, 30));
 $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 ' . DBcondition('hostid', $available_hosts) . ' ORDER BY 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"], 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(SPACE);
     $frmHostG->addItemToBottomRow(new CButton("clone", S_CLONE));
     $frmHostG->addItemToBottomRow(SPACE);
     $frmHostG->addItemToBottomRow(new CButtonDelete("Delete selected proxy?", url_param("form") . url_param("config") . url_param("hostid")));
 }
 $frmHostG->addItemToBottomRow(SPACE);
 $frmHostG->addItemToBottomRow(new CButtonCancel(url_param("config")));