Location: PHPKode > projects > QuickTicket > quickticket/qti_stats_g.php
<?php

// QuickTicket 2.3 build:20091102

include('qti_stats_inc.php');

// Display title & option

echo '<table class="hidden" cellspacing="0">';
echo '<tr class="hidden">';
echo '<td><h2>',$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(' &middot; ',$arrMenuTime),'</td>';
echo '</tr></table>
';

// Display table header

echo '<table class="data_t" cellspacing="0">
<tr class="data_t">
<td class="th_o" style="width:85px">&nbsp;</td>
<td class="th_o" style="width:14px">&nbsp;</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 TOPICS

echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['Topics'],'</td>',N;
echo '<td class="th_o"><div style="margin:0 auto;background-color:#000066;width:8px;height:10px">&nbsp;</div></td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) 
{
  echo '<td class="td_o" style="text-align:center;">',(isset($arrT[$y][$intBt]) ? $arrT[$y][$intBt] : '&middot;'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrTs[$y],'</b></td>',N;
echo '</tr>';

// DISPLAY REPLIES

echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['Replys'],'</td>',N;
echo '<td class="th_o"><div style="margin:0 auto;background-color:#990099;width:8px;height:10px">&nbsp;</div></td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) 
{
  echo '<td class="td_o" style="text-align:center;">',(isset($arrM[$y][$intBt]) ? $arrM[$y][$intBt] : '&middot;'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrMs[$y],'</b></td>',N;
echo '</tr>';

// DISPLAY USERS

echo '<tr class="data_o">',N;
echo '<td class="th_o">',$L['Users'],'*</td>',N;
echo '<td class="th_o"><div style="margin:0 auto;background-color:#009999;width:8px;height:10px">&nbsp;</div></td>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) 
{
  if ( isset($arrU[$y][$intBt]) ) { $str=$arrU[$y][$intBt]; } else { $str='&middot;'; }
  if ( $oVIP->output=='screen' && !empty($arrU[$y][$intBt]) && $ch['time']=='m' ) $str='<a href="qti_stat.php?y='.$y.'&amp;m='.$intBt.'&amp;s='.$s.'">'.$arrU[$y][$intBt].'</a>';
  echo '<td class="td_o" style="text-align:center;">',$str,'</td>',N;
}
if ( $oVIP->output=='screen' && $arrUs[$y] && $ch['time']=='m' ) { $str='<a href="qti_stat.php?y='.$y.'&amp;s='.$s.'">'.$arrUs[$y].'</a>'; } else { $str=$arrUs[$y]; }
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$str,'</b></td>',N;
echo '</tr>
</table>
';

echo '<p>*  <span class="small">',$L['Distinct_users'],'</span></p>
';

// After values display, change the null values to zero to be able to make charts

foreach($arrYears as $y)
{
$arrT[$y] = QTarrayzero($arrT[$y]);
$arrM[$y] = QTarrayzero($arrM[$y]);
$arrU[$y] = QTarrayzero($arrU[$y]);
}

// PCHART OR CHART

if ( file_exists('pChart/pChart.class') && file_exists('pChart/pData.class') && file_exists('pChart/pCache.class')  && !isset($_GET['oldgraph']) )
{
  // Standard inclusions and prepare CACHE
  include('pChart/pData.class');
  include('pChart/pChart.class');
  include('pChart/pCache.class');
  $Cache = new pCache('pChart/Cache/');

  // Check cache, clear cache if to much files
  $intHandle = opendir('pChart/Cache');
  $i = 0;
  while ( false!==($strFile = readdir($intHandle)) ) $i++;
  closedir($intHandle);
  if ( $i>60 || isset($_GET['clearcache']) ) $Cache->ClearCache();
  
  // -------
  // Graph 1
  // -------

  // Dataset definition
  $strName = $tt.'1'.$y.implode('',$ch);
  $DataSet = new pData;
  $DataSet->AddPoint( ($ch['value']=='p' ? QTpercent($arrT[$y]) : $arrT[$y]),'Serie1' );
  $DataSet->AddPoint($arrA,'Serie2');
  $DataSet->AddSerie('Serie1');
  $DataSet->SetAbsciseLabelSerie('Serie2');
  $DataSet->SetSerieName($y,'Serie1');
  if ( $ch['value']=='p' ) { $intTopY = (QTroof(QTpercent($arrT[$y]))>50 ? 100 : 50); } else { $intTopY = QTroof($arrT[$y]); }

  if ( !$Cache->IsInCache($strName,$DataSet->GetData()) )
  {    
    // Initialise the graph 
    $oChart = new pChart(380,230);
    $oChart->setColorPalette(0,0,0,102); //color 1
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',8);
    $oChart->setGraphArea(40,35,360,195);
    $oChart->setFixedScale(0,$intTopY);
    $oChart->drawFilledRoundedRectangle(7,7,373,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 0 line
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',6);
    $oChart->drawTreshold(0,143,55,72,TRUE,TRUE);

    // Draw the line graph
    if ( $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);
    }

    // Finish the graph
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",10);
    $oChart->drawTitle(40,25,$L['Topics_per_'.$ch['time']].($ch['value']=='p' ? ' (%)' : ''),50,50,50);
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",9);
    $oChart->drawLegend(310,15,$DataSet->GetDataDescription(),240,240,240,-1,-1,-1,0,0,0,false);
    $Cache->WriteToCache($strName,$DataSet->GetData(),$oChart);
    $oChart->Render('pChart/tmp/'.$strName.'.png');
  }

  // -------
  // Graph 2 // cumul
  // -------

  // Dataset definition
  $strName = $tt.'2'.$y.implode('',$ch);
  $DataSet = new pData;
  $DataSet->AddPoint( QTcumul(($ch['value']=='p' ? QTpercent($arrT[$y],2) : $arrT[$y])),'Serie1' );
  $DataSet->AddPoint($arrA,'Serie2');
  $DataSet->AddSerie('Serie1');
  $DataSet->SetAbsciseLabelSerie('Serie2');
  $DataSet->SetSerieName($y,'Serie1');
  if ( $ch['value']=='p' ) { $intTopY = (QTroof(QTcumul(QTpercent($arrT[$y])))>50 ? 100 : 50); } else { $intTopY = QTroof(QTcumul($arrT[$y])); }

  // Cache definition 
  $Cache = new pCache('pChart/Cache/');
  if ( !$Cache->IsInCache($strName,$DataSet->GetData()) )
  {  
    // Initialise the graph 
    $oChart = new pChart(380,230);
    $oChart->setColorPalette(0,0,0,102); //color 1
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',8);
    $oChart->setGraphArea(40,35,360,195);
    $oChart->setFixedScale(0,$intTopY);
    $oChart->drawFilledRoundedRectangle(7,7,373,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 0 line
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',6);
    $oChart->drawTreshold(0,143,55,72,TRUE,TRUE);

    // Draw the line graph
    if ( $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);
    }

    // Finish the graph
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",10);
    $oChart->drawTitle(40,25,$L['Topics_per_'.$ch['time'].'_cumul'].($ch['value']=='p' ? ' (%)' : ''),50,50,50);
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",9);
    $oChart->drawLegend(310,15,$DataSet->GetDataDescription(),240,240,240,-1,-1,-1,0,0,0,false);
    $Cache->WriteToCache($strName,$DataSet->GetData(),$oChart);
    $oChart->Render('pChart/tmp/'.$strName.'.png');
  }

  // -------
  // Graph 3
  // -------
  
  // Dataset definition
  $strName = $tt.'3'.$y.implode('',$ch);
  $DataSet = new pData;
  $DataSet->AddPoint( ($ch['value']=='p' ? QTpercent($arrM[$y]) : $arrM[$y]),'Serie1' );
  $DataSet->AddPoint($arrA,'Serie2');
  $DataSet->AddSerie('Serie1');
  $DataSet->SetAbsciseLabelSerie('Serie2');
  $DataSet->SetSerieName($y,'Serie1');
  if ( $ch['value']=='p' ) { $intTopY = (QTroof(QTpercent($arrM[$y]))>50 ? 100 : 50); } else { $intTopY = QTroof($arrM[$y]); }

  // Cache definition 
  $oCache = new pCache('pChart/Cache/');
  if ( !$Cache->IsInCache($strName,$DataSet->GetData()) )
  {
    // Initialise the graph 
    $oChart = new pChart(380,230);
    $oChart->setColorPalette(0,153,0,153); //color 2
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',8);
    $oChart->setGraphArea(40,35,360,195);
    $oChart->setFixedScale(0,$intTopY);
    $oChart->drawFilledRoundedRectangle(7,7,373,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 0 line
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',6);
    $oChart->drawTreshold(0,143,55,72,TRUE,TRUE);

    // Draw the line graph
    if ( $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);
    }

    // Finish the graph
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",10);
    $oChart->drawTitle(40,25,$L['Replies_per_'.$ch['time']].($ch['value']=='p' ? ' (%)' : ''),50,50,50);
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",9);
    $oChart->drawLegend(310,15,$DataSet->GetDataDescription(),240,240,240,-1,-1,-1,0,0,0,false);
    $Cache->WriteToCache($strName,$DataSet->GetData(),$oChart);
    $oChart->Render('pChart/tmp/'.$strName.'.png');
  }

  // -------
  // Graph 4
  // -------
  
  // Dataset definition
  $strName = $tt.'4'.$y.implode('',$ch);
  $DataSet = new pData;
  $DataSet->AddPoint( ($ch['value']=='p' ? QTpercent($arrU[$y]) : $arrU[$y]),'Serie1' );
  $DataSet->AddPoint($arrA,'Serie2');
  $DataSet->AddSerie('Serie1');
  $DataSet->SetAbsciseLabelSerie('Serie2');
  $DataSet->SetSerieName($y,'Serie1');
  if ( $ch['value']=='p' ) { $intTopY = (QTroof(QTpercent($arrU[$y]))>50 ? 100 : 50); } else { $intTopY = QTroof($arrU[$y]); }
 
  // Cache definition 
  $Cache = new pCache('pChart/Cache/');
  if ( !$Cache->IsInCache($strName,$DataSet->GetData()) )
  {  
    // Initialise the graph 
    $oChart = new pChart(380,230);
    $oChart->setColorPalette(0,0,153,153); //color 3
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',8);
    $oChart->setGraphArea(40,35,360,195);
    $oChart->setFixedScale(0,$intTopY);
    $oChart->drawFilledRoundedRectangle(7,7,373,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 0 line
    $oChart->setFontProperties('pChart/Fonts/tahoma.ttf',6);
    $oChart->drawTreshold(0,143,55,72,TRUE,TRUE);

    // Draw the line graph
    if ( $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);
    }

    // Finish the graph
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",10);
    $oChart->drawTitle(40,25,$L['Users_per_'.$ch['time']].($ch['value']=='p' ? ' (%)' : ''),50,50,50);
    $oChart->setFontProperties("pChart/Fonts/tahoma.ttf",9);
    $oChart->drawLegend(310,15,$DataSet->GetDataDescription(),240,240,240,-1,-1,-1,0,0,0,false);
    $Cache->WriteToCache($strName,$DataSet->GetData(),$oChart);
    $oChart->Render('pChart/tmp/'.$strName.'.png');
  }

  // -------
  // DISPLAY
  // -------

  if ( $oVIP->output=='screen' ) echo '<p class="small" style="text-align:right">',implode(' &middot; ',$arrMenuType),' | ',implode(' &middot; ',$arrMenuValue),'</p>';
  
  echo '<table class="hidden" cellspacing="0">',N;
  echo '<tr class="hidden">',N;
  echo '<td class="hidden"><img src="pChart/tmp/'.$tt.'1'.$y.implode('',$ch).'.png"/></td>',N;
  echo '<td class="hidden" style="text-align:right"><img src="pChart/tmp/'.$tt.'2'.$y.implode('',$ch).'.png"/></td>',N;
  echo '</tr>';
  echo '<tr class="hidden">',N;
  echo '<td class="hidden"><img src="pChart/tmp/'.$tt.'3'.$y.implode('',$ch).'.png"/></td>',N;
  echo '<td class="hidden" style="text-align:right"><img src="pChart/tmp/'.$tt.'4'.$y.implode('',$ch).'.png"/></td>',N;
  echo '</tr>';
  echo '</table>';

}
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(' &middot; ',$arrMenuValue),'</p>';
  
  // Topics & cumulated topics
  
  echo '<table class="data_t" cellspacing="0">',N;
  echo '<tr class="data_t">',N;

  echo '<td class="td_o" style="width:355px">',N;
  
  if ( $ch['value']=='a' ) 
  {
  QTbarchart(QTarraymerge($arrA,$arrT[$y]),320,100,QTroof($arrT[$y]),2,true,$L['Topics_per_'.$ch['time']],'','1');
  }
  else
  {
  QTbarchart(QTarraymerge($arrA,QTpercent($arrT[$y])),350,100,100,2,'P',$L['Topics_per_'.$ch['time']].' (%)','','1');
  }

  echo '</td>',N;  
  echo '<td class="td_o">&nbsp;</td>',N;
  echo '<td class="td_o" style="width:355px">',N;

  if ( $ch['value']=='a' ) 
  {
  QTbarchart(QTarraymerge($arrA,QTcumul($arrT[$y])),320,100,QTroof($arrT[$y]),2,true,$L['Topics_per_'.$ch['time'].'_cumul'],'','1');
  }
  else
  {
  QTbarchart(QTarraymerge($arrA,QTcumul(QTpercent($arrT[$y],2))),350,100,100,2,'P',$L['Topics_per_'.$ch['time'].'_cumul'].' (%)','','1');
  }
  echo '</td>',N;
  echo '</tr>',N;
  
  // Replies & Users
  
  echo '<tr class="data_o">',N;

  echo '<td class="td_o" style="width:355px">',N;
  
  if ( $ch['value']=='a' ) 
  {
  QTbarchart(QTarraymerge($arrA,$arrM[$y]),320,100,QTroof($arrM[$y]),2,true,$L['Replies_per_'.$ch['time']],'','2');
  }
  else
  {
  QTbarchart(QTarraymerge($arrA,QTpercent($arrM[$y])),350,100,100,2,'P',$L['Replies_per_'.$ch['time']].' (%)','','2');
  }

  echo '</td>',N;  
  echo '<td class="td_o">&nbsp;</td>',N;
  echo '<td class="td_o" style="width:355px">',N;

  if ( $ch['value']=='a' ) 
  {
  QTbarchart(QTarraymerge($arrA,$arrU[$y]),320,100,QTroof($arrM[$y]),2,true,$L['Users_per_'.$ch['time']],'','3');
  }
  else
  {
  QTbarchart(QTarraymerge($arrA,QTpercent($arrU[$y])),350,100,100,2,'P',$L['Users_per_'.$ch['time']].' (%)','','3');
  }
  echo '</td>',N;
  echo '</tr></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>';
}

?>
Return current item: QuickTicket