47 global $conf, $db, $langs;
49 dol_syslog(
"pdf_getFormat Get paper format with mode=".$mode.
" MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT) ?
'null' : $conf->global->MAIN_PDF_FORMAT).
" outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null').
" and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang :
'null'));
52 $width = 210; $height = 297; $unit =
'mm';
54 if ($mode ==
'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT ==
'auto')
56 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
59 $pdfformat = $conf->global->MAIN_PDF_FORMAT;
62 $sql =
"SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX.
"c_paper_format";
63 $sql .=
" WHERE code = '".$db->escape($pdfformat).
"'";
67 $obj = $db->fetch_object(
$resql);
70 $width = (int) $obj->width;
71 $height = (
int) $obj->height;
77 return array(
'width'=>$width,
'height'=>$height,
'unit'=>$unit);
93 if (!defined(
'K_TCPDF_EXTERNAL_CONFIG'))
95 define(
'K_TCPDF_EXTERNAL_CONFIG', 1);
96 define(
'K_PATH_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
97 define(
'K_PATH_URL_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
99 define(
'K_BLANK_IMAGE',
'_blank.png');
100 define(
'PDF_PAGE_FORMAT',
'A4');
101 define(
'PDF_PAGE_ORIENTATION',
'P');
102 define(
'PDF_CREATOR',
'TCPDF');
103 define(
'PDF_AUTHOR',
'TCPDF');
104 define(
'PDF_HEADER_TITLE',
'TCPDF Example');
105 define(
'PDF_HEADER_STRING',
"by Dolibarr ERP CRM");
106 define(
'PDF_UNIT',
'mm');
107 define(
'PDF_MARGIN_HEADER', 5);
108 define(
'PDF_MARGIN_FOOTER', 10);
109 define(
'PDF_MARGIN_TOP', 27);
110 define(
'PDF_MARGIN_BOTTOM', 25);
111 define(
'PDF_MARGIN_LEFT', 15);
112 define(
'PDF_MARGIN_RIGHT', 15);
113 define(
'PDF_FONT_NAME_MAIN',
'helvetica');
114 define(
'PDF_FONT_SIZE_MAIN', 10);
115 define(
'PDF_FONT_NAME_DATA',
'helvetica');
116 define(
'PDF_FONT_SIZE_DATA', 8);
117 define(
'PDF_FONT_MONOSPACED',
'courier');
118 define(
'PDF_IMAGE_SCALE_RATIO', 1.25);
119 define(
'HEAD_MAGNIFICATION', 1.1);
120 define(
'K_CELL_HEIGHT_RATIO', 1.25);
121 define(
'K_TITLE_MAGNIFICATION', 1.3);
122 define(
'K_SMALL_RATIO', 2 / 3);
123 define(
'K_THAI_TOPCHARS',
true);
124 define(
'K_TCPDF_CALLS_IN_HTML',
true);
125 if (!empty($conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE)) {
126 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
true);
128 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
false);
133 require_once TCPDF_PATH.
'tcpdf.php';
136 if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.
'tcpdi.php';
143 if (!empty($conf->global->PDF_USE_1A)) $pdfa =
true;
145 if (class_exists(
'TCPDI')) $pdf =
new TCPDI($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
146 else $pdf =
new TCPDF($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
149 if (!empty($conf->global->PDF_SECURITY_ENCRYPTION))
164 $pdfrights = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS,
true) : array(
'modify',
'copy'));
167 $pdfuserpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS :
'');
170 $pdfownerpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS : null);
173 $encstrength = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH) ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0);
177 $pubkeys = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS,
true) : null);
179 $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys);
193 require_once TCPDF_PATH.
'tcpdf_parser.php';
195 $isencrypted =
false;
197 $content = file_get_contents($pathoffile);
200 @($parser = new \TCPDF_PARSER(ltrim($content)));
201 list($xref, $data) = $parser->getParsedData();
205 if (isset($xref[
'trailer'][
'encrypt'])) {
226 if (!empty($conf->global->MAIN_PDF_FORCE_FONT))
return $conf->global->MAIN_PDF_FORCE_FONT;
229 if (class_exists(
'TCPDF'))
231 if ($outputlangs->trans(
'FONTFORPDF') !=
'FONTFORPDF')
233 $font = $outputlangs->trans(
'FONTFORPDF');
250 if (class_exists(
'TCPDF'))
252 if ($outputlangs->trans(
'FONTSIZEFORPDF') !=
'FONTSIZEFORPDF')
254 $size = (int) $outputlangs->trans(
'FONTSIZEFORPDF');
257 if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE;
273 $height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 20 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
275 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
279 $width = round($height * $tmp[
'width'] / $tmp[
'height']);
280 if ($width > $maxwidth) $height = $height * $maxwidth / $width;
297 $pdf->startTransaction();
299 $start_y = $pdf->GetY();
301 $start_page = $pdf->getPage();
303 $pdf->writeHTMLCell(0, 0, 0, $start_y, $htmlcontent, 0, 1,
false,
true,
'J',
true);
305 $end_y = $pdf->GetY();
306 $end_page = $pdf->getPage();
309 if ($end_page == $start_page) {
310 $height = $end_y - $start_y;
312 for ($page = $start_page; $page <= $end_page; ++$page) {
313 $pdf->setPage($page);
314 $tmpm = $pdf->getMargins();
315 $tMargin = $tmpm[
'top'];
316 if ($page == $start_page) {
318 $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin();
319 } elseif ($page == $end_page) {
321 $height = $end_y - $tMargin;
323 $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin();
328 $pdf = $pdf->rollbackTransaction();
349 if ($thirdparty instanceof
Societe) {
350 $socname .= $thirdparty->name;
351 if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) {
352 $socname .=
" - ".$thirdparty->name_alias;
354 } elseif ($thirdparty instanceof
Contact) {
355 $socname = $thirdparty->socname;
357 throw new InvalidArgumentException(
'Parameter 1 $thirdparty is not a Societe nor Contact');
376 function pdf_build_address($outputlangs, $sourcecompany, $targetcompany =
'', $targetcontact =
'', $usecontact = 0, $mode =
'source', $object = null)
378 global $conf, $hookmanager;
380 if ($mode ==
'source' && !is_object($sourcecompany))
return -1;
381 if ($mode ==
'target' && !is_object($targetcompany))
return -1;
383 if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state =
getState($sourcecompany->state_id);
384 if (!empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state =
getState($targetcompany->state_id);
388 if (is_object($hookmanager))
390 $parameters = array(
'sourcecompany' => &$sourcecompany,
'targetcompany' => &$targetcompany,
'targetcontact' => &$targetcontact,
'outputlangs' => $outputlangs,
'mode' => $mode,
'usecontact' => $usecontact);
392 $reshook = $hookmanager->executeHooks(
'pdf_build_address', $parameters, $object, $action);
393 $stringaddress .= $hookmanager->resPrint;
397 if ($mode ==
'source')
400 if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1;
402 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($sourcecompany, $withCountry,
"\n", $outputlangs)).
"\n";
404 if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS))
407 if ($sourcecompany->phone) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"PhoneShort").
": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
409 if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
411 if ($sourcecompany->email) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($sourcecompany->email);
413 if ($sourcecompany->url) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($sourcecompany->url);
416 if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS))
418 if ($sourcecompany->tva_intra) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
422 if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1))
424 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $sourcecompany->country_code);
425 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
426 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
428 if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2))
430 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $sourcecompany->country_code);
431 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
432 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
434 if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3))
436 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $sourcecompany->country_code);
437 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
438 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
440 if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4))
442 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $sourcecompany->country_code);
443 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
444 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
446 if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5))
448 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $sourcecompany->country_code);
449 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
450 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
452 if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6))
454 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $sourcecompany->country_code);
455 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
456 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
458 if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) {
459 $stringaddress .= ($stringaddress ?
"\n" :
'').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS;
463 if ($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode))
467 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
469 if (!empty($targetcontact->address)) {
470 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcontact));
472 $companytouseforaddress = $targetcompany;
475 if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id)
477 $targetcontact->fetch_thirdparty();
478 $companytouseforaddress = $targetcontact->thirdparty;
481 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($companytouseforaddress));
484 if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
485 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcontact->country_code));
486 } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
487 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
490 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode))
493 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode))
495 if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
496 if (!empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
497 if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) $stringaddress .=
" / ";
498 if (!empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
501 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode))
503 if ($targetcontact->fax) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcontact->fax);
506 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode))
508 if ($targetcontact->email) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcontact->email);
511 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode))
513 if ($targetcontact->url) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcontact->url);
517 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcompany));
519 if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
521 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode))
524 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode))
526 if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
527 if (!empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
528 if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) $stringaddress .=
" / ";
529 if (!empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
532 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode))
534 if ($targetcompany->fax) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcompany->fax);
537 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode))
539 if ($targetcompany->email) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcompany->email);
542 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode))
544 if ($targetcompany->url) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcompany->url);
550 if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))
552 if ($targetcompany->tva_intra) $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
556 if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1))
558 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $targetcompany->country_code);
559 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
560 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
562 if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2))
564 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $targetcompany->country_code);
565 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
566 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
568 if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3))
570 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $targetcompany->country_code);
571 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
572 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
574 if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4))
576 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $targetcompany->country_code);
577 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
578 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
580 if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5))
582 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $targetcompany->country_code);
583 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
584 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
586 if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6))
588 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $targetcompany->country_code);
589 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) $tmp = $reg[1];
590 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
594 if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS))
596 if ($mode ==
'source' && !empty($sourcecompany->note_public))
598 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($sourcecompany->note_public);
600 if (($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) && !empty($targetcompany->note_public))
602 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($targetcompany->note_public);
608 return $stringaddress;
625 if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF))
627 $pdf->SetAutoPageBreak(0, 0);
628 $pdf->Image($conf->mycompany->dir_output.
'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height);
629 $pdf->SetAutoPageBreak(1, 0);
646 $substitutionarray[
'__FROM_NAME__'] =
'__FROM_NAME__';
647 $substitutionarray[
'__FROM_EMAIL__'] =
'__FROM_EMAIL__';
648 return $substitutionarray;
665 global $langs, $mysoc, $user;
668 if ($unit ==
'pt') $k = 1;
669 elseif ($unit ==
'mm') $k = 72 / 25.4;
670 elseif ($unit ==
'cm') $k = 72 / 2.54;
671 elseif ($unit ==
'in') $k = 72;
677 $text = $outputlangs->convToOutputCharset($text);
679 $savx = $pdf->getX(); $savy = $pdf->getY();
681 $watermark_angle = atan($h / $w) / 2;
682 $watermark_x_pos = 0;
683 $watermark_y_pos = $h / 3;
684 $watermark_x = $w / 2;
685 $watermark_y = $h / 3;
686 $pdf->SetFont(
'',
'B', 40);
687 $pdf->SetTextColor(255, 192, 203);
689 $pdf->_out(sprintf(
'q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k));
691 $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
692 $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text),
"", 2,
"C", 0);
696 $pdf->SetXY($savx, $savy);
712 function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
714 global $mysoc, $conf;
716 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbank.class.php';
718 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
719 $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT);
720 $pdf->SetXY($curx, $cury);
722 if (empty($onlynumber))
724 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
725 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByTransferOnThisBankAccount').
':', 0,
'L', 0);
729 $outputlangs->load(
"banks");
732 $bickey =
"BICNumber";
733 if ($account->getCountryCode() ==
'IN') $bickey =
"SWIFT";
736 $usedetailedbban = $account->useDetailedBBAN();
739 if ($usedetailedbban)
743 if (empty($onlynumber))
745 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
746 $pdf->SetXY($curx, $cury);
747 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
751 if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN))
758 if (empty($onlynumber)) $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
761 foreach ($account->getFieldsToShow() as $val)
763 $pdf->SetXY($curx, $cury + 4);
764 $pdf->SetFont(
'',
'', $default_font_size - 3);
766 if ($val ==
'BankCode') {
769 $content = $account->code_banque;
770 } elseif ($val ==
'DeskCode') {
773 $content = $account->code_guichet;
774 } elseif ($val ==
'BankAccountNumber') {
777 $content = $account->number;
778 } elseif ($val ==
'BankAccountNumberKey') {
781 $content = $account->cle_rib;
782 } elseif ($val ==
'IBAN' || $val ==
'BIC') {
787 dol_print_error($account->db,
'Unexpected value for getFieldsToShow: '.$val);
791 $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0,
'C', 0);
792 $pdf->SetXY($curx, $cury + 1);
794 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
795 $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0,
'C', 0);
796 if (empty($onlynumber)) {
797 $pdf->line($curx, $cury + 1, $curx, $cury + 7);
805 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
806 $pdf->SetXY($curx, $cury);
807 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
810 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
811 $pdf->SetXY($curx, $cury);
812 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"BankAccountNumber").
': '.$outputlangs->convToOutputCharset($account->number), 0,
'L', 0);
815 if ($diffsizecontent <= 2) $cury += 1;
818 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
820 if (empty($onlynumber) && !empty($account->domiciliation)) {
821 $pdf->SetXY($curx, $cury);
822 $val = $outputlangs->transnoentities(
"Residence").
': '.$outputlangs->convToOutputCharset($account->domiciliation);
823 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
826 $tmpy = $pdf->getStringHeight(100, $val);
830 if (!empty($account->proprio)) {
831 $pdf->SetXY($curx, $cury);
832 $val = $outputlangs->transnoentities(
"BankAccountOwner").
': '.$outputlangs->convToOutputCharset($account->proprio);
833 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
834 $tmpy = $pdf->getStringHeight(100, $val);
836 } elseif (!$usedetailedbban) {
843 if (!empty($account->iban))
846 $ibanDisplay_temp = str_replace(
' ',
'', $outputlangs->convToOutputCharset($account->iban));
849 $nbIbanDisplay_temp =
dol_strlen($ibanDisplay_temp);
850 for ($i = 0; $i < $nbIbanDisplay_temp; $i++)
852 $ibanDisplay .= $ibanDisplay_temp[$i];
853 if ($i % 4 == 3 && $i > 0) $ibanDisplay .=
" ";
856 $pdf->SetFont(
'',
'B', $default_font_size - 3);
857 $pdf->SetXY($curx, $cury);
858 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).
': '.$ibanDisplay, 0,
'L', 0);
862 if (!empty($account->bic))
864 $pdf->SetFont(
'',
'B', $default_font_size - 3);
865 $pdf->SetXY($curx, $cury);
866 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).
': '.$outputlangs->convToOutputCharset($account->bic), 0,
'L', 0);
887 function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0)
889 global $conf, $user, $mysoc;
891 $outputlangs->load(
"dict");
894 $dims = $pdf->getPageDimensions();
897 if (empty($hidefreetext) && !empty($conf->global->$paramfreetext))
901 $substitutionarray[
'__FROM_NAME__'] = $fromcompany->name;
902 $substitutionarray[
'__FROM_EMAIL__'] = $fromcompany->email;
904 $newfreetext =
make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs);
910 $newfreetext = preg_replace(
'/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/',
'\1file:/'.DOL_DATA_ROOT.
'/medias/\2\3', $newfreetext);
912 $line .= $outputlangs->convToOutputCharset($newfreetext);
916 $line1 =
""; $line2 =
""; $line3 =
""; $line4 =
"";
918 if ($showdetails == 1 || $showdetails == 3)
921 if ($fromcompany->name)
923 $line1 .= ($line1 ?
" - " :
"").$outputlangs->transnoentities(
"RegisteredOffice").
": ".$fromcompany->name;
926 if ($fromcompany->address)
928 $line1 .= ($line1 ?
" - " :
"").str_replace(
"\n",
", ", $fromcompany->address);
931 if ($fromcompany->zip)
933 $line1 .= ($line1 ?
" - " :
"").$fromcompany->zip;
936 if ($fromcompany->town)
938 $line1 .= ($line1 ?
" " :
"").$fromcompany->town;
941 if ($fromcompany->country)
943 $line1 .= ($line1 ?
", " :
"").$fromcompany->country;
946 if ($fromcompany->phone)
948 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Phone").
": ".$fromcompany->phone;
951 if ($fromcompany->fax)
953 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Fax").
": ".$fromcompany->fax;
957 if ($fromcompany->url)
959 $line2 .= ($line2 ?
" - " :
"").$fromcompany->url;
962 if ($fromcompany->email)
964 $line2 .= ($line2 ?
" - " :
"").$fromcompany->email;
967 if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code ==
'DE'))
970 if ($fromcompany->managers)
972 $line2 .= ($line2 ?
" - " :
"").$fromcompany->managers;
978 if ($fromcompany->forme_juridique_code)
980 $line3 .= ($line3 ?
" - " :
"").$outputlangs->convToOutputCharset(
getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
983 if ($fromcompany->capital)
985 $tmpamounttoshow =
price2num($fromcompany->capital);
986 if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf",
price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
987 else $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf", $tmpamounttoshow, $outputlangs);
990 if ($fromcompany->idprof1 && ($fromcompany->country_code !=
'FR' || !$fromcompany->idprof2))
992 $field = $outputlangs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
993 if (preg_match(
'/\((.*)\)/i', $field, $reg)) $field = $reg[1];
994 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
997 if ($fromcompany->idprof2)
999 $field = $outputlangs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
1000 if (preg_match(
'/\((.*)\)/i', $field, $reg)) $field = $reg[1];
1001 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
1006 if ($fromcompany->idprof3)
1008 $field = $outputlangs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
1009 if (preg_match(
'/\((.*)\)/i', $field, $reg)) $field = $reg[1];
1010 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
1013 if ($fromcompany->idprof4)
1015 $field = $outputlangs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
1016 if (preg_match(
'/\((.*)\)/i', $field, $reg)) $field = $reg[1];
1017 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
1020 if ($fromcompany->idprof5)
1022 $field = $outputlangs->transcountrynoentities(
"ProfId5", $fromcompany->country_code);
1023 if (preg_match(
'/\((.*)\)/i', $field, $reg)) $field = $reg[1];
1024 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
1027 if ($fromcompany->idprof6)
1029 $field = $outputlangs->transcountrynoentities(
"ProfId6", $fromcompany->country_code);
1030 if (preg_match(
'/\((.*)\)/i', $field, $reg)) $field = $reg[1];
1031 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
1034 if ($fromcompany->tva_intra !=
'')
1036 $line4 .= ($line4 ?
" - " :
"").$outputlangs->transnoentities(
"VATIntraShort").
": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
1039 $pdf->SetFont(
'',
'', 7);
1040 $pdf->SetDrawColor(224, 224, 224);
1043 $freetextheight = 0;
1047 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
1049 $width = 20000; $align =
'L';
1050 if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
1051 $width = 200; $align =
'C';
1053 $freetextheight = $pdf->getStringHeight($width, $line);
1060 $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
1061 $posy = $marginwithfooter + 0;
1065 $pdf->SetXY($dims[
'lm'], -$posy);
1066 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
1068 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1070 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1072 $posy -= $freetextheight;
1076 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1081 $pdf->SetFont(
'',
'B', 7);
1082 $pdf->SetXY($dims[
'lm'], -$posy);
1083 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line1, 0,
'C', 0);
1085 $pdf->SetFont(
'',
'', 7);
1090 $pdf->SetFont(
'',
'B', 7);
1091 $pdf->SetXY($dims[
'lm'], -$posy);
1092 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line2, 0,
'C', 0);
1094 $pdf->SetFont(
'',
'', 7);
1099 $pdf->SetXY($dims[
'lm'], -$posy);
1100 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line3, 0,
'C', 0);
1106 $pdf->SetXY($dims[
'lm'], -$posy);
1107 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line4, 0,
'C', 0);
1113 $pdf->SetXY($dims[
'wk'] - $dims[
'rm'] - 15, -$posy);
1115 $pdf->MultiCell(15, 2, $pdf->PageNo().
'/'.$pdf->getAliasNbPages(), 0,
'R', 0);
1118 return $marginwithfooter;
1138 if (!empty($linkedobjects))
1140 foreach ($linkedobjects as $linkedobject)
1142 $reftoshow = $linkedobject[
"ref_title"].
' : '.$linkedobject[
"ref_value"];
1143 if (!empty($linkedobject[
"date_value"]))
1145 $reftoshow .=
' / '.$linkedobject[
"date_value"];
1149 $pdf->SetXY($posx, $posy);
1150 $pdf->SetFont(
'',
'', $default_font_size - 2);
1151 $pdf->MultiCell($w, $h, $reftoshow,
'', $align);
1155 return $pdf->getY();
1174 function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1176 global $db, $conf, $langs, $hookmanager;
1181 if (is_object($hookmanager))
1183 $special_code = empty($object->lines[$i]->special_code) ?
'' : $object->lines[$i]->special_code;
1184 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1185 $parameters = array(
'pdf'=>$pdf,
'i'=>$i,
'outputlangs'=>$outputlangs,
'w'=>$w,
'h'=>$h,
'posx'=>$posx,
'posy'=>$posy,
'hideref'=>$hideref,
'hidedesc'=>$hidedesc,
'issupplierline'=>$issupplierline,
'special_code'=>$special_code);
1187 $reshook = $hookmanager->executeHooks(
'pdf_writelinedesc', $parameters, $object, $action);
1189 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1191 if (empty($reshook))
1193 $labelproductservice =
pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
1199 $labelproductservice = preg_replace(
'/(<img[^>]*src=")([^"]*)(&)([^"]*")/',
'\1\2&\4', $labelproductservice, -1, $nbrep);
1204 $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1,
false,
true,
'J',
true);
1205 $result .= $labelproductservice;
1221 function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1223 global $db, $conf, $langs;
1225 $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product :
false);
1226 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label :
''));
1227 $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description :
''));
1228 $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn :
''));
1229 $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note :
'');
1230 $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch :
false);
1232 if ($issupplierline)
1234 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1237 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1243 $prodser->fetch($idprod);
1245 if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
1247 $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED));
1255 $textwasmodified = ($label == $prodser->label);
1256 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"label"]) && ($textwasmodified || $translatealsoifmodified)) {
1257 $label = $prodser->multilangs[$outputlangs->defaultlang][
"label"];
1262 $textwasmodified =
false;
1266 $textwasmodified = ($desc == $prodser->description);
1268 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"description"]) && ($textwasmodified || $translatealsoifmodified)) $desc = $prodser->multilangs[$outputlangs->defaultlang][
"description"];
1271 $textwasmodified = ($note == $prodser->note);
1272 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang][
"note"];
1274 } elseif ($object->element ==
'facture' || $object->element ==
'facturefourn') {
1275 if ($object->type == $object::TYPE_DEPOSIT) {
1276 $desc = str_replace(
'(DEPOSIT)', $outputlangs->trans(
'Deposit'), $desc);
1281 $libelleproduitservice = $label;
1282 if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
1283 $libelleproduitservice =
'<b>'.$libelleproduitservice.
'</b>';
1287 if (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) {
1288 $prodser->get_sousproduits_arbo();
1289 if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
1290 $tmparrayofsubproducts = reset($prodser->sousprods);
1291 foreach ($tmparrayofsubproducts as $subprodval) {
1292 $libelleproduitservice .=
"\n * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ?
' - ' :
'').$subprodval[3].
' ('.$subprodval[1].
')';
1298 if (!empty($desc) && ($desc != $label))
1300 if ($libelleproduitservice && empty($hidedesc))
1302 $libelleproduitservice .=
'__N__';
1305 if ($desc ==
'(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
1308 $discount->fetch($object->lines[$i]->fk_remise_except);
1309 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source;
1310 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromCreditNote", $sourceref);
1311 } elseif ($desc ==
'(DEPOSIT)' && $object->lines[$i]->fk_remise_except)
1314 $discount->fetch($object->lines[$i]->fk_remise_except);
1315 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source;
1316 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromDeposit", $sourceref);
1318 if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .=
' ('.dol_print_date($discount->datec,
'day',
'', $outputlangs).
')';
1319 } elseif ($desc ==
'(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except)
1322 $discount->fetch($object->lines[$i]->fk_remise_except);
1323 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessReceived", $discount->ref_facture_source);
1324 } elseif ($desc ==
'(EXCESS PAID)' && $object->lines[$i]->fk_remise_except)
1327 $discount->fetch($object->lines[$i]->fk_remise_except);
1328 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
1332 if (!empty($object->element)) {
1333 $tmpkey =
'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper($object->element);
1334 if (!empty($conf->global->$tmpkey)) {
1338 if (empty($hidedesc)) {
1339 if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) {
1340 $libelleproduitservice = $desc.
"\n".$libelleproduitservice;
1342 if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) {
1343 $libelleproduitservice = $desc;
1345 $libelleproduitservice .= $desc;
1350 $libelleproduitservice .= $desc;
1356 $prefix_prodserv =
"";
1358 if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
1359 if ($prodser->isService()) {
1360 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Service").
" ";
1362 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Product").
" ";
1366 if (empty($hideref)) {
1367 if ($issupplierline) {
1368 if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) {
1369 $ref_prodserv = $prodser->ref;
1370 if ($ref_supplier) $ref_prodserv .= ($prodser->ref ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
"SupplierRef").
' '.$ref_supplier.($prodser->ref ?
')' :
'');
1371 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
1372 $ref_prodserv = $ref_supplier;
1373 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
1374 $ref_prodserv = $ref_supplier.
' ('.$outputlangs->transnoentitiesnoconv(
"InternalRef").
' '.$prodser->ref.
')';
1377 $ref_prodserv = $prodser->ref;
1380 if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .=
" - ";
1383 if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { $ref_prodserv =
'<b>'.$ref_prodserv.
'</b>'; }
1384 $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
1387 if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled))
1389 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1392 $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
1393 foreach ($tblcateg as $cate)
1396 $desccateg = $cate->description;
1398 $libelleproduitservice .=
'__N__'.$desccateg;
1402 if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end))
1407 if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
1409 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($object->lines[$i]->date_start, $format,
false, $outputlangs),
dol_print_date($object->lines[$i]->date_end, $format,
false, $outputlangs)).
')';
1411 if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end)
1413 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($object->lines[$i]->date_start, $format,
false, $outputlangs)).
')';
1415 if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end)
1417 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($object->lines[$i]->date_end, $format,
false, $outputlangs)).
')';
1420 if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1421 $libelleproduitservice .=
'<b style="color:#333666;" ><em>'.
"__N__</b> ".$period.
'</em>';
1423 $libelleproduitservice .=
"__N__".$period;
1431 foreach ($dbatch as $detail)
1434 if ($detail->eatby) $dte[] = $outputlangs->transnoentitiesnoconv(
'printEatby',
dol_print_date($detail->eatby, $format,
false, $outputlangs));
1435 if ($detail->sellby) $dte[] = $outputlangs->transnoentitiesnoconv(
'printSellby',
dol_print_date($detail->sellby, $format,
false, $outputlangs));
1436 if ($detail->batch) $dte[] = $outputlangs->transnoentitiesnoconv(
'printBatch', $detail->batch);
1437 $dte[] = $outputlangs->transnoentitiesnoconv(
'printQty', $detail->qty);
1438 $libelleproduitservice .=
"__N__ ".implode(
" - ", $dte);
1443 if (
dol_textishtml($libelleproduitservice)) $libelleproduitservice = preg_replace(
'/__N__/',
'<br>', $libelleproduitservice);
1444 else $libelleproduitservice = preg_replace(
'/__N__/',
"\n", $libelleproduitservice);
1447 return $libelleproduitservice;
1461 global $hookmanager;
1466 if (is_object($hookmanager))
1468 $special_code = $object->lines[$i]->special_code;
1469 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1470 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1472 $reshook = $hookmanager->executeHooks(
'pdf_getlinenum', $parameters, $object, $action);
1473 $result .= $hookmanager->resPrint;
1475 if (empty($reshook))
1494 global $hookmanager;
1499 if (is_object($hookmanager))
1501 $special_code = $object->lines[$i]->special_code;
1502 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1503 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1505 $reshook = $hookmanager->executeHooks(
'pdf_getlineref', $parameters, $object, $action);
1506 $result .= $hookmanager->resPrint;
1508 if (empty($reshook))
1526 global $hookmanager;
1531 if (is_object($hookmanager))
1533 $special_code = $object->lines[$i]->special_code;
1534 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1535 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1537 $reshook = $hookmanager->executeHooks(
'pdf_getlineref_supplier', $parameters, $object, $action);
1538 $result .= $hookmanager->resPrint;
1540 if (empty($reshook))
1558 global $conf, $hookmanager, $mysoc;
1563 if (is_object($hookmanager))
1565 $special_code = $object->lines[$i]->special_code;
1566 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1567 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1569 $reshook = $hookmanager->executeHooks(
'pdf_getlinevatrate', $parameters, $object, $action);
1571 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1573 if (empty($reshook))
1575 if (empty($hidedetails) || $hidedetails > 1)
1579 $tmpresult .=
vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1);
1580 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX))
1582 if ($object->lines[$i]->total_localtax1 != 0)
1584 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) $tmpresult .=
'/';
1585 else $tmpresult =
'';
1586 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax1_tx), 0);
1589 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX))
1591 if ($object->lines[$i]->total_localtax2 != 0)
1593 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) $tmpresult .=
'/';
1594 else $tmpresult =
'';
1595 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax2_tx), 0);
1600 $result .= $tmpresult;
1617 global $conf, $hookmanager;
1620 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1625 if (is_object($hookmanager))
1627 $special_code = $object->lines[$i]->special_code;
1628 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1629 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1631 $reshook = $hookmanager->executeHooks(
'pdf_getlineupexcltax', $parameters, $object, $action);
1633 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1635 if (empty($reshook))
1637 if (empty($hidedetails) || $hidedetails > 1)
1639 $subprice = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
1640 $result .=
price($sign * $subprice, 0, $outputlangs);
1657 global $hookmanager, $conf;
1660 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1665 if (is_object($hookmanager))
1667 $special_code = $object->lines[$i]->special_code;
1668 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1669 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1671 $reshook = $hookmanager->executeHooks(
'pdf_getlineupwithtax', $parameters, $object, $action);
1673 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1675 if (empty($reshook))
1677 if (empty($hidedetails) || $hidedetails > 1) $result .=
price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
1693 global $hookmanager;
1698 if (is_object($hookmanager))
1700 $special_code = $object->lines[$i]->special_code;
1701 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1702 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1704 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty', $parameters, $object, $action);
1706 if (!empty($hookmanager->resPrint)) $result = $hookmanager->resPrint;
1708 if (empty($reshook))
1710 if ($object->lines[$i]->special_code == 3)
return '';
1711 if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty;
1727 global $hookmanager;
1732 if (is_object($hookmanager))
1734 $special_code = $object->lines[$i]->special_code;
1735 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1736 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1738 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_asked', $parameters, $object, $action);
1740 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1742 if (empty($reshook))
1744 if ($object->lines[$i]->special_code == 3)
return '';
1745 if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_asked;
1761 global $hookmanager;
1766 if (is_object($hookmanager))
1768 $special_code = $object->lines[$i]->special_code;
1769 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1770 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1772 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_shipped', $parameters, $object, $action);
1774 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1776 if (empty($reshook))
1778 if ($object->lines[$i]->special_code == 3)
return '';
1779 if (empty($hidedetails) || $hidedetails > 1) $result .= $object->lines[$i]->qty_shipped;
1795 global $hookmanager;
1800 if (is_object($hookmanager))
1802 $special_code = $object->lines[$i]->special_code;
1803 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1804 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1806 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_keeptoship', $parameters, $object, $action);
1808 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1810 if (empty($reshook))
1812 if ($object->lines[$i]->special_code == 3)
return '';
1813 if (empty($hidedetails) || $hidedetails > 1) $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
1828 function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager =
false)
1835 if (is_object($hookmanager))
1837 $special_code = $object->lines[$i]->special_code;
1838 if (!empty($object->lines[$i]->fk_parent_line)) {
1839 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1841 $parameters = array(
1843 'outputlangs' => $outputlangs,
1844 'hidedetails' => $hidedetails,
1845 'special_code' => $special_code
1848 $reshook = $hookmanager->executeHooks(
'pdf_getlineunit', $parameters, $object, $action);
1850 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1852 if (empty($reshook))
1854 if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit(
'short'));
1871 global $hookmanager;
1873 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1878 if (is_object($hookmanager))
1880 $special_code = $object->lines[$i]->special_code;
1881 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1882 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1884 $reshook = $hookmanager->executeHooks(
'pdf_getlineremisepercent', $parameters, $object, $action);
1886 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1888 if (empty($reshook))
1890 if ($object->lines[$i]->special_code == 3)
return '';
1891 if (empty($hidedetails) || $hidedetails > 1) $result .=
dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs);
1908 if (empty($hookmanager)) global $hookmanager;
1914 if (is_object($hookmanager))
1916 $special_code = $object->lines[$i]->special_code;
1917 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1918 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
1920 $reshook = $hookmanager->executeHooks(
'pdf_getlineprogress', $parameters, $object, $action);
1922 if (!empty($hookmanager->resPrint))
return $hookmanager->resPrint;
1924 if (empty($reshook))
1926 if ($object->lines[$i]->special_code == 3)
return '';
1927 if (empty($hidedetails) || $hidedetails > 1)
1929 if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)
1932 if (method_exists($object,
'get_prev_progress'))
1934 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
1936 $result = ($object->lines[$i]->situation_percent - $prev_progress).
'%';
1937 }
else $result = $object->lines[$i]->situation_percent.
'%';
1954 global $conf, $hookmanager;
1957 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1962 if (is_object($hookmanager))
1964 $special_code = $object->lines[$i]->special_code;
1965 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1966 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code,
'sign'=>$sign);
1968 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalexcltax', $parameters, $object, $action);
1970 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
1972 if (empty($reshook))
1974 if ($object->lines[$i]->special_code == 3)
1976 $result .= $outputlangs->transnoentities(
"Option");
1978 elseif (empty($hidedetails) || $hidedetails > 1)
1980 $total_ht = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
1981 if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0)
1986 if (method_exists($object->lines[$i],
'get_prev_progress'))
1988 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
1989 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
1991 $result .=
price($sign * ($total_ht / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
1993 $result .=
price($sign * $total_ht, 0, $outputlangs);
2011 global $hookmanager, $conf;
2014 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
2019 if (is_object($hookmanager))
2021 $special_code = $object->lines[$i]->special_code;
2022 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2023 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2025 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalwithtax', $parameters, $object, $action);
2027 if (!empty($hookmanager->resPrint)) $result .= $hookmanager->resPrint;
2029 if (empty($reshook))
2031 if ($object->lines[$i]->special_code == 3)
2033 $result .= $outputlangs->transnoentities(
"Option");
2035 elseif (empty($hidedetails) || $hidedetails > 1)
2037 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
2038 if ($object->lines[$i]->situation_percent > 0)
2043 if (method_exists($object->lines[$i],
'get_prev_progress'))
2045 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2046 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2048 $result .=
price($sign * ($total_ttc / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2050 $result .=
price($sign * $total_ttc, 0, $outputlangs);
2068 global $hookmanager;
2071 $nblines = count($object->lines);
2074 for ($i = 0; $i < $nblines; $i++)
2076 if ($object->lines[$i]->special_code != 3)
2080 $total += $object->lines[$i]->qty;
2081 } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line)))
2083 $special_code = $object->lines[$i]->special_code;
2084 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2085 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2087 $reshook = $hookmanager->executeHooks(
'pdf_getTotalQty', $parameters, $object, $action);
2088 return $hookmanager->resPrint;
2089 } elseif ($type == 0 && $object->lines[$i]->product_type == 0)
2091 $total += $object->lines[$i]->qty;
2092 } elseif ($type == 1 && $object->lines[$i]->product_type == 1)
2094 $total += $object->lines[$i]->qty;
2112 global $db, $hookmanager;
2114 $linkedobjects = array();
2116 $object->fetchObjectLinked();
2118 foreach ($object->linkedObjects as $objecttype => $objects)
2120 if ($objecttype ==
'facture')
2123 } elseif ($objecttype ==
'propal' || $objecttype ==
'supplier_proposal')
2125 $outputlangs->load(
'propal');
2127 foreach ($objects as $elementobject)
2129 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefProposal");
2130 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2131 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DatePropal");
2132 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2134 } elseif ($objecttype ==
'commande' || $objecttype ==
'supplier_order')
2136 $outputlangs->load(
'orders');
2137 foreach ($objects as $elementobject)
2139 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder");
2140 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ?
' ('.$elementobject->ref_client.
')' :
'').($elementobject->ref_supplier ?
' ('.$elementobject->ref_supplier.
')' :
'');
2141 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"OrderDate");
2142 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2144 } elseif ($objecttype ==
'contrat')
2146 $outputlangs->load(
'contracts');
2147 foreach ($objects as $elementobject)
2149 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefContract");
2150 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2151 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DateContract");
2152 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date_contrat,
'day',
'', $outputlangs);
2154 } elseif ($objecttype ==
'fichinter')
2156 $outputlangs->load(
'interventions');
2157 foreach ($objects as $elementobject)
2159 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"InterRef");
2160 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2161 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"InterDate");
2162 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->datec,
'day',
'', $outputlangs);
2164 } elseif ($objecttype ==
'shipping')
2166 $outputlangs->loadLangs(array(
"orders",
"sendings"));
2168 foreach ($objects as $x => $elementobject)
2172 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande')
2174 $elementobject->fetchObjectLinked(null,
'', null,
'',
'OR', 1,
'sourcetype', 0);
2175 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
2176 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2178 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2179 if ($ret < 1) { $order = null; }
2182 if (!is_object($order))
2184 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefSending");
2185 if (!empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] .=
' / ';
2186 $linkedobjects[$objecttype][
'ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
2191 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending");
2192 if (empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
'');
2193 $linkedobjects[$objecttype][
'ref_value'] .=
' / '.$outputlangs->transnoentities($elementobject->ref);
2203 if (is_object($hookmanager))
2205 $parameters = array(
'linkedobjects' => $linkedobjects,
'outputlangs'=>$outputlangs);
2207 $hookmanager->executeHooks(
'pdf_getLinkedObjects', $parameters, $object, $action);
2208 if (!empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
2211 return $linkedobjects;
2225 $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
2226 $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
2227 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2231 $width = (int) round($maxheight * $tmp[
'width'] / $tmp[
'height']);
2232 if ($width > $maxwidth)
2235 $height = (int) round($maxwidth * $tmp[
'height'] / $tmp[
'width']);
2238 $height = $maxheight;
2241 return array(
'width'=>$width,
'height'=>$height);
2255 global $conf, $hookmanager;
2257 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
2258 if ($object->lines[$i]->special_code == 3)
2260 return $outputlangs->transnoentities(
"Option");
2262 if (is_object($hookmanager))
2264 $special_code = $object->lines[$i]->special_code;
2265 if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2267 $parameters = array(
2269 'outputlangs'=>$outputlangs,
2270 'hidedetails'=>$hidedetails,
2271 'special_code'=>$special_code
2276 if ($hookmanager->executeHooks(
'getlinetotalremise', $parameters, $object, $action) > 0)
2278 return $hookmanager->resPrint;
2282 if (empty($hidedetails) || $hidedetails > 1)
return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht);
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
convToOutputCharset($str, $pagecodefrom= 'UTF-8')
Convert a string into output charset (this->charset_output that should be defined to conf->file->char...
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png and bmp) ...
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs= '', $mode=0, $extralangcode= '')
Return a formated address (part address/zip/town/state) according to country rules.
dol_print_reduction($reduction, $langs)
Returns formated reduction.
pdf_getLinkedObjects($object, $outputlangs)
Return linked objects to use for document generation.
pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails=0)
Return line keep to ship quantity.
pdf_getTotalQty($object, $type, $outputlangs)
Return total quantity of products and/or services.
dol_html_entity_decode($a, $b, $c= 'UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
pdf_getlinenum($object, $i, $outputlangs, $hidedetails=0)
Return line num.
pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails=0)
Return line quantity asked.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getEncryption($pathoffile)
Return if pdf file is protected/encrypted.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
Class to manage third parties objects (customers, suppliers, prospects...)
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
getFormeJuridiqueLabel($code)
Retourne le nom traduit de la forme juridique.
Class to manage categories.
pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails=0)
Return line quantity shipped.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdfGetHeightForHtmlContent(&$pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
Class to manage customers orders.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails=0)
Return line total amount discount.
dol_getDefaultFormat(Translate $outputlangs=null)
Try to guess default paper format according to language into $langs.
Class to manage translations.
pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price including tax.
getState($id, $withcode= '', $dbtouse=0, $withregion=0, $outputlangs= '', $entconv=1)
Return state translated from an id.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
pdf_getlineref($object, $i, $outputlangs, $hidedetails=0)
Return line product ref.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage absolute discounts.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
pdf_getlinedesc($object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
Return line description translated in outputlangs and encoded into htmlentities and with ...
Class to manage predefined suppliers products.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails=0)
Return line ref_supplier.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.