public function get($caption_l = S_IN, $caption_r = S_OTHER) { $grp_tab = new CTable(); $grp_tab->addOption('name', $this->name); $grp_tab->addOption('id', $this->name); $grp_tab->setCellSpacing(0); $grp_tab->setCellPadding(0); if (!is_null($caption_l) || !is_null($caption_r)) { $grp_tab->addRow(array($caption_l, SPACE, $caption_r)); } $add_btn = new CButton('add', ' « '); //S_ADD);// $add_btn->setType('button'); $add_btn->setAction('javascript: moveListBoxSelectedItem("' . $this->form->GetName() . '","' . $this->varname . '","' . $this->id_r . '","' . $this->id_l . '","add");'); $rmv_btn = new CButton('remove', ' » '); //S_REMOVE);// $rmv_btn->setType('button'); $rmv_btn->setAction('javascript: moveListBoxSelectedItem("' . $this->form->GetName() . '","' . $this->varname . '","' . $this->id_l . '","' . $this->id_r . '","rmv");'); $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox)); return $grp_tab; }
public function get($caption_l = null, $caption_r = null) { if (empty($caption_l)) { $caption_l = _('In'); } if (empty($caption_r)) { $caption_r = _('Other'); } $grp_tab = new CTable(); $grp_tab->attr('name', $this->name); $grp_tab->attr('id', zbx_formatDomId($this->name)); $grp_tab->setCellSpacing(0); $grp_tab->setCellPadding(0); if (!is_null($caption_l) || !is_null($caption_r)) { $grp_tab->addRow(array($caption_l, SPACE, $caption_r)); } $add_btn = new CButton('add', ' « ', null, 'formlist'); $add_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_r . '", "' . $this->id_l . '", "add");'); $rmv_btn = new CButton('remove', ' » ', null, 'formlist'); $rmv_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_l . '", "' . $this->id_r . '", "rmv");'); $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox)); return $grp_tab; }
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; }
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; }
public function bodyToString() { parent::bodyToString(); $tbl = new CTable(NULL, $this->tableclass); $tbl->setOddRowClass('form_odd_row'); $tbl->setEvenRowClass('form_even_row'); $tbl->setCellSpacing(0); $tbl->setCellPadding(1); $tbl->setAlign($this->align); // add first row $col = new CCol(NULL, 'form_row_first'); $col->setColSpan(2); if (isset($this->help)) { $col->addItem($this->help); } if (isset($this->title)) { $col->addItem($this->title); } foreach ($this->top_items as $item) { $col->addItem($item); } $tbl->setHeader($col); // add last row $tbl->setFooter($this->bottom_items); // add center rows foreach ($this->center_items as $item) { $tbl->addRow($item); } return $tbl->toString(); }
function get_table_header($columnLeft, $columnRights = SPACE) { $rights = array(); if ($columnRights) { if (!is_array($columnRights)) { $columnRights = array($columnRights); } foreach ($columnRights as $columnRight) { $rights[] = new CDiv($columnRight, 'floatright'); } $rights = array_reverse($rights); } $table = new CTable(null, 'ui-widget-header ui-corner-all header maxwidth'); $table->setCellSpacing(0); $table->setCellPadding(1); $table->addRow(array(new CCol($columnLeft, 'header_l left'), new CCol($rights, 'header_r right'))); return $table; }
function show_messages($bool = true, $okmsg = null, $errmsg = null) { global $page, $ZBX_MESSAGES; if (!defined('PAGE_HEADER_LOADED')) { return null; } if (defined('ZBX_API_REQUEST')) { return null; } if (!isset($page['type'])) { $page['type'] = PAGE_TYPE_HTML; } $message = array(); $width = 0; $height = 0; if (!$bool && !is_null($errmsg)) { $msg = _('ERROR') . ': ' . $errmsg; } elseif ($bool && !is_null($okmsg)) { $msg = $okmsg; } if (isset($msg)) { switch ($page['type']) { case PAGE_TYPE_IMAGE: array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2)); $width = max($width, imagefontwidth(2) * zbx_strlen($msg) + 1); $height += imagefontheight(2) + 1; break; case PAGE_TYPE_XML: echo htmlspecialchars($msg) . "\n"; break; case PAGE_TYPE_HTML: default: $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr'); $msg_tab->setCellPadding(0); $msg_tab->setCellSpacing(0); $row = array(); $msg_col = new CCol(bold($msg), 'msg_main msg'); $msg_col->setAttribute('id', 'page_msg'); $row[] = $msg_col; if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { $msg_details = new CDiv(_('Details'), 'blacklink'); $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");'); $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize')); array_unshift($row, new CCol($msg_details, 'clr')); } $msg_tab->addRow($row); $msg_tab->show(); break; } } if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { if ($page['type'] == PAGE_TYPE_IMAGE) { $msg_font = 2; foreach ($ZBX_MESSAGES as $msg) { if ($msg['type'] == 'error') { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font)); } else { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font)); } $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1); $height += imagefontheight($msg_font) + 1; } } elseif ($page['type'] == PAGE_TYPE_XML) { foreach ($ZBX_MESSAGES as $msg) { echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n"; } } else { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); $bool = $bool && 'error' != zbx_strtolower($msg['type']); } $msg_show = 6; $msg_count = count($ZBX_MESSAGES); if ($msg_count > $msg_show) { $msg_count = $msg_show * 16; $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;'); } $tab = new CTable(null, $bool ? 'msgok' : 'msgerr'); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('id', 'msg_messages'); $tab->setAttribute('style', 'width: 100%;'); if (isset($msg_tab) && $bool) { $tab->setAttribute('style', 'display: none;'); } $tab->addRow(new CCol($lst_error, 'msg')); $tab->show(); } $ZBX_MESSAGES = null; } if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) { $width += 2; $height += 2; $canvas = imagecreate($width, $height); imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255)); foreach ($message as $id => $msg) { $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0); $message[$id]['h'] = imagefontheight($msg['font']); imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B'])); $previd = $id; } imageOut($canvas); imagedestroy($canvas); } }
function get_table_header($col1, $col2 = SPACE) { if (isset($_REQUEST['print'])) { hide_form_items($col1); hide_form_items($col2); //if empty header than do not show it if ($col1 == SPACE && $col2 == SPACE) { return new CScript(''); } } $table = new CTable(NULL, 'header'); // $table->addOption('border',0); $table->setCellSpacing(0); $table->setCellPadding(1); $td_r = new CCol($col2, 'header_r'); $td_r->addOption('align', 'right'); $table->addRow(array(new CCol($col1, 'header_l'), $td_r)); return $table; }
} $icon->setAttribute('id', 'addrm_fav'); $url = '?elementid=' . $elementid . ($_REQUEST['fullscreen'] ? '' : '&fullscreen=1'); $url .= url_param('groupid') . url_param('hostid'); $fs_icon = new CDiv(SPACE, 'fullscreen'); $fs_icon->setAttribute('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN); $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';")); } $menu = array(); $submenu = array(); // js menu arrays make_refresh_menu('mainpage', 'hat_slides', get_profile('web.slides.rf_rate.hat_slides', $element['delay'], null, $elementid), array('elementid' => $elementid), $menu, $submenu); insert_js('var page_menu=' . zbx_jsvalue($menu) . ";\n" . 'var page_submenu=' . zbx_jsvalue($submenu) . ";\n"); // -------------- $tab = new CTable(); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('border', 0); $tab->setAttribute('width', '100%'); // Refresh tab $refresh_tab = array(array('id' => 'hat_slides', 'frequency' => get_profile('web.slides.rf_rate.hat_slides', $element['delay'], null, $elementid), 'url' => 'slides.php?elementid=' . $elementid . url_param('stime') . url_param('period') . url_param('groupid') . url_param('hostid'), 'params' => array('lastupdate' => time()))); add_doll_objects($refresh_tab); $refresh_icon = new CDiv(SPACE, 'iconmenu'); $refresh_icon->addAction('onclick', 'javascript: create_page_menu(event,"hat_slides");'); $refresh_icon->setAttribute('title', S_MENU); if (isset($elementid)) { $effectiveperiod = navigation_bar_calc(); if (2 != $_REQUEST['fullscreen']) { $stime = time() - 31536000; // ~1year $bstime = time() - $effectiveperiod;
function get_timeperiod_form() { $tblPeriod = new CTableInfo(); // init new_timeperiod variable $new_timeperiod = get_request('new_timeperiod', array()); $new = is_array($new_timeperiod); if (is_array($new_timeperiod)) { if (isset($new_timeperiod['id'])) { $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id'])); } if (isset($new_timeperiod['timeperiodid'])) { $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid'])); } } if (!is_array($new_timeperiod)) { $new_timeperiod = array(); $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME; } if (!isset($new_timeperiod['every'])) { $new_timeperiod['every'] = 1; } if (!isset($new_timeperiod['day'])) { $new_timeperiod['day'] = 1; } if (!isset($new_timeperiod['hour'])) { $new_timeperiod['hour'] = 12; } if (!isset($new_timeperiod['minute'])) { $new_timeperiod['minute'] = 0; } if (!isset($new_timeperiod['start_date'])) { $new_timeperiod['start_date'] = 0; } if (!isset($new_timeperiod['period_days'])) { $new_timeperiod['period_days'] = 0; } if (!isset($new_timeperiod['period_hours'])) { $new_timeperiod['period_hours'] = 1; } if (!isset($new_timeperiod['period_minutes'])) { $new_timeperiod['period_minutes'] = 0; } if (!isset($new_timeperiod['month_date_type'])) { $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day']; } // start time if (isset($new_timeperiod['start_time'])) { $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR); $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN); } // period if (isset($new_timeperiod['period'])) { $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY); $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR); $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN); } // daysofweek $dayofweek = ''; $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1'; if (isset($new_timeperiod['dayofweek'])) { $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true); } $new_timeperiod['dayofweek_mo'] = $dayofweek[0]; $new_timeperiod['dayofweek_tu'] = $dayofweek[1]; $new_timeperiod['dayofweek_we'] = $dayofweek[2]; $new_timeperiod['dayofweek_th'] = $dayofweek[3]; $new_timeperiod['dayofweek_fr'] = $dayofweek[4]; $new_timeperiod['dayofweek_sa'] = $dayofweek[5]; $new_timeperiod['dayofweek_su'] = $dayofweek[6]; // months $month = ''; $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_may']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1'; if (isset($new_timeperiod['month'])) { $month = zbx_num2bitstr($new_timeperiod['month'], true); } $new_timeperiod['month_jan'] = $month[0]; $new_timeperiod['month_feb'] = $month[1]; $new_timeperiod['month_mar'] = $month[2]; $new_timeperiod['month_apr'] = $month[3]; $new_timeperiod['month_may'] = $month[4]; $new_timeperiod['month_jun'] = $month[5]; $new_timeperiod['month_jul'] = $month[6]; $new_timeperiod['month_aug'] = $month[7]; $new_timeperiod['month_sep'] = $month[8]; $new_timeperiod['month_oct'] = $month[9]; $new_timeperiod['month_nov'] = $month[10]; $new_timeperiod['month_dec'] = $month[11]; $bit_dayofweek = zbx_str_revert($dayofweek); $bit_month = zbx_str_revert($month); $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()'); $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only')); $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily')); $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly')); $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly')); $tblPeriod->addRow(array(_('Period type'), $cmbType)); if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) { $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month))); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3))); } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) { $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month))); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2))); $tabDays = new CTable(); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday'))); $tblPeriod->addRow(array(_('Day of week'), $tabDays)); } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) { $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tabMonths = new CTable(); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December'))); $tblPeriod->addRow(array(_('Month'), $tabMonths)); $radioDaily = new CTag('input'); $radioDaily->setAttribute('type', 'radio'); $radioDaily->setAttribute('name', 'new_timeperiod[month_date_type]'); $radioDaily->setAttribute('value', '0'); $radioDaily->setAttribute('onclick', 'submit()'); $radioDaily2 = new CTag('input'); $radioDaily2->setAttribute('type', 'radio'); $radioDaily2->setAttribute('name', 'new_timeperiod[month_date_type]'); $radioDaily2->setAttribute('value', '1'); $radioDaily2->setAttribute('onclick', 'submit()'); if ($new_timeperiod['month_date_type']) { $radioDaily2->setAttribute('checked', 'checked'); } else { $radioDaily->setAttribute('checked', 'checked'); } $tblPeriod->addRow(array(_('Date'), array($radioDaily, _('Day'), SPACE, SPACE, $radioDaily2, _('Day of week')))); if ($new_timeperiod['month_date_type'] > 0) { $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']); $cmbCount->addItem(1, _('First')); $cmbCount->addItem(2, _('Second')); $cmbCount->addItem(3, _('Third')); $cmbCount->addItem(4, _('Fourth')); $cmbCount->addItem(5, _('Last')); $td = new CCol($cmbCount); $td->setColSpan(2); $tabDays = new CTable(); $tabDays->addRow($td); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday'))); $tblPeriod->addRow(array(_('Day of week'), $tabDays)); } else { $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2))); } } else { $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $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["new_timeperiod_date"].clndr.clndrshow(pos.top, pos.left);'); $filtertimetab = new CTable(null, 'calendar'); $filtertimetab->setAttribute('width', '10%'); $filtertimetab->setCellPadding(0); $filtertimetab->setCellSpacing(0); $startDate = zbxDateToTime($new_timeperiod['start_date']); if (isset($_REQUEST['add_timeperiod'])) { $newTimePeriodYear = get_request('new_timeperiod_year'); $newTimePeriodMonth = get_request('new_timeperiod_month'); $newTimePeriodDay = get_request('new_timeperiod_day'); $newTimePeriodHours = get_request('new_timeperiod_hour'); $newTimePeriodMinutes = get_request('new_timeperiod_minute'); } elseif ($startDate > 0) { $newTimePeriodYear = date('Y', $startDate); $newTimePeriodMonth = date('m', $startDate); $newTimePeriodDay = date('d', $startDate); $newTimePeriodHours = date('H', $startDate); $newTimePeriodMinutes = date('i', $startDate); } else { $newTimePeriodYear = ''; $newTimePeriodMonth = ''; $newTimePeriodDay = ''; $newTimePeriodHours = ''; $newTimePeriodMinutes = ''; } $filtertimetab->addRow(array(new CNumericBox('new_timeperiod_day', $newTimePeriodDay, 2), '/', new CNumericBox('new_timeperiod_month', $newTimePeriodMonth, 2), '/', new CNumericBox('new_timeperiod_year', $newTimePeriodYear, 4), SPACE, new CNumericBox('new_timeperiod_hour', $newTimePeriodHours, 2), ':', new CNumericBox('new_timeperiod_minute', $newTimePeriodMinutes, 2), $clndr_icon)); zbx_add_post_js('create_calendar(null, ["new_timeperiod_day", "new_timeperiod_month", "new_timeperiod_year", "new_timeperiod_hour", "new_timeperiod_minute"], "new_timeperiod_date", "new_timeperiod_start_date");'); $tblPeriod->addRow(array(_('Date'), $filtertimetab)); } if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) { $tabTime = new CTable(null, 'calendar'); $tabTime->addRow(array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2))); $tblPeriod->addRow(array(_('At (hour:minute)'), $tabTime)); } $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours']); for ($i = 0; $i < 24; $i++) { $perHours->addItem($i, $i); } $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes']); for ($i = 0; $i < 60; $i++) { $perMinutes->addItem($i, $i); } $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, SPACE . _('Hours'), $perMinutes, SPACE . _('Minutes')))); $td = new CCol(array(new CSubmit('add_timeperiod', $new ? _('Save') : _('Add')), SPACE, new CSubmit('cancel_new_timeperiod', _('Cancel')))); $td->setAttribute('colspan', '3'); $td->setAttribute('style', 'text-align: right;'); $tblPeriod->setFooter($td); return $tblPeriod; }
//------------------------------------- <HISTORY> --------------------------------------- if (isset($page['hist_arg']) && $USER_DETAILS['alias'] != ZBX_GUEST_USER && $page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) { add_user_history($page); } //------------------------------------- </HISTORY> -------------------------------------- show_messages(); $post_script = ''; if ($page['type'] == PAGE_TYPE_HTML) { $post_script .= 'function zbxCallPostScripts(){' . "\n"; if (isset($ZBX_PAGE_POST_JS)) { foreach ($ZBX_PAGE_POST_JS as $num => $script) { $post_script .= $script . "\n"; } } $post_script .= '}' . "\n"; // $post_script.= 'try{ chkbxRange.init(); } catch(e){ throw("Checkbox extension failed!");}'; $post_script .= 'chkbxRange.init();'; insert_js($post_script); if (!defined('ZBX_PAGE_NO_MENU') && !defined('ZBX_PAGE_NO_FOOTER')) { $table = new CTable(NULL, "page_footer"); $table->setCellSpacing(0); $table->setCellPadding(1); $table->AddRow(array(new CCol(new CLink(S_ZABBIX . SPACE . ZABBIX_VERSION . SPACE . S_COPYRIGHT_BY . SPACE . S_SIA_ZABBIX, 'http://www.zabbix.com', 'highlight', null, true), 'page_footer_l'), new CCol(array(new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), new CSpan($USER_DETAILS['userid'] == 0 ? S_NOT_CONNECTED : S_CONNECTED_AS . SPACE . "'" . $USER_DETAILS['alias'] . "'" . (ZBX_DISTRIBUTED ? SPACE . S_FROM_SMALL . SPACE . "'" . $USER_DETAILS['node']['name'] . "'" : ''), 'footer_sign')), "page_footer_r"))); $table->Show(); } COpt::profiling_stop("script"); print '<!--' . "\n" . 'SELECTS: ' . $DB['SELECT_COUNT'] . "\n" . 'EXECUTE: ' . $DB['EXECUTE_COUNT'] . "\n" . 'TOTAL: ' . ($DB['EXECUTE_COUNT'] + $DB['SELECT_COUNT']) . "\n" . '-->'; echo "</body>\n"; echo "</html>\n"; } exit;
private function createFlicker($col1, $col2 = NULL) { $table = new CTable(NULL, 'flicker'); // $table->setAttribute('border',1); $table->setCellSpacing(0); $table->setCellPadding(1); if (!is_null($col2)) { $td_r = new CCol($col2, 'flicker_r'); $td_r->setAttribute('align', 'right'); $table->addRow(array(new CCol($col1, 'flicker_l'), $td_r)); } else { $td_c = new CCol($col1, 'flicker_c'); $td_c->setAttribute('align', 'center'); $table->addRow($td_c); } return $table; }
private function makeRow($id) { $table = new CTable(); $table->setCellSpacing(0); $table->setCellPadding(0); $table->setAttribute('border', '0'); $table->setAttribute('height', '100%'); $tr = $this->makeSImgStr($id); $td = new CCol($this->tree[$id]['caption']); $td->setAttribute('style', 'height: 100%; vertical-align: top; white-space: normal; padding-right: 10px; padding-left: 2px;'); $tr->addItem($td); $table->addRow($tr); $tr = new CRow(); $tr->addItem($table); $tr->setAttribute('id', 'id_' . $id); $tr->setAttribute('style', $this->tree[$id]['parentid'] != '0' ? 'display: none;' : ''); foreach ($this->fields as $key => $value) { $td = new CCol($this->tree[$id][$value]); $td->setAttribute('style', ' padding-right: 10px; padding-left: 2px;'); $tr->addItem($td); } return $tr; }
function get_table_header($col1, $col2 = SPACE) { if (isset($_REQUEST['print'])) { hide_form_items($col1); hide_form_items($col2); //if empty header than do not show it if ($col1 == SPACE && $col2 == SPACE) { return new CJSscript(''); } } $td_l = new CCol(SPACE, 'header_r'); $td_l->setAttribute('width', '100%'); $right_row = array($td_l); if (!is_null($col2)) { if (!is_array($col2)) { $col2 = array($col2); } foreach ($col2 as $num => $r_item) { $right_row[] = new CCol($r_item, 'header_r'); } } $right_tab = new CTable(null, 'nowrap'); $right_tab->setAttribute('width', '100%'); $right_tab->addRow($right_row); $table = new CTable(NULL, 'header'); // $table->setAttribute('border',0); $table->setCellSpacing(0); $table->setCellPadding(1); $td_r = new CCol($right_tab, 'header_r'); $td_r->setAttribute('align', 'right'); $table->addRow(array(new CCol($col1, 'header_l'), $td_r)); return $table; }
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; }
} } $_REQUEST['report_timesince'] = zbxDateToTime(get_request('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY))); $_REQUEST['report_timetill'] = zbxDateToTime(get_request('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME, time()))); $rep6_wdgt = new CWidget(); $r_form = new CForm(); $cnfCmb = new CComboBox('config', $config, 'submit();'); $cnfCmb->addItem(1, _('Distribution of values for multiple periods')); $cnfCmb->addItem(2, _('Distribution of values for multiple items')); $cnfCmb->addItem(3, _('Compare values for multiple periods')); $r_form->addItem(array(_('Reports') . SPACE, $cnfCmb)); $rep6_wdgt->addPageHeader(_('Bar reports')); $rep6_wdgt->addHeader(_('Report'), $r_form); $rep6_wdgt->addItem(BR()); $rep_tab = new CTable(); $rep_tab->setCellPadding(3); $rep_tab->setCellSpacing(3); $rep_tab->setAttribute('border', 0); switch ($config) { default: case 1: $rep_form = valueDistributionFormForMultiplePeriods($validItems); break; case 2: $rep_form = valueDistributionFormForMultipleItems($validItems, $validPeriods); break; case 3: $rep_form = valueComparisonFormForMultiplePeriods(); break; } $rep6_wdgt->addFlicker($rep_form, CProfile::get('web.report6.filter.state', 1));
$report_timesince = get_request('report_timesince', time() - 86400); $report_timetill = get_request('report_timetill', time()); $frmPd->addVar('config', $config); $frmPd->addVar('report_timesince', $report_timesince); $frmPd->addVar('report_timetill', $report_timetill); if (isset($_REQUEST['period_id'])) { $frmPd->addVar('period_id', $_REQUEST['period_id']); } $frmPd->addRow(array(new CVisibilityBox('caption_visible', !zbx_empty($caption), 'caption', S_DEFAULT), S_CAPTION), new CTextBox('caption', $caption, 10)); // $frmPd->addRow(S_CAPTION, new CTextBox('caption',$caption,10)); //* $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer'); $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);"); $reporttimetab = new CTable(null, 'calendar'); $reporttimetab->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");'); $frmPd->addRow(S_PERIOD, $reporttimetab); //*/ if ($config != 1) { $frmPd->addRow(S_COLOR, new CColor('color', $color)); } else { $frmPd->addVar('color', $color); } $frmPd->addItemToBottomRow(new CButton('save', isset($_REQUEST['period_id']) ? S_UPDATE : S_ADD)); $frmPd->addItemToBottomRow(new CButtonCancel(null, 'close_window();'));
function show_messages($bool = TRUE, $okmsg = NULL, $errmsg = NULL) { global $page, $ZBX_MESSAGES; if (!defined('PAGE_HEADER_LOADED')) { return; } if (defined('ZBX_API_REQUEST')) { return; } if (!isset($page['type'])) { $page['type'] = PAGE_TYPE_HTML; } $message = array(); $width = 0; $height = 0; $img_space = null; if (!$bool && !is_null($errmsg)) { $msg = S_CONFIG_ERROR_HEAD . ': ' . $errmsg; } else { if ($bool && !is_null($okmsg)) { $msg = $okmsg; } } $api_errors = CZBXAPI::resetErrors(); if (!empty($api_errors)) { error($api_errors); } if (isset($msg)) { switch ($page['type']) { case PAGE_TYPE_IMAGE: array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2)); $width = max($width, ImageFontWidth(2) * zbx_strlen($msg) + 1); $height += imagefontheight(2) + 1; break; case PAGE_TYPE_XML: echo htmlspecialchars($msg) . "\n"; break; // case PAGE_TYPE_JS: break; // case PAGE_TYPE_JS: break; case PAGE_TYPE_HTML: default: $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr'); $msg_tab->setCellPadding(0); $msg_tab->setCellSpacing(0); $row = array(); $msg_col = new CCol(bold($msg), 'msg_main msg'); $msg_col->setAttribute('id', 'page_msg'); $row[] = $msg_col; if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { $msg_details = new CDiv(S_DETAILS, 'blacklink'); $msg_details->setAttribute('onclick', "javascript: ShowHide('msg_messages', IE?'block':'table');"); $msg_details->setAttribute('title', S_MAXIMIZE . '/' . S_MINIMIZE); array_unshift($row, new CCol($msg_details, 'clr')); } $msg_tab->addRow($row); $msg_tab->show(); $img_space = new CImg('images/general/tree/zero.gif', 'space', '100', '2'); break; } } if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { if ($page['type'] == PAGE_TYPE_IMAGE) { $msg_font = 2; foreach ($ZBX_MESSAGES as $msg) { if ($msg['type'] == 'error') { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font)); } else { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font)); } $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1); $height += imagefontheight($msg_font) + 1; } } else { if ($page['type'] == PAGE_TYPE_XML) { foreach ($ZBX_MESSAGES as $msg) { echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n"; } } else { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); $bool = $bool && 'error' != zbx_strtolower($msg['type']); } //message scroll if needed $msg_show = 6; $msg_count = count($ZBX_MESSAGES); if ($msg_count > $msg_show) { $msg_count = $msg_show; $msg_count = $msg_count * 16; $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;'); } $tab = new CTable(null, $bool ? 'msgok' : 'msgerr'); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('id', 'msg_messages'); $tab->setAttribute('style', 'width: 100%;'); if (isset($msg_tab) && $bool) { $tab->setAttribute('style', 'display: none;'); } $tab->addRow(new CCol($lst_error, 'msg')); $tab->Show(); //--- } } $ZBX_MESSAGES = null; } if (!is_null($img_space)) { print unpack_object($img_space); } if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) { $width += 2; $height += 2; $canvas = imagecreate($width, $height); imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255)); foreach ($message as $id => $msg) { $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0); $message[$id]['h'] = imagefontheight($msg['font']); imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B'])); $previd = $id; } imageOut($canvas); imagedestroy($canvas); } }
if (isset($_REQUEST['hostid'])) { /************************* FILTER *************************/ /***********************************************************/ $filterForm = new CFormTable(S_FILTER); //,'events.php?filter_set=1','POST',null,'sform'); $filterForm->AddOption('name', 'zbx_filter'); $filterForm->AddOption('id', 'zbx_filter'); // $filterForm->SetMethod('post'); $filterForm->addVar('filter_timesince', $_REQUEST['filter_timesince'] > 0 ? $_REQUEST['filter_timesince'] : ''); $filterForm->addVar('filter_timetill', $_REQUEST['filter_timetill'] > 0 ? $_REQUEST['filter_timetill'] : ''); //* $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer'); $clndr_icon->AddAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);"); $filtertimetab = new CTable(null, 'calendar'); $filtertimetab->addOption('width', '10%'); $filtertimetab->setCellPadding(0); $filtertimetab->setCellSpacing(0); $filtertimetab->addRow(array(S_FROM, new CNumericBox('filter_since_day', $_REQUEST['filter_timesince'] > 0 ? date('d', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_month', $_REQUEST['filter_timesince'] > 0 ? date('m', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_year', $_REQUEST['filter_timesince'] > 0 ? date('Y', $_REQUEST['filter_timesince']) : '', 4), SPACE, new CNumericBox('filter_since_hour', $_REQUEST['filter_timesince'] > 0 ? date('H', $_REQUEST['filter_timesince']) : '', 2), ':', new CNumericBox('filter_since_minute', $_REQUEST['filter_timesince'] > 0 ? date('i', $_REQUEST['filter_timesince']) : '', 2), $clndr_icon)); zbx_add_post_js('create_calendar(null,' . '["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],' . '"avail_report_since",' . '"filter_timesince");'); $clndr_icon->AddAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);"); $filtertimetab->AddRow(array(S_TILL, new CNumericBox('filter_till_day', $_REQUEST['filter_timetill'] > 0 ? date('d', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_month', $_REQUEST['filter_timetill'] > 0 ? date('m', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_year', $_REQUEST['filter_timetill'] > 0 ? date('Y', $_REQUEST['filter_timetill']) : '', 4), SPACE, new CNumericBox('filter_till_hour', $_REQUEST['filter_timetill'] > 0 ? date('H', $_REQUEST['filter_timetill']) : '', 2), ':', new CNumericBox('filter_till_minute', $_REQUEST['filter_timetill'] > 0 ? date('i', $_REQUEST['filter_timetill']) : '', 2), $clndr_icon)); zbx_add_post_js('create_calendar(null,' . '["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],' . '"avail_report_till",' . '"filter_timetill");'); zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),"click",CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));'); $filterForm->addRow(S_PERIOD, $filtertimetab); //*/ $filterForm->addItemToBottomRow(new CButton('filter_set', S_FILTER)); $reset = new CButton("filter_rst", S_RESET); $reset->SetType('button'); $reset->SetAction('javascript: var url = new Curl(location.href); url.setArgument("filter_rst",1); location.href = url.getUrl();'); $filterForm->addItemToBottomRow($reset); $filter = create_filter(S_FILTER, NULL, $filterForm, 'tr_filter', get_profile('web.avail_report.filter.state', 0));
function get_table_header($columnLeft, $columnRights = SPACE) { if (isset($_REQUEST['print'])) { hide_form_items($columnLeft); hide_form_items($columnRights); if ($columnLeft == SPACE && $columnRights == SPACE) { return new CJSscript(''); } } $rights = array(); if ($columnRights) { if (!is_array($columnRights)) { $columnRights = array($columnRights); } foreach ($columnRights as $columnRight) { $rights[] = new CDiv($columnRight, 'floatright'); } $rights = array_reverse($rights); } $table = new CTable(null, 'ui-widget-header ui-corner-all header maxwidth'); $table->setCellSpacing(0); $table->setCellPadding(1); $table->addRow(array(new CCol($columnLeft, 'header_l left'), new CCol($rights, 'header_r right'))); return $table; }
if (isset($_REQUEST['form'])) { /* form */ // insert_action_form(); //* NEW Form $frmAction = new CForm('actionconf.php', 'post'); $frmAction->setName(S_ACTION); $frmAction->addVar('form', get_request('form', 1)); $from_rfr = get_request('form_refresh', 0); $frmAction->addVar('form_refresh', $from_rfr + 1); $action = null; if (isset($_REQUEST['actionid'])) { $action = get_action_by_actionid($_REQUEST['actionid']); $frmAction->addVar('actionid', $_REQUEST['actionid']); } $left_tab = new CTable(); $left_tab->setCellPadding(3); $left_tab->setCellSpacing(3); $left_tab->addOption('border', 0); $left_tab->addRow(create_hat(S_ACTION, get_act_action_form($action), null, 'hat_action')); $left_tab->addRow(create_hat(S_ACTION_CONDITIONS, get_act_condition_form($action), null, 'hat_conditions')); if (isset($_REQUEST['new_condition'])) { $left_tab->addRow(create_hat(S_NEW_CONDITION, get_act_new_cond_form($action), null, 'hat_new_cond')); } $right_tab = new CTable(); $right_tab->SetCellPadding(3); $right_tab->SetCellSpacing(3); $right_tab->addOption('border', 0); $right_tab->addRow(create_hat(S_ACTION_OPERATIONS, get_act_operations_form($action), null, 'hat_operations')); if (isset($_REQUEST['new_operation'])) { $right_tab->addRow(create_hat(S_EDIT_OPERATION, get_act_new_oper_form($action), null, 'hat_new_oper')); }
public function bodyToString() { $res = parent::bodyToString(); $tbl = new CTable(null, $this->tableclass); $tbl->setCellSpacing(0); $tbl->setCellPadding(1); $tbl->setAlign($this->align); // add first row if (!is_null($this->title)) { $col = new CCol(null, 'form_row_first'); $col->setColSpan(2); if (isset($this->help)) { $col->addItem($this->help); } if (isset($this->title)) { $col->addItem($this->title); } $tbl->setHeader($col); } // add last row $tbl->setFooter($this->bottom_items); // add center rows foreach ($this->center_items as $item) { $tbl->addRow($item); } return $res . $tbl->toString(); }
if ($filter['groupids'] !== null) { $filterGroups = API::HostGroup()->get(array('output' => array('groupid', 'name'), 'groupids' => $filter['groupids'])); foreach ($filterGroups as $group) { $multiSelectHostGroupData[] = array('id' => $group['groupid'], 'name' => $group['name']); } } /* * Display */ $latestWidget = new CWidget(null, 'latest-mon'); $latestWidget->addHeader(_('Items')); $filterForm = new CForm('get'); $filterForm->setAttribute('name', ' zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterTable = new CTable(null, 'filter'); $filterTable->setCellPadding(0); $filterTable->setCellSpacing(0); $filterTable->addRow(array(new CCol(bold(_('Host groups') . ':'), 'label'), new CCol(new CMultiSelect(array('name' => 'groupids[]', 'objectName' => 'hostGroup', 'data' => $multiSelectHostGroupData, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $filterForm->getName() . '&dstfld1=groupids_' . '&srcfld1=groupid&multiselect=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button'))), 'inputcol'), new CCol(bold(_('Name') . ':'), 'label'), new CCol(new CTextBox('select', $filter['select'], 40), 'inputcol'))); $filterTable->addRow(array(new CCol(bold(_('Hosts') . ':'), 'label'), new CCol(new CMultiSelect(array('name' => 'hostids[]', 'objectName' => 'hosts', 'data' => $multiSelectHostData, 'popup' => array('parameters' => 'srctbl=hosts&dstfrm=' . $filterForm->getName() . '&dstfld1=hostids_&srcfld1=hostid' . '&real_hosts=1&multiselect=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button'))), 'inputcol'), new CCol(bold(_('Show items without data') . ':'), 'label'), new CCol(new CCheckBox('show_without_data', $filter['showWithoutData'], null, 1), 'inputcol'))); $filterTable->addRow(array(new CCol(bold(_('Application') . ':'), 'label'), new CCol(array(new CTextBox('application', $filter['application']), new CButton('application_name', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name&real_hosts=1&dstfld1=application' . '&with_applications=1&dstfrm=' . $filterForm->getName() . '");', 'filter-select-button')), 'inputcol'), new CCol(bold(_('Show details') . ':'), 'label'), new CCol(new CCheckBox('show_details', $filter['showDetails'], null, 1), 'inputcol'))); $filterButton = new CSubmit('filter_set', _('Filter'), 'chkbxRange.clearSelectedOnFilterChange();'); $filterButton->useJQueryStyle(); $resetButton = new CSubmit('filter_rst', _('Reset'), 'chkbxRange.clearSelectedOnFilterChange();'); $resetButton->useJQueryStyle(); $divButtons = new CDiv(array($filterButton, SPACE, $resetButton)); $divButtons->setAttribute('style', 'padding: 4px 0px;'); $filterTable->addRow(new CCol($divButtons, 'controls', 4)); $filterForm->addItem($filterTable); $latestWidget->addFlicker($filterForm, CProfile::get('web.latest.filter.state', 0)); $latestWidget->addPageHeader(_('LATEST DATA'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); $form = new CForm('GET', 'history.php');
$page_header_r_col[] = array('|', new CLink(S_LOGIN, 'index.php?reconnect=1', 'small_font', null, 'nosid')); } $logo = new CLink(new CDiv(SPACE, 'zabbix_logo'), 'http://www.zabbix.com/', 'image', null, 'nosid'); $logo->setTarget('_blank'); $td_r = new CCol($page_header_r_col, 'page_header_r'); $td_r->setAttribute('width', '100%'); $top_page_row = array(new CCol($logo, 'page_header_l'), $td_r); unset($logo, $page_header_r_col, $help, $support); $table = new CTable(NULL, 'page_header'); $table->setCellSpacing(0); $table->setCellPadding(5); $table->addRow($top_page_row); $table->show(); $menu_table = new CTable(NULL, 'menu'); $menu_table->setCellSpacing(0); $menu_table->setCellPadding(5); $menu_table->addRow($main_menu); $node_form = null; if (ZBX_DISTRIBUTED && !defined('ZBX_HIDE_NODE_SELECTION')) { insert_js_function('check_all'); $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_DATA_ARRAY); $available_nodes = get_tree_by_parentid($ZBX_LOCALNODEID, $available_nodes, 'masterid'); //remove parent nodes if (!empty($available_nodes)) { $node_form = new CForm(); $node_form->setMethod('get'); $node_form->setAttribute('id', 'node_form'); // +++ create Combo Box with selected nodes +++ $combo_node_list = null; if (count($ZBX_VIEWED_NODES['nodes']) > 0) { $combo_node_list = new CComboBox('switch_node', $ZBX_VIEWED_NODES['selected'], 'submit()');
$host_footer->setColSpan(2); $template_tbl->setFooter($host_footer); $tplForm_wdgt = new CWidget(); $tplForm_wdgt->setClass('header'); $tplForm_wdgt->addHeader($frm_title); $tplForm_wdgt->addItem($template_tbl); // } TEMPLATE WIDGET // MACROS WIDGET { $macros_wdgt = get_macros_widget($templateid); // } MACROS WIDGET $left_table = new CTable(); $left_table->setCellPadding(4); $left_table->setCellSpacing(4); $left_table->addRow($tplForm_wdgt); $right_table = new CTable(); $right_table->setCellPadding(4); $right_table->setCellSpacing(4); $right_table->addRow($macros_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); $template_wdgt->addItem($frmHost); } } else { // TABLE WITH TEMPLATES $frmForm = new CForm(null, 'get'); $frmForm->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB()));
$admin = uint_in_array($USER_DETAILS['type'], array(USER_TYPE_ZABBIX_ADMIN, USER_TYPE_SUPER_ADMIN)); $rows_per_page = $USER_DETAILS['rows_per_page']; $search_wdgt = new CWidget('search_wdgt'); $search = get_request('search', ''); // Header if (zbx_empty($search)) { $search = 'Search pattern is empty'; } $search_wdgt->addHeader(array(S_SEARCH_BIG . ': ', bold($search)), SPACE); //------------- $left_tab = new CTable(); $left_tab->setCellPadding(3); $left_tab->setCellSpacing(3); $left_tab->setAttribute('border', 0); $right_tab = new CTable(); $right_tab->setCellPadding(3); $right_tab->setCellSpacing(3); $right_tab->setAttribute('border', 0); // FIND Hosts $params = array('nodeids' => get_current_nodeid(), 'extendoutput' => true, 'pattern' => $search, 'extend_pattern' => true, 'limit' => $rows_per_page, 'order' => 'host'); $db_hosts = CHost::get($params); $hosts = selectByPattern($db_hosts, 'host', $search, $rows_per_page); $hostids = array_keys($hosts); $hostsgroups = array(); $sql = 'SELECT * FROM hosts_groups hg WHERE ' . DBcondition('hg.hostid', $hostids); $res = DBselect($sql); while ($hostgroup = DBfetch($res)) { $hostsgroups[$hostgroup['hostid']] = $hostgroup['groupid']; } $params = array('nodeids' => get_current_nodeid(), 'pattern' => $search, 'extend_pattern' => true, 'count' => 1); $hosts_count = CHost::get($params);
private function createFlicker($col1, $col2 = null) { $table = new CTable(null, 'textwhite maxwidth middle flicker'); $table->setCellSpacing(0); $table->setCellPadding(1); if (!is_null($col2)) { $td_r = new CCol($col2, 'flicker_r'); $td_r->setAttribute('align', 'right'); $table->addRow(array(new CCol($col1, 'flicker_l'), $td_r)); } else { $td_c = new CCol($col1, 'flicker_c'); $td_c->setAttribute('align', 'center'); $table->addRow($td_c); } return $table; }
$fs_icon = new CDiv(SPACE, 'fullscreen'); $fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN); $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';")); //------- $left_tab = new CTable(); $left_tab->setCellPadding(3); $left_tab->setCellSpacing(3); $left_tab->addOption('border', 0); $left_tab->addRow(create_hat(S_EVENT . SPACE . S_SOURCE . SPACE . S_DETAILS, make_trigger_details($_REQUEST['triggerid'], $trigger_data), null, 'hat_triggerdetails')); $left_tab->addRow(create_hat(S_EVENT_DETAILS, make_event_details($_REQUEST['eventid']), null, 'hat_eventdetails')); $right_tab = new CTable(); $right_tab->setCellPadding(3); $right_tab->setCellSpacing(3); $right_tab->addOption('border', 0); $right_tab->addRow(create_hat(S_ACKNOWLEDGES, make_acktab_by_eventid($_REQUEST['eventid']), null, 'hat_eventack', get_profile('web.tr_events.hats.hat_eventack.state', 1))); $right_tab->addRow(create_hat(S_MESSAGE_ACTIONS, get_action_msgs_for_event($_REQUEST['eventid']), null, 'hat_eventactionmsgs', get_profile('web.tr_events.hats.hat_eventactionmsgs.state', 1))); $right_tab->addRow(create_hat(S_COMMAND_ACTIONS, get_action_cmds_for_event($_REQUEST['eventid']), null, 'hat_eventactioncmds', get_profile('web.tr_events.hats.hat_eventactioncmds.state', 1))); $right_tab->addRow(create_hat(S_EVENTS . SPACE . S_LIST . SPACE . '[' . S_LAST . ' 20]', make_small_eventlist($_REQUEST['triggerid'], $trigger_data), null, 'hat_eventlist', get_profile('web.tr_events.hats.hat_eventlist.state', 1))); $td_l = new CCol($left_tab); $td_l->addOption('valign', 'top'); $td_r = new CCol($right_tab); $td_r->addOption('valign', 'top'); $outer_table = new CTable(); $outer_table->addOption('border', 0); $outer_table->setCellPadding(1); $outer_table->setCellSpacing(1); $outer_table->addRow(array($td_l, $td_r)); $p_elements[] = $outer_table; $latest_hat = create_hat($text, $p_elements, array($fs_icon), 'hat_tr_events', get_profile('web.tr_events.hats.hat_tr_events.state', 1)); $latest_hat->show(); include_once 'include/page_footer.php';
function getItemFilterForm(&$items) { $filter_groupId = $_REQUEST['filter_groupid']; $filter_hostId = $_REQUEST['filter_hostid']; $filter_application = $_REQUEST['filter_application']; $filter_name = $_REQUEST['filter_name']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_port = $_REQUEST['filter_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_state = $_REQUEST['filter_state']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_state = $_REQUEST['subfilter_state']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm('get'); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_state', $subfilter_state); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // type select $fTypeVisibility = array(); $cmbType = new CComboBox('filter_type', $filter_type); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, _('all')); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); unset($itemTypes[ITEM_TYPE_HTTPTEST]); // httptest items are only for internal zabbix logic $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ');'); // type of information select $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); $cmbValType->addItem(-1, _('all')); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, _('Numeric (unsigned)')); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, _('Numeric (float)')); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, _('Character')); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, _('Log')); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, _('Text')); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ');'); // status select $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, _('all')); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED) as $status) { $cmbStatus->addItem($status, item_status2str($status)); } // state select $cmbState = new CComboBox('filter_state', $filter_state); $cmbState->addItem(-1, _('all')); foreach (array(ITEM_STATE_NORMAL, ITEM_STATE_NOTSUPPORTED) as $state) { $cmbState->addItem($state, itemState($state)); } // update interval $updateIntervalLabel = new CSpan(array(bold(_('Update interval')), SPACE . _('(in sec)') . NAME_DELIMITER)); $updateIntervalLabel->setAttribute('id', 'filter_delay_label'); $updateIntervalInput = new CNumericBox('filter_delay', $filter_delay, 5, false, true); $updateIntervalInput->setEnabled('no'); // data type $dataTypeLabel = new CSpan(bold(_('Data type') . NAME_DELIMITER)); $dataTypeLabel->setAttribute('id', 'filter_data_type_label'); $dataTypeInput = new CComboBox('filter_data_type', $filter_data_type); $dataTypeInput->addItem(-1, _('all')); $dataTypeInput->addItems(item_data_type2str()); $dataTypeInput->setEnabled('no'); // filter table $table = new CTable('', 'filter'); $table->setCellPadding(0); $table->setCellSpacing(0); // SNMP community $snmpCommunityLabel = new CSpan(array(bold(_('SNMP community')), SPACE . _('like') . NAME_DELIMITER)); $snmpCommunityLabel->setAttribute('id', 'filter_snmp_community_label'); $snmpCommunityField = new CTextBox('filter_snmp_community', $filter_snmp_community, ZBX_TEXTBOX_FILTER_SIZE); $snmpCommunityField->setEnabled('no'); // SNMPv3 security name $snmpSecurityLabel = new CSpan(array(bold(_('Security name')), SPACE . _('like') . NAME_DELIMITER)); $snmpSecurityLabel->setAttribute('id', 'filter_snmpv3_securityname_label'); $snmpSecurityField = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, ZBX_TEXTBOX_FILTER_SIZE); $snmpSecurityField->setEnabled('no'); // SNMP OID $snmpOidLabel = new CSpan(array(bold(_('SNMP OID')), SPACE . _('like') . NAME_DELIMITER)); $snmpOidLabel->setAttribute('id', 'filter_snmp_oid_label'); $snmpOidField = new CTextBox('filter_snmp_oid', $filter_snmp_oid, ZBX_TEXTBOX_FILTER_SIZE); $snmpOidField->setEnabled('no'); // port $portLabel = new CSpan(array(bold(_('Port')), SPACE . _('like') . NAME_DELIMITER)); $portLabel->setAttribute('id', 'filter_port_label'); $portField = new CNumericBox('filter_port', $filter_port, 5, false, true); $portField->setEnabled('no'); // row 1 $groupFilter = null; if (!empty($filter_groupId)) { $getHostInfo = API::HostGroup()->get(array('groupids' => $filter_groupId, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $groupFilter[] = array('id' => $getHostInfo['groupid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host group') . NAME_DELIMITER), 'label col1'), new CCol(array(new CMultiSelect(array('name' => 'filter_groupid', 'selectedLimit' => 1, 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'data' => $groupFilter, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=filter_groupid' . '&srcfld1=groupid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol(bold(_('Type') . NAME_DELIMITER), 'label col2'), new CCol($cmbType, 'col2'), new CCol(bold(_('Type of information') . NAME_DELIMITER), 'label col3'), new CCol($cmbValType, 'col3'), new CCol(bold(_('State') . NAME_DELIMITER), 'label'), new CCol($cmbState, 'col4')), 'item-list-row'); // row 2 $hostFilterData = null; if (!empty($filter_hostId)) { $getHostInfo = API::Host()->get(array('hostids' => $filter_hostId, 'templated_hosts' => true, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $hostFilterData[] = array('id' => $getHostInfo['hostid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host') . NAME_DELIMITER), 'label'), new CCol(array(new CMultiSelect(array('name' => 'filter_hostid', 'selectedLimit' => 1, 'objectName' => 'hosts', 'objectOptions' => array('editable' => true, 'templated_hosts' => true), 'data' => $hostFilterData, 'popup' => array('parameters' => 'srctbl=host_templates&dstfrm=' . $form->getName() . '&dstfld1=filter_hostid' . '&srcfld1=hostid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol($updateIntervalLabel, 'label'), new CCol($updateIntervalInput), new CCol($dataTypeLabel, 'label'), new CCol($dataTypeInput), new CCol(bold(_('Status') . NAME_DELIMITER), 'label col4'), new CCol($cmbStatus, 'col4')), 'item-list-row'); // row 3 $table->addRow(array(new CCol(bold(_('Application') . NAME_DELIMITER), 'label'), new CCol(array(new CTextBox('filter_application', $filter_application, ZBX_TEXTBOX_FILTER_SIZE), new CButton('btn_app', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name' . '&dstfrm=' . $form->getName() . '&dstfld1=filter_application' . '&with_applications=1' . '" + (jQuery("input[name=\'filter_hostid\']").length > 0 ? "&hostid="+jQuery("input[name=\'filter_hostid\']").val() : "")' . ', 550, 450, "application");', 'filter-select-button')), 'col1'), new CCol(array($snmpCommunityLabel, $snmpSecurityLabel), 'label'), new CCol(array($snmpCommunityField, $snmpSecurityField)), new CCol(array(bold(_('History')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_history', $filter_history, 8, false, true)), new CCol(bold(_('Triggers') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_with_triggers', $filter_with_triggers, null, array(-1 => _('all'), 1 => _('With triggers'), 0 => _('Without triggers'))))), 'item-list-row'); // row 4 $table->addRow(array(new CCol(array(bold(_('Name')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_name', $filter_name, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($snmpOidLabel, 'label'), new CCol($snmpOidField), new CCol(array(bold(_('Trends')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_trends', $filter_trends, 8, false, true)), new CCol(bold(_('Template') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_templated_items', $filter_templated_items, null, array(-1 => _('all'), 1 => _('Templated items'), 0 => _('Not Templated items'))))), 'item-list-row'); // row 5 $table->addRow(array(new CCol(array(bold(_('Key')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_key', $filter_key, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($portLabel, 'label'), new CCol($portField), new CCol(null, 'label'), new CCol(), new CCol(null, 'label'), new CCol()), 'item-list-row'); $filter = new CSubmit('filter_set', _('Filter'), 'chkbxRange.clearSelectedOnFilterChange();'); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset'), 'chkbxRange.clearSelectedOnFilterChange();'); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer = new CCol($div_buttons, 'controls', 8); $table->addRow($footer); $form->addItem($table); // subfilters $table_subfilter = new CTable(null, 'filter sub-filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'state' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $item) { // hosts if (zbx_empty($filter_hostId)) { $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['name'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications if (!empty($item['applications'])) { foreach ($item['applications'] as $application) { if (!isset($item_params['applications'][$application['name']])) { $item_params['applications'][$application['name']] = array('name' => $application['name'], 'count' => 0); } } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => itemValueTypeString($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // state if ($filter_state == -1) { if (!isset($item_params['state'][$item['state']])) { $item_params['state'][$item['state']] = array('name' => itemState($item['state']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_state') { continue; } $show_item &= $value; } if ($show_item) { $item_params['state'][$item['state']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => _('Not Templated items'), 'count' => 0); } elseif ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => _('Templated items'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => _('Without triggers'), 'count' => 0); } elseif (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => _('With triggers'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_hostId) && count($item_params['hosts']) > 1) { $hosts_output = prepareSubfilterOutput($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(_('Hosts'), $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepareSubfilterOutput($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(_('Applications'), $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepareSubfilterOutput($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(_('Types'), $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepareSubfilterOutput($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(_('Type of information'), $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepareSubfilterOutput($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(_('Status'), $status_output)); } if ($filter_state == -1 && count($item_params['state']) > 1) { $state_output = prepareSubfilterOutput($item_params['state'], $subfilter_state, 'subfilter_state'); $table_subfilter->addRow(array(_('State'), $state_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepareSubfilterOutput($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(_('Template'), $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepareSubfilterOutput($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(_('With triggers'), $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepareSubfilterOutput($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(_('History'), $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepareSubfilterOutput($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(_('Trends'), $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepareSubfilterOutput($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(_('Interval'), $interval_output)); } $form->addItem(new CDiv(_('Subfilter [affects only filtered data!]'), 'thin_header')); $form->addItem($table_subfilter); return $form; }
function show_messages($bool = true, $okmsg = null, $errmsg = null) { global $page, $ZBX_MESSAGES; if (!defined('PAGE_HEADER_LOADED')) { return null; } if (defined('ZBX_API_REQUEST')) { return null; } if (!isset($page['type'])) { $page['type'] = PAGE_TYPE_HTML; } $imageMessages = array(); if (!$bool && !is_null($errmsg)) { $msg = _('ERROR') . ': ' . $errmsg; } elseif ($bool && !is_null($okmsg)) { $msg = $okmsg; } if (isset($msg)) { switch ($page['type']) { case PAGE_TYPE_IMAGE: // save all of the messages in an array to display them later in an image $imageMessages[] = array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68)); break; case PAGE_TYPE_XML: echo htmlspecialchars($msg) . "\n"; break; case PAGE_TYPE_HTML: default: $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr'); $msg_tab->setCellPadding(0); $msg_tab->setCellSpacing(0); $row = array(); $msg_col = new CCol(bold($msg), 'msg_main msg'); $msg_col->setAttribute('id', 'page_msg'); $row[] = $msg_col; if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { $msg_details = new CDiv(_('Details'), 'blacklink'); $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");'); $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize')); array_unshift($row, new CCol($msg_details, 'clr')); } $msg_tab->addRow($row); $msg_tab->show(); break; } } if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { if ($page['type'] == PAGE_TYPE_IMAGE) { foreach ($ZBX_MESSAGES as $msg) { // save all of the messages in an array to display them later in an image if ($msg['type'] == 'error') { $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55)); } else { $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55)); } } } elseif ($page['type'] == PAGE_TYPE_XML) { foreach ($ZBX_MESSAGES as $msg) { echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n"; } } else { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); $bool = $bool && 'error' !== strtolower($msg['type']); } $msg_show = 6; $msg_count = count($ZBX_MESSAGES); if ($msg_count > $msg_show) { $msg_count = $msg_show * 16; $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;'); } $tab = new CTable(null, $bool ? 'msgok' : 'msgerr'); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('id', 'msg_messages'); $tab->setAttribute('style', 'width: 100%;'); if (isset($msg_tab) && $bool) { $tab->setAttribute('style', 'display: none;'); } $tab->addRow(new CCol($lst_error, 'msg')); $tab->show(); } $ZBX_MESSAGES = null; } // draw an image with the messages if ($page['type'] == PAGE_TYPE_IMAGE && count($imageMessages) > 0) { $imageFontSize = 8; // calculate the size of the text $imageWidth = 0; $imageHeight = 0; foreach ($imageMessages as &$msg) { $size = imageTextSize($imageFontSize, 0, $msg['text']); $msg['height'] = $size['height'] - $size['baseline']; // calculate the total size of the image $imageWidth = max($imageWidth, $size['width']); $imageHeight += $size['height'] + 1; } unset($msg); // additional padding $imageWidth += 2; $imageHeight += 2; // create the image $canvas = imagecreate($imageWidth, $imageHeight); imagefilledrectangle($canvas, 0, 0, $imageWidth, $imageHeight, imagecolorallocate($canvas, 255, 255, 255)); // draw each message $y = 1; foreach ($imageMessages as $msg) { $y += $msg['height']; imageText($canvas, $imageFontSize, 0, 1, $y, imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']), $msg['text']); } imageOut($canvas); imagedestroy($canvas); } }