dolibarr 19.0.3
pdf_sepamandate.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2020 Josep LluĂ­s Amador <joseplluis@lliuretic.cat>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
26require_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
27require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31
32
38{
43 public $version = 'dolibarr';
44
48 public $heightforinfotot;
49
53 public $heightforfreetext;
54
58 public $heightforfooter;
59
63 public $xPosSignArea;
69 public function __construct($db)
70 {
71 global $conf, $langs, $mysoc;
72
73 // Translations
74 $langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
75
76 $this->db = $db;
77 $this->name = "sepamandate";
78 $this->description = $langs->transnoentitiesnoconv("DocumentModelSepaMandate");
79
80 // Page size for A4 format
81 $this->type = 'pdf';
82 $formatarray = pdf_getFormat();
83 $this->page_largeur = $formatarray['width'];
84 $this->page_hauteur = $formatarray['height'];
85 $this->format = array($this->page_largeur, $this->page_hauteur);
86 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
87 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
88 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
89 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
90
91 $this->option_logo = 1; // Display logo FAC_PDF_LOGO
92 $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
93
94 // Retrieves transmitter
95 $this->emetteur = $mysoc;
96 if (!$this->emetteur->country_code) {
97 $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
98 }
99
100 // Define column position
101 $this->posxref = $this->marge_gauche;
102
103 $this->update_main_doc_field=1;
104
105 $this->heightforinfotot=50;
106
107 $this->xPosSignArea=120;
108
109 $this->heightforfreetext = (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') > 0 ? getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') : 5);
110
111 $this->heightforfooter = $this->marge_basse + 8;
112 }
113
114 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
127 public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
128 {
129 // phpcs:enable
130 global $conf, $hookmanager, $langs, $user, $mysoc;
131
132 if (!is_object($outputlangs)) {
133 $outputlangs = $langs;
134 }
135 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
136 if (getDolGlobalString('MAIN_USE_FPDF')) {
137 $outputlangs->charset_output = 'ISO-8859-1';
138 }
139
140 // Load translation files required by the page
141 $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
142
143 if (!empty($conf->bank->dir_output)) {
144 //$nblines = count($object->lines); // This is set later with array of tasks
145
146 // Definition of $dir and $file
147 if ($object->specimen) {
148 if (!empty($moreparams['force_dir_output'])) {
149 $dir = $moreparams['force_dir_output'];
150 } else {
151 $dir = $conf->bank->dir_output;
152 }
153 $file = $dir."/SPECIMEN.pdf";
154 } else {
155 $objectref = dol_sanitizeFileName($object->ref);
156 if (!empty($moreparams['force_dir_output'])) {
157 $dir = $moreparams['force_dir_output'];
158 } else {
159 $dir = $conf->bank->dir_output."/".$objectref;
160 }
161 $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
162 }
163
164 if (!file_exists($dir)) {
165 if (dol_mkdir($dir) < 0) {
166 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
167 return 0;
168 }
169 }
170
171 if (file_exists($dir)) {
172 // Add pdfgeneration hook
173 if (!is_object($hookmanager)) {
174 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
175 $hookmanager = new HookManager($this->db);
176 }
177 $hookmanager->initHooks(array('pdfgeneration'));
178 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
179 global $action;
180 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
181
182 $pdf = pdf_getInstance($this->format);
183 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
184
185 if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) {
186 $this->heightforfooter += 6;
187 }
188 $pdf->SetAutoPageBreak(1, 0);
189
190 if (class_exists('TCPDF')) {
191 $pdf->setPrintHeader(false);
192 $pdf->setPrintFooter(false);
193 }
194 $pdf->SetFont(pdf_getPDFFont($outputlangs));
195
196 $pdf->Open();
197 $pagenb = 0;
198 $pdf->SetDrawColor(128, 128, 128);
199
200 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
201 $pdf->SetSubject($outputlangs->transnoentities("SepaMandate"));
202 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
203 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
204 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("SepaMandate"));
205 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
206 $pdf->SetCompression(false);
207 }
208
209 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
210
211 // New page
212 $pdf->AddPage();
213 $pagenb++;
214 $this->_pagehead($pdf, $object, 1, $outputlangs);
215 $pdf->SetFont('', '', $default_font_size - 1);
216 $pdf->MultiCell(0, 3, ''); // Set interline to 3
217 $pdf->SetTextColor(0, 0, 0);
218
219 $tab_top = 50;
220 $tab_top_newpage = 40;
221
222 $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ;
223
224 // Show notes
225 if (!empty($object->note_public)) {
226 $pdf->SetFont('', '', $default_font_size - 1);
227 $pdf->writeHTMLCell(190, 3, $this->posxref, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
228 $nexY = $pdf->GetY();
229 $height_note = $nexY - ($tab_top - 2);
230
231 // Rect takes a length in 3rd parameter
232 $pdf->SetDrawColor(192, 192, 192);
233 $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
234
235 $tab_height = $tab_height - $height_note;
236 $tab_top = $nexY + 6;
237 } else {
238 $height_note = 0;
239 }
240
241 $iniY = $tab_top + 7;
242 $curY = $tab_top + 7;
243 $nexY = $tab_top + 7;
244
245 $posY = $curY;
246
247 $pdf->SetFont('', '', $default_font_size);
248
249 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
250 $posY += 2;
251
252 $pdf->SetXY($this->marge_gauche, $posY);
253 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("RUMLong").' ('.$outputlangs->transnoentitiesnoconv("RUM").') : '.$object->rum, 0, 'L');
254
255 $posY = $pdf->GetY();
256 $posY += 2;
257 $pdf->SetXY($this->marge_gauche, $posY);
258
259 $ics = '';
260 $idbankfordirectdebit = getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT');
261 if ($idbankfordirectdebit > 0) {
262 $tmpbankfordirectdebit = new Account($this->db);
263 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
264 $ics = $tmpbankfordirectdebit->ics; // ICS for direct debit
265 }
266 if (empty($ics) && getDolGlobalString('PRELEVEMENT_ICS')) {
267 $ics = $conf->global->PRELEVEMENT_ICS;
268 }
269 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorIdentifier").' ('.$outputlangs->transnoentitiesnoconv("ICS").') : '.$ics, 0, 'L');
270
271 $posY = $pdf->GetY();
272 $posY += 1;
273 $pdf->SetXY($this->marge_gauche, $posY);
274 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("CreditorName").' : '.$mysoc->name, 0, 'L');
275
276 $posY = $pdf->GetY();
277 $posY += 1;
278 $pdf->SetXY($this->marge_gauche, $posY);
279 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
280 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0, 'L');
281
282 $posY = $pdf->GetY();
283 $posY += 3;
284
285 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
286
287 $pdf->SetFont('', '', $default_font_size - 1);
288
289 $posY += 8;
290 $pdf->SetXY($this->marge_gauche, $posY);
291 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv("SEPALegalText", $mysoc->name, $mysoc->name), 0, 'L');
292
293 // Your data form
294 $posY = $pdf->GetY();
295 $posY += 8;
296 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
297 $posY += 2;
298
299 $pdf->SetFont('', '', $default_font_size);
300
301 $pdf->SetXY($this->marge_gauche, $posY);
302 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFillForm"), 0, 'C');
303
304 $thirdparty = new Societe($this->db);
305 if ($object->socid > 0) {
306 $thirdparty->fetch($object->socid);
307 }
308
309 $sepaname = '______________________________________________';
310 if ($thirdparty->id > 0) {
311 $sepaname = $thirdparty->name.($object->proprio ? ' ('.$object->proprio.')' : '');
312 }
313 $posY = $pdf->GetY();
314 $posY += 3;
315 $pdf->SetXY($this->marge_gauche, $posY);
316 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourName").' * : ', 0, 'L');
317 $pdf->SetXY(80, $posY);
318 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0, 'L');
319
320 $sepavatid = '__________________________________________________';
321 if (!empty($thirdparty->idprof1)) {
322 $sepavatid = $thirdparty->idprof1;
323 }
324 $posY = $pdf->GetY();
325 $posY += 1;
326 $pdf->SetXY($this->marge_gauche, $posY);
327 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv('ProfId1'.$thirdparty->country_code).' * : ', 0, 'L');
328 $pdf->SetXY(80, $posY);
329 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0, 'L');
330
331 $address = '______________________________________________';
332 if (!empty($object->owner_address)) {
333 $address = $object->owner_address;
334 } elseif ($thirdparty->id > 0) {
335 $tmpaddresswithoutcountry = $thirdparty->getFullAddress(); // we test on address without country
336 if ($tmpaddresswithoutcountry) {
337 $address = $thirdparty->getFullAddress(1); // full address
338 }
339 }
340 $posY = $pdf->GetY();
341 $posY += 1;
342 $pdf->SetXY($this->marge_gauche, $posY);
343 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("Address").' : ', 0, 'L');
344 $pdf->SetXY(80, $posY);
345 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
346 if (preg_match('/_____/', $address)) {
347 $posY += 6;
348 $pdf->SetXY(80, $posY);
349 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
350 }
351
352 $ban = '__________________________________________________';
353 if (!empty($object->iban)) {
354 $ban = $object->iban;
355 }
356 $posY = $pdf->GetY();
357 $posY += 1;
358 $pdf->SetXY($this->marge_gauche, $posY);
359 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBAN").' * : ', 0, 'L');
360 $pdf->SetXY(80, $posY);
361 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0, 'L');
362
363 $bic = '__________________________________________________';
364 if (!empty($object->bic)) {
365 $bic = $object->bic;
366 }
367 $posY = $pdf->GetY();
368 $posY += 1;
369 $pdf->SetXY($this->marge_gauche, $posY);
370 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv("SEPAFormYourBIC").' * : ', 0, 'L');
371 $pdf->SetXY(80, $posY);
372 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0, 'L');
373
374
375 $posY = $pdf->GetY();
376 $posY += 1;
377 $pdf->SetXY($this->marge_gauche, $posY);
378 $txt = $outputlangs->transnoentitiesnoconv("SEPAFrstOrRecur").' * : ';
379 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
380 $pdf->Rect(80, $posY, 5, 5);
381 $pdf->SetXY(80, $posY);
382 if ($object->frstrecur == 'RCUR') {
383 $pdf->MultiCell(5, 3, 'X', 0, 'L');
384 }
385 $pdf->SetXY(86, $posY);
386 $txt = $langs->transnoentitiesnoconv("ModeRECUR").' '.$langs->transnoentitiesnoconv("or");
387 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
388 $posY += 6;
389 $pdf->Rect(80, $posY, 5, 5);
390 $pdf->SetXY(80, $posY);
391 if ($object->frstrecur == 'FRST') {
392 $pdf->MultiCell(5, 3, 'X', 0, 'L');
393 }
394 $pdf->SetXY(86, $posY);
395 $txt = $langs->transnoentitiesnoconv("ModeFRST");
396 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
397 if (empty($object->frstrecur)) {
398 $posY += 6;
399 $pdf->SetXY(80, $posY);
400 $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
401 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
402 }
403
404 $posY = $pdf->GetY();
405 $posY += 3;
406 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
407 $posY += 3;
408
409
410 // Show square
411 if ($pagenb == 1) {
412 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0);
413 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
414 } else {
415 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0);
416 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
417 }
418
419 //var_dump($tab_top);
420 //var_dump($this->heightforinfotot );
421 //var_dump($this->heightforfreetext );
422 //var_dump($this->heightforfooter );
423 //var_dump($bottomlasttab);
424
425 // Affiche zone infos
426 $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
427
428 /*
429 * Footer of the page
430 */
431 $this->_pagefoot($pdf, $object, $outputlangs);
432 if (method_exists($pdf, 'AliasNbPages')) {
433 $pdf->AliasNbPages();
434 }
435
436 $pdf->Close();
437
438 $pdf->Output($file, 'F');
439
440 // Add pdfgeneration hook
441 if (!is_object($hookmanager)) {
442 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
443 $hookmanager = new HookManager($this->db);
444 }
445 $hookmanager->initHooks(array('pdfgeneration'));
446 $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
447 global $action;
448 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
449 if ($reshook < 0) {
450 $this->error = $hookmanager->error;
451 $this->errors = $hookmanager->errors;
452 }
453
454 dolChmod($file);
455
456 $this->result = array('fullpath'=>$file);
457
458 return 1; // No error
459 } else {
460 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
461 return 0;
462 }
463 }
464
465 $this->error = $langs->transnoentities("ErrorConstantNotDefined", "DELIVERY_OUTPUTDIR");
466 return 0;
467 }
468
469
470 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
483 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
484 {
485 // phpcs:enable
486 global $conf, $mysoc;
487
488 $default_font_size = pdf_getPDFFontSize($outputlangs);
489 }
490
491
492 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
493 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
503 protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
504 {
505 // phpcs:enable
506 global $conf, $mysoc;
507
508 $default_font_size = pdf_getPDFFontSize($outputlangs);
509
510 $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
511
512 $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
513
514 $pdf->SetXY($this->marge_gauche, $posy);
515 $pdf->SetFont('', '', $default_font_size);
516 $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
517 $posy = $pdf->GetY() + 2;
518
519 $pdf->SetXY($this->marge_gauche, $posy);
520 $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
521 $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
522 $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress(1)), 0, 'L', 0);
523 $posy = $pdf->GetY() + 2;
524
525 return $posy;
526 }
527
528
529 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
530 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
540 protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
541 {
542 // phpcs:enable
543 $default_font_size = pdf_getPDFFontSize($outputlangs);
544 $tab_top = $posy + 4;
545 $tab_hl = 4;
546
547 $posx = $this->marge_gauche;
548 $pdf->SetXY($posx, $tab_top);
549
550 $pdf->SetFont('', '', $default_font_size - 2);
551
552 $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateSigning"), 0, 'L', 0);
553 $pdf->MultiCell(100, 3, ' ');
554 $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
555
556 $posx = $this->xPosSignArea;
557 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
558
559 // Total HT
560 $pdf->SetFillColor(255, 255, 255);
561 $pdf->SetXY($posx, $tab_top);
562 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
563
564 $pdf->SetXY($posx, $tab_top + $tab_hl);
565 $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
566
567 return ($tab_hl * 7);
568 }
569
570
571 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
581 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
582 {
583 // phpcs:enable
584 global $langs, $conf, $mysoc;
585
586 $default_font_size = pdf_getPDFFontSize($outputlangs);
587
588 pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
589
590 $pdf->SetTextColor(0, 0, 60);
591 $pdf->SetFont('', 'B', $default_font_size + 3);
592
593 $posx = $this->page_largeur - $this->marge_droite - 100;
594 $posy = $this->marge_haute;
595
596 $pdf->SetXY($this->marge_gauche, $posy);
597
598 // Logo
599 $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
600 if ($mysoc->logo) {
601 if (is_readable($logo)) {
602 $height = pdf_getHeightForLogo($logo);
603 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
604 } else {
605 $pdf->SetTextColor(200, 0, 0);
606 $pdf->SetFont('', 'B', $default_font_size - 2);
607 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
608 $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
609 }
610 } else {
611 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
612 }
613
614 $pdf->SetFont('', 'B', $default_font_size + 3);
615 $pdf->SetXY($posx, $posy);
616 $pdf->SetTextColor(0, 0, 60);
617 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SepaMandate"), '', 'R');
618 $pdf->SetFont('', '', $default_font_size + 2);
619
620 $posy += 6;
621 $pdf->SetXY($posx, $posy);
622 $pdf->SetTextColor(0, 0, 60);
623 $daterum = '__________________';
624 if (!empty($object->date_rum)) {
625 $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
626 } else {
627 $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved.
628 }
629 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R');
630 /*$posy+=6;
631 $pdf->SetXY($posx,$posy);
632 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
633 */
634
635 $pdf->SetTextColor(0, 0, 60);
636
637 // Add list of linked objects
638 /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
639 $object->fetchObjectLinked();
640
641 foreach($object->linkedObjects as $objecttype => $objects)
642 {
643 var_dump($objects);exit;
644 if ($objecttype == 'commande')
645 {
646 $outputlangs->load('orders');
647 $num=count($objects);
648 for ($i=0;$i<$num;$i++)
649 {
650 $posy+=4;
651 $pdf->SetXY($posx,$posy);
652 $pdf->SetFont('','', $default_font_size - 1);
653 $text=$objects[$i]->ref;
654 if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
655 $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
656 }
657 }
658 }
659 */
660 }
661
662 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
672 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
673 {
674 // phpcs:enable
675 $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
676 return pdf_pagefoot($pdf, $outputlangs, 'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
677 }
678}
Class to manage bank accounts.
Class to manage hooks.
Parent class for bank account models.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to generate SEPA mandate.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
__construct($db)
Constructor.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Function to create pdf of company bank account sepa mandate.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_signature_area(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:289
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:85
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition pdf.lib.php:314
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition pdf.lib.php:1014
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition pdf.lib.php:726
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:266
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:127
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:121
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124