">
array(
"color_id" => "0",
"graph_type_id" => "9",
"consolidation_function_id" => "4",
"text_format" => "Current:",
"hard_return" => ""
),
1 => array(
"color_id" => "0",
"graph_type_id" => "9",
"consolidation_function_id" => "1",
"text_format" => "Average:",
"hard_return" => ""
),
2 => array(
"color_id" => "0",
"graph_type_id" => "9",
"consolidation_function_id" => "3",
"text_format" => "Maximum:",
"hard_return" => "on"
));
}
foreach ($items as $item) {
/* generate a new sequence if needed */
if (empty($_POST["sequence"])) {
$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
}
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = 0;
$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
$save["color_id"] = form_input_validate((isset($item["color_id"]) ? $item["color_id"] : $_POST["color_id"]), "color_id", "", true, 3);
$save["graph_type_id"] = form_input_validate((isset($item["graph_type_id"]) ? $item["graph_type_id"] : $_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((isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : $_POST["consolidation_function_id"]), "consolidation_function_id", "", true, 3);
$save["text_format"] = form_input_validate((isset($item["text_format"]) ? $item["text_format"] : $_POST["text_format"]), "text_format", "", true, 3);
$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
$save["hard_return"] = form_input_validate(((isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_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);
push_out_graph_item($graph_template_item_id);
}else{
raise_message(2);
}
}
$_POST["sequence"] = 0;
}
if (is_error_message()) {
header ("Location: graph_templates.php?action=item_edit&graph_template_item_id=" . (empty($graph_template_item_id) ? $_POST["graph_template_item_id"] : $graph_template_item_id) . "&id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "") {
header ("Location: graph_templates.php?action=item&id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "on") {
header ("Location: graph_templates.php?action=template_edit&id=" . $_POST["graph_template_id"]);
exit;
}
}
if ((isset($_POST["save_component_input"])) && (!is_error_message())) {
$save["id"] = $_POST["graph_template_input_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
$save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
$save["column_name"] = form_input_validate($_POST["column_name"], "column_name", "", true, 3);
if (!is_error_message()) {
$graph_template_input_id = sql_save($save, "graph_template_input");
if ($graph_template_input_id) {
raise_message(1);
db_execute("delete from graph_template_input_defs where graph_template_input_id=$graph_template_input_id");
while (list($var, $val) = each($_POST)) {
if (eregi("^i_", $var)) {
db_execute ("insert into graph_template_input_defs (graph_template_input_id,graph_template_item_id)
values ($graph_template_input_id," . str_replace("i_", "", $var) . ")");
}
}
}else{
raise_message(2);
}
}
if (is_error_message()) {
header ("Location: graph_templates.php?action=input_edit&graph_template_input_id=" . (empty($graph_template_input_id) ? $_POST["graph_template_input_id"] : $graph_template_input_id) . "&id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "") {
header ("Location: graph_templates.php?action=item&id=" . $_POST["graph_template_id"]);
exit;
}elseif (read_config_option("full_view_graph_template") == "on") {
header ("Location: graph_templates.php?action=template_edit&id=" . $_POST["graph_template_id"]);
exit;
}
}
if ((is_error_message()) || (empty($_POST["graph_template_id"]))) {
header ("Location: graph_templates.php?action=template_edit&id=" . (empty($graph_template_id) ? $_POST["graph_template_id"] : $graph_template_id));
}else{
header ("Location: graph_templates.php");
}
}
/* -----------------------
item - Graph Items
----------------------- */
function item_movedown() {
include_once ("include/functions.php");
$arr = get_graph_group($_GET["id"]);
$next_id = get_graph_parent($_GET["id"], "next");
if ((!empty($next_id)) && (isset($arr{$_GET["id"]}))) {
move_graph_group($_GET["id"], $arr, $next_id, "next");
}elseif (db_fetch_cell("select graph_type_id from graph_templates_item where id=" . $_GET["id"]) == "9") {
/* this is so we know the "other" graph item to propagate the changes to */
$next_item = get_item("graph_templates_item", "sequence", $_GET["id"], "graph_template_id=" . $_GET["graph_template_id"] . " and local_graph_id=0", "next");
move_item_down("graph_templates_item", $_GET["id"], "graph_template_id=" . $_GET["graph_template_id"] . " and local_graph_id=0");
db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $_GET["id"]) . " where local_graph_template_item_id=" . $_GET["id"]);
db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $next_item). " where local_graph_template_item_id=" . $next_item);
}
}
function item_moveup() {
include_once ("include/functions.php");
$arr = get_graph_group($_GET["id"]);
$next_id = get_graph_parent($_GET["id"], "previous");
if ((!empty($next_id)) && (isset($arr{$_GET["id"]}))) {
move_graph_group($_GET["id"], $arr, $next_id, "previous");
}elseif (db_fetch_cell("select graph_type_id from graph_templates_item where id=" . $_GET["id"]) == "9") {
/* this is so we know the "other" graph item to propagate the changes to */
$last_item = get_item("graph_templates_item", "sequence", $_GET["id"], "graph_template_id=" . $_GET["graph_template_id"] . " and local_graph_id=0", "previous");
move_item_up("graph_templates_item", $_GET["id"], "graph_template_id=" . $_GET["graph_template_id"] . " and local_graph_id=0");
db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $_GET["id"]) . " where local_graph_template_item_id=" . $_GET["id"]);
db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $last_item). " where local_graph_template_item_id=" . $last_item);
}
}
function item() {
global $colors, $consolidation_functions, $graph_item_types;
if (empty($_GET["id"])) {
$template_item_list = array();
$header_label = "[new]";
}else{
$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.graph_template_id=" . $_GET["id"] . "
and graph_templates_item.local_graph_id=0
order by graph_templates_item.sequence");
$header_label = "[edit: " . db_fetch_cell("select name from graph_templates where id=" . $_GET["id"]) . "]";
}
if (read_config_option("full_view_graph_template") == "") {
start_box("Graph Template Management $header_label", "98%", $colors["header"], "3", "center", "");
draw_graph_form_select("?action=item&id=" . $_GET["id"]);
end_box();
}
start_box("Graph Template Items $header_label", "98%", $colors["header"], "3", "center", "graph_templates.php?action=item_edit&graph_template_id=" . $_GET["id"]);
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 "
";
$group_counter = 0; $_graph_type_name = ""; $i = 0;
$alternate_color_1 = $colors["alternate"]; $alternate_color_2 = $colors["alternate"];
if (sizeof($template_item_list) > 0) {
foreach ($template_item_list as $item) {
$this_row_style = ""; $use_custom_row_color = false; $hard_return = "";
if ($graph_item_types{$item["graph_type_id"]} != "GPRINT") {
$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"]};
if ($use_custom_row_color == false) {
form_alternate_row_color($alternate_color_1,$alternate_color_2,$i);
}else{
print "";
}
print "| Item # " . ($i+1) . " | \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();
start_box("Graph Item Inputs", "98%", $colors["header"], "3", "center", "graph_templates.php?action=input_edit&graph_template_id=" . $_GET["id"]);
print "";
DrawMatrixHeaderItem("Name",$colors["header_text"],2);
print "
";
$template_item_list = db_fetch_assoc("select id,name from graph_template_input where graph_template_id=" . $_GET["id"] . " order by name");
if (sizeof($template_item_list) > 0) {
foreach ($template_item_list as $item) {
form_alternate_row_color($colors["alternate"],$colors["light"],$i);
?>
&graph_template_id=">
|
&graph_template_id=">
|
No Inputs | ";
}
end_box();
}
function item_remove() {
db_execute("delete from graph_templates_item where id=" . $_GET["id"]);
}
function item_edit() {
global $colors, $struct_graph_item, $graph_item_types, $consolidation_functions;
$header_label = "[edit graph: " . db_fetch_cell("select name from graph_templates where id=" . $_GET["graph_template_id"]) . "]";
if (read_config_option("full_view_graph_template") == "") {
start_box("Graph Template Management $header_label", "98%", $colors["header"], "3", "center", "");
draw_graph_form_select("?action=item&id=" . $_GET["id"]);
end_box();
}
start_box("Graph Template Items $header_label", "98%", $colors["header"], "3", "center", "");
if (!empty($_GET["id"])) {
$template_item = db_fetch_row("select * from graph_templates_item where id=" . $_GET["id"]);
}
print "