<html>
<link rel="stylesheet" href="style.css">
<body>
<?php include 'header.php'; ?>
<h1 align="center">Statistics module</h1>
<p align="center"><b></b></p>
<?php require_once('statistics_impl.php'); ?>
<?php require_once('errors.php'); ?>
<?php
$graphArray = array(
'1' => 'SetGraph1Data',
'2' => 'SetGraph2Data',
'3' => 'SetGraph3Data'
);
// the connection that'll be used for graph render
ttdb_connect($db);
if ( ($fProject == "") || ($fProject == "null") )
$projectCondition = "";
else
$projectCondition = " AND d.iidproject = $fProject ";
if (($fSoftware == "") || ($fSoftware == "null") )
$softwareCondition = "";
else
$softwareCondition = " AND d.iidsoftware = $fSoftware ";
function SetGraph1Data()
{
global $graphDescription;
global $projectCondition;
global $softwareCondition;
$graphDescription = "absolute monthly defect status";
ttst_setGraphicType(TTST_GRAPHTYPE_STACKED_COLUMNS);
ttst_setNumberOfLevels(2);
ttst_setMainColumn("month");
ttst_setChildColumn("type");
ttst_setCountColumn("count");
ttst_setDataQuery("select count(d.iid) as count,t.sname as type,".
"extract(month from d.ddetectdate) as month ".
"from defect d, defectstatus t where ".
"d.iiddefectstatus=t.iid ".
$projectCondition.$softwareCondition.
"group by t.sname, month ".
"order by month");
ttst_setGraphicDimensions(400, 200);
}
function SetGraph2Data()
{
global $graphDescription;
global $projectCondition;
global $softwareCondition;
$graphDescription = "Defect type / priority distribution";
ttst_setGraphicType(TTST_GRAPHTYPE_STACKED_COLUMNS);
ttst_setNumberOfLevels(2);
ttst_setMainColumn("priority");
ttst_setChildColumn("type");
ttst_setCountColumn("count");
ttst_setDataQuery("select count(d.iid), p.sname as priority, ".
"t.sname as type FROM defect d, defecttype t, ".
"priority p WHERE ".
" d.iidpriority = p.iid AND d.iiddefecttype = t.iid ".
$projectCondition.$softwareCondition.
" GROUP BY priority,type ORDER BY priority");
ttst_setGraphicDimensions(400, 200);
}
function SetGraph3Data()
{
global $graphDescription;
global $projectCondition;
global $softwareCondition;
$graphDescription = "priority / pending distribution";
ttst_setGraphicType(TTST_GRAPHTYPE_STACKED_COLUMNS);
ttst_setNumberOfLevels(2);
ttst_setMainColumn("priority");
ttst_setChildColumn("pendity");
ttst_setCountColumn("count");
ttst_setDataQuery("SELECT p.sname as priority, count(d.iid), ".
"case when iiddefectstatus < 3 then 'pending' else 'non-pending' ".
"end as pendity from defect d, priority p ".
"WHERE d.iidpriority = p.iid ".
$projectCondition.$softwareCondition.
"GROUP BY pendity, priority ".
"order by priority");
ttst_setGraphicDimensions(400, 200);
}
// assert idquery
if ( ($idquery == "") || ($graphArray[$idquery] == "") ) {
tter_errorWithBackButton("No query has been specified. ".
"If you arrived here by clicking a link in the application ".
"then there is a problem. Contact your system administrator. ".
"<p>If you arrived here by trying URLs yourself, then you missed ".
"some argument.");
exit;
}
$graphArray[$idquery]();
?>
<p align="center">Description of the graph: <?php echo $graphDescription; ?>.</p>
<p align="center"><b>Project:</b> <?php
$res = ttdb_execQuery($db, "select sname from project where iid = $fProject");
$fields = ttdb_getArray($res);
if (is_array($fields))
echo $fields['sname'];
else
echo "no project selected";
?>. <b>Software:</b> <?php
$res = ttdb_execQuery($db, "select sname from software where iid = $fSoftware");
$fields = ttdb_getArray($res);
if (is_array($fields))
echo $fields['sname'];
else
echo "no software selected";
?></p>
<?php ttst_render($db); ?>
<p align="center"> </p>
<?php ttdb_close($db); ?>
<?php include 'footer.php'; ?>
</body>
</html>