summaryrefslogtreecommitdiff
path: root/html/pages/match_info_charts.php
blob: ed62fe50544a21479ae464bb8474fe981b6bb4e9 (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
<?php

include_once 'includes/renderer-general-output.php';

global $renderer_heigth;
global $renderer_width;

$mid = mysql_real_escape_string($mid);
$prevCategory = "";
$chartOutput = "";
$prevRenderedChart = "";

// get all charts for this match
$charts = mysql_query("SELECT d.* , t.charttype, t.category, t.type, t.color, t.layout,t.columns
	FROM uts_chartdata d
	JOIN uts_charttypes t ON d.chartid = t.id
	WHERE d.mid = $mid
	ORDER BY d.id ASC") or die(mysql_error());

$chartCount = mysql_num_rows($charts);

if ($chartCount >0) {
	$i = 0;

	// cycle over charts
	while ($chart = mysql_fetch_array($charts)) {

		// retrieve both generic as the specific data
		$category = $chart['category'];
		$type = $chart['type'];
		$color = $chart['color'];
		$layout = $chart['layout'];
		$charttype = $chart['charttype'];
		$columns = $chart['columns'];
		$title = $chart['title'];
		$data = unserialize(gzdecode($chart['data']));
		$labels = unserialize(gzdecode($chart['labels']));
		$categories = unserialize(gzdecode($chart['categories']));

		// append previous chart - this is done to ensure proper outlining (can only know in +1 round)
		$chartOutput .= $prevRenderedChart;

		// print a new section if we're now in a different category
		if ($category != $prevCategory) {

			if(strlen($prevCategory) > 0)
				$chartOutput .= renderFootBlock();

			$chartOutput .= renderHeaderBlock($category);
			$prevCategory = $category;

		} else {
			if ($i>1 && $i%2 == 0)
				$chartOutput .= "</td></tr><tr><td>";
			else
				$chartOutput .= "</td><td>";
		}

		$prevRenderedChart = renderChart($mid."-".$i,$layout,$color,$title,$data,$labels,$categories,$renderer_width*$columns,$renderer_heigth,$charttype);

		$i++;
	}

	// finishing up
	$chartOutput .= $prevRenderedChart;
	$chartOutput .= renderFootBlock();

	echo '
	<script type="text/javascript">
		function toggle_visibility(id) {
		  var e = document.getElementById(id);
		  if (e.style.display != "none")
			  e.style.display = "none";
		  else
			  e.style.display = "";
		}
	</script>';

	echo $chartOutput;
}

?>