Location: PHPKode > projects > QuickTicket > quickticket/qti_stats_d_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 = 'd'; // 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');

$arrTable = array();

// PDF START

$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_Details']) );

$pdf->SetFont('Arial','B',14);
$pdf->SetTextColor(150);
$pdf->Ln();
$pdf->Cell(0, 10, PdfClean($L['H_Details']), '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 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 new topic

  $arrRow = array();
  $oCell = new cPdfCell($L['New_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($arrN[$y][$intBt]) ? $arrN[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
  }
  $oCell = new cPdfCell($arrNs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
  $arrTable[] = $arrRow;

// Table body closed topic

  $arrRow = array();
  $oCell = new cPdfCell($L['Closed_topics'],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($arrC[$y][$intBt]) ? $arrC[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
  }
  $oCell = new cPdfCell($arrCs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
  $arrTable[] = $arrRow;

// Table body backlog

  $arrRow = array();
  $oCell = new cPdfCell($L['Backlog'],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($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;

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

// 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('bin/qt_lib_graph.php') && file_exists($_SESSION[QT]['skin_dir'].'/qti_main2.css') )
{

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

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

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

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

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

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

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

  $intTopValue = QTroof(QTcumul($arrT[$y]));
  if ( $ch['value']=='a' ) 
  {
  $pdf = QTbarchartpdf($pdf,QTcumul($arrT[$y]),92,30,$intTopValue,2,true,$L['Backlog_cumul'],'','3');
  }
  else
  {
  $pdf = QTbarchartpdf($pdf,QTcumul($arrT[$y]),92,30,$intTopValue,2,'P',$L['Backlog_cumul'].' (%)','','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);
}

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

$pdf->Output();

?>
Return current item: QuickTicket