128 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
131 global $conf, $hookmanager, $langs, $user, $mysoc;
134 dol_syslog(get_class($this).
"::write_file object is of type ".get_class(
$object).
" which is not expected", LOG_ERR);
138 if (!is_object($outputlangs)) {
139 $outputlangs = $langs;
143 $outputlangs->charset_output =
'ISO-8859-1';
147 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
149 if (!empty($conf->bank->dir_output)) {
154 if (!empty($moreparams[
'force_dir_output'])) {
155 $dir = $moreparams[
'force_dir_output'];
157 $dir = $conf->bank->dir_output;
159 $file = $dir.
"/SPECIMEN.pdf";
162 if (!empty($moreparams[
'force_dir_output'])) {
163 $dir = $moreparams[
'force_dir_output'];
165 $dir = $conf->bank->dir_output.
"/".$objectref;
170 if (!file_exists($dir)) {
172 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
177 if (file_exists($dir)) {
179 if (!is_object($hookmanager)) {
180 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
183 $hookmanager->initHooks(array(
'pdfgeneration'));
184 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
186 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
192 $this->heightforfooter += 6;
194 $pdf->SetAutoPageBreak(1, 0);
196 if (class_exists(
'TCPDF')) {
197 $pdf->setPrintHeader(
false);
198 $pdf->setPrintFooter(
false);
204 $pdf->SetDrawColor(128, 128, 128);
206 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
207 $pdf->SetSubject($outputlangs->transnoentities(
"SepaMandate"));
208 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
209 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
210 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"SepaMandate"));
212 $pdf->SetCompression(
false);
216 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
222 $pdf->SetFont(
'',
'', $default_font_size - 1);
223 $pdf->MultiCell(0, 3,
'');
224 $pdf->SetTextColor(0, 0, 0);
227 $tab_top_newpage = 40;
229 $tab_height = $this->page_hauteur - $tab_top - $this->heightforfooter - $this->heightforfreetext ;
232 if (!empty(
$object->note_public)) {
233 $pdf->SetFont(
'',
'', $default_font_size - 1);
235 $nexY = $pdf->GetY();
236 $height_note = $nexY - ($tab_top - 2);
239 $pdf->SetDrawColor(192, 192, 192);
240 $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
242 $tab_height = $tab_height - $height_note;
243 $tab_top = $nexY + 6;
248 $iniY = $tab_top + 7;
249 $curY = $tab_top + 7;
250 $nexY = $tab_top + 7;
254 $pdf->SetFont(
'',
'', $default_font_size - 1);
256 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
259 $pdf->SetXY($this->marge_gauche, $posY);
260 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"RUMLong").
' ('.$outputlangs->transnoentitiesnoconv(
"RUM").
') : '.
$object->rum, 0,
'L');
262 $posY = $pdf->GetY();
264 $pdf->SetXY($this->marge_gauche, $posY);
268 if ($idbankfordirectdebit > 0) {
269 $tmpbankfordirectdebit =
new Account($this->db);
270 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
271 $ics = $tmpbankfordirectdebit->ics;
276 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
278 $posY = $pdf->GetY();
280 $pdf->SetXY($this->marge_gauche, $posY);
281 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorName").
' : '.$mysoc->name, 0,
'L');
283 $posY = $pdf->GetY();
285 $pdf->SetXY($this->marge_gauche, $posY);
286 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
287 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0,
'L');
289 $posY = $pdf->GetY();
292 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
294 $pdf->SetFont(
'',
'', $default_font_size - 1);
297 $pdf->SetXY($this->marge_gauche, $posY);
298 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv(
"SEPALegalText", $mysoc->name, $mysoc->name), 0,
'L');
301 $posY = $pdf->GetY();
303 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
306 $pdf->SetFont(
'',
'', $default_font_size - 2);
308 $pdf->SetXY($this->marge_gauche, $posY);
309 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFillForm"), 0,
'C');
311 $thirdparty =
new Societe($this->db);
313 $thirdparty->fetch(
$object->socid);
316 $sepaname =
'______________________________________________';
317 if ($thirdparty->id > 0) {
318 $sepaname = $thirdparty->name.($object->owner_name ?
' ('.$object->owner_name.
')' :
'');
320 $posY = $pdf->GetY();
322 $pdf->SetXY($this->marge_gauche, $posY);
323 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourName").
' * : ', 0,
'L');
324 $pdf->SetXY(80, $posY);
325 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0,
'L');
327 $sepavatid =
'__________________________________________________';
328 if (!empty($thirdparty->idprof1)) {
329 $sepavatid = $thirdparty->idprof1;
331 $posY = $pdf->GetY();
333 $pdf->SetXY($this->marge_gauche, $posY);
334 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
'ProfId1'.$thirdparty->country_code).
' * : ', 0,
'L');
335 $pdf->SetXY(80, $posY);
336 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0,
'L');
338 $address =
'__________________________________________________';
339 if (!empty(
$object->owner_address)) {
340 $address =
$object->owner_address;
341 } elseif ($thirdparty->id > 0) {
342 $tmpaddresswithoutcountry = $thirdparty->getFullAddress();
343 if ($tmpaddresswithoutcountry) {
344 $address = $thirdparty->getFullAddress(1);
347 $posY = $pdf->GetY();
349 $pdf->SetXY($this->marge_gauche, $posY);
350 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
351 $pdf->SetXY(80, $posY);
352 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
353 if (preg_match(
'/_____/', $address)) {
355 $pdf->SetXY(80, $posY);
356 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
359 $ban =
'__________________________________________________';
363 $posY = $pdf->GetY();
365 $pdf->SetXY($this->marge_gauche, $posY);
366 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBAN").
' * : ', 0,
'L');
367 $pdf->SetXY(80, $posY);
368 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0,
'L');
370 $bic =
'__________________________________________________';
374 $posY = $pdf->GetY();
376 $pdf->SetXY($this->marge_gauche, $posY);
377 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBIC").
' * : ', 0,
'L');
378 $pdf->SetXY(80, $posY);
379 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0,
'L');
382 $posY = $pdf->GetY();
384 $pdf->SetXY($this->marge_gauche, $posY);
385 $txt = $outputlangs->transnoentitiesnoconv(
"SEPAFrstOrRecur").
' * : ';
386 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
387 $pdf->Rect(80, $posY, 5, 5);
388 $pdf->SetXY(80, $posY);
389 if (
$object->frstrecur ==
'RCUR') {
390 $pdf->MultiCell(5, 3,
'X', 0,
'L');
392 $pdf->SetXY(86, $posY);
393 $txt = $langs->transnoentitiesnoconv(
"ModeRECUR").
' '.$langs->transnoentitiesnoconv(
"or");
394 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
396 $pdf->Rect(80, $posY, 5, 5);
397 $pdf->SetXY(80, $posY);
398 if (
$object->frstrecur ==
'FRST') {
399 $pdf->MultiCell(5, 3,
'X', 0,
'L');
401 $pdf->SetXY(86, $posY);
402 $txt = $langs->transnoentitiesnoconv(
"ModeFRST");
403 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
404 if (empty(
$object->frstrecur)) {
406 $pdf->SetXY(80, $posY);
407 $txt =
'('.$langs->transnoentitiesnoconv(
"PleaseCheckOne").
')';
408 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
411 $posY = $pdf->GetY();
413 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
419 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 0, 0);
420 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
422 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter, 0, $outputlangs, 1, 0);
423 $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter + 1;
439 if (method_exists($pdf,
'AliasNbPages')) {
440 $pdf->AliasNbPages();
445 $pdf->Output($file,
'F');
448 if (!is_object($hookmanager)) {
449 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
452 $hookmanager->initHooks(array(
'pdfgeneration'));
453 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
455 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
457 $this->error = $hookmanager->error;
458 $this->errors = $hookmanager->errors;
463 $this->result = array(
'fullpath' => $file);
467 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
472 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
591 global $langs, $conf, $mysoc;
597 $pdf->SetTextColor(0, 0, 60);
598 $pdf->SetFont(
'',
'B', $default_font_size + 3);
600 $posx = $this->page_largeur - $this->marge_droite - 100;
601 $posy = $this->marge_haute;
603 $pdf->SetXY($this->marge_gauche, $posy);
606 $logo = $conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
608 if (is_readable($logo)) {
610 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
612 $pdf->SetTextColor(200, 0, 0);
613 $pdf->SetFont(
'',
'B', $default_font_size - 2);
614 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
615 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
618 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
621 $pdf->SetFont(
'',
'B', $default_font_size + 3);
622 $pdf->SetXY($posx, $posy);
623 $pdf->SetTextColor(0, 0, 60);
624 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"SepaMandate"),
'',
'R');
625 $pdf->SetFont(
'',
'', $default_font_size + 2);
628 $pdf->SetXY($posx, $posy);
629 $pdf->SetTextColor(0, 0, 60);
630 $daterum =
'__________________';
631 if (!empty(
$object->date_rum)) {
636 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
642 $pdf->SetTextColor(0, 0, 60);