">
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"]);
/* 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 " . $input["column_name"] . "='" . $_POST{$column_name . "_" . $input["id"]} . "' where id=" . $item["id"]);
}
}
}
}
}
if (isset($_POST["save_component_graph_diff"])) {
if ($_POST["type"] == "1") {
$intrusive = true;
}elseif ($_POST["type"] == "2") {
$intrusive = false;
}
change_graph_template($_POST["local_graph_id"], $_POST["graph_template_id"], $intrusive);
}
if (isset($_POST["save_component_item"])) {
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = $_POST["local_graph_id"];
$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
$save["color_id"] = form_input_validate($_POST["color_id"], "color_id", "", true, 3);
$save["graph_type_id"] = form_input_validate($_POST["graph_type_id"], "graph_type_id", "", true, 3);
$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
$save["consolidation_function_id"] = form_input_validate($_POST["consolidation_function_id"], "consolidation_function_id", "", true, 3);
$save["text_format"] = form_input_validate($_POST["text_format"], "text_format", "", true, 3);
$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
$save["hard_return"] = form_input_validate($_POST["hard_return"], "hard_return", "", true, 3);
$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
$save["sequence"] = $_POST["sequence"];
if (!is_error_message()) {
$graph_template_item_id = sql_save($save, "graph_templates_item");
if ($graph_template_item_id) {
raise_message(1);
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: graphs.php?action=item_edit&graph_template_item_id=" . (empty($graph_template_item_id) ? $_POST["graph_template_item_id"] : $graph_template_item_id) . "&local_graph_id=" . $_POST["local_graph_id"]);
exit;
}elseif (read_config_option("full_view_graph") == "") {
header ("Location: graphs.php?action=item&local_graph_id=" . $_POST["local_graph_id"]);
exit;
}elseif (read_config_option("full_view_graph") == "on") {
header ("Location: graphs.php?action=graph_edit&local_graph_id=" . $_POST["local_graph_id"]);
exit;
}
}
if ((is_error_message()) || (empty($_POST["local_graph_id"])) || (isset($_POST["save_component_input"])) || (isset($_POST["save_component_graph_diff"]))) {
header ("Location: graphs.php?action=graph_edit&local_graph_id=" . (empty($local_graph_id) ? $_POST["local_graph_id"] : $local_graph_id));
}else{
header ("Location: graphs.php");
}
}
/* -----------------------
item - Graph Items
----------------------- */
function item() {
global $colors, $consolidation_functions, $graph_item_types, $struct_graph_item;
if (empty($_GET["local_graph_id"])) {
$header_label = "[new]";
}else{
$header_label = "[edit: " . db_fetch_cell("select title from graph_templates_graph where local_graph_id=" . $_GET["local_graph_id"]) . "]";
}
if (read_config_option("full_view_graph") == "") {
start_box("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 "