109 global $conf, $hookmanager, $langs, $user;
111 if (!is_object($outputlangs)) {
112 $outputlangs = $langs;
116 $outputlangs->charset_output =
'ISO-8859-1';
120 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"projects"));
122 if ($conf->bank->dir_output) {
126 if ($object->specimen) {
127 $dir = $conf->bank->dir_output;
128 $file = $dir.
"/SPECIMEN.pdf";
131 $dir = $conf->bank->dir_output.
"/".$objectref;
132 $file = $dir.
"/".$objectref.
".pdf";
135 if (!file_exists($dir)) {
137 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
142 if (file_exists($dir)) {
144 if (!is_object($hookmanager)) {
145 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
148 $hookmanager->initHooks(array(
'pdfgeneration'));
149 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
151 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
155 $heightforinfotot = 50;
156 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
157 $heightforfooter = $this->marge_basse + 8;
159 $heightforfooter += 6;
161 $pdf->SetAutoPageBreak(1, 0);
163 if (class_exists(
'TCPDF')) {
164 $pdf->setPrintHeader(
false);
165 $pdf->setPrintFooter(
false);
171 $pdf->SetDrawColor(128, 128, 128);
173 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
174 $pdf->SetSubject($outputlangs->transnoentities(
"BAN"));
175 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
176 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
177 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"BAN"));
179 $pdf->SetCompression(
false);
182 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
187 $this->
_pagehead($pdf, $object, 1, $outputlangs);
188 $pdf->SetFont(
'',
'', $default_font_size - 1);
189 $pdf->MultiCell(0, 3,
'');
190 $pdf->SetTextColor(0, 0, 0);
193 $tab_top_newpage = 40;
195 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
198 if (!empty($object->note_public)) {
199 $pdf->SetFont(
'',
'', $default_font_size - 1);
200 $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2,
dol_htmlentitiesbr($object->note_public), 0, 1);
201 $nexY = $pdf->GetY();
202 $height_note = $nexY - ($tab_top - 2);
205 $pdf->SetDrawColor(192, 192, 192);
206 $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
208 $tab_height = $tab_height - $height_note;
209 $tab_top = $nexY + 6;
214 $iniY = $tab_top + 7;
215 $curY = $tab_top + 7;
216 $nexY = $tab_top + 7;
218 $pdf->SetXY($this->marge_gauche, $curY);
219 $pdf->MultiCell(200, 3, $outputlangs->trans(
"BAN").
' : '.$object->account_number, 0,
'L');
225 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
226 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
228 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
229 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
235 $this->
_pagefoot($pdf, $object, $outputlangs);
236 if (method_exists($pdf,
'AliasNbPages')) {
237 $pdf->AliasNbPages();
242 $pdf->Output($file,
'F');
245 if (!is_object($hookmanager)) {
246 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
249 $hookmanager->initHooks(array(
'pdfgeneration'));
250 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
252 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
254 $this->error = $hookmanager->error;
255 $this->errors = $hookmanager->errors;
260 $this->result = array(
'fullpath'=>$file);
264 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
269 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
305 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
307 global $langs, $conf, $mysoc;
314 $pdf->SetTextColor(0, 0, 60);
315 $pdf->SetFont(
'',
'B', $default_font_size + 3);
317 $posx = $this->page_largeur - $this->marge_droite - 100;
318 $posy = $this->marge_haute;
320 $pdf->SetXY($this->marge_gauche, $posy);
323 $logo = $conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
325 if (is_readable($logo)) {
327 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
329 $pdf->SetTextColor(200, 0, 0);
330 $pdf->SetFont(
'',
'B', $default_font_size - 2);
331 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
332 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
335 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
338 $pdf->SetFont(
'',
'B', $default_font_size + 3);
339 $pdf->SetXY($posx, $posy);
340 $pdf->SetTextColor(0, 0, 60);
341 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"BAN").
" ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
342 $pdf->SetFont(
'',
'', $default_font_size + 2);
345 $pdf->SetXY($posx, $posy);
346 $pdf->SetTextColor(0, 0, 60);
347 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
dol_now(),
'day',
false, $outputlangs,
true),
'',
'R');
353 $pdf->SetTextColor(0, 0, 60);