134 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
137 global
$conf, $hookmanager, $langs, $user, $mysoc;
140 dol_syslog(get_class($this).
"::write_file object is of type ".get_class(
$object).
" which is not expected", LOG_ERR);
144 if (!is_object($outputlangs)) {
145 $outputlangs = $langs;
149 $outputlangs->charset_output =
'ISO-8859-1';
153 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
155 if (!empty(
$conf->bank->dir_output)) {
160 if (!empty($moreparams[
'force_dir_output'])) {
161 $dir = $moreparams[
'force_dir_output'];
163 $dir =
$conf->bank->dir_output;
165 $file = $dir.
"/SPECIMEN.pdf";
168 if (!empty($moreparams[
'force_dir_output'])) {
169 $dir = $moreparams[
'force_dir_output'];
171 $dir =
$conf->bank->dir_output.
"/".$objectref;
176 if (!file_exists($dir)) {
178 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
183 if (file_exists($dir)) {
185 if (!is_object($hookmanager)) {
186 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
189 $hookmanager->initHooks(array(
'pdfgeneration'));
190 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
192 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
198 $this->heightforfooter += 6;
200 $pdf->SetAutoPageBreak(1, 0);
202 if (class_exists(
'TCPDF')) {
203 $pdf->setPrintHeader(
false);
204 $pdf->setPrintFooter(
false);
210 $pdf->SetDrawColor(128, 128, 128);
212 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
213 $pdf->SetSubject($outputlangs->transnoentities(
"SepaMandate"));
214 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
215 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
216 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"SepaMandate"));
218 $pdf->SetCompression(
false);
222 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
228 $pdf->SetFont(
'',
'', $default_font_size - 1);
229 $pdf->MultiCell(0, 3,
'');
230 $pdf->SetTextColor(0, 0, 0);
233 $tab_top_newpage = 40;
235 $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ;
238 if (!empty(
$object->note_public)) {
239 $pdf->SetFont(
'',
'', $default_font_size - 1);
241 $nexY = $pdf->GetY();
242 $height_note = $nexY - ($tab_top - 2);
245 $pdf->SetDrawColor(192, 192, 192);
246 $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');
248 $tab_height -= $height_note;
249 $tab_top = $nexY + 6;
254 $iniY = $tab_top + 7;
255 $curY = $tab_top + 7;
256 $nexY = $tab_top + 7;
260 $pdf->SetFont(
'',
'', $default_font_size - 1);
262 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
265 $pdf->SetXY($this->marge_gauche, $posY);
266 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"RUMLong").
' ('.$outputlangs->transnoentitiesnoconv(
"RUM").
') : '.
$object->rum, 0,
'L');
268 $posY = $pdf->GetY();
270 $pdf->SetXY($this->marge_gauche, $posY);
274 if ($idbankfordirectdebit > 0) {
275 $tmpbankfordirectdebit =
new Account($this->db);
276 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
277 $ics = $tmpbankfordirectdebit->ics;
282 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
284 $posY = $pdf->GetY();
286 $pdf->SetXY($this->marge_gauche, $posY);
287 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorName").
' : '.$mysoc->name, 0,
'L');
289 $posY = $pdf->GetY();
291 $pdf->SetXY($this->marge_gauche, $posY);
292 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
293 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0,
'L');
295 $posY = $pdf->GetY();
298 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
300 $pdf->SetFont(
'',
'', $default_font_size - 1);
303 $pdf->SetXY($this->marge_gauche, $posY);
304 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv(
"SEPALegalText", $mysoc->name, $mysoc->name), 0,
'L');
307 $posY = $pdf->GetY();
309 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
312 $pdf->SetFont(
'',
'', $default_font_size - 2);
314 $pdf->SetXY($this->marge_gauche, $posY);
315 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFillForm"), 0,
'C');
317 $thirdparty =
new Societe($this->db);
319 $thirdparty->fetch(
$object->socid);
322 $sepaname =
'______________________________________________';
323 if ($thirdparty->id > 0) {
324 $sepaname = $thirdparty->name.($object->owner_name ?
' ('.$object->owner_name.
')' :
'');
326 $posY = $pdf->GetY();
328 $pdf->SetXY($this->marge_gauche, $posY);
329 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourName").
' * : ', 0,
'L');
330 $pdf->SetXY(80, $posY);
331 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0,
'L');
333 $sepavatid =
'__________________________________________________';
334 if (!empty($thirdparty->idprof1)) {
335 $sepavatid = $thirdparty->idprof1;
337 $posY = $pdf->GetY();
339 $pdf->SetXY($this->marge_gauche, $posY);
340 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
'ProfId1'.$thirdparty->country_code).
' * : ', 0,
'L');
341 $pdf->SetXY(80, $posY);
342 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0,
'L');
344 $address =
'__________________________________________________';
345 if (!empty(
$object->owner_address)) {
346 $address =
$object->owner_address;
347 } elseif ($thirdparty->id > 0) {
348 $tmpaddresswithoutcountry = $thirdparty->getFullAddress();
349 if ($tmpaddresswithoutcountry) {
350 $address = $thirdparty->getFullAddress(1);
353 $posY = $pdf->GetY();
355 $pdf->SetXY($this->marge_gauche, $posY);
356 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
357 $pdf->SetXY(80, $posY);
358 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
359 if (preg_match(
'/_____/', $address)) {
361 $pdf->SetXY(80, $posY);
362 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
365 $ban =
'__________________________________________________';
369 $posY = $pdf->GetY();
371 $pdf->SetXY($this->marge_gauche, $posY);
372 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBAN").
' * : ', 0,
'L');
373 $pdf->SetXY(80, $posY);
374 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0,
'L');
376 $bic =
'__________________________________________________';
380 $posY = $pdf->GetY();
382 $pdf->SetXY($this->marge_gauche, $posY);
383 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBIC").
' * : ', 0,
'L');
384 $pdf->SetXY(80, $posY);
385 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0,
'L');
388 $posY = $pdf->GetY();
390 $pdf->SetXY($this->marge_gauche, $posY);
391 $txt = $outputlangs->transnoentitiesnoconv(
"SEPAFrstOrRecur").
' * : ';
392 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
393 $pdf->RoundedRect(80, $posY, 5, 5, $this->corner_radius,
'1234',
'D');
394 $pdf->SetXY(80, $posY);
395 if (
$object->frstrecur ==
'RCUR') {
396 $pdf->MultiCell(5, 3,
'X', 0,
'L');
398 $pdf->SetXY(86, $posY);
399 $txt = $langs->transnoentitiesnoconv(
"ModeRECUR").
' '.$langs->transnoentitiesnoconv(
"or");
400 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
402 $pdf->RoundedRect(80, $posY, 5, 5, $this->corner_radius,
'1234',
'D');
403 $pdf->SetXY(80, $posY);
404 if (
$object->frstrecur ==
'FRST') {
405 $pdf->MultiCell(5, 3,
'X', 0,
'L');
407 $pdf->SetXY(86, $posY);
408 $txt = $langs->transnoentitiesnoconv(
"ModeFRST");
409 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
410 if (empty(
$object->frstrecur)) {
412 $pdf->SetXY(80, $posY);
413 $txt =
'('.$langs->transnoentitiesnoconv(
"PleaseCheckOne").
')';
414 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
417 $posY = $pdf->GetY();
419 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
425 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0);
426 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
428 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0);
429 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
445 if (method_exists($pdf,
'AliasNbPages')) {
446 $pdf->AliasNbPages();
451 $pdf->Output($file,
'F');
454 if (!is_object($hookmanager)) {
455 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
458 $hookmanager->initHooks(array(
'pdfgeneration'));
459 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
461 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
463 $this->error = $hookmanager->error;
464 $this->errors = $hookmanager->errors;
469 $this->result = array(
'fullpath' => $file);
473 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
478 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
598 global $langs,
$conf, $mysoc;
604 $pdf->SetTextColor(0, 0, 60);
605 $pdf->SetFont(
'',
'B', $default_font_size + 3);
607 $posx = $this->page_largeur - $this->marge_droite - 100;
608 $posy = $this->marge_haute;
610 $pdf->SetXY($this->marge_gauche, $posy);
613 $logo =
$conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
615 if (is_readable($logo)) {
617 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
619 $pdf->SetTextColor(200, 0, 0);
620 $pdf->SetFont(
'',
'B', $default_font_size - 2);
621 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
622 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
625 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
628 $pdf->SetFont(
'',
'B', $default_font_size + 3);
629 $pdf->SetXY($posx, $posy);
630 $pdf->SetTextColor(0, 0, 60);
631 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"SepaMandate"),
'',
'R');
632 $pdf->SetFont(
'',
'', $default_font_size + 2);
635 $pdf->SetXY($posx, $posy);
636 $pdf->SetTextColor(0, 0, 60);
637 $daterum =
'__________________';
638 if (!empty(
$object->date_rum)) {
643 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
649 $pdf->SetTextColor(0, 0, 60);