$section = "Add/Edit Graphs"; include ('include/auth.php');
include_once ("include/database.php");
$heirarchy = db_fetch_assoc("SELECT *,graph_viewing.Title HTitle,rrd_graph.Title GTitle, graph_viewing.ID VID
FROM graph_viewing
LEFT JOIN rrd_graph ON graph_viewing.GraphID = rrd_graph.ID
WHERE OrderKey LIKE '$search_key%' ORDER BY OrderKey");
/*
for ($i = (sizeof($heirarchy) - 1); $i > 0; --$i) {
$leaf = $heirarchy[$i];
$tier = tree_tier($leaf[OrderKey], 2);
if ($tier > 1) {
$parent_key = str_pad(substr($leaf[OrderKey],0,(($tier - 1) * 2) ),60,'0',STR_PAD_RIGHT);
if ($leaf[GraphID] && (! isset($counted_graphs[$parent_key]))) {
++$num_children[$parent_key];
++$counted_graphs[$parent_key];
}
if (!$leaf[GraphID]) {
++$num_children[$parent_key];
++$num_children[$parent_key];
}
}
if ($tier > $max_tier) { $max_tier = $tier; }
}
*/
if (sizeof($heirarchy) > 0) {
foreach ($heirarchy as $leaf) {
$no_children = 0;
if (sizeof($hide) > 0) {
foreach (array_keys($hide) as $key_root) {
if (preg_match("/^$key_root/",$leaf[OrderKey])) {
if (preg_match("/^".$key_root."00/",$leaf[OrderKey])) {
$no_children = 1;
}else{
$skip_entry = 1;
}
}
}
}
if ($skip_entry) {
$skip_entry = 0;
continue;
}
$tier = tree_tier($leaf[OrderKey], 2);
//$current_leaf_type = $leaf[GraphID] ? "graph" : "heading";
//if ($current_leaf_type == 'heading') {
//if ($heading_ct > 0) {
// if ($graph_ct % 2 != 0) { print "\n"; }
// print "\n";
//}
$pix = $tier * 20;
$indent = "
";
if ($leaf[GraphID] == "0") {
print $indent . $leaf[HTitle] . "
";
}else{
print $indent . $leaf[Title] . "
";
}
//$colspan = (($max_tier - $tier) * 2);
//$rowspan = $num_children[$leaf[OrderKey]];
# print "Children for $leaf[HTitle] = '".$num_children[$leaf[OrderKey]]."'
\n";
//print "
| \n"; // break; //case "2": // print " | $leaf[GTitle] | "; // break; //} //if ($graph_ct % 2 == 0) { print "|