Source for file class.PDFADMIN.php

Documentation is available at class.PDFADMIN.php

  1. <?php
  2.  
  3. /**
  4.  * Verwaltet die Erstellung eines wöchentlichen PDF-Dokumentes
  5.  *
  6.  * @author Kay Koch, <kay.koch@gmx.de>
  7.  * @package src
  8.  * @subpackage pdf
  9.  */
  10.  
  11. if (version_compare(PHP_VERSION'5')) {
  12.    die('This file was generated for PHP 5');
  13. }
  14.  
  15. /**
  16.  * Interface zur Erstellung von pdf-Dokumenten
  17.  *
  18.  * @author Kay Koch, <kay.koch@gmx.de>
  19.  */
  20. require_once ('src/interfaces/interface.PDFINTERFACE.php');
  21.  
  22. /**
  23.  * Erstellt PDF-Dokumente
  24.  *
  25.  * @author Olivier PLATHEY
  26.  * @version 1.52
  27.  */
  28. require_once ('src/pdf/class.FPDF.php');
  29.  
  30. /* user defined includes */
  31. // section -64--88-122--2-1a4ded3:102c56edcaa:-7ff4-includes begin
  32. // section -64--88-122--2-1a4ded3:102c56edcaa:-7ff4-includes end
  33.  
  34. /* user defined constants */
  35. // section -64--88-122--2-1a4ded3:102c56edcaa:-7ff4-constants begin
  36. // section -64--88-122--2-1a4ded3:102c56edcaa:-7ff4-constants end
  37.  
  38. /**
  39.  * Verwaltet die Erstellung eines wöchentlichen PDF-Dokumentes
  40.  *
  41.  * @access public
  42.  * @author Kay Koch, <kay.koch@gmx.de>
  43.  * @package src
  44.  * @subpackage pdf
  45.  */
  46.  
  47.    // --- ATTRIBUTES ---
  48.  
  49.    
  50.    /**
  51.     * Array mit Breiten der einzelnen Felder eines Eintrags
  52.     *
  53.     * @access private
  54.     * @var array 
  55.     */
  56.    private $widthArray array (
  57.       29,
  58.       13,
  59.       13
  60.    );
  61.  
  62.    /**
  63.     * Buchstabengröße im PDF
  64.     *
  65.     * @access private
  66.     * @var int 
  67.     */
  68.    private $fontHeight 9;
  69.  
  70.    // --- OPERATIONS ---
  71.  
  72.    
  73.    /**
  74.     * Kopfzeile des Dokumentes
  75.     *
  76.     * @access public
  77.     * @author Kay Koch, <kay.koch@gmx.de>
  78.     * @return void 
  79.     */
  80.    public function header({
  81.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fd5 begin
  82.       // Title
  83.       $this->SetFont('Arial''B'11);
  84.       $this->Cell(010$this->pageTitle00'R');
  85.       $this->Ln(5);
  86.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fd5 end
  87.    }
  88.  
  89.    /**
  90.     * Fußzeile des Dokumentes
  91.     *
  92.     * @access public
  93.     * @author Kay Koch, <kay.koch@gmx.de>
  94.     * @return void 
  95.     */
  96.    public function footer({
  97.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fd3 begin
  98.       $this->SetY(-15);
  99.       $this->SetFont('Arial''B'7);
  100.       $this->Cell(22$this->lineHeight"Name, Vorname"10);
  101.       $this->Cell(24$this->lineHeight"Vereinsnummer"10);
  102.       $this->Cell(61$this->lineHeight"Gesamtanzahl / Gesamtpreis (" $this->prizePerPerson chr(128" pro Person)"10);
  103.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fd3 end
  104.    }
  105.  
  106.    /**
  107.     * nimmt Daten für einen Tag auf und bearbeitet sie weiter
  108.     *
  109.     * @access public
  110.     * @author Kay Koch, <kay.koch@gmx.de>
  111.     * @param array 
  112.     * @param date 
  113.     * @return void 
  114.     */
  115.    public function createDate($arrHour$datum{
  116.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fd1 begin
  117.       $this->datum $datum;
  118.       $aktWeekDay (in_array($this->datum$this->arrFeiertage)) src_tools_TIME :: sqlT2realT($this->datum"%w");
  119.       $this->rowMaxFrei $this->tableMaxFrei[$this->oSee->see_id][$aktWeekDay];
  120.       $this->beginNewPage("");
  121.       if ($this->oSee->buchbarProTag OR isset ($this->arrBuchungen[$arrHour['see_id']][$datum]['00:00']))
  122.          $arrHour['00:00'$arrHour['sumTag'];
  123.       unset ($arrHour['see_id']);
  124.       unset ($arrHour['datum']);
  125.       unset ($arrHour['sumTag']);
  126.       foreach ($arrHour as $key => $hour)
  127.          $this->createHour($hour$key);
  128.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fd1 end
  129.    }
  130.  
  131.    /**
  132.     * Beginnt eine neues Dokument
  133.     *
  134.     * @access public
  135.     * @author Kay Koch, <kay.koch@gmx.de>
  136.     * @param EINSEE 
  137.     * @return void 
  138.     */
  139.    public function beginNewDocument($oSee{
  140.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fcc begin
  141.       // Seitenüberschrift erstellen
  142.       $this->oSee $oSee;
  143.       $this->pageTitle utf8_decode($oSee->name " --> " $oSee->oVorOrtKontakt->vorname " " $oSee->oVorOrtKontakt->name " | Tel: " $oSee->oVorOrtKontakt->telefon " | Email: " $oSee->oVorOrtKontakt->email);
  144.       $this->open()// Dokument beginnen
  145.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fcc end
  146.    }
  147.  
  148.    /**
  149.     * Beginnt eine neue Seite
  150.     *
  151.     * @access public
  152.     * @author Kay Koch, <kay.koch@gmx.de>
  153.     * @param time 
  154.     * @return void 
  155.     */
  156.    public function beginNewPage($title{
  157.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fc5 begin
  158.       $this->AddPage("L")// Seite beginnen (Landscape)
  159.       // überschrift
  160.       $this->SetFont('Arial''B'10);
  161.       $this->SetXY(1515);
  162.       $this->Cell(02src_tools_TIME :: sqlT2realT($this->datum"%A - %d. %B %Y"$title02);
  163.       // Schriftart für Tabellen
  164.       $this->SetFont('Arial''B'$this->fontHeight);
  165.       // section -64--88-122--2-339007d5:1043cd4e8c9:-7fc5 end
  166.    }
  167.  
  168.    /**
  169.     * Konstruktor
  170.     *
  171.     * setzt Preis fest
  172.     * setzt Breite pro Eintrag fest
  173.     * setzt Zeilenhöhe fest
  174.     *
  175.     * @access public
  176.     * @author Kay Koch, <kay.koch@gmx.de>
  177.     * @param array 
  178.     * @param float 
  179.     * @return void 
  180.     */
  181.    public function __construct($arrBuchungen$prizePerPerson{
  182.       // section -64--88-122--2-1a4ded3:102c56edcaa:-7fed begin
  183.       parent :: __construct();
  184.       $this->prizePerPerson $prizePerPerson;
  185.       $this->arrBuchungen $arrBuchungen;
  186.       $this->entryWitdh array_sum($this->widthArray1// max. Größe eines Eintrags errechnen, + 1px Abstand
  187.       $this->lineHeight $this->fontHeight 2// Zeilenhöhe (in mm)
  188.       $oMaxFrei new src_foundation_tables_MAXFREI();
  189.       $this->tableMaxFrei $oMaxFrei->getRow();
  190.       $this->arrFeiertage src_tools_TIME :: getFeiertage();
  191.       // section -64--88-122--2-1a4ded3:102c56edcaa:-7fed end
  192.    }
  193.  
  194.    /**
  195.     * Bearbeitet eine Stunde eines Eintrags
  196.     *
  197.     * Fügt an die leeren Einträge die Buchungen an
  198.     * überprüft einen möglichen Seitenumbruch
  199.     *
  200.     * @access private
  201.     * @author Kay Koch, <kay.koch@gmx.de>
  202.     * @param int 
  203.     * @param array 
  204.     * @return void 
  205.     */
  206.    private function createHour($places$keyHour{
  207.  
  208.       // section -64--88-122--2-66879486:104007981a3:-7fb0 begin
  209.       if (isset ($this->arrBuchungen[$this->oSee->see_id][$this->datum][$keyHour]))
  210.          $arrBuchungen $this->arrBuchungen[$this->oSee->see_id][$this->datum][$keyHour];
  211.       else
  212.          $arrBuchungen array ();
  213.       $nrOfEntries count($arrBuchungen$places;
  214.       if ($nrOfEntries == 0)
  215.          return;
  216.       $nrOfLines $nrOfEntries 1// Zeilenanzahl des Arrays + 1 für Stundentitel
  217.       $h $nrOfLines $this->lineHeight// benötigter Platz für diese Stunde
  218.       if ($this->GetY($h $this->PageBreakTrigger// wenn Platz nicht ausreicht
  219.          $this->beginNewPage("-Fortsetzung");
  220.       $this->Ln();
  221.       if ($keyHour == "00:00"// Ganztägige Anmeldung (z.B.: 09:00h - 20:00h)
  222.          $keyHour $this->oSee->getStartTime($this->datum"h - " $this->oSee->getEndTime($this->datum"h (" $places " von " $this->rowMaxFrei['sumTag'" Plätzen frei)";
  223.       else // z.B. 20:00h
  224.          $keyHour $keyHour "h (" $places " von " $this->rowMaxFrei[$keyHour" Plätzen frei)";
  225.       $this->Cell(02" "01);
  226.       $this->Cell(0$this->lineHeightutf8_decode($keyHour)00);
  227.       $this->YPos $this->GetY()// Y-Position der aktuellen Zeile
  228.       $arrEntry array_pad($arrBuchungen$nrOfEntriesarray (
  229.          "name" => "",
  230.          "verein" => "",
  231.          "anzahl" => "",
  232.          "anzahlZahler" => ""
  233.       ));
  234.       array_walk($arrEntryarray (
  235.          $this,
  236.          'createPlaces'
  237.       ));
  238.       // section -64--88-122--2-66879486:104007981a3:-7fb0 end
  239.    }
  240.  
  241.    /**
  242.     * Schreibt einen Eintrag in das PDF
  243.     *
  244.     * @access private
  245.     * @author Kay Koch, <kay.koch@gmx.de>
  246.     * @param array 
  247.     * @param int 
  248.     * @return void 
  249.     */
  250.    private function createPlaces($arrEntries$counter{
  251.       // section -64--88-122--2-66879486:104007981a3:-7fa8 begin
  252.       if (($counter 5== 0{
  253.          $this->Ln($this->lineHeight)// nach 5 Einträge erfolgt Zeilenumbruch
  254.          $this->YPos $this->GetY()// Y-Position der neuen Zeile
  255.          $this->XPos 10;
  256.       }
  257.       if (!empty ($arrEntries['anzahl'])) {
  258.          $arrEntries['anzahl'utf8_decode($arrEntries['anzahl'"/" ($arrEntries['anzahlZahler'$this->prizePerPersonchr(128));
  259.       // Bei Eintrag, Preis ausrechnen
  260.  
  261.       $this->SetXY($this->XPos$this->YPos);
  262.       $this->Cell($this->widthArray[0]$this->lineHeight$arrEntries['name']10);
  263.       $this->Cell($this->widthArray[1]$this->lineHeight$arrEntries['verein']10);
  264.       $this->Cell($this->widthArray[2]$this->lineHeight$arrEntries['anzahl']10);
  265.       $this->XPos $this->GetX(1;
  266.       // section -64--88-122--2-66879486:104007981a3:-7fa8 end
  267.    }
  268.  
  269. /* end of class src_pdf_PDFADMIN */
  270. ?>

Documentation generated on Sat, 24 Mar 2007 09:59:49 +0100 by phpDocumentor 1.3.1