105 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
108 global $conf, $hookmanager, $langs, $user, $mysoc;
110 if (!is_object($outputlangs)) {
111 $outputlangs = $langs;
114 if (!empty($conf->global->MAIN_USE_FPDF)) {
115 $outputlangs->charset_output =
'ISO-8859-1';
119 $outputlangs->loadLangs(array(
"main",
"dict",
"withdrawals",
"companies",
"projects",
"bills"));
121 if (!empty($conf->bank->dir_output)) {
125 if ($object->specimen) {
126 if (!empty($moreparams[
'force_dir_output'])) {
127 $dir = $moreparams[
'force_dir_output'];
129 $dir = $conf->bank->dir_output;
131 $file = $dir.
"/SPECIMEN.pdf";
134 if (!empty($moreparams[
'force_dir_output'])) {
135 $dir = $moreparams[
'force_dir_output'];
137 $dir = $conf->bank->dir_output.
"/".$objectref;
139 $file = $dir.
"/".$langs->transnoentitiesnoconv(
"SepaMandateShort").
' '.$objectref.
"-".
dol_sanitizeFileName($object->rum).
".pdf";
142 if (!file_exists($dir)) {
144 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
149 if (file_exists($dir)) {
151 if (!is_object($hookmanager)) {
152 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
155 $hookmanager->initHooks(array(
'pdfgeneration'));
156 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
158 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
162 $heightforinfotot = 50;
163 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
164 $heightforfooter = $this->marge_basse + 8;
165 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
166 $heightforfooter += 6;
168 $pdf->SetAutoPageBreak(1, 0);
170 if (class_exists(
'TCPDF')) {
171 $pdf->setPrintHeader(
false);
172 $pdf->setPrintFooter(
false);
178 $pdf->SetDrawColor(128, 128, 128);
180 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
181 $pdf->SetSubject($outputlangs->transnoentities(
"SepaMandate"));
182 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
183 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
184 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"SepaMandate"));
186 $pdf->SetCompression(
false);
189 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
194 $this->
_pagehead($pdf, $object, 1, $outputlangs);
195 $pdf->SetFont(
'',
'', $default_font_size - 1);
196 $pdf->MultiCell(0, 3,
'');
197 $pdf->SetTextColor(0, 0, 0);
200 $tab_top_newpage = 40;
202 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
205 if (!empty($object->note_public)) {
206 $pdf->SetFont(
'',
'', $default_font_size - 1);
207 $pdf->writeHTMLCell(190, 3, $this->posxref, $tab_top - 2,
dol_htmlentitiesbr($object->note_public), 0, 1);
208 $nexY = $pdf->GetY();
209 $height_note = $nexY - ($tab_top - 2);
212 $pdf->SetDrawColor(192, 192, 192);
213 $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
215 $tab_height = $tab_height - $height_note;
216 $tab_top = $nexY + 6;
221 $iniY = $tab_top + 7;
222 $curY = $tab_top + 7;
223 $nexY = $tab_top + 7;
227 $pdf->SetFont(
'',
'', $default_font_size);
229 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
232 $pdf->SetXY($this->marge_gauche, $posY);
233 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"RUMLong").
' ('.$outputlangs->transnoentitiesnoconv(
"RUM").
') : '.$object->rum, 0,
'L');
235 $posY = $pdf->GetY();
237 $pdf->SetXY($this->marge_gauche, $posY);
241 if ($idbankfordirectdebit > 0) {
242 $tmpbankfordirectdebit =
new Account($this->db);
243 $tmpbankfordirectdebit->fetch($idbankfordirectdebit);
244 $ics = $tmpbankfordirectdebit->ics;
246 if (empty($ics) && !empty($conf->global->PRELEVEMENT_ICS)) {
247 $ics = $conf->global->PRELEVEMENT_ICS;
249 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorIdentifier").
' ('.$outputlangs->transnoentitiesnoconv(
"ICS").
') : '.$ics, 0,
'L');
251 $posY = $pdf->GetY();
253 $pdf->SetXY($this->marge_gauche, $posY);
254 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"CreditorName").
' : '.$mysoc->name, 0,
'L');
256 $posY = $pdf->GetY();
258 $pdf->SetXY($this->marge_gauche, $posY);
259 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
260 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $mysoc->getFullAddress(1), 0,
'L');
262 $posY = $pdf->GetY();
265 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
267 $pdf->SetFont(
'',
'', $default_font_size - 1);
270 $pdf->SetXY($this->marge_gauche, $posY);
271 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 8, $outputlangs->transnoentitiesnoconv(
"SEPALegalText", $mysoc->name, $mysoc->name), 0,
'L');
274 $posY = $pdf->GetY();
276 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
279 $pdf->SetFont(
'',
'', $default_font_size);
281 $pdf->SetXY($this->marge_gauche, $posY);
282 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFillForm"), 0,
'C');
284 $thirdparty =
new Societe($this->db);
285 if ($object->socid > 0) {
286 $thirdparty->fetch($object->socid);
289 $sepaname =
'______________________________________________';
290 if ($thirdparty->id > 0) {
291 $sepaname = $thirdparty->name.($object->proprio ?
' ('.$object->proprio.
')' :
'');
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(
"SEPAFormYourName").
' * : ', 0,
'L');
297 $pdf->SetXY(80, $posY);
298 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepaname, 0,
'L');
300 $sepavatid =
'__________________________________________________';
301 if (!empty($thirdparty->idprof1)) {
302 $sepavatid = $thirdparty->idprof1;
304 $posY = $pdf->GetY();
306 $pdf->SetXY($this->marge_gauche, $posY);
307 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
'ProfId1'.$thirdparty->country_code).
' * : ', 0,
'L');
308 $pdf->SetXY(80, $posY);
309 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $sepavatid, 0,
'L');
311 $address =
'______________________________________________';
312 if ($thirdparty->id > 0) {
313 $tmpaddresswithoutcountry = $thirdparty->getFullAddress();
314 if ($tmpaddresswithoutcountry) {
315 $address = $thirdparty->getFullAddress(1);
318 $posY = $pdf->GetY();
320 $pdf->SetXY($this->marge_gauche, $posY);
321 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"Address").
' : ', 0,
'L');
322 $pdf->SetXY(80, $posY);
323 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
324 if (preg_match(
'/_____/', $address)) {
326 $pdf->SetXY(80, $posY);
327 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0,
'L');
330 $ban =
'__________________________________________________';
331 if (!empty($object->iban)) {
332 $ban = $object->iban;
334 $posY = $pdf->GetY();
336 $pdf->SetXY($this->marge_gauche, $posY);
337 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBAN").
' * : ', 0,
'L');
338 $pdf->SetXY(80, $posY);
339 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $ban, 0,
'L');
341 $bic =
'__________________________________________________';
342 if (!empty($object->bic)) {
345 $posY = $pdf->GetY();
347 $pdf->SetXY($this->marge_gauche, $posY);
348 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $outputlangs->transnoentitiesnoconv(
"SEPAFormYourBIC").
' * : ', 0,
'L');
349 $pdf->SetXY(80, $posY);
350 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $bic, 0,
'L');
353 $posY = $pdf->GetY();
355 $pdf->SetXY($this->marge_gauche, $posY);
356 $txt = $outputlangs->transnoentitiesnoconv(
"SEPAFrstOrRecur").
' * : ';
357 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
358 $pdf->Rect(80, $posY, 5, 5);
359 $pdf->SetXY(80, $posY);
360 if ($object->frstrecur ==
'RECUR') {
361 $pdf->MultiCell(5, 3,
'X', 0,
'L');
363 $pdf->SetXY(86, $posY);
364 $txt = $langs->transnoentitiesnoconv(
"ModeRECUR").
' '.$langs->transnoentitiesnoconv(
"or");
365 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
367 $pdf->Rect(80, $posY, 5, 5);
368 $pdf->SetXY(80, $posY);
369 if ($object->frstrecur ==
'FRST') {
370 $pdf->MultiCell(5, 3,
'X', 0,
'L');
372 $pdf->SetXY(86, $posY);
373 $txt = $langs->transnoentitiesnoconv(
"ModeFRST");
374 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
375 if (empty($object->frstrecur)) {
377 $pdf->SetXY(80, $posY);
378 $txt =
'('.$langs->transnoentitiesnoconv(
"PleaseCheckOne").
')';
379 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0,
'L');
382 $posY = $pdf->GetY();
384 $pdf->line($this->marge_gauche, $posY, $this->page_largeur - $this->marge_droite, $posY);
390 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
391 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
393 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
394 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
404 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
409 $this->
_pagefoot($pdf, $object, $outputlangs);
410 if (method_exists($pdf,
'AliasNbPages')) {
411 $pdf->AliasNbPages();
416 $pdf->Output($file,
'F');
419 if (!is_object($hookmanager)) {
420 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
423 $hookmanager->initHooks(array(
'pdfgeneration'));
424 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
426 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
428 $this->error = $hookmanager->error;
429 $this->errors = $hookmanager->errors;
434 $this->result = array(
'fullpath'=>$file);
438 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
443 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"DELIVERY_OUTPUTDIR");
560 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
563 global $langs, $conf, $mysoc;
569 $pdf->SetTextColor(0, 0, 60);
570 $pdf->SetFont(
'',
'B', $default_font_size + 3);
572 $posx = $this->page_largeur - $this->marge_droite - 100;
573 $posy = $this->marge_haute;
575 $pdf->SetXY($this->marge_gauche, $posy);
578 $logo = $conf->mycompany->dir_output.
'/logos/'.$mysoc->logo;
580 if (is_readable($logo)) {
582 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
584 $pdf->SetTextColor(200, 0, 0);
585 $pdf->SetFont(
'',
'B', $default_font_size - 2);
586 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
587 $pdf->MultiCell(100, 3, $langs->transnoentities(
"ErrorGoToModuleSetup"), 0,
'L');
590 $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0,
'L');
593 $pdf->SetFont(
'',
'B', $default_font_size + 3);
594 $pdf->SetXY($posx, $posy);
595 $pdf->SetTextColor(0, 0, 60);
596 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"SepaMandate"),
'',
'R');
597 $pdf->SetFont(
'',
'', $default_font_size + 2);
600 $pdf->SetXY($posx, $posy);
601 $pdf->SetTextColor(0, 0, 60);
602 $daterum =
'__________________';
603 if (!empty($object->date_rum)) {
604 $daterum =
dol_print_date($object->date_rum,
'day',
false, $outputlangs,
true);
606 $daterum =
dol_print_date($object->datec,
'day',
false, $outputlangs,
true);
608 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".$daterum,
'',
'R');
614 $pdf->SetTextColor(0, 0, 60);