">
Graph Management $header_label", "98%", $colors["header"], "3", "center", "");
draw_graph_form_select("?action=item&local_graph_id=" . $_GET["local_graph_id"]);
end_box();
}
$graph_template_id = db_fetch_cell("select graph_template_id from graph_local where id=" . $_GET["local_graph_id"]);
if (empty($graph_template_id)) {
$add_text = "graphs.php?action=item_edit&local_graph_id=" . $_GET["local_graph_id"];
}else{
$add_text = "";
}
start_box("Graph Items $header_label", "98%", $colors["header"], "3", "center", $add_text);
print "";
DrawMatrixHeaderItem("Graph Item",$colors["header_text"],1);
DrawMatrixHeaderItem("Task Name",$colors["header_text"],1);
DrawMatrixHeaderItem("Graph Item Type",$colors["header_text"],1);
DrawMatrixHeaderItem("CF Type",$colors["header_text"],1);
DrawMatrixHeaderItem("Item Color",$colors["header_text"],4);
print "
";
$template_item_list = db_fetch_assoc("select
graph_templates_item.id,
graph_templates_item.text_format,
graph_templates_item.value,
graph_templates_item.hard_return,
graph_templates_item.graph_type_id,
graph_templates_item.consolidation_function_id,
CONCAT_WS(' - ',data_template_data.name,data_template_rrd.data_source_name) as data_source_name,
cdef.name as cdef_name,
colors.hex
from graph_templates_item
left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
left join data_local on data_template_rrd.local_data_id=data_local.id
left join data_template_data on data_local.id=data_template_data.local_data_id
left join cdef on cdef_id=cdef.id
left join colors on color_id=colors.id
where graph_templates_item.local_graph_id=" . $_GET["local_graph_id"] . "
order by graph_templates_item.sequence");
$group_counter = 0;
if (sizeof($template_item_list) > 0) {
foreach ($template_item_list as $item) {
/* graph grouping display logic */
$this_row_style = ""; $use_custom_row_color = false; $hard_return = "";
if (($graph_item_types{$item["graph_type_id"]} != "GPRINT") && ($graph_item_types{$item["graph_type_id"]} != $_graph_type_name)) {
$this_row_style = "font-weight: bold;"; $use_custom_row_color = true;
if ($group_counter % 2 == 0) {
$alternate_color_1 = "EEEEEE";
$alternate_color_2 = "EEEEEE";
$custom_row_color = "D5D5D5";
}else{
$alternate_color_1 = $colors["alternate"];
$alternate_color_2 = $colors["alternate"];
$custom_row_color = "D2D6E7";
}
$group_counter++;
}
$_graph_type_name = $graph_item_types{$item["graph_type_id"]};
/* alternating row color */
if ($use_custom_row_color == false) {
form_alternate_row_color($alternate_color_1,$alternate_color_2,$i);
}else{
print "";
}
print "| ";
if (empty($graph_template_id)) { print ""; }
print "Item # " . ($i+1) . "";
if (empty($graph_template_id)) { print ""; }
print " | \n";
if (empty($item["data_source_name"])) { $item["data_source_name"] = "No Task"; }
switch (true) {
case ereg("(AREA|STACK|GPRINT|LINE[123])", $_graph_type_name):
$matrix_title = "(" . $item["data_source_name"] . "): " . $item["text_format"];
break;
case ereg("(HRULE|VRULE)", $_graph_type_name):
$matrix_title = "HRULE: " . $item["value"];
break;
case ereg("(COMMENT)", $_graph_type_name):
$matrix_title = "COMMENT: " . $item["text_format"];
break;
}
if ($item["hard_return"] == "on") {
$hard_return = "<HR>";
}
print "" . htmlspecialchars($matrix_title) . $hard_return . " | \n";
print "" . $graph_item_types{$item["graph_type_id"]} . " | \n";
print "" . $consolidation_functions{$item["consolidation_function_id"]} . " | \n";
print " | \n";
print "" . $item["hex"] . " | \n";
print "
 | \n";
print " | \n";
print "
";
$i++;
}
}else{
print " | No Items |
";
}
end_box();
/* only display the "inputs" area if we are using a graph template for this graph */
if ($graph_template_id != "0") {
start_box("Graph Item Inputs", "98%", $colors["header"], "3", "center", "");
print "
0) {
foreach ($input_list as $input) {
/* we need to find out which graph items will be affected by saving this particular item */
$item_list = db_fetch_assoc("select
graph_templates_item.id
from graph_template_input_defs,graph_templates_item
where graph_template_input_defs.graph_template_item_id=graph_templates_item.local_graph_template_item_id
and graph_templates_item.local_graph_id=" . $_POST["local_graph_id"] . "
and graph_template_input_defs.graph_template_input_id=" . $input["id"]);
/* get some variables */
$column_name = $input["column_name"];
$column_value = $_POST{$column_name . "_" . $input["id"]};
/* loop through each item affected and update column data */
if (sizeof($item_list) > 0) {
foreach ($item_list as $item) {
db_execute("update graph_templates_item set $column_name='$column_value' where id=" . $item["id"]);
}
}
}
}
}
/* ------------------------------------
graph - Graphs
------------------------------------ */
function graph_save() {
include_once ("include/utility_functions.php");
if ($_POST["lower_limit"] == "") { $_POST["lower_limit"] = 0; }
if ($_POST["upper_limit"] == "") { $_POST["upper_limit"] = 0; }
if ($_POST["unit_exponent_value"] == "") { $_POST["unit_exponent_value"] = 0; }
$save["id"] = $_POST["local_graph_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$local_graph_id = sql_save($save, "graph_local");
unset($save);
$save["id"] = $_POST["graph_template_graph_id"];
$save["local_graph_template_graph_id"] = $_POST["local_graph_template_graph_id"];
$save["local_graph_id"] = $local_graph_id;
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["image_format_id"] = $_POST["image_format_id"];
$save["title"] = $_POST["title"];
$save["height"] = $_POST["height"];
$save["width"] = $_POST["width"];
$save["upper_limit"] = $_POST["upper_limit"];
$save["lower_limit"] = $_POST["lower_limit"];
$save["vertical_label"] = $_POST["vertical_label"];
$save["auto_scale"] = $_POST["auto_scale"];
$save["auto_scale_opts"] = $_POST["auto_scale_opts"];
$save["auto_scale_log"] = $_POST["auto_scale_log"];
$save["auto_scale_rigid"] = $_POST["auto_scale_rigid"];
$save["auto_padding"] = $_POST["auto_padding"];
$save["base_value"] = $_POST["base_value"];
$save["export"] = $_POST["export"];
$save["unit_value"] = $_POST["unit_value"];
$save["unit_exponent_value"] = $_POST["unit_exponent_value"];
sql_save($save, "graph_templates_graph");
/* if template information chanegd, update all nessesary template information */
if ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) {
/* check to see if the number of graph items differs, if it does; we need user input */
if ((!empty($_POST["graph_template_id"])) && (sizeof(db_fetch_assoc("select id from graph_templates_item where local_graph_id=$local_graph_id")) != sizeof(db_fetch_assoc("select id from graph_templates_item where local_graph_id=0 and graph_template_id=" . $_POST["graph_template_id"])))) {
/* set the template back, since the user may choose not to go through with the change
at this point */
db_execute("update graph_local set graph_template_id=" . $_POST["_graph_template_id"] . " where id=$local_graph_id");
db_execute("update graph_templates_graph set graph_template_id=" . $_POST["_graph_template_id"] . " where local_graph_id=$local_graph_id");
header("Location: graphs.php?action=graph_diff&local_graph_id=$local_graph_id&graph_template_id=" . $_POST["graph_template_id"]);
exit;
}
change_graph_template($local_graph_id, $_POST["graph_template_id"], true);
}
/* so we get redirected to the correct page, not '&local_graph_id=0' */
$_POST["local_graph_id"] = $local_graph_id;
}
function graph_diff_save() {
include_once ("include/utility_functions.php");
if ($_POST["type"] == "1") {
$intrusive = true;
}elseif ($_POST["type"] == "2") {
$intrusive = false;
}
change_graph_template($_POST["local_graph_id"], $_POST["graph_template_id"], $intrusive);
}
function graph_diff() {
global $colors;
include("include/config_arrays.php");
$template_query = "select
graph_templates_item.id,
graph_templates_item.text_format,
graph_templates_item.value,
graph_templates_item.hard_return,
graph_templates_item.consolidation_function_id,
graph_templates_item.graph_type_id,
CONCAT_WS(' - ',data_template_data.name,data_template_rrd.data_source_name) as task_item_id,
cdef.name as cdef_id,
colors.hex as color_id
from graph_templates_item left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
left join data_local on data_template_rrd.local_data_id=data_local.id
left join data_template_data on data_local.id=data_template_data.local_data_id
left join cdef on cdef_id=cdef.id
left join colors on color_id=colors.id";
/* first, get information about the graph template as that's what we're going to model this
graph after */
$graph_template_items = db_fetch_assoc("
$template_query
where graph_templates_item.graph_template_id=" . $_GET["graph_template_id"] . "
and graph_templates_item.local_graph_id=0
order by graph_templates_item.sequence");
/* next, get information about the current graph so we can make the appropriate comparisons */
$graph_items = db_fetch_assoc("
$template_query
where graph_templates_item.local_graph_id=" . $_GET["local_graph_id"] . "
order by graph_templates_item.sequence");
$graph_template_inputs = db_fetch_assoc("select
graph_template_input.column_name,
graph_template_input_defs.graph_template_item_id
from graph_template_input,graph_template_input_defs
where graph_template_input.id=graph_template_input_defs.graph_template_input_id
and graph_template_input.graph_template_id=" . $_GET["graph_template_id"]);
/* ok, we want to loop through the array with the GREATEST number of items so we don't have to worry
about tacking items on the end */
if (sizeof($graph_template_items) > sizeof($graph_items)) {
$items = $graph_template_items;
}else{
$items = $graph_items;
}
?>
|
The template you have selected requires some changes to be made to the structure of
your graph. Below is a preview of your graph along with changes that need to be completed
as shown in the left-hand column.
|
Graph Preview", "98%", $colors["header"], "3", "center", "");
$graph_item_actions = array("normal" => "", "add" => "+", "delete" => "-");
$group_counter = 0; $i = 0; $mode = "normal";
if (sizeof($items) > 0) {
foreach ($items as $item) {
reset($struct_graph_item);
/* graph grouping display logic */
$bold_this_row = false; $use_custom_row_color = false; $action_css = ""; unset($graph_preview_item_values);
if ((sizeof($graph_template_items) > sizeof($graph_items)) && ($i >= sizeof($graph_items))) {
$mode = "add";
$user_message = "When you click save, the items marked with a '+' will be added (Recommended).";
}elseif ((sizeof($graph_template_items) < sizeof($graph_items)) && ($i >= sizeof($graph_template_items))) {
$mode = "delete";
$user_message = "When you click save, the items marked with a '-' will be removed (Recommended).";
}
/* here is the fun meshing part. first we check the graph template to see if there is an input
for each field of this row. if there is, we revert to the value stored in the graph, if not
we revert to the value stored in the template. got that? ;) */
for ($j=0; ($j < count($graph_template_inputs)); $j++) {
if ($graph_template_inputs[$j]["graph_template_item_id"] == $graph_template_items[$i]["id"]) {
/* if we find out that there is an "input" covering this field/item, use the
value from the graph, not the template */
$graph_item_field_name = $graph_template_inputs[$j]["column_name"];
$graph_preview_item_values[$graph_item_field_name] = $graph_items[$i][$graph_item_field_name];
}
}
/* go back through each graph field and find out which ones haven't been covered by the
"inputs" above. for each one, use the value from the template */
while (list($field_name, $field_array) = each($struct_graph_item)) {
if ($mode == "delete") {
$graph_preview_item_values[$field_name] = $graph_items[$i][$field_name];
}elseif (!isset($graph_preview_item_values[$field_name])) {
$graph_preview_item_values[$field_name] = $graph_template_items[$i][$field_name];
}
}
/* "prepare" array values */
$consolidation_function_id = $graph_preview_item_values["consolidation_function_id"];
$graph_type_id = $graph_preview_item_values["graph_type_id"];
/* color logic */
if (($graph_item_types[$graph_type_id] != "GPRINT") && ($graph_item_types[$graph_type_id] != $_graph_type_name)) {
$bold_this_row = true; $use_custom_row_color = true; $hard_return = "";
if ($group_counter % 2 == 0) {
$alternate_color_1 = "EEEEEE";
$alternate_color_2 = "EEEEEE";
$custom_row_color = "D5D5D5";
}else{
$alternate_color_1 = $colors["alternate"];
$alternate_color_2 = $colors["alternate"];
$custom_row_color = "D2D6E7";
}
$group_counter++;
}
$_graph_type_name = $graph_item_types[$graph_type_id];
/* alternating row colors */
if ($use_custom_row_color == false) {
if ($i % 2 == 0) {
$action_column_color = $alternate_color_1;
}else{
$action_column_color = $alternate_color_2;
}
}else{
$action_column_color = $custom_row_color;
}
print ""; $i++;
/* make the left-hand column blue or red depending on if "add"/"remove" mode is set */
if ($mode == "add") {
$action_column_color = $colors["header"];
$action_css = "";
}elseif ($mode == "delete") {
$action_column_color = "C63636";
$action_css = "text-decoration: line-through;";
}
if ($bold_this_row == true) {
$action_css .= " font-weight:bold;";
}
/* draw the TD that shows the user whether we are going to: KEEP, ADD, or DROP the item */
print "| " . $graph_item_actions[$mode] . " | ";
print "Item # " . $i . " | \n";
if (empty($graph_preview_item_values["task_item_id"])) { $graph_preview_item_values["task_item_id"] = "No Task"; }
switch (true) {
case ereg("(AREA|STACK|GPRINT|LINE[123])", $_graph_type_name):
$matrix_title = "(" . $graph_preview_item_values["task_item_id"] . "): " . $graph_preview_item_values["text_format"];
break;
case ereg("(HRULE|VRULE)", $_graph_type_name):
$matrix_title = "HRULE: " . $graph_preview_item_values["value"];
break;
case ereg("(COMMENT)", $_graph_type_name):
$matrix_title = "COMMENT: " . $graph_preview_item_values["text_format"];
break;
}
/* use the cdef name (if in use) if all else fails */
if ($matrix_title == "") {
if ($graph_preview_item_values["cdef_id"] != "") {
$matrix_title .= "CDEF: " . $graph_preview_item_values["cdef_id"];
}
}
if ($graph_preview_item_values["hard_return"] == "on") {
$hard_return = "<HR>";
}
print "" . htmlspecialchars($matrix_title) . $hard_return . " | \n";
print "" . $graph_item_types{$graph_preview_item_values["graph_type_id"]} . " | \n";
print "" . $consolidation_functions{$graph_preview_item_values["consolidation_function_id"]} . " | \n";
print " | \n";
print "" . $graph_preview_item_values["color_id"] . " | \n";
print "
";
}
}else{
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?>
No Items
|
" . db_fetch_cell("select title from graph_templates_graph where local_graph_id=" . $_GET["local_graph_id"]) . "?", getenv("HTTP_REFERER"), "graphs.php?action=graph_remove&local_graph_id=" . $_GET["local_graph_id"]);
include ('include/bottom_footer.php');
exit;
}
if ((read_config_option("remove_verification") == "") || ($_GET["confirm"] == "yes")) {
db_execute("delete from graph_templates_graph where local_graph_id=" . $_GET["local_graph_id"]);
db_execute("delete from graph_templates_item where local_graph_id=" . $_GET["local_graph_id"]);
db_execute("delete from graph_local where id=" . $_GET["local_graph_id"]);
}
}
function graph_edit() {
global $colors, $struct_graph, $image_types;
if (read_config_option("full_view_graph") == "") {
start_box("Graph Management [edit]", "98%", $colors["header"], "3", "center", "");
draw_graph_form_select("?action=graph_edit&local_graph_id=" . $_GET["local_graph_id"]);
end_box();
}
$use_graph_template = true;
if (isset($_GET["local_graph_id"])) {
$local_graph_template_graph_id = db_fetch_cell("select local_graph_template_graph_id from graph_templates_graph where local_graph_id=" . $_GET["local_graph_id"]);
$graphs = db_fetch_row("select * from graph_templates_graph where local_graph_id=" . $_GET["local_graph_id"]);
$graphs_template = db_fetch_row("select * from graph_templates_graph where id=$local_graph_template_graph_id");
$header_label = "[edit: " . $graphs["title"] . "]";
}else{
$header_label = "[new]";
$use_graph_template = false;
}
if ($graphs["graph_template_id"] == "0") {
$use_graph_template = false;
}
if ((read_config_option("full_view_graph") == "on") && ($_GET["local_graph_id"] > 0)) {
item();
}
start_box("Graph Template Selection $header_label", "98%", $colors["header"], "3", "center", "");
?>
Graph Management", "98%", $colors["header"], "3", "center", "graphs.php?action=graph_edit");
?>
">
0
and graph_templates_graph.title like '%%" . $_REQUEST["filter"] . "%%'
group by graph_templates_graph.id";
$total_rows = sizeof(db_fetch_assoc("select
graph_templates_graph.local_graph_id
$sql_base"));
$graph_list = db_fetch_assoc("select
graph_templates_graph.id,
graph_templates_graph.local_graph_id,
graph_templates_graph.height,
graph_templates_graph.width,
graph_templates_graph.title,
graph_templates.name
$sql_base
order by graph_templates_graph.title
limit " . (ROWS_PER_PAGE*($_GET["page"]-1)) . "," . ROWS_PER_PAGE);
}else{
$total_rows = db_fetch_cell("select
COUNT(id)
from graph_templates_graph
where graph_templates_graph.local_graph_id!=0
and graph_templates_graph.title like '%%" . $_REQUEST["filter"] . "%%'");
$graph_list = db_fetch_assoc("select
graph_templates_graph.id,
graph_templates_graph.local_graph_id,
graph_templates_graph.height,
graph_templates_graph.width,
graph_templates_graph.title,
graph_templates.name
from graph_templates_graph left join graph_templates on graph_templates_graph.graph_template_id=graph_templates.id
where graph_templates_graph.local_graph_id!=0
and graph_templates_graph.title like '%%" . $_REQUEST["filter"] . "%%'
order by graph_templates_graph.title
limit " . (ROWS_PER_PAGE*($_GET["page"]-1)) . "," . ROWS_PER_PAGE);
}
print "
|
|
\n";
print "";
DrawMatrixHeaderItem("Graph Title",$colors["header_text"],1);
DrawMatrixHeaderItem("Template Name",$colors["header_text"],1);
DrawMatrixHeaderItem("Size",$colors["header_text"],2);
print "
";
if (sizeof($graph_list) > 0) {
foreach ($graph_list as $graph) {
form_alternate_row_color($colors["alternate"],$colors["light"],$i);
?>
">\\1", $graph["title"]);?>
|
None" : $graph["name"]); ?>
|
x
|
">
|
No Graphs Found | ";
}
end_box();
}
?>