[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/includes/fpdf/ -> fpdf_indexes.php (source)

   1  <?php
   2  /* Modifié par Rodolphe Quiédeville
   3   * Auteur : Pierre-André Vullioud
   4   * Licence : Freeware
   5   * Source : http://www.fpdf.org
   6   *
   7   * $Id: fpdf_indexes.php,v 1.4 2004/02/29 14:32:39 rodolphe Exp $
   8   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/fpdf/fpdf_indexes.php,v $
   9   */
  10  
  11  class PDF_Indexes extends FPDF
  12  {
  13    var $Reference=array();  //Array containing the references
  14    var $col=0;              //Current column number
  15    var $NbCol;              //Total number of columns
  16    var $y0;                 //Top ordinate of columns
  17    var $IndexesName=array();  
  18    
  19    function Reference($txt, $index)
  20    {
  21      $Present=0;
  22      $size=sizeof($this->Reference[$index]);
  23      
  24      //Search the reference in the array
  25      for ($i=0;$i<$size;$i++)
  26        {
  27      if ($this->Reference[$index][$i]['t']==$txt)
  28        {
  29          $Present=1;
  30          $this->Reference[$index][$i]['p'].=','.$this->PageNo();
  31        }
  32        }
  33  
  34      //If not found, add it
  35      if ($Present==0)
  36        {
  37      $this->Reference[$index][]=array('t'=>$txt,'p'=>$this->PageNo());
  38        }
  39    }
  40  
  41    function ReferenceNewPage($link='')
  42    {
  43      $this->AddPage();
  44      if ($link)
  45        {
  46      $this->SetLink($link);
  47        }
  48      $this->SetFont('Arial','',15);
  49      $this->SetXY(10,10);
  50      $this->MultiCell(190,12, $this->IndexesName[$this->IndexName], 1 ,'C', 0);
  51      $this->y0 = $this->GetY() + 2;
  52      $this->SetY($this->y0);
  53      $this->SetFontSize(8);
  54    }
  55    
  56    function ReferencePrintSection()
  57    {
  58      $this->SetY($this->GetY() + 2);
  59  
  60      if ($this->GetY() > $this->YMax)
  61        {
  62      $this->ReferenceNewPage();
  63        }
  64      if ( $this->ReferenceNextSection == $this->ReferenceCurrentSection)
  65        {
  66      $this->SetFontSize(9);
  67      $this->MultiCell(90, 4, $this->ReferenceCurrentSection ,0,1,'L');
  68      $this->SetFontSize(8);
  69        }
  70    }
  71  
  72    function CreateReference($NbCol, $index, $link='')
  73    {
  74      $this->YMax = 270;
  75      $this->NbCol = $NbCol;
  76      $this->SetCol(0);
  77      $this->IndexName = $index;
  78      $page = 1;
  79      // New Page
  80      $page = $this->ReferenceNewPage($link);
  81  
  82      //Initialization
  83      $this->SetFontSize(8);
  84      
  85      $size = sizeof($this->Reference[$index]);
  86      $PageWidth = $this->w - $this->lMargin - $this->rMargin;
  87      $last = '';
  88      for ($i=0 ; $i < $size ; $i++)
  89        {    
  90      $this->ReferenceNextSection = $this->Reference[$index][$i]['t'][0];
  91  
  92      if ($this->GetY() > $this->YMax)
  93        {
  94          $this->ReferenceNextCol();
  95        }
  96      //
  97      // Section Break
  98      //  
  99      if ($last <> $this->Reference[$index][$i]['t'][0])
 100        {
 101          $last = $this->Reference[$index][$i]['t'][0];
 102          $this->ReferenceCurrentSection = $last;
 103          $this->ReferencePrintSection();
 104        }
 105      
 106      //LibelleLabel
 107      if (is_array($this->Reference[$index][$i]['t']))
 108        {
 109          $str= "  ".$this->Reference[$index][$i]['t'][1];
 110        }
 111      else
 112        {
 113          $str= $this->Reference[$index][$i]['t'];
 114        }
 115      
 116      $strsize=$this->GetStringWidth($str);
 117  
 118      $this->Cell($strsize+2,$this->FontSize+2,$str,0,0,'R');
 119      
 120      //Dots
 121      //Computes the widths
 122      $ColWidth = ($PageWidth/$NbCol)-2;
 123      $w=$ColWidth-$this->GetStringWidth($this->Reference[$index][$i]['p'])-($strsize+4);
 124      if ($w<15)
 125        $w=15;
 126      $nb=$w/$this->GetStringWidth('.');
 127      $dots=str_repeat('.',$nb-2);
 128      $this->Cell($w,$this->FontSize+2,$dots,0,0,'L');
 129      
 130      //Page number
 131      $Largeur=$ColWidth-$strsize-$w;
 132      $this->MultiCell($Largeur,$this->FontSize+1,$this->Reference[$index][$i]['p'],0,1,'R');
 133        }
 134    }
 135    
 136    function SetCol($col)
 137    {
 138      //Set position on a column
 139      $this->col=$col;
 140      $x=$this->rMargin+$col*($this->w-$this->rMargin-$this->rMargin)/$this->NbCol;
 141      $this->SetLeftMargin($x);
 142      $this->SetX($x);
 143    }
 144    
 145    function ReferenceNextCol()
 146    {
 147      if($this->col < $this->NbCol-1)
 148        {
 149      //Go to the next column
 150      $this->SetCol($this->col+1);
 151      $this->SetY($this->y0);
 152      $this->ReferencePrintSection();
 153      //Stay on the page
 154      return false;
 155        }
 156      else
 157        {
 158      //Go back to the first column
 159      $this->SetCol(0);
 160      $this->ReferenceNewPage();
 161      $this->ReferencePrintSection();
 162      //Page break
 163      return true;
 164        }
 165    }
 166    /*
 167     *
 168     *
 169     */
 170    function SortReference($index)
 171    {
 172      $ar = $this->Reference[$index];
 173  
 174      $size=sizeof($this->Reference[$index]);
 175      $cats = array();
 176      $last = '';
 177      for ($i=0;$i<$size;$i++)
 178        {
 179      //print $ar[$i]['t'][0] . "<br>";
 180      $cat = $ar[$i]['t'][0];
 181      if (! array_key_exists($cat, $cats))
 182        {
 183          $cats[$cat] = array();
 184        }
 185      array_push($cats[$cat], array($ar[$i]['t'][1], $ar[$i]['p']));
 186        }
 187      
 188      ksort($cats);
 189      //var_dump($cats);
 190      $i = 0;
 191      foreach ($cats as $key => $value)
 192        {
 193      foreach ($value as $skey => $svalue)
 194        {        
 195          $this->Reference[$index][$i]['t'][0] = $key;
 196          $this->Reference[$index][$i]['t'][1] = $svalue[0];
 197          $this->Reference[$index][$i]['p'] = $svalue[1];
 198          $i++;
 199        }
 200                       
 201        }
 202  
 203    }
 204  
 205  }
 206  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics