135 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
141 dol_syslog(get_class($this).
"::write_file object is of type ".get_class(
$object).
" which is not expected", LOG_ERR);
144 if (empty($moreparams) && !empty(
$object->context[
'moreparams']) && is_array(
$object->context[
'moreparams'])) {
145 $moreparams =
$object->context[
'moreparams'];
148 if (!is_object($outputlangs)) {
149 $outputlangs = $langs;
153 $outputlangs->charset_output =
'ISO-8859-1';
157 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
159 if (!empty(
$conf->bank->dir_output)) {
164 if (!empty($moreparams[
'force_dir_output'])) {
165 $dir = $moreparams[
'force_dir_output'];
167 $dir =
$conf->bank->dir_output;
169 $file = $dir.
"/SPECIMEN.pdf";
172 if (!empty($moreparams[
'force_dir_output'])) {
173 $dir = $moreparams[
'force_dir_output'];
175 $dir =
$conf->bank->dir_output.
"/".$objectref;
180 if (!file_exists($dir)) {
182 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
187 if (file_exists($dir)) {
189 if (!is_object($hookmanager)) {
190 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
193 $hookmanager->initHooks(array(
'pdfgeneration'));
194 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
196 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
202 $this->heightforfooter += 6;
204 $pdf->setAutoPageBreak(
true, 0);
206 if (class_exists(
'TCPDF')) {
207 $pdf->setPrintHeader(
false);
208 $pdf->setPrintFooter(
false);
214 $pdf->SetDrawColor(128, 128, 128);
216 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
217 $pdf->SetSubject($outputlangs->transnoentities(
"SepaMandate"));
218 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
219 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
220 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"SepaMandate"));
222 $pdf->SetCompression(
false);
226 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
232 $pdf->SetFont(
'',
'', $default_font_size - 1);
233 $pdf->MultiCell(0, 3,
'');
234 $pdf->SetTextColor(0, 0, 0);
236 $tab_top = 40 + $this->marge_haute;
237 $tab_top_newpage = 30 + $this->marge_haute;
239 $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ;
242 if (!empty(
$object->note_public)) {
243 $pdf->SetFont(
'',
'', $default_font_size - 1);
245 $nexY = $pdf->GetY();
246 $height_note = $nexY - ($tab_top - 2);
249 $pdf->SetDrawColor(192, 192, 192);
250 $pdf->RoundedRect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
252 $tab_height -= $height_note;
253 $tab_top = $nexY + 6;
258 $iniY = $tab_top + 7;
259 $curY = $tab_top + 7;
260 $nexY = $tab_top + 7;
264 $pdf->SetFont(
'',
'', $default_font_size - 1);
266 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
269 $pdf->SetXY($this->marge_gauche, $posY);
270 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"RUMLong").
' ('.$outputlangs->transnoentitiesnoconv(
"RUM").
') : '.
$object->rum, 0,
'L');
272 $posY = $pdf->GetY();
274 $pdf->SetXY($this->marge_gauche, $posY);
278 if ($idbankfordirectdebit > 0) {
279 $tmpbankfordirectdebit =
new Account($this->db);
280 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
281 $ics = $tmpbankfordirectdebit->ics;
286 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
288 $posY = $pdf->GetY();
290 $pdf->SetXY($this->marge_gauche, $posY);
291 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorName").
' : '.
$mysoc->name, 0,
'L');
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(
"Address").
' : ', 0,
'L');
297 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3,
$mysoc->getFullAddress(1), 0,
'L');
299 $posY = $pdf->GetY();
302 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
304 $pdf->SetFont(
'',
'', $default_font_size - 1);
307 $pdf->SetXY($this->marge_gauche, $posY);
308 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv(
"SEPALegalText",
$mysoc->name,
$mysoc->name), 0,
'L');
311 $posY = $pdf->GetY();
313 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
316 $pdf->SetFont(
'',
'', $default_font_size - 2);
318 $pdf->SetXY($this->marge_gauche, $posY);
319 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFillForm"), 0,
'C');
321 $thirdparty =
new Societe($this->db);
323 $thirdparty->fetch(
$object->socid);
326 $sepaname =
'______________________________________________';
327 if ($thirdparty->id > 0) {
328 $sepaname = $thirdparty->name.($object->owner_name ?
' ('.$object->owner_name.
')' :
'');
330 $posY = $pdf->GetY();
332 $pdf->SetXY($this->marge_gauche, $posY);
333 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourName").
' * : ', 0,
'L');
334 $pdf->SetXY(80, $posY);
335 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0,
'L');
337 $sepavatid =
'__________________________________________________';
338 if (!is_null($thirdparty->idprof1) && !empty($thirdparty->idprof1)) {
339 $sepavatid = (
string) $thirdparty->idprof1;
341 $posY = $pdf->GetY();
343 $pdf->SetXY($this->marge_gauche, $posY);
344 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
'ProfId1'.$thirdparty->country_code).
' * : ', 0,
'L');
345 $pdf->SetXY(80, $posY);
346 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0,
'L');
348 $address =
'__________________________________________________';
349 if (!empty(
$object->owner_address)) {
350 $address =
$object->owner_address;
351 } elseif ($thirdparty->id > 0) {
352 $tmpaddresswithoutcountry = $thirdparty->getFullAddress();
353 if ($tmpaddresswithoutcountry) {
354 $address = $thirdparty->getFullAddress(1);
357 $posY = $pdf->GetY();
359 $pdf->SetXY($this->marge_gauche, $posY);
360 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
361 $pdf->SetXY(80, $posY);
362 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
363 if (preg_match(
'/_____/', $address)) {
365 $pdf->SetXY(80, $posY);
366 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
369 $ban =
'__________________________________________________';
373 $posY = $pdf->GetY();
375 $pdf->SetXY($this->marge_gauche, $posY);
376 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBAN").
' * : ', 0,
'L');
377 $pdf->SetXY(80, $posY);
378 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0,
'L');
380 $bic =
'__________________________________________________';
384 $posY = $pdf->GetY();
386 $pdf->SetXY($this->marge_gauche, $posY);
387 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBIC").
' * : ', 0,
'L');
388 $pdf->SetXY(80, $posY);
389 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0,
'L');
392 $posY = $pdf->GetY();
394 $pdf->SetXY($this->marge_gauche, $posY);
395 $txt = $outputlangs->transnoentitiesnoconv(
"SEPAFrstOrRecur").
' * : ';
396 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
397 $pdf->RoundedRect(80, $posY, 5, 5, $this->corner_radius,
'1234',
'D');
398 $pdf->SetXY(80, $posY);
399 if (
$object->frstrecur ==
'RCUR') {
400 $pdf->MultiCell(5, 3,
'X', 0,
'L');
402 $pdf->SetXY(86, $posY);
403 $txt = $langs->transnoentitiesnoconv(
"ModeRECUR").
' '.$langs->transnoentitiesnoconv(
"or");
404 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
406 $pdf->RoundedRect(80, $posY, 5, 5, $this->corner_radius,
'1234',
'D');
407 $pdf->SetXY(80, $posY);
408 if (
$object->frstrecur ==
'FRST') {
409 $pdf->MultiCell(5, 3,
'X', 0,
'L');
411 $pdf->SetXY(86, $posY);
412 $txt = $langs->transnoentitiesnoconv(
"ModeFRST");
413 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
414 if (empty(
$object->frstrecur)) {
416 $pdf->SetXY(80, $posY);
417 $txt =
'('.$langs->transnoentitiesnoconv(
"PleaseCheckOne").
')';
418 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
421 $posY = $pdf->GetY();
423 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
429 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0);
430 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
432 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0);
433 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
449 if (method_exists($pdf,
'AliasNbPages')) {
450 $pdf->AliasNbPages();
455 $pdf->Output($file,
'F');
458 if (!is_object($hookmanager)) {
459 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
462 $hookmanager->initHooks(array(
'pdfgeneration'));
463 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
465 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
466 $this->warnings = $hookmanager->warnings;
468 $this->error = $hookmanager->error;
469 $this->errors = $hookmanager->errors;
476 $this->result = array(
'fullpath' => $file);
480 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
485 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
611 $pdf->SetTextColor(0, 0, 60);
612 $pdf->SetFont(
'',
'B', $default_font_size + 3);
614 $posx = $this->page_largeur - $this->marge_droite - 100;
615 $posy = $this->marge_haute;
617 $pdf->SetXY($this->marge_gauche, $posy);
620 $logo =
$conf->mycompany->dir_output.
'/logos/'.
$mysoc->logo;
622 if (is_readable($logo)) {
624 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
626 $pdf->SetTextColor(200, 0, 0);
627 $pdf->SetFont(
'',
'B', $default_font_size - 2);
628 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
629 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
632 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
635 $pdf->SetFont(
'',
'B', $default_font_size + 3);
636 $pdf->SetXY($posx, $posy);
637 $pdf->SetTextColor(0, 0, 60);
638 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"SepaMandate"),
'',
'R');
639 $pdf->SetFont(
'',
'', $default_font_size + 2);
642 $pdf->SetXY($posx, $posy);
643 $pdf->SetTextColor(0, 0, 60);
644 $daterum =
'__________________';
645 if (!empty(
$object->date_rum)) {
650 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
656 $pdf->SetTextColor(0, 0, 60);