class.pdf.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. require("fpdf.php");
  3. class GCPDF extends FPDF
  4. {
  5. var $feld = array("","","","");
  6. var $pdf_version = "1.0";
  7. var $produkt = "Undefiniert";
  8. function setFeld ($feld) {
  9. $this->feld = $feld;
  10. }
  11. function Header()
  12. {
  13. //assign Props:
  14. $this -> produkt = $_POST['pdf_titel'];
  15. //LucidaSansUnicode 20
  16. $this->SetFont('LucidaSansUnicode','', 20);
  17. //Font Color
  18. $this->SetTextColor(17, 17,175);
  19. //Fill Color
  20. $this->SetFillColor(147, 147, 147);
  21. //Title
  22. $this->Cell(160,7,$this->produkt,0,0,'L');
  23. //LucidaSansUnicode 10
  24. $this->SetFont('LucidaSansUnicode','',10);
  25. //Font Color
  26. $this->SetTextColor(147, 147, 147);
  27. //Niederlassung
  28. $this->Cell(60,7,$this->feld[0],0,0,'L');
  29. //Planner Version
  30. $this->Cell(60,7,$this->feld[1],0,1,'L');
  31. //Font Color
  32. $this->SetTextColor(255, 255, 255);
  33. //Version
  34. //$this->Cell(286,4,'PDF Generator Version: '.$this->pdf_version,0,1,'L',1);
  35. //Font Color
  36. $this->SetTextColor(255, 255, 255);
  37. //nach rechts
  38. $this->Cell(160,4,'',0,0,'L',1);
  39. //Bereich
  40. $this->Cell(60,4,$this->feld[2],0,0,'L',1);
  41. //Kategorie
  42. $this->Cell(60,4,$this->feld[3],0,0,'L',1);
  43. //Line break
  44. $this->Ln(15);
  45. }
  46. function Footer()
  47. {
  48. //&Uuml;bermalen
  49. $this->SetTextColor(255, 255, 255);
  50. $this->SetX(0);
  51. $this->SetX(160);
  52. $this->Cell();
  53. $datenquelle = 'Datei';
  54. //Position at 1.5 cm from bottom
  55. $this->SetY(-15);
  56. //Arial italic 8
  57. $this->SetFont('Arial','I',8);
  58. //Font Color
  59. $this->SetTextColor(147, 147, 147);
  60. //Date
  61. $timestamp = time();
  62. $date = date("d.m.Y", $timestamp);
  63. $time = date("H:i:s", $timestamp);
  64. //Date
  65. $this->Cell(1,5,'Erstellungsdatum: '.$date . ' - ' . $time,0,0,'L');
  66. //Page number
  67. $this->Cell(0,5,'- Seite '.$this->PageNo().'/{nb} -',0,1,'C');
  68. //Arial italic 8
  69. $this->SetFont('Arial','',6);
  70. //Copyright information
  71. $this->Cell(0,4,'PDF Generator Version: ' . $this -> pdf_version . ' Copyright 2005 Global-Cube Business Solutions',0,0,'C');
  72. }
  73. function insertData ($daten)
  74. {
  75. foreach ($daten as $key_tabelle => $tabelle)
  76. {
  77. if (!isset($daten[$key_tabelle][0][0])) die ("\$daten[" . $key_tabelle . "][0][0] ist undefiniert!");
  78. foreach ($tabelle as $key_zeile => $zeile)
  79. {
  80. foreach ($zeile as $key_zelle => $zelle)
  81. {
  82. //echo "Tabelle: ".$key_tabelle." - Zeile: ".$key_zeile." - Zelle: ".$key_zelle." - Zelleninhalt: ".@$zelle['TEXT']." - Zellenbreite: ".@$zelle['WIDTH']." Background: ".@$zelle['BG_COLOR'][0].", ".@$zelle['BG_COLOR'][1].", ".@$zelle['BG_COLOR'][2]."<br>";
  83. if (!isset($daten[$key_tabelle][0][$key_zelle])) $daten[$key_tabelle][0][$key_zelle] = array();
  84. if (!isset($daten[$key_tabelle][$key_zeile][0])) $daten[$key_tabelle][$key_zeile][0] = array();
  85. if (!isset($daten[$key_tabelle][$key_zeile][$key_zelle])) $daten[$key_tabelle][$key_zeile][$key_zelle] = array();
  86. if (($key_zeile == 0) && ($key_zelle > 0))
  87. {
  88. $ausgabe[$key_tabelle][$key_zeile][($key_zelle - 1)] = array_merge($daten[$key_tabelle][0][0], $daten[$key_tabelle][0][$key_zelle]);
  89. }
  90. if (($key_zeile > 0) && ($key_zelle > 0))
  91. {
  92. $ausgabe[$key_tabelle][$key_zeile][($key_zelle - 1)] = array_merge($daten[$key_tabelle][0][0], $daten[$key_tabelle][0][$key_zelle], $daten[$key_tabelle][$key_zeile][0], $daten[$key_tabelle][$key_zeile][$key_zelle]);
  93. }
  94. }
  95. }
  96. }
  97. foreach ($ausgabe as $key_tabelle => $tabelle)
  98. {
  99. $cols = count($tabelle[0]);
  100. $rows = count ($tabelle) - 1;
  101. //initialize the table with 3 columns
  102. $this->Table_Init($cols);
  103. //set header style
  104. foreach ($tabelle[1] as $key_titel => $titel)
  105. {
  106. $header_type[$key_titel] = $titel;
  107. }
  108. $this->Set_Header_Type($header_type);
  109. //set data style
  110. foreach ($tabelle[0] as $key_spalten_format => $spalten_format)
  111. {
  112. $data_type[$key_spalten_format] = $tabelle[0][$key_spalten_format];
  113. }
  114. $this->Set_Data_Type($data_type);
  115. //draw the first header
  116. $this->Draw_Header();
  117. for($i=1; $i < $rows; $i++)
  118. {
  119. for($k=0; $k < $cols; $k++)
  120. {
  121. $data[$k] = $ausgabe[$key_tabelle][$i+1][$k];
  122. }
  123. $this->Draw_Data($data);
  124. }
  125. }
  126. $this->Set_Header_Type($header_type);
  127. $this->Draw_Table_Border();
  128. }
  129. }
  130. ?>