127 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
130 global $conf, $hookmanager, $langs, $user, $mysoc;
132 if (!is_object($outputlangs)) {
133 $outputlangs = $langs;
137 $outputlangs->charset_output =
'ISO-8859-1';
141 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
143 if (!empty($conf->bank->dir_output)) {
147 if ($object->specimen) {
148 if (!empty($moreparams[
'force_dir_output'])) {
149 $dir = $moreparams[
'force_dir_output'];
151 $dir = $conf->bank->dir_output;
153 $file = $dir.
"/SPECIMEN.pdf";
156 if (!empty($moreparams[
'force_dir_output'])) {
157 $dir = $moreparams[
'force_dir_output'];
159 $dir = $conf->bank->dir_output.
"/".$objectref;
161 $file = $dir.
"/".$langs->transnoentitiesnoconv(
"SepaMandateShort").
' '.$objectref.
"-".
dol_sanitizeFileName($object->rum).
".pdf";
164 if (!file_exists($dir)) {
166 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
171 if (file_exists($dir)) {
173 if (!is_object($hookmanager)) {
174 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
177 $hookmanager->initHooks(array(
'pdfgeneration'));
178 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
180 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
186 $this->heightforfooter += 6;
188 $pdf->SetAutoPageBreak(1, 0);
190 if (class_exists(
'TCPDF')) {
191 $pdf->setPrintHeader(
false);
192 $pdf->setPrintFooter(
false);
198 $pdf->SetDrawColor(128, 128, 128);
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"));
206 $pdf->SetCompression(
false);
209 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
214 $this->
_pagehead($pdf, $object, 1, $outputlangs);
215 $pdf->SetFont(
'',
'', $default_font_size - 1);
216 $pdf->MultiCell(0, 3,
'');
217 $pdf->SetTextColor(0, 0, 0);
220 $tab_top_newpage = 40;
222 $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ;
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);
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);
235 $tab_height = $tab_height - $height_note;
236 $tab_top = $nexY + 6;
241 $iniY = $tab_top + 7;
242 $curY = $tab_top + 7;
243 $nexY = $tab_top + 7;
247 $pdf->SetFont(
'',
'', $default_font_size);
249 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
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');
255 $posY = $pdf->GetY();
257 $pdf->SetXY($this->marge_gauche, $posY);
261 if ($idbankfordirectdebit > 0) {
262 $tmpbankfordirectdebit =
new Account($this->db);
263 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
264 $ics = $tmpbankfordirectdebit->ics;
267 $ics = $conf->global->PRELEVEMENT_ICS;
269 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
271 $posY = $pdf->GetY();
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');
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(
"Address").
' : ', 0,
'L');
280 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0,
'L');
282 $posY = $pdf->GetY();
285 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
287 $pdf->SetFont(
'',
'', $default_font_size - 1);
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');
294 $posY = $pdf->GetY();
296 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
299 $pdf->SetFont(
'',
'', $default_font_size);
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');
304 $thirdparty =
new Societe($this->db);
305 if ($object->socid > 0) {
306 $thirdparty->fetch($object->socid);
309 $sepaname =
'______________________________________________';
310 if ($thirdparty->id > 0) {
311 $sepaname = $thirdparty->name.($object->proprio ?
' ('.$object->proprio.
')' :
'');
313 $posY = $pdf->GetY();
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');
320 $sepavatid =
'__________________________________________________';
321 if (!empty($thirdparty->idprof1)) {
322 $sepavatid = $thirdparty->idprof1;
324 $posY = $pdf->GetY();
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');
331 $address =
'______________________________________________';
332 if (!empty($object->owner_address)) {
333 $address = $object->owner_address;
334 } elseif ($thirdparty->id > 0) {
335 $tmpaddresswithoutcountry = $thirdparty->getFullAddress();
336 if ($tmpaddresswithoutcountry) {
337 $address = $thirdparty->getFullAddress(1);
340 $posY = $pdf->GetY();
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)) {
348 $pdf->SetXY(80, $posY);
349 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
352 $ban =
'__________________________________________________';
353 if (!empty($object->iban)) {
354 $ban = $object->iban;
356 $posY = $pdf->GetY();
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');
363 $bic =
'__________________________________________________';
364 if (!empty($object->bic)) {
367 $posY = $pdf->GetY();
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');
375 $posY = $pdf->GetY();
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');
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');
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');
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)) {
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');
404 $posY = $pdf->GetY();
406 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
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;
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;
426 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
431 $this->
_pagefoot($pdf, $object, $outputlangs);
432 if (method_exists($pdf,
'AliasNbPages')) {
433 $pdf->AliasNbPages();
438 $pdf->Output($file,
'F');
441 if (!is_object($hookmanager)) {
442 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
445 $hookmanager->initHooks(array(
'pdfgeneration'));
446 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
448 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
450 $this->error = $hookmanager->error;
451 $this->errors = $hookmanager->errors;
456 $this->result = array(
'fullpath'=>$file);
460 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
465 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
581 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
584 global $langs, $conf, $mysoc;
590 $pdf->SetTextColor(0, 0, 60);
591 $pdf->SetFont(
'',
'B', $default_font_size + 3);
593 $posx = $this->page_largeur - $this->marge_droite - 100;
594 $posy = $this->marge_haute;
596 $pdf->SetXY($this->marge_gauche, $posy);
599 $logo = $conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
601 if (is_readable($logo)) {
603 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
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');
611 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
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);
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);
627 $daterum =
dol_print_date($object->datec,
'day',
false, $outputlangs,
true);
629 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
635 $pdf->SetTextColor(0, 0, 60);