summaryrefslogtreecommitdiffstats
path: root/frontends/php/graphs.php
blob: ee03eaeb5c4baafff275341f4cd6ff4dd6b0bbb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
	include "include/config.inc.php";
	$page["title"] = "Graphs";
	$page["file"] = "graphs.php";
	show_header($page["title"],0,0);
?>

<?php
	show_table_header("CONFIGURATION OF GRAPHS");
	echo "<br>";
?>

<?php
	if(!check_right("Graph","U",0))
	{
		show_table_header("<font color=\"AA0000\">No permissions !</font>");
		show_footer();
		exit;
	}
?>

<?php
	if(isset($HTTP_GET_VARS["register"]))
	{
		if($HTTP_GET_VARS["register"]=="add")
		{
			$result=add_graph($HTTP_GET_VARS["name"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]);
			show_messages($result,"Graph added","Cannot add graph");
		}
		if($HTTP_GET_VARS["register"]=="update")
		{
			$result=update_graph($HTTP_GET_VARS["graphid"],$HTTP_GET_VARS["name"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]);
			show_messages($result,"Graph updated","Cannot update graph");
		}
		if($HTTP_GET_VARS["register"]=="delete")
		{
			$result=delete_graph($HTTP_GET_VARS["graphid"]);
			show_messages($result,"Graph deleted","Cannot delete graph");
			unset($HTTP_GET_VARS["graphid"]);
		}
	}
?>

<?php
	show_table_header("GRAPHS");
	echo "<TABLE BORDER=0 COLS=4 WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
	echo "<TD WIDTH=5% NOSAVE><B>Id</B></TD>";
	echo "<TD WIDTH=10% NOSAVE><B>Name</B></TD>";
	echo "<TD WIDTH=10% NOSAVE><B>Width</B></TD>";
	echo "<TD WIDTH=10% NOSAVE><B>Height</B></TD>";
	echo "<TD WIDTH=10% NOSAVE><B>Actions</B></TD>";
	echo "</TR>";

	$result=DBselect("select g.graphid,g.name,g.width,g.height from graphs g order by g.name");
	$col=0;
	while($row=DBfetch($result))
	{
		if(!check_right("Graph","R",$row["graphid"]))
		{
			continue;
		}
		if($col++%2==0)	{ echo "<TR BGCOLOR=#EEEEEE>"; }
		else		{ echo "<TR BGCOLOR=#DDDDDD>"; }
	
		echo "<TD>".$row["graphid"]."</TD>";
		echo "<TD><a href=\"graph.php?graphid=".$row["graphid"]."\">".$row["name"]."</a></TD>";
		echo "<TD>".$row["width"]."</TD>";
		echo "<TD>".$row["height"]."</TD>";
		echo "<TD><A HREF=\"graphs.php?graphid=".$row["graphid"]."#form\">Change</A> - ";
		echo "<A HREF=\"graphs.php?register=delete&graphid=".$row["graphid"]."\">Delete</A></TD>";
		echo "</TR>";
	}
	echo "</TABLE>";
?>

<?php
	echo "<a name=\"form\"></a>";

	if(isset($HTTP_GET_VARS["graphid"]))
	{
		$result=DBselect("select g.graphid,g.name,g.width,g.height from graphs g where graphid=".$HTTP_GET_VARS["graphid"]);
		$row=DBfetch($result);
		$name=$row["name"];
		$width=$row["width"];
		$height=$row["height"];
	}
	else
	{
		$name="";
		$width=900;
		$height=200;
	}

	echo "<br>";
	show_table2_header_begin();
	echo "New graph";

	show_table2_v_delimiter();
	echo "<form method=\"get\" action=\"graphs.php\">";
	if(isset($HTTP_GET_VARS["graphid"]))
	{
		echo "<input class=\"biginput\" name=\"graphid\" type=\"hidden\" value=".$HTTP_GET_VARS["graphid"].">";
	}
	echo "Name";
	show_table2_h_delimiter();
	echo "<input class=\"biginput\" name=\"name\" value=\"$name\" size=32>";

	show_table2_v_delimiter();
	echo "Width";
	show_table2_h_delimiter();
	echo "<input class=\"biginput\" name=\"width\" size=5 value=\"$width\">";

	show_table2_v_delimiter();
	echo "Height";
	show_table2_h_delimiter();
	echo "<input class=\"biginput\" name=\"height\" size=5 value=\"$height\">";

	show_table2_v_delimiter2();
	echo "<input type=\"submit\" name=\"register\" value=\"add\">";
	if(isset($HTTP_GET_VARS["graphid"]))
	{
		echo "<input type=\"submit\" name=\"register\" value=\"update\">";
	}

	show_table2_header_end();
?>

<?php
	show_footer();
?>