<?php
// QuickTicket 2.3 build:20091102
include('qti_stats_inc.php');
// DISPLAY title & option
echo '<table class="hidden" cellspacing="0">';
echo '<tr class="hidden" style="vertical-align:middle;">';
echo '<td><h2>',$y-1,' - ',$y,($s>=0 ? ' ('.$oVIP->sections[$s].')' : ''),(empty($tag) ? '' : ', '.$L['With_tag'].' '.str_replace(';',' '.$L['or'].' ',$tag)),'</h2></td>',N;
if ( $oVIP->output=='screen' ) echo '<td class="small" style="text-align:right">',implode(' · ',$arrMenuTime),'</td>';
echo '</tr>
</table>
';
// DISPLAY VALUES
foreach($arrYears as $y) {
// Display table header
echo '<table class="data_t" cellspacing="0">
<tr class="data_t">
<td class="th_o" style="width:100px">',$y,'</td>
<td class="th_o" style="width:14px"> </td>
';
switch($ch['time'])
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { echo '<td class="th_o" style="text-align:center;">Q',$i,'</td>'; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { echo '<td class="th_o" style="text-align:center;">',$L['dateMM'][$i],'</td>'; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { echo '<td class="th_o" style="text-align:center;">',str_replace(' ','<br/>',QTdatestr(DateAdd($strTendaysago,$i,'day'),'d M','')),'</td>'; } break;
}
echo '<td class="th_o" style="text-align:center;"><b>',($ch['time']=='d' ? '10 '.strtolower($L['Days']) : $L['Year']),'</b></td>
</tr>';
// DISPLAY NEW TOPICS
echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['New_topics'],'</td>',N;
echo '<td class="th_o"><div style="margin:0 auto;background-color:'.($y==$intCurrentYear ? '#000066' : '#00AFFF').';width:8px;height:10px"> </div></td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
echo '<td class="td_o" style="text-align:center;">',(isset($arrN[$y][$intBt]) ? $arrN[$y][$intBt] : '·'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrNs[$y],'</b></td></tr>',N;
// DISPLAY CLOSED TOPICS
echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['Closed_topics'],'</td>',N;
echo '<td class="th_o"><div style="margin:0 auto;background-color:'.($y==$intCurrentYear ? '#990099' : '#F1B8FF').';width:8px;height:10px"> </div></td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
echo '<td class="td_o" style="text-align:center;">',(isset($arrC[$y][$intBt]) ? $arrC[$y][$intBt] : '·'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrCs[$y],'</b></td></tr>',N;
echo '</table>
';
}
// DISPLAY TRENDS
// Display table header
if ( $oVIP->output=='screen' ) echo '<p class="small" style="text-align:right">',implode(' · ',$arrMenuTrend),'</p>';
echo '<table class="data_t" cellspacing="0">
<tr class="data_t">
<td class="th_o" style="width:100px">',$L['Trends'],'</td>
<td class="th_o" style="width:14px"> </td>
';
switch($ch['time'])
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { echo '<td class="th_o" style="text-align:center;">Q',$i,'</td>'; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { echo '<td class="th_o" style="text-align:center;">',$L['dateMM'][$i],'</td>'; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { echo '<td class="th_o" style="text-align:center;">',str_replace(' ','<br/>',QTdatestr(DateAdd($strTendaysago,$i,'day'),'d M','')),'</td>'; } break;
}
echo '<td class="th_o" style="text-align:center;"><b>',($ch['time']=='d' ? '10 '.strtolower($L['Days']) : $L['Year']),'</b></td>
</tr>';
// New Topics trends
echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['New_topics'],'</td>',N;
echo '<td class="th_o"> </td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$str = '0';
$i = QTtrend((isset($arrN[$y][$intBt]) ? $arrN[$y][$intBt] : 0),(isset($arrN[$y-1][$intBt]) ? $arrN[$y-1][$intBt] : 0),$ch['trend']=='p');
if ( isset($i) )
{
if ( $i>0 ) $str = '<span style="color:red">'.'+'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
if ( $i<0 ) $str = '<span style="color:green">'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
}
else
{
$str = '·';
}
echo '<td class="td_o" style="text-align:center;">',$str,'</td>',N;
}
$str = '0';
$i = QTtrend($arrNs[$y],$arrNs[$y-1],$ch['trend']=='p');
if ( isset($i) )
{
if ( $i>0 ) $str = '<span style="color:red">'.'+'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
if ( $i<0 ) $str = '<span style="color:green">'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
}
else
{
$str = '·';
}
echo '<td class="td_o" style="text-align:center;"><b>',$str,'</b></td></tr>',N;
// Closed Topics trends
echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['Closed_topics'],'</td>',N;
echo '<td class="th_o"> </td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$str = '0';
$i = QTtrend((isset($arrC[$y][$intBt]) ? $arrC[$y][$intBt] : 0),(isset($arrC[$y-1][$intBt]) ? $arrC[$y-1][$intBt] : 0),$ch['trend']=='p');
if ( isset($i) )
{
if ( $i>0 ) $str = '<span style="color:red">'.'+'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
if ( $i<0 ) $str = '<span style="color:green">'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
}
else
{
$str = '·';
}
echo '<td class="td_o" style="text-align:center;">',$str,'</td>',N;
}
$str = '0';
$i = QTtrend($arrCs[$y],$arrCs[$y-1],$ch['trend']=='p');
if ( isset($i) )
{
if ( $i>0 ) $str = '<span style="color:red">'.'+'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
if ( $i<0 ) $str = '<span style="color:green">'.$i.($ch['trend']=='p' ? '%' : '').'</span>';
}
else
{
$str = '·';
}
echo '<td class="td_o" style="text-align:center;"><b>',$str,'</b></td></tr>',N;
echo '</table>
';
// After values display change the null values to zero to be able to make charts
foreach($arrYears as $y)
{
$arrT[$y] = QTarrayzero($arrT[$y]);
$arrN[$y] = QTarrayzero($arrN[$y]);
$arrC[$y] = QTarrayzero($arrC[$y]);
}
// GRAPH
if ( file_exists('pChart/pChart.class') && file_exists('pChart/pData.class') && file_exists('pChart/pCache.class') )
{
// abscise Label (2 characters)
$arrA = array();
switch($ch['time'])
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $arrA[$i]='Q'.$i; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $arrA[$i]=$L['dateMM'][$i]; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $arrA[$i]=substr(DateAdd($strTendaysago,$i,'day'),-2,2); } break;
}
// Standard inclusions and prepare CACHE
include('pChart/pData.class');
include('pChart/pChart.class');
include('pChart/pCache.class');
$Cache = new pCache('pChart/Cache/');
// Check cache
$intHandle = opendir('pChart/Cache');
$i = 0;
while ( false!==($strFile = readdir($intHandle)) ) $i++;
closedir($intHandle);
// clear cache if to much files
if ( $i>60 || isset($_GET['clearcache']) ) $Cache->ClearCache();
// -------
// Graph 1 [value]
// -------
// Dataset definition
$strName = $tt.'1'.$y.implode('',$ch);
$DataSet = new pData;
$DataSet->AddPoint($arrN[$y-1],'Serie1');
$DataSet->AddPoint($arrN[$y],'Serie2');
$DataSet->AddPoint($arrA,'Serie3');
$DataSet->AddSerie('Serie1');
$DataSet->AddSerie('Serie2');
$DataSet->SetSerieName($y-1,'Serie1');
$DataSet->SetSerieName($y,'Serie2');
$DataSet->SetAbsciseLabelSerie('Serie3');
$intTopY = QTroof( array(max($arrN[$y-1]),max($arrN[$y])) );
if ( !$Cache->IsInCache($strName,$DataSet->GetData()) )
{
// Initialise the graph
$oChart = new pChart(600,230);
$oChart->setColorPalette(0,0,175,255); //color color1b
$oChart->setColorPalette(1,0,0,102); //color 1
$oChart->setFontProperties('pChart/Fonts/tahoma.ttf',8);
$oChart->setGraphArea(40,35,560,195);
$oChart->setFixedScale(0,$intTopY);
$oChart->drawFilledRoundedRectangle(7,7,593,223,5,240,240,240);
$oChart->drawGraphArea(255,255,255,TRUE);
$oChart->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,125,125,125,TRUE,0,0,TRUE);
$oChart->drawGrid(4,TRUE,230,230,230,50);
// Draw the line/bar graph
if ( strtolower($ch['type'])=='l' )
{
$oChart->drawFilledLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(),40,TRUE);
$oChart->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
}
else
{
$oChart->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE);
}
// label with the trend
if ( $ch['type']=='B' || $ch['type']=='L' )
{
$oChart->setFontProperties('pChart/Fonts/tahoma.ttf',7);
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$i = QTtrend((isset($arrN[$y][$intBt]) ? $arrN[$y][$intBt] : 0),(isset($arrN[$y-1][$intBt]) ? $arrN[$y-1][$intBt] : 0),$ch['trend']=='p');
if ( $i>0 ) $oChart->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),'Serie2',$arrA[$intBt],'+'.$i,220,220,220);
if ( $i<0 ) $oChart->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),'Serie2',$arrA[$intBt],$i,220,220,220);
}
}
// Finish the graph
$oChart->setFontProperties("pChart/Fonts/tahoma.ttf",10);
$oChart->drawTitle(40,25,$L['New_topics'].($ch['value']=='p' ? ' (%)' : ''),50,50,50,560);
$oChart->setFontProperties("pChart/Fonts/tahoma.ttf",9);
$oChart->drawLegend(520,18,$DataSet->GetDataDescription(),255,255,255);
$Cache->WriteToCache($strName,$DataSet->GetData(),$oChart);
$oChart->Render('pChart/tmp/'.$strName.'.png');
}
// -------
// Graph 2 [value]
// -------
// Dataset definition
$strName = $tt.'2'.$y.implode('',$ch);
$DataSet = new pData;
$DataSet->AddPoint($arrC[$y-1],'Serie1');
$DataSet->AddPoint($arrC[$y],'Serie2');
$DataSet->AddPoint($arrA,'Serie3');
$DataSet->AddSerie('Serie1');
$DataSet->AddSerie('Serie2');
$DataSet->SetSerieName($y-1,'Serie1');
$DataSet->SetSerieName($y,'Serie2');
$DataSet->SetAbsciseLabelSerie('Serie3');
$intTopY = QTroof( array(max($arrC[$y-1]),max($arrC[$y])) );
if ( !$Cache->IsInCache($strName,$DataSet->GetData()) )
{
// Initialise the graph
$oChart = new pChart(640,230);
$oChart->setColorPalette(0,241,184,255); //color 2b
$oChart->setColorPalette(1,153,0,153); //color 2
$oChart->setFontProperties('pChart/Fonts/tahoma.ttf',8);
$oChart->setGraphArea(40,35,560,195);
$oChart->setFixedScale(0,$intTopY);
$oChart->drawFilledRoundedRectangle(7,7,593,223,5,240,240,240);
$oChart->drawGraphArea(255,255,255,TRUE);
$oChart->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,125,125,125,TRUE,0,0,TRUE);
$oChart->drawGrid(4,TRUE,230,230,230,50);
// Draw the line/bar graph
if ( strtolower($ch['type'])=='l' )
{
$oChart->drawFilledLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(),40,TRUE);
$oChart->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
}
else
{
$oChart->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE);
}
// label with the trend
if ( $ch['type']=='B' || $ch['type']=='L' )
{
$oChart->setFontProperties('pChart/Fonts/tahoma.ttf',7);
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$i = QTtrend((isset($arrC[$y][$intBt]) ? $arrC[$y][$intBt] : 0),(isset($arrC[$y-1][$intBt]) ? $arrC[$y-1][$intBt] : 0),$ch['trend']=='p');
if ( $i>0 ) $oChart->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),'Serie2',$arrA[$intBt],'+'.$i,220,220,220);
if ( $i<0 ) $oChart->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),'Serie2',$arrA[$intBt],$i,220,220,220);
}
}
// Finish the graph
$oChart->setFontProperties("pChart/Fonts/tahoma.ttf",10);
$oChart->drawTitle(40,25,$L['Closed_topics'].($ch['value']=='p' ? ' (%)' : ''),50,50,50,560);
$oChart->setFontProperties("pChart/Fonts/tahoma.ttf",9);
$oChart->drawLegend(520,18,$DataSet->GetDataDescription(),255,255,255);
$Cache->WriteToCache($strName,$DataSet->GetData(),$oChart);
$oChart->Render('pChart/tmp/'.$strName.'.png');
}
// -------
// DISPLAY
// -------
echo '<div style="margin:0 auto; width:600px">',N;
if ( $oVIP->output=='screen' ) echo '<p class="small" style="text-align:right">',implode(' · ',$arrMenuType),'</p>';
echo '<img src="pChart/tmp/'.$tt.'1'.$y.implode('',$ch).'.png"/><br/>';
echo '<img src="pChart/tmp/'.$tt.'2'.$y.implode('',$ch).'.png"/><br/>';
echo '</div>',N;
}
elseif ( file_exists('bin/qt_lib_graph.php') && file_exists($_SESSION[QT]['skin_dir'].'/qti_main2.css') )
{
if ( $oVIP->output=='screen' ) echo '<p class="small" style="text-align:right">',implode(' · ',$arrMenuValue),'</p>';
echo '<table class="data_t" cellspacing="0">',N;
// first serie
$intTopY = QTroof( array(max($arrN[$y-1]),max($arrN[$y])) );
echo '<tr class="data_o">',N;
echo '<td class="td_o" style="width:355px">',N;
if ( $ch['value']=='a' )
{
QTbarchart(QTarraymerge($arrA,$arrN[$y-1]),320,100,$intTopY,2,true,$L['New_topics'].' '.($y-1));
}
else
{
QTbarchart(QTarraymerge($arrA,QTpercent($arrN[$y-1])),350,100,100,2,'P',$L['New_topics'].' (%) '.($y-1));
}
echo '</td>',N;
echo '<td class="td_o"> </td>',N;
echo '<td class="td_o" style="width:355px">',N;
// second serie
if ( $ch['value']=='a' )
{
QTbarchart(QTarraymerge($arrA,$arrN[$y]),320,100,$intTopY,2,true,$L['New_topics'].' '.$y);
}
else
{
QTbarchart(QTarraymerge($arrA,QTpercent($arrN[$y])),350,100,100,2,'P',$L['New_topics'].' (%) '.$y);
}
echo '</td>',N;
echo '</tr>',N;
// 3d serie
$intTopY = QTroof( array(max($arrC[$y-1]),max($arrC[$y])) );
echo '<tr class="data_o">',N;
echo '<td class="td_o" style="width:355px">',N;
if ( $ch['value']=='a' )
{
QTbarchart(QTarraymerge($arrA,$arrC[$y-1]),320,100,$intTopY,2,true,$L['Closed_topics'].' '.($y-1),'','2');
}
else
{
QTbarchart(QTarraymerge($arrA,QTpercent($arrC[$y-1])),350,100,100,2,'P',$L['Closed_topics'].' (%) '.($y-1),'','2');
}
echo '</td>',N;
echo '<td class="td_o"> </td>',N;
echo '<td class="td_o" style="width:355px">',N;
// 4th serie
if ( $ch['value']=='a' )
{
QTbarchart(QTarraymerge($arrA,$arrC[$y]),320,100,$intTopY,2,true,$L['Closed_topics'].' '.$y,'','2');
}
else
{
QTbarchart(QTarraymerge($arrA,QTpercent($arrC[$y])),350,100,$intTopY,2,'P',$L['Closed_topics'].' (%) '.$y,'','2');
}
echo '</td>',N;
echo '</tr>',N;
echo '</table>',N;
}
else
{
echo '<p class="small">Graphs cannot be displayed because one of these files is missing: bin/qt_lib_graph.php, ',$_SESSION[QT]['skin_dir'].'/qti_main2.css</p>';
}
?>