|
From: Benjamin C. <bc...@us...> - 2001-08-03 03:50:31
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv19166
Modified Files:
include.php index.php
Added Files:
images.php
Log Message:
Start the inclusion of graphs for reporting
--- NEW FILE: images.php ---
<?php
// images.php - Draw graphs using jpgraph
define ('JPGRAPH_PATH', '/home/bcurtis/public_html/jp/');
include 'include.php';
include JPGRAPH_PATH.'jpgraph.php';
function bug_cat_summary() {
global $q;
include_once JPGRAPH_PATH.'jpgraph_pie.php';
// Grab the legend
$q->query("select StatusID, Name from Status order by SortOrder");
while ($row = $q->grab()) {
$stats[$row['StatusID']]['Name'] = $row['Name'];
}
// Grab the data
$q->query("select Status, count(Status) as Count from Bug group by Status");
while ($row = $q->grab()) {
$stats[$row['Status']]['Count'] = $row['Count'];
}
$totalbugs = 0;
foreach ($stats as $stat) {
if ($stat['Count']) {
$data[] = $stat['Count'];
$legend[] = "{$stat['Name']} ({$stat['Count']})";
$totalbugs += $stat['Count'];
}
}
// Create the Pie Graph.
$graph = new PieGraph(300,200,"bug_cat_summary");
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set(sprintf("Bug Summary (%d bug%s)",
$totalbugs, $totalbugs == 1 ? '' : 's'));
$graph->title->SetFont(FONT1,FS_BOLD);
$graph->legend->Pos(0.03, 0.5, 'right', 'center');
// Create
$p1 = new PiePlot($data);
$p1->SetLegends($legend);
$p1->SetCenter(0.25);
$p1->SetPrecision(0);
$graph->Add($p1);
$graph->Stroke();
}
switch($pic) {
default : bug_cat_summary();
}
?>
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- include.php 2001/08/01 13:55:56 1.15
+++ include.php 2001/08/03 03:50:28 1.16
@@ -12,6 +12,7 @@
define ('ADMINEMAIL','ph...@be...');
define ('ENCRYPTPASS',0); // Whether to store passwords encrypted
define ('THEME','default/'); // Which set of templates to use
+define ('USE_JPGRAPH',0); // Whether to show images or not
require PHPLIBPATH.'db_mysql.inc';
require PHPLIBPATH.'ct_sql.inc';
Index: index.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/index.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- index.php 2001/07/21 03:03:05 1.4
+++ index.php 2001/08/03 03:50:28 1.5
@@ -10,30 +10,36 @@
'wrap' => 'wrap.html',
'content' => 'index.html'
));
-$t->set_block('content','row','rows');
+$t->set_block('content', 'statsblock', 'sblock');
+$t->set_block('statsblock','row','rows');
$t->set_var('TITLE','Home');
-$q->query("select * from Status order by SortOrder");
-while ($row = $q->grab()) {
- $stats[$row['StatusID']]['Name'] = $row['Name'];
-}
-$q->query("select Status, count(Status) as Count from Bug group by Status");
-while ($row = $q->grab()) {
- $stats[$row['Status']]['Count'] = $row['Count'];
-}
-foreach ($stats as $stat) {
+if (USE_JPGRAPH) {
+ $t->set_var('sblock', '<img src="images.php" align="right">');
+} else {
+ $q->query("select * from Status order by SortOrder");
+ while ($row = $q->grab()) {
+ $stats[$row['StatusID']]['Name'] = $row['Name'];
+ }
+ $q->query("select Status, count(Status) as Count from Bug group by Status");
+ while ($row = $q->grab()) {
+ $stats[$row['Status']]['Count'] = $row['Count'];
+ }
+ foreach ($stats as $stat) {
+ $t->set_var(array(
+ 'status' => $stat['Name'],
+ 'count' => $stat['Count'] ? $stat['Count'] : 0
+ ));
+ $total += $stat['Count'];
+ $t->parse('rows','row',true);
+ }
$t->set_var(array(
- 'status' => $stat['Name'],
- 'count' => $stat['Count'] ? $stat['Count'] : 0
+ 'status' => "<b>{$STRING['totalbugs']}</b>",
+ 'count' => $total ? "<b>$total</b>" : 0
));
- $total += $stat['Count'];
$t->parse('rows','row',true);
+ $t->parse('sblock', 'statsblock', true);
}
-$t->set_var(array(
- 'status' => "<b>{$STRING['totalbugs']}</b>",
- 'count' => $total ? "<b>$total</b>" : 0
- ));
-$t->parse('rows','row',true);
$t->pparse('main',array('content','wrap','main'));
|