1 |
<?php |
2 |
/** |
3 |
* Classe de base permettant l'édition d'un document pdf à imprimer sur |
4 |
* les feuillets d'accusé de récéption de la poste |
5 |
* |
6 |
* @package openfoncier |
7 |
* @version SVN : $Id$ |
8 |
*/ |
9 |
|
10 |
require_once "../core/fpdf_etat.php"; |
11 |
|
12 |
/** |
13 |
* |
14 |
*/ |
15 |
class pdf_lettre_rar extends PDF{ |
16 |
|
17 |
private $pdf; |
18 |
private $utils; |
19 |
private $filename; |
20 |
private $adresse_dest; |
21 |
private $adresse_emetteur; |
22 |
private $specifique_content; |
23 |
private $font = 'Arial'; |
24 |
private $fontsize = 10; |
25 |
private $path; |
26 |
private $cell_width = 84; |
27 |
private $cell_height = 7; |
28 |
|
29 |
|
30 |
// Initialisation des attributs |
31 |
function init($f, $filename = "lettre_rar", |
32 |
$path = "../tmp/", $font = 'Arial', $fontsize = 10 ){ |
33 |
|
34 |
// Definition des attributs |
35 |
$this->filename = $filename.date("dmYHis"); |
36 |
$this->path = $path; |
37 |
$this->font = $font; |
38 |
$this->fontsize = $fontsize; |
39 |
$this->utils = $f; |
40 |
$this->adresse_emetteur = explode("\n",$this->utils->getParameter('adresse_direction_urbanisme')); |
41 |
|
42 |
//Creation du pdf |
43 |
//$this=new FPDF('P', 'mm', 'A4'); |
44 |
$this->SetFont($font, '', $fontsize); |
45 |
$this->SetMargins(0,0,0); |
46 |
$this->SetAutoPageBreak(false, 0); |
47 |
} |
48 |
|
49 |
// Ajout d'une page au document pdf |
50 |
function addLetter($adresse_dest, $specifique_content) { |
51 |
$this->adresse_dest = $adresse_dest; |
52 |
$this->specifique_content = $specifique_content; |
53 |
$this->addPage(); |
54 |
$this->printAvisPassage(); |
55 |
$this->printPreuveDistri(); |
56 |
$this->printAvisRecept(); |
57 |
} |
58 |
|
59 |
// Insertion des adresses dans la partie "Avis de passage" |
60 |
private function printAvisPassage() { |
61 |
if( DEBUG != 0) { |
62 |
$this->SetXY(0, 0); |
63 |
$this->SetDrawColor(255, 215, 0); |
64 |
$this->Cell(209.5, 98.5,"",1,2,true); |
65 |
} |
66 |
$this->printCellRAR(33, 40, $this->adresse_dest); |
67 |
$this->printCellRAR(117, 40, $this->adresse_dest); |
68 |
} |
69 |
|
70 |
// Insertion des adresses dans la partie "Preuve de distribution" |
71 |
private function printPreuveDistri() { |
72 |
if( DEBUG != 0) { |
73 |
$this->SetXY(0, 98.5); |
74 |
$this->SetDrawColor(131, 131, 131); |
75 |
$this->Cell(209.5, 101.5,"",1,2,true); |
76 |
} |
77 |
$this->printCellRAR(53.5, 141, $this->adresse_dest); |
78 |
$this->printCellRAR(53.5, 171, $this->adresse_emetteur, true); |
79 |
} |
80 |
|
81 |
// Insertion des adresses dans la partie "Avis de reception" |
82 |
private function printAvisRecept() { |
83 |
if( DEBUG != 0) { |
84 |
$this->SetXY(0, 200); |
85 |
$this->SetDrawColor(205, 51, 51); |
86 |
$this->Cell(209.5, 97,"",1,2,true); |
87 |
} |
88 |
$this->printCellRAR(53.5, 230, $this->specifique_content, true); |
89 |
$this->printCellRAR(53.5, 259, $this->adresse_emetteur, true); |
90 |
} |
91 |
|
92 |
// Insertion d'une adresse |
93 |
private function printCellRAR($left, $top, $content,$fullBold = false) { |
94 |
|
95 |
// 1ere ligne en gras |
96 |
$this->SetFont($this->font, 'B', $this->fontsize); |
97 |
$this->SetXY($left, $top); |
98 |
$border = 0; |
99 |
if( DEBUG != 0) { |
100 |
$this->SetDrawColor(0, 0, 0); |
101 |
$border = 1; |
102 |
} |
103 |
foreach ($content as $line) { |
104 |
|
105 |
//Gestion du code barres |
106 |
if ( preg_match('/^\|{5}[0-9]{12}\|{5}$/', $line)){ |
107 |
$this->Code128($this->GetX()+19, $this->GetY(), str_replace("|||||", "", $line), 50, 8); |
108 |
$this->Cell($this->cell_width, $this->cell_height*2,"",$border,2,false); |
109 |
} |
110 |
else{ |
111 |
$this->Cell($this->cell_width, $this->cell_height,utf8_decode(trim($line)),$border,2,false); |
112 |
} |
113 |
// test si tout le contenu de la cellule doit être en gras |
114 |
if(!$fullBold) { |
115 |
$this->SetFont($this->font, '', $this->fontsize); |
116 |
} |
117 |
} |
118 |
|
119 |
} |
120 |
|
121 |
// Récupération du fichier |
122 |
function getFile() { |
123 |
$this->Output($this->path.$this->filename.".pdf", 'F'); |
124 |
return $this->path.$this->filename.".pdf"; |
125 |
} |
126 |
|
127 |
// setters |
128 |
function setPath($path) { |
129 |
$this->path = $path; |
130 |
} |
131 |
function setFilename($filename) { |
132 |
$this->filename = $filename; |
133 |
} |
134 |
|
135 |
|
136 |
//Surchage afin que le nombre de page ne s'affiche pas |
137 |
function Footer() { |
138 |
} |
139 |
} |
140 |
?> |