$row['sla2'] = "-"; } if (isset($services[$row['serviceid']])) { $services[$row['serviceid']] = array_merge($services[$row['serviceid']], $row); } else { $services[$row['serviceid']] = $row; } if (isset($row['serviceupid'])) { $services[$row['serviceupid']]['childs'][] = array('id' => $row['serviceid'], 'soft' => 0, 'linkid' => 0); } if (isset($row['servicedownid'])) { $services[$row['serviceid']]['childs'][] = array('id' => $row['servicedownid'], 'soft' => 1, 'linkid' => $row['linkid']); } } $treeServ = array(); createShowServiceTree($services, $treeServ); //return into $treeServ parametr //permission issue $treeServ = del_empty_nodes($treeServ); $tree = new CTree($treeServ, array('caption' => bold(S_SERVICE), 'status' => bold(S_STATUS), 'reason' => bold(S_REASON), 'sla' => bold(S_SLA_LAST_7_DAYS), 'sla2' => bold(nbsp(S_SLA)), 'graph' => bold(S_GRAPH))); if ($tree) { $url = '?fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1'); $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 . "';")); $tab = create_hat(S_IT_SERVICES_BIG, $tree->getHTML(), null, 'hat_services', get_profile('web.srv_status.hats.hat_services.state', 1)); $tab->Show(); unset($tab); } else { error('Can not format Tree. Check logik structure in service links'); }
function createShowServiceTree(&$services, &$temp, $id = 0, $serviceupid = 0, $parentid = 0, $soft = 0, $linkid = '') { $rows = $services[$id]; //---------------------------- if not leaf ----------------------------- $rows['parentid'] = $parentid; if ($rows['serviceid'] > 0 && $rows['caption'] != 'root') { $rows['status'] = get_service_status_description($rows["status"]); } if ($soft == 0) { $temp[$rows['serviceid']] = $rows; if (isset($rows['childs'])) { foreach ($rows['childs'] as $cid => $nodeid) { if (!isset($services[$nodeid['id']])) { continue; } if (isset($services[$nodeid['id']]['serviceupid'])) { createShowServiceTree($services, $temp, $nodeid['id'], $services[$nodeid['id']]['serviceupid'], $rows['serviceid'], $nodeid['soft'], $nodeid['linkid']); } } } } else { $rows['caption'] = new CSpan($rows['caption']); $rows['caption']->setAttribute('style', 'color: #888888;'); $temp[$rows['serviceid'] . '.' . $linkid] = $rows; } return; }