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);
73 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
74 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
75 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
76 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
78 $this->option_logo = 1;
79 $this->option_tva = 1;
80 $this->option_codeproduitservice = 1;
83 $this->emetteur = $mysoc;
84 if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2);
87 $this->posxref = $this->marge_gauche;
104 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
107 global $conf, $hookmanager, $langs, $user, $mysoc;
109 if (!is_object($outputlangs)) $outputlangs = $langs;
111 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
114 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
116 if (!empty($conf->bank->dir_output))
121 if ($object->specimen)
123 if (!empty($moreparams[
'force_dir_output'])) $dir = $moreparams[
'force_dir_output'];
124 else $dir = $conf->bank->dir_output;
125 $file = $dir.
"/SPECIMEN.pdf";
128 if (!empty($moreparams[
'force_dir_output'])) $dir = $moreparams[
'force_dir_output'];
129 else $dir = $conf->bank->dir_output.
"/".$objectref;
130 $file = $dir.
"/".$langs->transnoentitiesnoconv(
"SepaMandateShort").
' '.$objectref.
"-".
dol_sanitizeFileName($object->rum).
".pdf";
133 if (!file_exists($dir))
137 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
142 if (file_exists($dir))
145 if (!is_object($hookmanager))
147 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
150 $hookmanager->initHooks(array(
'pdfgeneration'));
151 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
153 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
157 $heightforinfotot = 50;
158 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
159 $heightforfooter = $this->marge_basse + 8;
160 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
161 $pdf->SetAutoPageBreak(1, 0);
163 if (class_exists(
'TCPDF'))
165 $pdf->setPrintHeader(
false);
166 $pdf->setPrintFooter(
false);
172 $pdf->SetDrawColor(128, 128, 128);
174 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
175 $pdf->SetSubject($outputlangs->transnoentities(
"SepaMandate"));
176 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
177 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
178 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"SepaMandate"));
179 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
181 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
186 $this->
_pagehead($pdf, $object, 1, $outputlangs);
187 $pdf->SetFont(
'',
'', $default_font_size - 1);
188 $pdf->MultiCell(0, 3,
'');
189 $pdf->SetTextColor(0, 0, 0);
193 $tab_top_newpage = 40;
194 $tab_height_newpage = 210;
197 if (!empty($object->note_public))
199 $pdf->SetFont(
'',
'', $default_font_size - 1);
200 $pdf->writeHTMLCell(190, 3, $this->posxref, $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;
220 $pdf->SetFont(
'',
'', $default_font_size);
222 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
225 $pdf->SetXY($this->marge_gauche, $posY);
226 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"RUMLong").
' ('.$outputlangs->transnoentitiesnoconv(
"RUM").
') : '.$object->rum, 0,
'L');
228 $posY = $pdf->GetY();
230 $pdf->SetXY($this->marge_gauche, $posY);
232 if (!empty($conf->global->PRELEVEMENT_ICS)) $ics = $conf->global->PRELEVEMENT_ICS;
233 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
235 $posY = $pdf->GetY();
237 $pdf->SetXY($this->marge_gauche, $posY);
238 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorName").
' : '.$mysoc->name, 0,
'L');
240 $posY = $pdf->GetY();
242 $pdf->SetXY($this->marge_gauche, $posY);
243 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
244 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(), 0,
'L');
246 $posY = $pdf->GetY();
249 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
251 $pdf->SetFont(
'',
'', $default_font_size - 1);
254 $pdf->SetXY($this->marge_gauche, $posY);
255 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv(
"SEPALegalText", $mysoc->name, $mysoc->name), 0,
'L');
258 $posY = $pdf->GetY();
260 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
263 $pdf->SetFont(
'',
'', $default_font_size);
265 $pdf->SetXY($this->marge_gauche, $posY);
266 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFillForm"), 0,
'C');
269 if ($object->socid > 0) $thirdparty->fetch($object->socid);
271 $sepaname =
'______________________________________________';
272 if ($thirdparty->id > 0)
274 $sepaname = $thirdparty->name.($object->account_owner ?
' ('.$object->account_owner.
')' :
'');
276 $posY = $pdf->GetY();
278 $pdf->SetXY($this->marge_gauche, $posY);
279 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourName").
' * : ', 0,
'L');
280 $pdf->SetXY(80, $posY);
281 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0,
'L');
283 $sepavatid =
'__________________________________________________';
284 if (!empty($thirdparty->idprof1)) $sepavatid = $thirdparty->idprof1;
285 $posY = $pdf->GetY();
287 $pdf->SetXY($this->marge_gauche, $posY);
288 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
'ProfId1'.$thirdparty->country_code).
' * : ', 0,
'L');
289 $pdf->SetXY(80, $posY);
290 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0,
'L');
292 $address =
'______________________________________________';
293 if ($thirdparty->id > 0)
295 $address = $thirdparty->getFullAddress();
297 $posY = $pdf->GetY();
299 $pdf->SetXY($this->marge_gauche, $posY);
300 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
301 $pdf->SetXY(80, $posY);
302 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
303 if (preg_match(
'/_____/', $address))
306 $pdf->SetXY(80, $posY);
307 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
310 $ban =
'__________________________________________________';
311 if (!empty($object->iban)) $ban = $object->iban;
312 $posY = $pdf->GetY();
314 $pdf->SetXY($this->marge_gauche, $posY);
315 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBAN").
' * : ', 0,
'L');
316 $pdf->SetXY(80, $posY);
317 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0,
'L');
319 $bic =
'__________________________________________________';
320 if (!empty($object->bic)) $bic = $object->bic;
321 $posY = $pdf->GetY();
323 $pdf->SetXY($this->marge_gauche, $posY);
324 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBIC").
' * : ', 0,
'L');
325 $pdf->SetXY(80, $posY);
326 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0,
'L');
329 $posY = $pdf->GetY();
331 $pdf->SetXY($this->marge_gauche, $posY);
332 $txt = $outputlangs->transnoentitiesnoconv(
"SEPAFrstOrRecur").
' * : ';
333 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
334 $pdf->Rect(80, $posY, 5, 5);
335 $pdf->SetXY(80, $posY);
336 if ($object->frstrecur ==
'RECUR') $pdf->MultiCell(5, 3,
'X', 0,
'L');
337 $pdf->SetXY(86, $posY);
338 $txt = $langs->transnoentitiesnoconv(
"ModeRECUR").
' '.$langs->transnoentitiesnoconv(
"or");
339 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
341 $pdf->Rect(80, $posY, 5, 5);
342 $pdf->SetXY(80, $posY);
343 if ($object->frstrecur ==
'FRST') $pdf->MultiCell(5, 3,
'X', 0,
'L');
344 $pdf->SetXY(86, $posY);
345 $txt = $langs->transnoentitiesnoconv(
"ModeFRST");
346 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
347 if (empty($object->frstrecur))
350 $pdf->SetXY(80, $posY);
351 $txt =
'('.$langs->transnoentitiesnoconv(
"PleaseCheckOne").
')';
352 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
355 $posY = $pdf->GetY();
357 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
364 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
365 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
367 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
368 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
378 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
383 $this->
_pagefoot($pdf, $object, $outputlangs);
384 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
388 $pdf->Output($file,
'F');
391 if (!is_object($hookmanager))
393 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
396 $hookmanager->initHooks(array(
'pdfgeneration'));
397 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
399 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
402 $this->error = $hookmanager->error;
403 $this->errors = $hookmanager->errors;
406 if (!empty($conf->global->MAIN_UMASK))
407 @chmod($file, octdec($conf->global->MAIN_UMASK));
409 $this->result = array(
'fullpath'=>$file);
413 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
418 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
436 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
439 global $conf, $mysoc;
459 global $conf, $mysoc;
463 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
467 $pdf->SetXY($this->marge_gauche, $posy);
468 $pdf->SetFont(
'',
'', $default_font_size);
469 $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv(
"PleaseReturnMandate", $mysoc->email).
':', 0,
'L', 0);
470 $posy = $pdf->GetY() + 2;
472 $pdf->SetXY($this->marge_gauche, $posy);
473 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
474 $pdf->MultiCell(100, 6, $mysoc->name, 0,
'L', 0);
475 $pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0,
'L', 0);
476 $posy = $pdf->GetY() + 2;
498 $tab_top = $posy + 4;
501 $posx = $this->marge_gauche;
502 $pdf->SetXY($posx, $tab_top + 0);
504 $pdf->SetFont(
'',
'', $default_font_size - 2);
506 $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv(
"DateOfSignature"), 0,
'L', 0);
507 $pdf->MultiCell(100, 3,
' ');
508 $pdf->MultiCell(100, 3,
'______________________', 0,
'L', 0);
511 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
515 $pdf->SetFillColor(255, 255, 255);
516 $pdf->SetXY($posx, $tab_top + 0);
517 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv(
"Signature"), 0,
'L', 1);
519 $pdf->SetXY($posx, $tab_top + $tab_hl);
520 $pdf->MultiCell($largcol, $tab_hl * 3,
'', 1,
'R');
522 return ($tab_hl * 7);
536 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
539 global $langs, $conf, $mysoc;
545 $pdf->SetTextColor(0, 0, 60);
546 $pdf->SetFont(
'',
'B', $default_font_size + 3);
548 $posx = $this->page_largeur - $this->marge_droite - 100;
549 $posy = $this->marge_haute;
551 $pdf->SetXY($this->marge_gauche, $posy);
554 $logo = $conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
557 if (is_readable($logo))
560 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
562 $pdf->SetTextColor(200, 0, 0);
563 $pdf->SetFont(
'',
'B', $default_font_size - 2);
564 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
565 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
567 }
else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
569 $pdf->SetFont(
'',
'B', $default_font_size + 3);
570 $pdf->SetXY($posx, $posy);
571 $pdf->SetTextColor(0, 0, 60);
572 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"SepaMandate"),
'',
'R');
573 $pdf->SetFont(
'',
'', $default_font_size + 2);
576 $pdf->SetXY($posx, $posy);
577 $pdf->SetTextColor(0, 0, 60);
578 $daterum =
'__________________';
579 if (!empty($object->date_rum))
581 $daterum =
dol_print_date($object->date_rum,
'day',
false, $outputlangs,
true);
582 }
else $daterum =
dol_print_date($object->datec,
'day',
false, $outputlangs,
true);
583 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
589 $pdf->SetTextColor(0, 0, 60);
626 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
631 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
632 return pdf_pagefoot($pdf, $outputlangs,
'PAYMENTORDER_FREE_TEXT', null, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Parent class for bank account models.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Function to create pdf of company bank account sepa mandate.
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...
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
Class to manage third parties objects (customers, suppliers, prospects...)
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Class to generate SEPA mandate.
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
_signature_area(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
__construct($db)
Constructor.