26 require_once DOL_DOCUMENT_ROOT.
'/core/modules/bank/modules_bank.php';
27 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
49 public $version =
'dolibarr';
58 global $conf, $langs, $mysoc;
61 $langs->loadLangs(array(
"main",
"bank",
"withdrawals",
"companies"));
64 $this->
name =
"sepamandate";
65 $this->
description = $langs->transnoentitiesnoconv(
"DocumentModelSepaMandate");
70 $this->page_largeur = $formatarray[
'width'];
71 $this->page_hauteur = $formatarray[
'height'];
72 $this->format = array($this->page_largeur, $this->page_hauteur);
78 $this->option_logo = 1;
79 $this->option_tva = 1;
82 $this->emetteur = $mysoc;
83 if (!$this->emetteur->country_code) {
84 $this->emetteur->country_code = substr($langs->defaultlang, -2);
88 $this->posxref = $this->marge_gauche;
105 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
108 global $conf, $hookmanager, $langs, $user, $mysoc;
110 if (!is_object($outputlangs)) {
111 $outputlangs = $langs;
114 if (!empty($conf->global->MAIN_USE_FPDF)) {
115 $outputlangs->charset_output =
'ISO-8859-1';
119 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
121 if (!empty($conf->bank->dir_output)) {
125 if ($object->specimen) {
126 if (!empty($moreparams[
'force_dir_output'])) {
127 $dir = $moreparams[
'force_dir_output'];
129 $dir = $conf->bank->dir_output;
131 $file = $dir.
"/SPECIMEN.pdf";
134 if (!empty($moreparams[
'force_dir_output'])) {
135 $dir = $moreparams[
'force_dir_output'];
137 $dir = $conf->bank->dir_output.
"/".$objectref;
139 $file = $dir.
"/".$langs->transnoentitiesnoconv(
"SepaMandateShort").
' '.$objectref.
"-".
dol_sanitizeFileName($object->rum).
".pdf";
142 if (!file_exists($dir)) {
144 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
149 if (file_exists($dir)) {
151 if (!is_object($hookmanager)) {
152 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
155 $hookmanager->initHooks(array(
'pdfgeneration'));
156 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
158 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
162 $heightforinfotot = 50;
163 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
164 $heightforfooter = $this->marge_basse + 8;
165 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
166 $heightforfooter += 6;
168 $pdf->SetAutoPageBreak(1, 0);
170 if (class_exists(
'TCPDF')) {
171 $pdf->setPrintHeader(
false);
172 $pdf->setPrintFooter(
false);
178 $pdf->SetDrawColor(128, 128, 128);
180 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
181 $pdf->SetSubject($outputlangs->transnoentities(
"SepaMandate"));
182 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
183 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
184 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"SepaMandate"));
186 $pdf->SetCompression(
false);
189 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
194 $this->
_pagehead($pdf, $object, 1, $outputlangs);
195 $pdf->SetFont(
'',
'', $default_font_size - 1);
196 $pdf->MultiCell(0, 3,
'');
197 $pdf->SetTextColor(0, 0, 0);
200 $tab_top_newpage = 40;
202 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
205 if (!empty($object->note_public)) {
206 $pdf->SetFont(
'',
'', $default_font_size - 1);
207 $pdf->writeHTMLCell(190, 3, $this->posxref, $tab_top - 2,
dol_htmlentitiesbr($object->note_public), 0, 1);
208 $nexY = $pdf->GetY();
209 $height_note = $nexY - ($tab_top - 2);
212 $pdf->SetDrawColor(192, 192, 192);
213 $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
215 $tab_height = $tab_height - $height_note;
216 $tab_top = $nexY + 6;
221 $iniY = $tab_top + 7;
222 $curY = $tab_top + 7;
223 $nexY = $tab_top + 7;
227 $pdf->SetFont(
'',
'', $default_font_size);
229 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
232 $pdf->SetXY($this->marge_gauche, $posY);
233 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"RUMLong").
' ('.$outputlangs->transnoentitiesnoconv(
"RUM").
') : '.$object->rum, 0,
'L');
235 $posY = $pdf->GetY();
237 $pdf->SetXY($this->marge_gauche, $posY);
241 if ($idbankfordirectdebit > 0) {
242 $tmpbankfordirectdebit =
new Account($this->
db);
243 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
244 $ics = $tmpbankfordirectdebit->ics;
246 if (empty($ics) && !empty($conf->global->PRELEVEMENT_ICS)) {
247 $ics = $conf->global->PRELEVEMENT_ICS;
249 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
251 $posY = $pdf->GetY();
253 $pdf->SetXY($this->marge_gauche, $posY);
254 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorName").
' : '.$mysoc->name, 0,
'L');
256 $posY = $pdf->GetY();
258 $pdf->SetXY($this->marge_gauche, $posY);
259 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
260 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0,
'L');
262 $posY = $pdf->GetY();
265 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
267 $pdf->SetFont(
'',
'', $default_font_size - 1);
270 $pdf->SetXY($this->marge_gauche, $posY);
271 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv(
"SEPALegalText", $mysoc->name, $mysoc->name), 0,
'L');
274 $posY = $pdf->GetY();
276 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
279 $pdf->SetFont(
'',
'', $default_font_size);
281 $pdf->SetXY($this->marge_gauche, $posY);
282 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFillForm"), 0,
'C');
285 if ($object->socid > 0) {
286 $thirdparty->fetch($object->socid);
289 $sepaname =
'______________________________________________';
290 if ($thirdparty->id > 0) {
291 $sepaname = $thirdparty->name.($object->proprio ?
' ('.$object->proprio.
')' :
'');
293 $posY = $pdf->GetY();
295 $pdf->SetXY($this->marge_gauche, $posY);
296 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourName").
' * : ', 0,
'L');
297 $pdf->SetXY(80, $posY);
298 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0,
'L');
300 $sepavatid =
'__________________________________________________';
301 if (!empty($thirdparty->idprof1)) {
302 $sepavatid = $thirdparty->idprof1;
304 $posY = $pdf->GetY();
306 $pdf->SetXY($this->marge_gauche, $posY);
307 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
'ProfId1'.$thirdparty->country_code).
' * : ', 0,
'L');
308 $pdf->SetXY(80, $posY);
309 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0,
'L');
311 $address =
'______________________________________________';
312 if ($thirdparty->id > 0) {
313 $tmpaddresswithoutcountry = $thirdparty->getFullAddress();
314 if ($tmpaddresswithoutcountry) {
315 $address = $thirdparty->getFullAddress(1);
318 $posY = $pdf->GetY();
320 $pdf->SetXY($this->marge_gauche, $posY);
321 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
322 $pdf->SetXY(80, $posY);
323 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
324 if (preg_match(
'/_____/', $address)) {
326 $pdf->SetXY(80, $posY);
327 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
330 $ban =
'__________________________________________________';
331 if (!empty($object->iban)) {
332 $ban = $object->iban;
334 $posY = $pdf->GetY();
336 $pdf->SetXY($this->marge_gauche, $posY);
337 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBAN").
' * : ', 0,
'L');
338 $pdf->SetXY(80, $posY);
339 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0,
'L');
341 $bic =
'__________________________________________________';
342 if (!empty($object->bic)) {
345 $posY = $pdf->GetY();
347 $pdf->SetXY($this->marge_gauche, $posY);
348 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBIC").
' * : ', 0,
'L');
349 $pdf->SetXY(80, $posY);
350 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0,
'L');
353 $posY = $pdf->GetY();
355 $pdf->SetXY($this->marge_gauche, $posY);
356 $txt = $outputlangs->transnoentitiesnoconv(
"SEPAFrstOrRecur").
' * : ';
357 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
358 $pdf->Rect(80, $posY, 5, 5);
359 $pdf->SetXY(80, $posY);
360 if ($object->frstrecur ==
'RECUR') {
361 $pdf->MultiCell(5, 3,
'X', 0,
'L');
363 $pdf->SetXY(86, $posY);
364 $txt = $langs->transnoentitiesnoconv(
"ModeRECUR").
' '.$langs->transnoentitiesnoconv(
"or");
365 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
367 $pdf->Rect(80, $posY, 5, 5);
368 $pdf->SetXY(80, $posY);
369 if ($object->frstrecur ==
'FRST') {
370 $pdf->MultiCell(5, 3,
'X', 0,
'L');
372 $pdf->SetXY(86, $posY);
373 $txt = $langs->transnoentitiesnoconv(
"ModeFRST");
374 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
375 if (empty($object->frstrecur)) {
377 $pdf->SetXY(80, $posY);
378 $txt =
'('.$langs->transnoentitiesnoconv(
"PleaseCheckOne").
')';
379 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
382 $posY = $pdf->GetY();
384 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
390 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
391 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
393 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
394 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
404 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
409 $this->
_pagefoot($pdf, $object, $outputlangs);
410 if (method_exists($pdf,
'AliasNbPages')) {
411 $pdf->AliasNbPages();
416 $pdf->Output($file,
'F');
419 if (!is_object($hookmanager)) {
420 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
423 $hookmanager->initHooks(array(
'pdfgeneration'));
424 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
426 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
428 $this->error = $hookmanager->error;
429 $this->errors = $hookmanager->errors;
432 if (!empty($conf->global->MAIN_UMASK)) {
433 @chmod($file, octdec($conf->global->MAIN_UMASK));
436 $this->result = array(
'fullpath'=>$file);
440 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
445 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
463 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
466 global $conf, $mysoc;
486 global $conf, $mysoc;
490 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
494 $pdf->SetXY($this->marge_gauche, $posy);
495 $pdf->SetFont(
'',
'', $default_font_size);
496 $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv(
"PleaseReturnMandate", $mysoc->email).
':', 0,
'L', 0);
497 $posy = $pdf->GetY() + 2;
499 $pdf->SetXY($this->marge_gauche, $posy);
500 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
501 $pdf->MultiCell(100, 6, $mysoc->name, 0,
'L', 0);
502 $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress(1)), 0,
'L', 0);
503 $posy = $pdf->GetY() + 2;
525 $tab_top = $posy + 4;
528 $posx = $this->marge_gauche;
529 $pdf->SetXY($posx, $tab_top);
531 $pdf->SetFont(
'',
'', $default_font_size - 2);
533 $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv(
"DateOfSignature"), 0,
'L', 0);
534 $pdf->MultiCell(100, 3,
' ');
535 $pdf->MultiCell(100, 3,
'______________________', 0,
'L', 0);
538 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
542 $pdf->SetFillColor(255, 255, 255);
543 $pdf->SetXY($posx, $tab_top);
544 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv(
"Signature"), 0,
'L', 1);
546 $pdf->SetXY($posx, $tab_top + $tab_hl);
547 $pdf->MultiCell($largcol, $tab_hl * 3,
'', 1,
'R');
549 return ($tab_hl * 7);
563 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
566 global $langs, $conf, $mysoc;
572 $pdf->SetTextColor(0, 0, 60);
573 $pdf->SetFont(
'',
'B', $default_font_size + 3);
575 $posx = $this->page_largeur - $this->marge_droite - 100;
576 $posy = $this->marge_haute;
578 $pdf->SetXY($this->marge_gauche, $posy);
581 $logo = $conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
583 if (is_readable($logo)) {
585 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
587 $pdf->SetTextColor(200, 0, 0);
588 $pdf->SetFont(
'',
'B', $default_font_size - 2);
589 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
590 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
593 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
596 $pdf->SetFont(
'',
'B', $default_font_size + 3);
597 $pdf->SetXY($posx, $posy);
598 $pdf->SetTextColor(0, 0, 60);
599 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"SepaMandate"),
'',
'R');
600 $pdf->SetFont(
'',
'', $default_font_size + 2);
603 $pdf->SetXY($posx, $posy);
604 $pdf->SetTextColor(0, 0, 60);
605 $daterum =
'__________________';
606 if (!empty($object->date_rum)) {
607 $daterum =
dol_print_date($object->date_rum,
'day',
false, $outputlangs,
true);
609 $daterum =
dol_print_date($object->datec,
'day',
false, $outputlangs,
true);
611 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
617 $pdf->SetTextColor(0, 0, 60);
654 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
657 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
658 return pdf_pagefoot($pdf, $outputlangs,
'PAYMENTORDER_FREE_TEXT',
null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
Class to manage bank accounts.
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(".$version.") pid 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).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string 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...
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.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
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.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.