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

// QuickTicket 2.3 build:20091102

// --------
// INITIALISE
// --------

$oVIP->output='print';

$s = -1;   // section filter
$y = date('Y'); if ( intval(date('n'))<2 ) $y--; // year filter
$tag = ''; // tags filter
$tt = 'g'; // tab: g=global, gt=globaltrend, d=detail, dt=detailtrend
$ch = array('m','b','a','a'); // chart parameters
// [0] blocktime: m=month, q=quarter, d=10days 
// [1] graph type: b=bar, l=line, B=bar+variation, L=line+variation
// [2] graphics reals: a=actual, p=percent
// [3] trends reals: a=actual, p=percent

// --------
// SUBMITTED
// --------
  
if ( isset($_GET['y']) ) $y = intval($_GET['y']);
if ( isset($_GET['s']) ) $s = intval($_GET['s']);
if ( $s>=0 ) { $strSection = 'forum='.$s.' AND'; } else { $strSection=''; }
if ( isset($_GET['tag']) ) $tag = strip_tags($_GET['tag']);
  $strTags = '';
  if ( !empty($tag) )
  {
    if ( substr($tag,-1,1)==';' ) $tag = substr($tag,0,-1); 
    $arrTags = explode(';',$tag);
    $str = '';
    foreach($arrTags as $strTag)
    {
    if ( !empty($str) ) $str .= ' OR ';
    $str .= 'UPPER(tags) LIKE "%'.strtoupper($strTag).'%"';
    }
    if ( !empty($str) ) $strTags = ' ('.$str.') AND';
  }
if ( isset($_GET['tt']) ) $tt = strip_tags($_GET['tt']);
if ( isset($_GET['ch']) )
{
  $str = strip_tags($_GET['ch']);
  if ( str_len($str)>0 ) $ch['time'] = substr($str,0,1); // blocktime
  if ( str_len($str)>1 ) $ch['type'] = substr($str,1,1); // graph type
  if ( str_len($str)>2 ) $ch['value'] = substr($str,2,1); // value type
  if ( str_len($str)>3 ) $ch['trend'] = substr($str,3,1); // trends value type
}

// ------
// OUTPUT
// ------

$arrYears = array($y);

include('qti_stats_inc.php');

if ( $ch['time']=='q' ) { $intWidth=16; } else { $intWidth=11; }

$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetTitle( PdfClean($L['Statistics']) );
$pdf->SetAuthor( PdfClean($_SESSION[QT]['site_name']) );
$pdf->SetSubject( PdfClean(PdfClean($L['H_Global']) );

$pdf->SetFont('Arial','B',14);
$pdf->SetTextColor(150);
$pdf->Ln();
$pdf->Cell(0, 10, PdfClean($L['H_Global']), 'T', 1, 'R');
$pdf->SetTextColor(0);

if ( $ch['time']=='q' ) { $intWidth=16; } else { $intWidth=11; }

// Title

$pdf->SetFont('Arial','B',10);
$arr = QTarrget(GetSections($oVIP->role));
$pdf->Cell(0, 8, PdfClean($y.($s>=0 ? ' ('.$arr[$s].')' : '').(empty($tag) ? '' : ', '.$L['With_tag'].' '.str_replace(';',' '.$L['or'].' ',$tag))), '', 1);

// Table

$arrTable = array();

// Table header

  $arrRow = array();
  $oCell = new cPdfCell(' ',28,5,'',true); $arrRow[]=$oCell;
  $oCell = new cPdfCell(' ',4, 5,'',true); $arrRow[]=$oCell;
  switch($ch['time'])
  {
  case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( 'Q'.$i,                                                    $intWidth,5,'C',true); $arrRow[]=$oCell; } break;
  case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( $L['dateMM'][$i],                                          $intWidth,5,'C',true); $arrRow[]=$oCell; } break;
  case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( QTdatestr(DateAdd($strTendaysago,$i,'day'),'d/n','',false),$intWidth,5,'C',true); $arrRow[]=$oCell; } break;
  }
  $oCell = new cPdfCell(($ch['time']=='d' ? '10 '.strtolower($L['Days']) : PdfClean($L['Year'])),$intWidth+3,5,'C',true); $arrRow[]=$oCell;
  $arrTable[] = $arrRow;

// Table body topics

  $arrRow = array();
  $oCell = new cPdfCell($L['Topics'],28,5,'',true); $arrRow[]=$oCell;
  $oCell = new cPdfCell(' ',         4, 5,'',true,array(0,0,102)); $arrRow[]=$oCell;
  for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
  {
  $oCell = new cPdfCell((isset($arrT[$y][$intBt]) ? $arrT[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
  }
  $oCell = new cPdfCell($arrTs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
  $arrTable[] = $arrRow;

// Table body messages

  $arrRow = array();
  $oCell = new cPdfCell($L['Replys'],28,5,'',true); $arrRow[]=$oCell;
  $oCell = new cPdfCell(' ',4, 5,'',true,array(153,0,153)); $arrRow[]=$oCell;
  for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
  {
  $oCell = new cPdfCell((isset($arrM[$y][$intBt]) ? $arrM[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
  }
  $oCell = new cPdfCell($arrMs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
  $arrTable[] = $arrRow;

// Table body users

  $arrRow = array();
  $oCell = new cPdfCell($L['Users'].'*',28,5,'',true); $arrRow[]=$oCell;
  $oCell = new cPdfCell(' ',4, 5,'',true,array(0,153,153)); $arrRow[]=$oCell;
  for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
  {
  $oCell = new cPdfCell((isset($arrU[$y][$intBt]) ? $arrU[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
  }
  $oCell = new cPdfCell($arrUs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
  $arrTable[] = $arrRow;

// Show table
 
$pdf->BasicTable($arrTable);
$pdf->Ln();

// GRAPH

if ( file_exists('bin/qt_lib_graph.php') && file_exists($_SESSION[QT]['skin_dir'].'/qti_main2.css') )
{

  $y = $pdf->GetY();
  $x = $pdf->GetX();

  // Topics
  
  $intTopValue = QTroof($arrT[$y]);
  if ( $ch['value']=='a' ) 
  {
  $pdf = QTbarchartpdf($pdf,$arrT[$y],92,30,$intTopValue,2,true,$L['Topics_per_'.$ch['time']],'','1');
  }
  else
  {
  $pdf = QTbarchartpdf($pdf,$arrT[$y],92,30,$intTopValue,2,'P',$L['Topics_per_'.$ch['time']].' (%)','','1');
  }

  $pdf->SetXY($x+94,$y);

  $intTopValue = QTroof(QTcumul($arrT[$y]));
  if ( $ch['value']=='a' ) 
  {
  $pdf = QTbarchartpdf($pdf,QTcumul($arrT[$y]),92,30,$intTopValue,2,true,$L['Topics_per_'.$ch['time'].'_cumul'],'','1');
  }
  else
  {
  $pdf = QTbarchartpdf($pdf,QTcumul($arrT[$y]),92,30,$intTopValue,2,'P',$L['Topics_per_'.$ch['time'].'_cumul'].' (%)','','1');
  }

  $pdf->SetXY($x,$y+50);

  // Replies & Users
    
  $intTopValue = QTroof($arrM[$y]);
  if ( $ch['value']=='a' ) 
  {
  $pdf = QTbarchartpdf($pdf,$arrM[$y],92,30,$intTopValue,2,true,$L['Replies_per_'.$ch['time']],'','2');
  }
  else
  {
  $pdf = QTbarchartpdf($pdf,$arrM[$y],92,30,$intTopValue,2,'P',$L['Replies_per_'.$ch['time']].' (%)','','2');
  }

  $pdf->SetXY($x+94,$y+50);

  $intTopValue = QTroof($arrU[$y]);
  if ( $ch['value']=='a' ) 
  {
  $pdf = QTbarchartpdf($pdf,$arrU[$y],92,30,$intTopValue,2,true,$L['Users_per_'.$ch['time']],'','3');
  }
  else
  {
  $pdf = QTbarchartpdf($pdf,$arrU[$y],92,30,$intTopValue,2,'P',$L['Users_per_'.$ch['time']].' (%)','','3');
  }

}
else
{
  $pdf->SetFont('Arial','',8);
  $pdf->Cell(0, 10, PdfClean('Graphs cannot be displayed because one of these files is missing: bin/qt_lib_graph.php, '.$_SESSION[QT]['skin_dir'].'/qti_main2.css'), 'T', 1);
}

// Note

$pdf->SetFont('Arial','',8);
$pdf->Cell(0, 8, '* '.PdfClean($L['Distinct_users']), '', 1);

// --------
// PDF END
// --------

$pdf->Output();

?>
Return current item: QuickTicket