41include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
56 $head[$h][0] = DOL_URL_ROOT.
'/admin/pdf.php';
57 $head[$h][1] = $langs->trans(
"GlobalParameters");
58 $head[$h][2] =
'general';
68 $head[$h][0] = DOL_URL_ROOT.
'/admin/pdf_other.php';
69 $head[$h][1] = $langs->trans(
"SpecificParameters");
70 $head[$h][2] =
'other';
91 dol_syslog(
"pdf_getFormat Get paper format with mode=".$mode.
" MAIN_PDF_FORMAT=".
getDolGlobalString(
'MAIN_PDF_FORMAT').
" outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null').
" and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang :
'null'));
99 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
105 $sql =
"SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX.
"c_paper_format";
106 $sql .=
" WHERE code = '".$db->escape($pdfformat).
"'";
107 $resql =
$db->query($sql);
109 $obj =
$db->fetch_object($resql);
111 $width = (int) $obj->width;
112 $height = (int) $obj->height;
118 return array(
'width' => $width,
'height' => $height,
'unit' => $unit);
134 if (!defined(
'K_TCPDF_EXTERNAL_CONFIG')) {
135 define(
'K_TCPDF_EXTERNAL_CONFIG', 1);
136 define(
'K_PATH_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
137 define(
'K_PATH_URL_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
139 define(
'K_BLANK_IMAGE',
'_blank.png');
140 define(
'PDF_PAGE_FORMAT',
'A4');
141 define(
'PDF_PAGE_ORIENTATION',
'P');
142 define(
'PDF_CREATOR',
'TCPDF');
143 define(
'PDF_AUTHOR',
'TCPDF');
144 define(
'PDF_HEADER_TITLE',
'TCPDF Example');
145 define(
'PDF_HEADER_STRING',
"by Dolibarr ERP CRM");
146 define(
'PDF_UNIT',
'mm');
147 define(
'PDF_MARGIN_HEADER', 5);
148 define(
'PDF_MARGIN_FOOTER', 10);
149 define(
'PDF_MARGIN_TOP', 27);
150 define(
'PDF_MARGIN_BOTTOM', 25);
151 define(
'PDF_MARGIN_LEFT', 15);
152 define(
'PDF_MARGIN_RIGHT', 15);
153 define(
'PDF_FONT_NAME_MAIN',
'helvetica');
154 define(
'PDF_FONT_SIZE_MAIN', 10);
155 define(
'PDF_FONT_NAME_DATA',
'helvetica');
156 define(
'PDF_FONT_SIZE_DATA', 8);
157 define(
'PDF_FONT_MONOSPACED',
'courier');
158 define(
'PDF_IMAGE_SCALE_RATIO', 1.25);
159 define(
'HEAD_MAGNIFICATION', 1.1);
160 define(
'K_CELL_HEIGHT_RATIO', 1.25);
161 define(
'K_TITLE_MAGNIFICATION', 1.3);
162 define(
'K_SMALL_RATIO', 2 / 3);
163 define(
'K_THAI_TOPCHARS',
true);
164 define(
'K_TCPDF_CALLS_IN_HTML',
true);
171 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
true);
173 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
false);
178 require_once TCPDF_PATH.
'tcpdf.php';
182 require_once TCPDI_PATH.
'tcpdi.php';
193 $pdf =
new TCPDI($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
195 $pdf =
new TCPDF($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
228 $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys);
242 require_once TCPDF_PATH.
'tcpdf_parser.php';
244 $isencrypted =
false;
246 $content = file_get_contents($pathoffile);
249 @($parser =
new TCPDF_PARSER(ltrim($content)));
250 $tmp = $parser->getParsedData();
252 $data = $tmp[1] ??
null;
256 if (isset($xref[
'trailer'][
'encrypt'])) {
280 if (class_exists(
'TCPDF')) {
281 if ($outputlangs->trans(
'FONTFORPDF') !=
'FONTFORPDF') {
282 $font = $outputlangs->trans(
'FONTFORPDF');
297 if (class_exists(
'TCPDF')) {
298 if ($outputlangs->trans(
'FONTSIZEFORPDF') !=
'FONTSIZEFORPDF') {
299 $size = (int) $outputlangs->trans(
'FONTSIZEFORPDF');
321 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
323 if ($tmp[
'height']) {
324 $width = round($height * $tmp[
'width'] / $tmp[
'height']);
325 if ($width > $maxwidth) {
326 $height = $height * $maxwidth / $width;
352 if ($emetteur->logo) {
354 $logo = $logodir.
'/logos/thumbs/'.$emetteur->logo_small;
356 $logo = $logodir.
'/logos/'.$emetteur->logo;
358 if (is_readable($logo)) {
360 $pdf->Image($logo, $posx, $posy, 0, $height);
362 $pdf->SetTextColor(200, 0, 0);
363 $pdf->SetFont(
'',
'B', $default_font_size - 2);
364 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
365 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
368 $text = (
string) $emetteur->name;
369 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $align);
386 $pdf->startTransaction();
391 $start_y = $pdf->GetY();
393 $start_page = $pdf->getPage();
395 $pdf->writeHTMLCell(0, 0, 0, $start_y, $htmlcontent, 0, 1,
false,
true,
'J',
true);
397 $end_y = $pdf->GetY();
398 $end_page = $pdf->getPage();
401 if ($end_page == $start_page) {
402 $height = $end_y - $start_y;
404 for ($page = $start_page; $page <= $end_page; ++$page) {
405 $pdf->setPage($page);
406 $tmpm = $pdf->getMargins();
407 $tMargin = $tmpm[
'top'];
408 if ($page == $start_page) {
410 $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin();
411 } elseif ($page == $end_page) {
413 $height = $end_y - $tMargin;
415 $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin();
420 $pdf->rollbackTransaction(
true);
439 if ($thirdparty instanceof
Societe) {
440 $socname = $thirdparty->name;
441 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
443 $socname = $thirdparty->name_alias.
" - ".$thirdparty->name;
445 $socname = $thirdparty->name.
" - ".$thirdparty->name_alias;
448 } elseif ($thirdparty instanceof
Contact) {
449 if ($thirdparty->socid > 0) {
450 $thirdparty->fetch_thirdparty();
451 $socname = $thirdparty->thirdparty->name;
452 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->thirdparty->name_alias)) {
454 $socname = $thirdparty->thirdparty->name_alias.
" - ".$thirdparty->thirdparty->name;
456 $socname = $thirdparty->thirdparty->name.
" - ".$thirdparty->thirdparty->name_alias;
461 throw new InvalidArgumentException(
'Parameter 1 $thirdparty is not a Societe nor Contact');
464 return $outputlangs->convToOutputCharset((
string) $socname);
479function pdf_build_address($outputlangs, $sourcecompany, $targetcompany =
'', $targetcontact =
'', $usecontact = 0, $mode =
'source',
$object =
null)
483 if ($mode ==
'source' && !is_object($sourcecompany)) {
486 if ($mode ==
'target' && !is_object($targetcompany)) {
490 if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
491 $sourcecompany->state =
getState($sourcecompany->state_id);
493 if (!empty($targetcompany->state_id) && empty($targetcompany->state)) {
494 $targetcompany->state =
getState($targetcompany->state_id);
499 if (is_object($hookmanager)) {
500 $parameters = array(
'sourcecompany' => &$sourcecompany,
'targetcompany' => &$targetcompany,
'targetcontact' => &$targetcontact,
'outputlangs' => $outputlangs,
'mode' => $mode,
'usecontact' => $usecontact);
503 $reshook = $hookmanager->executeHooks(
'pdf_build_address', $parameters,
$object, $action);
504 $stringaddress .= $hookmanager->resPrint;
506 if (empty($reshook)) {
507 if ($mode ==
'source') {
509 if (isset($targetcompany->country_code) && !empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
515 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($fulladdress).
"\n";
520 if ($sourcecompany->phone) {
521 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"PhoneShort").
": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
524 if ($sourcecompany->phone_mobile &&
getDolGlobalString(
'MAIN_PDF_SHOW_SOURCE_PHONE_MOBILE')) {
525 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"PhoneShort").
": ".$outputlangs->convToOutputCharset($sourcecompany->phone_mobile);
528 if ($sourcecompany->fax) {
529 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
532 if ($sourcecompany->email) {
533 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($sourcecompany->email);
536 if ($sourcecompany->url) {
537 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($sourcecompany->url);
542 if ($sourcecompany->tva_intra) {
543 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
548 if (
getDolGlobalString(
'MAIN_PROFID1_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof1)) {
549 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $sourcecompany->country_code);
550 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
553 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
555 if (
getDolGlobalString(
'MAIN_PROFID2_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof2)) {
556 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $sourcecompany->country_code);
557 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
560 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
562 if (
getDolGlobalString(
'MAIN_PROFID3_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof3)) {
563 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $sourcecompany->country_code);
564 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
567 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
569 if (
getDolGlobalString(
'MAIN_PROFID4_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof4)) {
570 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $sourcecompany->country_code);
571 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
574 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
576 if (
getDolGlobalString(
'MAIN_PROFID5_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof5)) {
577 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $sourcecompany->country_code);
578 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
581 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
583 if (
getDolGlobalString(
'MAIN_PROFID6_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof6)) {
584 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $sourcecompany->country_code);
585 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
588 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
591 $stringaddress .= ($stringaddress ?
"\n" :
'') .
getDolGlobalString(
'PDF_ADD_MORE_AFTER_SOURCE_ADDRESS');
595 if ($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) {
596 if ($usecontact && (is_object($targetcontact))) {
597 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
599 if (!empty($targetcontact->address)) {
600 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcontact)).
"\n";
601 } elseif (is_object($targetcompany)) {
602 $companytouseforaddress = $targetcompany;
605 if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
606 $targetcontact->fetch_thirdparty();
607 $companytouseforaddress = $targetcontact->thirdparty;
610 if (is_object($companytouseforaddress)) {
611 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($companytouseforaddress)).
"\n";
615 if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
616 $stringaddress .= (($stringaddress && !
getDolGlobalString(
'MAIN_PDF_REMOVE_BREAK_BEFORE_COUNTRY')) ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcontact->country_code));
617 } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
618 $stringaddress .= (($stringaddress && !
getDolGlobalString(
'MAIN_PDF_REMOVE_BREAK_BEFORE_COUNTRY')) ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
621 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || preg_match(
'/targetwithdetails/', $mode)) {
623 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
624 if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
625 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
627 if (!empty($targetcontact->phone_pro)) {
628 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
630 if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
631 $stringaddress .=
" / ";
633 if (!empty($targetcontact->phone_mobile)) {
634 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
638 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
639 if ($targetcontact->fax) {
640 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcontact->fax);
644 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
645 if ($targetcontact->email) {
646 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcontact->email);
650 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
651 if ($targetcontact->url) {
652 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset((
string) $targetcontact->url);
657 if (is_object($targetcompany)) {
658 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcompany));
660 if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
661 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
663 $stringaddress .= ($stringaddress ?
"\n" :
'');
666 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || preg_match(
'/targetwithdetails/', $mode)) {
668 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
669 if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) {
670 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
672 if (!empty($targetcompany->phone)) {
673 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
675 if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) {
676 $stringaddress .=
" / ";
678 if (!empty($targetcompany->phone_mobile)) {
679 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
683 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
684 if ($targetcompany->fax) {
685 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcompany->fax);
689 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
690 if ($targetcompany->email) {
691 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcompany->email);
695 if (
getDolGlobalString(
'MAIN_PDF_ADDALSOTARGETDETAILS') || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
696 if ($targetcompany->url) {
697 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcompany->url);
706 if ($usecontact && is_object($targetcontact) &&
getDolGlobalInt(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
707 $targetcontact->fetch_thirdparty();
708 if (!empty($targetcontact->thirdparty->id) && $targetcontact->thirdparty->tva_intra) {
709 $stringaddress .= ($stringaddress ?
"\n" :
'') . $outputlangs->transnoentities(
"VATIntraShort") .
': ' . $outputlangs->convToOutputCharset($targetcontact->thirdparty->tva_intra);
711 } elseif (!empty($targetcompany->tva_intra)) {
712 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
717 if (
getDolGlobalString(
'MAIN_LEGALFORM_IN_ADDRESS') && !empty($targetcompany->forme_juridique_code)) {
719 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp;
723 if (
getDolGlobalString(
'MAIN_PROFID1_IN_ADDRESS') && !empty($targetcompany->idprof1)) {
724 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $targetcompany->country_code);
725 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
728 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
730 if (
getDolGlobalString(
'MAIN_PROFID2_IN_ADDRESS') && !empty($targetcompany->idprof2)) {
731 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $targetcompany->country_code);
732 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
735 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
737 if (
getDolGlobalString(
'MAIN_PROFID3_IN_ADDRESS') && !empty($targetcompany->idprof3)) {
738 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $targetcompany->country_code);
739 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
742 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
744 if (
getDolGlobalString(
'MAIN_PROFID4_IN_ADDRESS') && !empty($targetcompany->idprof4)) {
745 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $targetcompany->country_code);
746 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
749 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
751 if (
getDolGlobalString(
'MAIN_PROFID5_IN_ADDRESS') && !empty($targetcompany->idprof5)) {
752 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $targetcompany->country_code);
753 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
756 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
758 if (
getDolGlobalString(
'MAIN_PROFID6_IN_ADDRESS') && !empty($targetcompany->idprof6)) {
759 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $targetcompany->country_code);
760 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
763 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
768 if ($mode ==
'source' && !empty($sourcecompany->note_public)) {
769 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($sourcecompany->note_public);
771 if (($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) {
772 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($targetcompany->note_public);
778 return $stringaddress;
797 if (file_exists($filepath)) {
798 $pdf->setAutoPageBreak(
false, 0);
807 $pdf->setAutoPageBreak(
true, 0);
831 include_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
853function pdfWriteVATArray($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis,
$object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl)
857 $tmpatleastoneratenotnull = 0;
860 foreach ($docgenerator->localtax1 as $localtax_type => $localtax_rate) {
861 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
865 foreach ($localtax_rate as $tvakey => $tvaval) {
870 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
873 if (preg_match(
'/\*/', (
string) $tvakey)) {
874 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
875 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
878 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
882 $totalvat .= $tvacompl;
884 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
887 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
891 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
892 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
898 foreach ($docgenerator->localtax2 as $localtax_type => $localtax_rate) {
899 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
903 foreach ($localtax_rate as $tvakey => $tvaval) {
908 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
911 if (preg_match(
'/\*/', (
string) $tvakey)) {
912 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
913 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
915 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
919 $totalvat .= $tvacompl;
921 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
924 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
928 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
929 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
937 foreach ($docgenerator->tva as $tvakey => $tvaval) {
938 $sum_pdf_tva += $tvaval;
941 if ($sum_pdf_tva !=
$object->total_tva) {
942 if (!empty($sum_pdf_tva)) {
943 $coef_fix_tva =
$object->total_tva / $sum_pdf_tva;
949 foreach ($docgenerator->tva as $tvakey => $tvaval) {
950 $docgenerator->tva[$tvakey] = $tvaval * $coef_fix_tva;
952 foreach ($docgenerator->tva_array as $tvakey => $tvaval) {
953 $docgenerator->tva_array[$tvakey][
'amount'] = $tvaval[
'amount'] * $coef_fix_tva;
960 foreach ($docgenerator->tva_array as $tvakey => $tvaval) {
962 $tmpatleastoneratenotnull++;
965 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
968 if (preg_match(
'/\*/', $tvakey)) {
969 $tvakey = str_replace(
'*',
'', $tvakey);
970 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
972 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT",
$mysoc->country_code) :
'');
975 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
977 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
979 $totalvat .= $tvacompl;
981 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
984 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
986 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
988 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
994 foreach ($docgenerator->localtax1 as $localtax_type => $localtax_rate) {
995 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
999 foreach ($localtax_rate as $tvakey => $tvaval) {
1000 if ($tvakey != 0 ||
getDolGlobalString(
'INVOICE_SHOW_ALSO_LOCALTAX1_LINE_IF_ZERO')) {
1004 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1007 if (preg_match(
'/\*/', (
string) $tvakey)) {
1008 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1009 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1011 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1",
$mysoc->country_code) :
'');
1015 $totalvat .= $tvacompl;
1017 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1020 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1024 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1025 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1031 foreach ($docgenerator->localtax2 as $localtax_type => $localtax_rate) {
1032 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1036 foreach ($localtax_rate as $tvakey => $tvaval) {
1038 if ($tvakey != 0 ||
getDolGlobalString(
'INVOICE_SHOW_ALSO_LOCALTAX2_LINE_IF_ZERO')) {
1042 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 if (preg_match(
'/\*/', (
string) $tvakey)) {
1046 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1047 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1049 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2",
$mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2",
$mysoc->country_code) :
'');
1053 $totalvat .= $tvacompl;
1055 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1058 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1062 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1063 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1068 $docgenerator->atleastoneratenotnull = $tmpatleastoneratenotnull;
1093function pdfWriteAlreadyPaid($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis,
$object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl, $deja_regle, $creditnoteamount, $depositsamount, $resteapayer, $resteapayer_origin)
1099 if ((($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS'))
1103 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1104 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"Paid") :
''), 0,
'L',
false);
1105 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1107 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R',
false);
1120 if ($creditnoteamount) {
1121 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1122 $labeltouse .= (is_object($outputlangsbis) ? (
' / '.(($outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities(
"CreditNotes"))) :
'');
1124 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1125 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L',
false);
1126 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1127 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R',
false);
1130 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1132 $pdf->SetFillColor(255, 255, 255);
1134 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1135 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"EscompteOfferedShort") :
''), $useborder,
'L',
true);
1136 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1137 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT'), 0, $outputlangs), $useborder,
'R',
true);
1140 $resteapayer_origin = 0;
1144 $pdf->SetTextColor(0, 0, 60);
1145 $pdf->SetFillColor(224, 224, 224);
1146 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1147 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L',
true);
1148 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1150 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1152 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1156 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1157 $pdf->SetTextColor(0, 0, 60);
1158 $pdf->SetFillColor(224, 224, 224);
1159 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
'').
' ('.$outputlangs->getCurrencySymbol(
$mysoc->currency_code).
')', $useborder,
'L',
true);
1161 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1162 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer_origin, 0, $outputlangs, 1, -1, -1,
$mysoc->currency_code), $useborder,
'L',
true);
1180 $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykey, $exclude,
$object, $include);
1181 $substitutionarray[
'__FROM_NAME__'] =
'__FROM_NAME__';
1182 $substitutionarray[
'__FROM_EMAIL__'] =
'__FROM_EMAIL__';
1183 return $substitutionarray;
1201 if ($unit ==
'pt') {
1203 } elseif ($unit ==
'mm') {
1205 } elseif ($unit ==
'cm') {
1207 } elseif ($unit ==
'in') {
1211 dol_print_error(
null,
'Unexpected unit "'.$unit.
'" for pdf_watermark');
1218 $text = $outputlangs->convToOutputCharset($text);
1220 $savx = $pdf->getX();
1221 $savy = $pdf->getY();
1223 $watermark_angle = atan($h / $w) / 2;
1224 $watermark_x_pos = 0;
1225 $watermark_y_pos = $h / 3;
1226 $watermark_x = $w / 2;
1227 $watermark_y = $h / 3;
1228 $pdf->SetFont(
'',
'B', 40);
1229 $pdf->SetTextColor(255, 0, 0);
1232 $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));
1234 $pdf->SetAlpha(0.5);
1235 $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
1238 $pdf->SetAlpha(0.3);
1239 $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text),
"", 2,
"C",
false);
1244 $pdf->SetXY($savx, $savy);
1262function pdfCertifMention($pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
1264 include_once DOL_DOCUMENT_ROOT.
'/blockedlog/lib/blockedlog.lib.php';
1282function pdf_bank($pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
1284 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbank.class.php';
1288 $pdf->SetXY($curx, $cury);
1290 if (empty($onlynumber)) {
1291 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1292 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByTransferOnThisBankAccount').
':', 0,
'L',
false);
1296 $outputlangs->load(
"banks");
1299 $bickey =
"BICNumber";
1300 if ($account->getCountryCode() ==
'IN') {
1305 $usedetailedbban = $account->useDetailedBBAN();
1308 if ($usedetailedbban) {
1311 if (empty($onlynumber)) {
1312 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
1313 $pdf->SetXY($curx, $cury);
1314 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L',
false);
1324 if (empty($onlynumber)) {
1325 $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
1328 $bank_number_length = 0;
1329 foreach ($account->getFieldsToShow() as $val) {
1330 $pdf->SetXY($curx, $cury + 4);
1331 $pdf->SetFont(
'',
'', $default_font_size - 3);
1333 if ($val ==
'BankCode') {
1336 $content = $account->code_banque;
1337 } elseif ($val ==
'DeskCode') {
1340 $content = $account->code_guichet;
1341 } elseif ($val ==
'BankAccountNumber') {
1344 $content = $account->number;
1345 } elseif ($val ==
'BankAccountNumberKey') {
1348 $content = $account->cle_rib;
1349 } elseif ($val ==
'IBAN' || $val ==
'BIC') {
1354 dol_print_error($account->db,
'Unexpected value for getFieldsToShow: '.$val);
1358 if ($content ==
'') {
1362 $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0,
'C',
false);
1363 $pdf->SetXY($curx, $cury + 1);
1364 $curx += $tmplength;
1365 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
1366 $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0,
'C',
false);
1367 if (empty($onlynumber)) {
1368 $pdf->line($curx, $cury + 1, $curx, $cury + 7);
1372 $bank_number_length = 8;
1376 $cury += $bank_number_length;
1378 } elseif (!empty($account->number)) {
1379 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
1380 $pdf->SetXY($curx, $cury);
1381 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L',
false);
1384 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
1385 $pdf->SetXY($curx, $cury);
1386 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"BankAccountNumber").
': '.$outputlangs->convToOutputCharset($account->number), 0,
'L',
false);
1389 if ($diffsizecontent <= 2) {
1394 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
1396 if (empty($onlynumber) && !empty($account->address)) {
1397 $pdf->SetXY($curx, $cury);
1398 $val = $outputlangs->transnoentities(
"Residence").
': '.$outputlangs->convToOutputCharset($account->address);
1399 $pdf->MultiCell(100, 3, $val, 0,
'L',
false);
1402 $tmpy = $pdf->getStringHeight(100, $val);
1406 if (!empty($account->owner_name)) {
1407 $pdf->SetXY($curx, $cury);
1408 $val = $outputlangs->transnoentities(
"BankAccountOwner").
': '.$outputlangs->convToOutputCharset($account->owner_name);
1409 $pdf->MultiCell(100, 3, $val, 0,
'L',
false);
1410 $tmpy = $pdf->getStringHeight(100, $val);
1412 } elseif (!$usedetailedbban) {
1419 if (!empty($account->iban)) {
1421 $ibanDisplay_temp = str_replace(
' ',
'', $outputlangs->convToOutputCharset($account->iban));
1424 $nbIbanDisplay_temp =
dol_strlen($ibanDisplay_temp);
1425 for ($i = 0; $i < $nbIbanDisplay_temp; $i++) {
1426 $ibanDisplay .= $ibanDisplay_temp[$i];
1427 if ($i % 4 == 3 && $i > 0) {
1428 $ibanDisplay .=
" ";
1432 $pdf->SetFont(
'',
'B', $default_font_size - 3);
1433 $pdf->SetXY($curx, $cury);
1434 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).
': '.$ibanDisplay, 0,
'L',
false);
1438 if (!empty($account->bic)) {
1439 $pdf->SetFont(
'',
'B', $default_font_size - 3);
1440 $pdf->SetXY($curx, $cury);
1441 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).
': '.$outputlangs->convToOutputCharset($account->bic), 0,
'L',
false);
1444 return $pdf->getY();
1464function pdf_pagefoot($pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur,
$object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark =
'')
1466 global
$conf, $hookmanager;
1468 $outputlangs->load(
"dict");
1471 $marginwithfooter = 0;
1473 $dims = $pdf->getPageDimensions();
1479 if (is_object($fromcompany)) {
1480 $substitutionarray[
'__FROM_NAME__'] = $fromcompany->name;
1481 $substitutionarray[
'__FROM_EMAIL__'] = $fromcompany->email;
1490 $newfreetext = preg_replace(
'/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/',
'\1file:/'.DOL_DATA_ROOT.
'/medias/\2\3', $newfreetext);
1492 $line .= $outputlangs->convToOutputCharset($newfreetext);
1501 if (is_object($fromcompany) && in_array($showdetails, array(1, 3))) {
1503 if ($fromcompany->name) {
1504 $line1 .= ($line1 ?
" - " :
"").$outputlangs->transnoentities(
"RegisteredOffice").
": ".$fromcompany->name;
1507 if ($fromcompany->address) {
1508 $line1 .= ($line1 ?
" - " :
"").str_replace(
"\n",
", ", $fromcompany->address);
1511 if ($fromcompany->zip) {
1512 $line1 .= ($line1 ?
" - " :
"").$fromcompany->zip;
1515 if ($fromcompany->town) {
1516 $line1 .= ($line1 ?
" " :
"").$fromcompany->town;
1519 if ($fromcompany->country) {
1520 $line1 .= ($line1 ?
", " :
"").$fromcompany->country;
1523 if ($fromcompany->phone) {
1524 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Phone").
": ".$fromcompany->phone;
1527 if ($fromcompany->fax) {
1528 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Fax").
": ".$fromcompany->fax;
1532 if ($fromcompany->url) {
1533 $line2 .= ($line2 ?
" - " :
"").$fromcompany->url;
1536 if ($fromcompany->email) {
1537 $line2 .= ($line2 ?
" - " :
"").$fromcompany->email;
1540 if ($showdetails == 2 || $showdetails == 3 || (!empty($fromcompany->country_code) && $fromcompany->country_code ==
'DE')) {
1542 if ($fromcompany->managers) {
1543 $line2 .= ($line2 ?
" - " :
"").$fromcompany->managers;
1549 if (!empty($fromcompany->forme_juridique_code)) {
1550 $line3 .= ($line3 ?
" - " :
"").$outputlangs->convToOutputCharset(
getFormeJuridiqueLabel((
string) $fromcompany->forme_juridique_code));
1553 if (!empty($fromcompany->capital)) {
1554 $tmpamounttoshow =
price2num($fromcompany->capital);
1555 if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
1556 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf",
price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0,
getDolCurrency()));
1557 } elseif (!empty($fromcompany->capital)) {
1558 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf", (
string) $fromcompany->capital);
1562 if (!empty($fromcompany->idprof1) && ($fromcompany->country_code !=
'FR' || (empty($fromcompany->idprof2) || strpos($fromcompany->idprof2, $fromcompany->idprof1) !== 0))) {
1563 $field = $outputlangs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
1564 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1567 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
1570 if (!empty($fromcompany->idprof2)) {
1571 $field = $outputlangs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
1572 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1575 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
1580 if (!empty($fromcompany->idprof3)) {
1581 $field = $outputlangs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
1582 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1585 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
1588 if (!empty($fromcompany->idprof4)) {
1589 $field = $outputlangs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
1590 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1593 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
1596 if (!empty($fromcompany->idprof5)) {
1597 $field = $outputlangs->transcountrynoentities(
"ProfId5", $fromcompany->country_code);
1598 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1601 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
1604 if (!empty($fromcompany->idprof6)) {
1605 $field = $outputlangs->transcountrynoentities(
"ProfId6", $fromcompany->country_code);
1606 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1609 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
1612 if (!empty($fromcompany->idprof7)) {
1613 $field = $outputlangs->transcountrynoentities(
"ProfId7", $fromcompany->country_code);
1614 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1617 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof7);
1620 if (!empty($fromcompany->idprof8)) {
1621 $field = $outputlangs->transcountrynoentities(
"ProfId8", $fromcompany->country_code);
1622 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1625 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof8);
1628 if (!empty($fromcompany->idprof9)) {
1629 $field = $outputlangs->transcountrynoentities(
"ProfId9", $fromcompany->country_code);
1630 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1633 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof9);
1636 if (!empty($fromcompany->idprof10)) {
1637 $field = $outputlangs->transcountrynoentities(
"ProfId10", $fromcompany->country_code);
1638 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1641 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof10);
1644 if (!empty($fromcompany->tva_intra) && $fromcompany->tva_intra !=
'') {
1645 $line4 .= ($line4 ?
" - " :
"").$outputlangs->transnoentities(
"VATIntraShort").
": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
1648 $pdf->SetFont(
'',
'', 7);
1649 $pdf->SetDrawColor(224, 224, 224);
1656 $pdf->SetTextColor($r, $g, $b);
1660 $freetextheight = 0;
1671 $freetextheight = $pdf->getStringHeight($width, $line);
1680 if (is_object($hookmanager)) {
1681 $parameters = array(
'line1' => $line1,
'line2' => $line2,
'line3' => $line3,
'line4' => $line4,
'outputlangs' => $outputlangs);
1683 $hookmanager->executeHooks(
'pdf_pagefoot', $parameters,
$object, $action);
1684 if (!empty($hookmanager->resPrint) && $hidefreetext == 0) {
1685 $mycustomfooter = $hookmanager->resPrint;
1688 $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight;
1689 $posy = (float) $marginwithfooter;
1697 $pdf->setAutoPageBreak(
false, 0);
1698 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F', array(), $fill_color = array($r, $g, $b));
1699 $pdf->setAutoPageBreak(
true, 0);
1703 $pdf->setAutoPageBreak(
false, 0);
1706 $pdf->SetXY($dims[
'lm'], -$posy);
1708 $pdf->MultiCell(0, 3, $line, 0, $align,
false);
1710 $pdf->writeHTMLCell($dims[
'wk'] - $dims[
'lm'] - $dims[
'rm'], $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1712 $posy -= $freetextheight;
1715 $pdf->setAutoPageBreak(
true, 0);
1722 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1733 $pdf->setAutoPageBreak(
false, 0);
1735 $pdf->writeHTMLCell($dims[
'wk'] - $dims[
'lm'] - $dims[
'rm'], $mycustomfooterheight, $dims[
'lm'], $dims[
'hk'] - $posy,
dol_htmlentitiesbr($mycustomfooter, 1,
'UTF-8', 0));
1737 $pdf->setAutoPageBreak(
true, 0);
1740 $posy -= $mycustomfooterheight - 3;
1743 $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
1744 $posy = (float) $marginwithfooter;
1752 $pdf->setAutoPageBreak(
false, 0);
1753 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F', array(), $fill_color = array($r, $g, $b));
1754 $pdf->setAutoPageBreak(
true, 0);
1758 $pdf->setAutoPageBreak(
false, 0);
1761 $pdf->SetXY($dims[
'lm'], -$posy);
1763 $pdf->MultiCell(0, 3, $line, 0, $align,
false);
1765 $pdf->writeHTMLCell($dims[
'wk'] - $dims[
'lm'] - $dims[
'rm'], $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1767 $posy -= $freetextheight;
1770 $pdf->setAutoPageBreak(
true, 0);
1779 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1789 if (!empty($line1)) {
1790 $pdf->SetFont(
'',
'B', 7);
1791 $pdf->SetXY($dims[
'lm'], -$posy);
1792 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line1, 0,
'C',
false);
1794 $pdf->SetFont(
'',
'', 7);
1797 if (!empty($line2)) {
1798 $pdf->SetFont(
'',
'B', 7);
1799 $pdf->SetXY($dims[
'lm'], -$posy);
1800 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line2, 0,
'C',
false);
1802 $pdf->SetFont(
'',
'', 7);
1805 if (!empty($line3)) {
1806 $pdf->SetXY($dims[
'lm'], -$posy);
1807 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line3, 0,
'C',
false);
1810 if (!empty($line4)) {
1812 $pdf->SetXY($dims[
'lm'], -$posy);
1813 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line4, 0,
'C',
false);
1820 $pdf->SetXY($dims[
'wk'] - $dims[
'rm'] - 18 -
getDolGlobalInt(
'PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy -
getDolGlobalInt(
'PDF_FOOTER_PAGE_NUMBER_Y', 0));
1822 $pagination = $pdf->PageNo().
' / '.$pdf->getAliasNbPages();
1823 $fontRenderCorrection = 0;
1824 if (in_array(
pdf_getPDFFont($outputlangs), array(
'freemono',
'DejaVuSans'))) {
1825 $fontRenderCorrection = 10;
1827 $pdf->MultiCell(18 + $fontRenderCorrection, 2, $pagination, 0,
'R',
false);
1830 if (!empty($watermark)) {
1831 pdf_watermark($pdf, $outputlangs, $page_hauteur, $page_largeur,
'mm', $watermark);
1834 return $marginwithfooter;
1853 $linkedobjects = pdf_getLinkedObjects(
$object, $outputlangs);
1855 if (!empty($linkedobjects)) {
1856 foreach ($linkedobjects as $linkedobject) {
1857 $reftoshow = $linkedobject[
"ref_title"].
' : '.$linkedobject[
"ref_value"];
1858 if (!empty($linkedobject[
"date_value"])) {
1859 $reftoshow .=
' / '.$linkedobject[
"date_value"];
1863 $pdf->SetXY($posx, $posy);
1864 $pdf->SetFont(
'',
'', (
float) $default_font_size - 2);
1865 $pdf->MultiCell($w, $h, $reftoshow,
'', $align);
1869 return $pdf->getY();
1889function pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0, $align =
'J')
1891 global $hookmanager;
1896 if (is_object($hookmanager)) {
1897 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
1898 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
1899 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
1901 $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);
1905 $reshook = $hookmanager->executeHooks(
'pdf_writelinedesc', $parameters,
$object, $action);
1907 if (!empty($hookmanager->resPrint)) {
1908 $result .= $hookmanager->resPrint;
1911 if (empty($reshook)) {
1913 $labelproductservice = preg_replace(
'/(<img[^>]*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)/',
'\1file:/'.DOL_DATA_ROOT.
'/medias/\2\3', $labelproductservice, -1, $nbrep);
1920 $labelproductservice = preg_replace(
'/(<img[^>]*src=")([^"]*)(&)([^"]*")/',
'\1\2&\4', $labelproductservice, -1, $nbrep);
1923 $pdf->setListIndentWidth(5);
1924 $TMarginList = [
'ul' => [[
'h' => 0.1, ],[
'h' => 0.1, ]],
'li' => [[
'h' => 0.1, ],],];
1925 $pdf->setHtmlVSpace($TMarginList);
1929 $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1,
false,
true, $align,
true);
1930 $result .= $labelproductservice;
1950 $idprod = (!empty(
$object->lines[$i]->fk_product) ?
$object->lines[$i]->fk_product :
false);
1951 $label = (!empty(
$object->lines[$i]->label) ?
$object->lines[$i]->label : (!empty(
$object->lines[$i]->product_label) ?
$object->lines[$i]->product_label :
''));
1952 $product_barcode = (!empty(
$object->lines[$i]->product_barcode) ?
$object->lines[$i]->product_barcode :
"");
1953 $desc = (!empty(
$object->lines[$i]->desc) ?
$object->lines[$i]->desc : (!empty(
$object->lines[$i]->description) ?
$object->lines[$i]->description :
''));
1954 $ref_supplier = (!empty(
$object->lines[$i]->ref_supplier) ?
$object->lines[$i]->ref_supplier : (!empty(
$object->lines[$i]->ref_fourn) ?
$object->lines[$i]->ref_fourn :
''));
1955 $note = (!empty(
$object->lines[$i]->note) ?
$object->lines[$i]->note :
'');
1956 $dbatch = (!empty(
$object->lines[$i]->detail_batch) ?
$object->lines[$i]->detail_batch :
false);
1960 if ($issupplierline) {
1961 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1964 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1968 include_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1973 $idprod = (!empty(
$object->lines[$i]->fk_product) ?
$object->lines[$i]->fk_product :
false);
1975 $prodser->fetch($idprod);
1977 if ($multilangsactive) {
1978 $prodser->getMultiLangs();
1979 $object->lines[$i]->multilangs = $prodser->multilangs;
1983 if (!empty(
$object->lines[$i]->label)) {
1984 $label =
$object->lines[$i]->label;
1986 if (!empty(
$object->lines[$i]->multilangs[$outputlangs->defaultlang][
'label']) && $multilangsactive) {
1987 $label =
$object->lines[$i]->multilangs[$outputlangs->defaultlang][
'label'];
1989 if (!empty(
$object->lines[$i]->product_label)) {
1990 $label =
$object->lines[$i]->product_label;
1997 if (!empty(
$object->lines[$i]->desc)) {
1998 $desc =
$object->lines[$i]->desc;
2000 if (!empty(
$object->lines[$i]->multilangs[$outputlangs->defaultlang][
'description']) && $multilangsactive) {
2001 $desc =
$object->lines[$i]->multilangs[$outputlangs->defaultlang][
'description'];
2003 if (!empty(
$object->lines[$i]->description)) {
2004 $desc =
$object->lines[$i]->description;
2011 $ref_supplier = (!empty(
$object->lines[$i]->ref_supplier) ?
$object->lines[$i]->ref_supplier : (!empty(
$object->lines[$i]->ref_fourn) ?
$object->lines[$i]->ref_fourn :
''));
2013 $note = (!empty(
$object->lines[$i]->note) ?
$object->lines[$i]->note :
'');
2015 $dbatch = (!empty(
$object->lines[$i]->detail_batch) ?
$object->lines[$i]->detail_batch :
false);
2019 if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) {
2020 $translatealsoifmodified =
getDolGlobalString(
'MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED');
2028 $textwasnotmodified = ($label == $prodser->label);
2029 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"label"]) && ($textwasnotmodified || $translatealsoifmodified)) {
2030 $label = $prodser->multilangs[$outputlangs->defaultlang][
"label"];
2035 $textwasnotmodified =
false;
2039 $textwasnotmodified = ($desc == $prodser->description);
2041 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"description"])) {
2042 if ($textwasnotmodified) {
2043 $desc = str_replace($prodser->description, $prodser->multilangs[$outputlangs->defaultlang][
"description"], $desc);
2044 } elseif ($translatealsoifmodified) {
2045 $desc = $prodser->multilangs[$outputlangs->defaultlang][
"description"];
2050 $textwasnotmodified = ($note == $prodser->note_public);
2051 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"other"]) && ($textwasnotmodified || $translatealsoifmodified)) {
2052 $note = $prodser->multilangs[$outputlangs->defaultlang][
"other"];
2055 } elseif ((
$object->element ==
'facture' ||
$object->element ==
'facturefourn') && preg_match(
'/^\(DEPOSIT\).+/', $desc)) {
2056 $desc = str_replace(
'(DEPOSIT)', $outputlangs->trans(
'Deposit'), $desc);
2059 $labelproductservice =
'';
2062 $labelproductservice = $label;
2067 $labelproductservice = str_replace(
"\n",
'<br>', $labelproductservice);
2069 $labelproductservice =
'<b>'.$labelproductservice.
'</b>';
2076 $prodser->get_sousproduits_arbo();
2077 if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
2078 $outputlangs->load(
'mrp');
2079 $tmparrayofsubproducts = reset($prodser->sousprods);
2082 if (isset(
$object->lines[$i]->qty) && !empty(
$object->lines[$i]->qty)) {
2083 $qtyText =
$object->lines[$i]->qty;
2084 } elseif (isset(
$object->lines[$i]->qty_shipped) && !empty(
$object->lines[$i]->qty_shipped)) {
2085 $qtyText =
$object->lines[$i]->qty;
2089 foreach ($tmparrayofsubproducts as $subprodval) {
2093 $outputlangs->trans(
'Qty').
':'.$qtyText.
' x '.$outputlangs->trans(
'AssociatedProducts').
':'.$subprodval[1].
'= '.$outputlangs->trans(
'QtyTot').
':'.$subprodval[1] * $qtyText :
2094 $outputlangs->trans(
'Qty').
' '.$outputlangs->trans(
'AssociatedProducts').
':'.$subprodval[1])
2098 foreach ($tmparrayofsubproducts as $subprodval) {
2100 dol_concatdesc($labelproductservice,
" * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ?
' - ' :
'').$subprodval[3]),
2102 $outputlangs->trans(
'Qty').
':'.$qtyText.
' x '.$outputlangs->trans(
'AssociatedProducts').
':'.$subprodval[1].
'= '.$outputlangs->trans(
'QtyTot').
':'.$subprodval[1] * $qtyText :
2103 $outputlangs->trans(
'Qty').
' '.$outputlangs->trans(
'AssociatedProducts').
':'.$subprodval[1])
2111 $labelproductservice =
dol_concatdesc($labelproductservice, $outputlangs->trans(
"BarCode").
" ".$product_barcode);
2115 if (!empty($desc) && ($desc != $label)) {
2116 if ($desc ==
'(CREDIT_NOTE)' &&
$object->lines[$i]->fk_remise_except) {
2118 $discount->fetch(
$object->lines[$i]->fk_remise_except);
2119 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
2120 $labelproductservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromCreditNote", $sourceref);
2121 } elseif ($desc ==
'(DEPOSIT)' &&
$object->lines[$i]->fk_remise_except) {
2123 $discount->fetch(
$object->lines[$i]->fk_remise_except);
2124 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
2125 $labelproductservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromDeposit", $sourceref);
2128 $labelproductservice .=
' ('.dol_print_date($discount->datec,
'day',
'', $outputlangs).
')';
2130 } elseif ($desc ==
'(EXCESS RECEIVED)' &&
$object->lines[$i]->fk_remise_except) {
2132 $discount->fetch(
$object->lines[$i]->fk_remise_except);
2133 $labelproductservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessReceived", $discount->ref_facture_source);
2134 } elseif ($desc ==
'(EXCESS PAID)' &&
$object->lines[$i]->fk_remise_except) {
2136 $discount->fetch(
$object->lines[$i]->fk_remise_except);
2137 $labelproductservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
2141 if (!empty(
$object->element)) {
2142 $tmpkey =
'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper(
$object->element);
2147 if (empty($hidedesc)) {
2149 $labelproductservice =
dol_concatdesc($desc, $labelproductservice);
2152 $labelproductservice = $desc;
2154 $labelproductservice =
dol_concatdesc($labelproductservice, $desc);
2159 $labelproductservice =
dol_concatdesc($labelproductservice, $desc);
2165 $prefix_prodserv =
"";
2168 if ($prodser->isService()) {
2169 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Service").
" ";
2171 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Product").
" ";
2175 if (empty($hideref)) {
2176 if ($issupplierline) {
2178 $ref_prodserv = $prodser->ref;
2179 if ($ref_supplier) {
2180 $ref_prodserv .= ($prodser->ref ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
"SupplierRef").
' '.$ref_supplier.($prodser->ref ?
')' :
'');
2182 } elseif (
getDolGlobalInt(
'PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES') == 1) {
2183 $ref_prodserv = $ref_supplier;
2184 } elseif (
getDolGlobalInt(
'PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES') == 2) {
2185 $ref_prodserv = $ref_supplier.
' ('.$outputlangs->transnoentitiesnoconv(
"InternalRef").
' '.$prodser->ref.
')';
2188 $ref_prodserv = $prodser->ref;
2192 $filter = array(
'fk_product' => (
string) $idprod,
'fk_soc' => (
string)
$object->socid);
2194 $nbCustomerPrices = $productCustomerPriceStatic->fetchAll(
'',
'', 1, 0, $filter);
2196 if ($nbCustomerPrices > 0) {
2197 $productCustomerPrice =
null;
2198 if (count($productCustomerPriceStatic->lines) > 0) {
2199 $date_now = (int) floor(
dol_now() / 86400) * 86400;
2200 foreach ($productCustomerPriceStatic->lines as $k => $custprice_line) {
2201 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
2202 $productCustomerPrice = $custprice_line;
2208 if (isset($productCustomerPrice) && !empty($productCustomerPrice->ref_customer)) {
2209 $idcustprice =
getDolGlobalInt(
'PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE');
2210 switch ($idcustprice) {
2212 $ref_prodserv = $productCustomerPrice->ref_customer;
2216 $ref_prodserv = $productCustomerPrice->ref_customer .
' (' . $outputlangs->transnoentitiesnoconv(
'InternalRef') .
' ' . $ref_prodserv .
')';
2220 $ref_prodserv = $ref_prodserv .
' (' . $outputlangs->transnoentitiesnoconv(
'RefCustomer') .
' ' . $productCustomerPrice->ref_customer .
')';
2227 if (!empty($labelproductservice) && !empty($ref_prodserv)) {
2228 $ref_prodserv .=
" - ";
2232 if (!empty($ref_prodserv) &&
getDolGlobalString(
'PDF_BOLD_PRODUCT_REF_AND_PERIOD')) {
2234 $labelproductservice = str_replace(
"\n",
'<br>', $labelproductservice);
2236 $ref_prodserv =
'<b>'.$ref_prodserv.
'</b>';
2239 $labelproductservice = $prefix_prodserv.$ref_prodserv.$labelproductservice;
2243 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2246 $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
2247 foreach ($tblcateg as $cate) {
2249 $desccateg = $cate->description;
2251 $labelproductservice =
dol_concatdesc($labelproductservice, $desccateg);
2256 if (!empty(
$object->lines[$i]->date_start) || !empty(
$object->lines[$i]->date_end)) {
2260 if (
$object->lines[$i]->date_start &&
$object->lines[$i]->date_end) {
2261 $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)).
')';
2263 if (
$object->lines[$i]->date_start && !
$object->lines[$i]->date_end) {
2264 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date(
$object->lines[$i]->date_start, $format,
false, $outputlangs)).
')';
2266 if (!
$object->lines[$i]->date_start &&
$object->lines[$i]->date_end) {
2267 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date(
$object->lines[$i]->date_end, $format,
false, $outputlangs)).
')';
2272 $labelproductservice = str_replace(
"\n",
'<br>', $labelproductservice);
2274 $labelproductservice .=
'<br><b style="color:#333666;" ><em>'.$period.
'</em></b>';
2276 $labelproductservice =
dol_concatdesc($labelproductservice, $period);
2282 if (!empty($dbatch)) {
2287 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
2288 include_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
2293 foreach ($dbatch as $detail) {
2295 if ($detail->eatby) {
2296 $dte[] = $outputlangs->transnoentitiesnoconv(
'printEatby',
dol_print_date($detail->eatby, $format,
false, $outputlangs));
2298 if ($detail->sellby) {
2299 $dte[] = $outputlangs->transnoentitiesnoconv(
'printSellby',
dol_print_date($detail->sellby, $format,
false, $outputlangs));
2301 if ($detail->batch) {
2302 $dte[] = $outputlangs->transnoentitiesnoconv(
'printBatch', $detail->batch);
2305 $dte[] = $outputlangs->transnoentitiesnoconv(
'printQty', (
string) $detail->qty);
2309 if (
$object->element ==
'shipping' && $detail->fk_origin_stock > 0 &&
getDolGlobalInt(
'PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT')) {
2310 $resproductbatch = $tmpproductbatch->fetch($detail->fk_origin_stock);
2311 if ($resproductbatch > 0) {
2312 $reswarehouse = $tmpwarehouse->fetch($tmpproductbatch->warehouseid);
2313 if ($reswarehouse > 0) {
2314 $dte[] = $tmpwarehouse->ref;
2319 $labelproductservice .=
"__N__ ".implode(
" - ", $dte);
2329 $labelproductservice = preg_replace(
'/__N__/',
'<br>', $labelproductservice);
2331 $labelproductservice = preg_replace(
'/__N__/',
"\n", $labelproductservice);
2335 return $labelproductservice;
2349 global $hookmanager;
2354 if (is_object($hookmanager)) {
2355 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2356 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2357 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2359 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2361 $reshook = $hookmanager->executeHooks(
'pdf_getlinenum', $parameters,
$object, $action);
2362 $result .= $hookmanager->resPrint;
2364 if (empty($reshook)) {
2382 global $hookmanager;
2387 if (is_object($hookmanager)) {
2388 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2389 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2390 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2392 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2394 $reshook = $hookmanager->executeHooks(
'pdf_getlineref', $parameters,
$object, $action);
2395 $result .= $hookmanager->resPrint;
2397 if (empty($reshook)) {
2415 global $hookmanager;
2420 if (is_object($hookmanager)) {
2421 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2422 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2423 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2425 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2427 $reshook = $hookmanager->executeHooks(
'pdf_getlineref_supplier', $parameters,
$object, $action);
2428 $result .= $hookmanager->resPrint;
2430 if (empty($reshook)) {
2452 if (is_object($hookmanager)) {
2453 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2454 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2455 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2457 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2459 $reshook = $hookmanager->executeHooks(
'pdf_getlinevatrate', $parameters,
$object, $action);
2461 if (!empty($hookmanager->resPrint)) {
2462 $result .= $hookmanager->resPrint;
2465 if (empty($reshook)) {
2466 if (empty($hidedetails) || $hidedetails > 1) {
2472 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
2477 $tmpresult .=
vatrate((
string) abs(
$object->lines[$i]->localtax1_tx),
false);
2482 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
2487 $tmpresult .=
vatrate((
string) abs(
$object->lines[$i]->localtax2_tx),
false);
2492 $result .= $tmpresult;
2509 global $hookmanager;
2519 if (is_object($hookmanager)) {
2520 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2521 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2522 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2524 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2526 $reshook = $hookmanager->executeHooks(
'pdf_getlineupexcltax', $parameters,
$object, $action);
2528 if (!empty($hookmanager->resPrint)) {
2529 $result .= $hookmanager->resPrint;
2532 if (empty($reshook)) {
2533 if (empty($hidedetails) || $hidedetails > 1) {
2535 $result .=
price($sign * $subprice, 0, $outputlangs);
2552 global $hookmanager;
2562 if (is_object($hookmanager)) {
2563 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2564 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2565 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2567 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2569 $reshook = $hookmanager->executeHooks(
'pdf_getlineupwithtax', $parameters,
$object, $action);
2571 if (!empty($hookmanager->resPrint)) {
2572 $result .= $hookmanager->resPrint;
2575 if (empty($reshook)) {
2576 if (empty($hidedetails) || $hidedetails > 1) {
2577 $result .=
price($sign * ((
$object->lines[$i]->subprice) + (
$object->lines[$i]->subprice) * (
$object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
2594 global $hookmanager;
2599 if (is_object($hookmanager)) {
2600 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2601 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2602 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2604 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2606 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty', $parameters,
$object, $action);
2608 if (!empty($hookmanager->resPrint)) {
2609 $result = $hookmanager->resPrint;
2612 if (empty($reshook)) {
2613 if (
$object->lines[$i]->special_code == 3) {
2616 if (empty($hidedetails) || $hidedetails > 1) {
2617 $result .=
$object->lines[$i]->qty;
2634 global $hookmanager;
2639 if (is_object($hookmanager)) {
2640 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2641 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2642 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2644 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2646 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_asked', $parameters,
$object, $action);
2648 if (!empty($hookmanager->resPrint)) {
2649 $result .= $hookmanager->resPrint;
2652 if (empty($reshook)) {
2653 if (
$object->lines[$i]->special_code == 3) {
2656 if (empty($hidedetails) || $hidedetails > 1) {
2657 $result .=
$object->lines[$i]->qty_asked;
2674 global $hookmanager;
2679 if (is_object($hookmanager)) {
2680 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2681 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2682 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2684 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2686 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_shipped', $parameters,
$object, $action);
2688 if (!empty($hookmanager->resPrint)) {
2689 $result .= $hookmanager->resPrint;
2692 if (empty($reshook)) {
2693 if (
$object->lines[$i]->special_code == 3) {
2696 if (empty($hidedetails) || $hidedetails > 1) {
2697 $result .=
$object->lines[$i]->qty_shipped;
2714 global $hookmanager;
2719 if (is_object($hookmanager)) {
2720 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2721 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2722 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2724 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2726 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_keeptoship', $parameters,
$object, $action);
2728 if (!empty($hookmanager->resPrint)) {
2729 $result .= $hookmanager->resPrint;
2732 if (empty($reshook)) {
2733 if (
$object->lines[$i]->special_code == 3) {
2736 if (empty($hidedetails) || $hidedetails > 1) {
2737 $result .= (
$object->lines[$i]->qty_asked -
$object->lines[$i]->qty_shipped);
2754 global $hookmanager;
2759 if (is_object($hookmanager)) {
2760 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2761 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2762 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2764 $parameters = array(
2766 'outputlangs' => $outputlangs,
2767 'hidedetails' => $hidedetails,
2768 'special_code' => $special_code
2771 $reshook = $hookmanager->executeHooks(
'pdf_getlineunit', $parameters,
$object, $action);
2773 if (!empty($hookmanager->resPrint)) {
2774 $result .= $hookmanager->resPrint;
2777 if (empty($reshook)) {
2778 if (empty($hidedetails) || $hidedetails > 1) {
2779 $result .=
$object->lines[$i]->getLabelOfUnit(
'short', $outputlangs, 1);
2797 global $hookmanager;
2799 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2804 if (is_object($hookmanager)) {
2805 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2806 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2807 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2809 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2811 $reshook = $hookmanager->executeHooks(
'pdf_getlineremisepercent', $parameters,
$object, $action);
2813 if (!empty($hookmanager->resPrint)) {
2814 $result .= $hookmanager->resPrint;
2817 if (empty($reshook)) {
2818 if (
$object->lines[$i]->special_code == 3) {
2821 if (empty($hidedetails) || $hidedetails > 1) {
2840 if (empty($hookmanager)) {
2841 global $hookmanager;
2847 if (is_object($hookmanager)) {
2848 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2849 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2850 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2852 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2854 $reshook = $hookmanager->executeHooks(
'pdf_getlineprogress', $parameters,
$object, $action);
2856 if (!empty($hookmanager->resPrint)) {
2857 return $hookmanager->resPrint;
2860 if (empty($reshook)) {
2861 if (
$object->lines[$i]->special_code == 3) {
2864 if (empty($hidedetails) || $hidedetails > 1) {
2870 if ($isCumulative xor $showDelta) {
2874 $result =
$object->lines[$i]->situation_percent;
2880 if ($isCumulative) {
2882 if (method_exists(
$object->lines[$i],
'get_prev_progress')) {
2883 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
2891 if (method_exists(
$object->lines[$i],
'getAllPrevProgress')) {
2892 $prev_progress =
$object->lines[$i]->getAllPrevProgress(
$object->id);
2893 } elseif (method_exists(
$object->lines[$i],
'get_prev_progress')) {
2894 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
2897 $result = $isCumulative ?
2899 $object->lines[$i]->situation_percent - $prev_progress :
2901 $prev_progress +
$object->lines[$i]->situation_percent;
2903 $result = round($result, 1).
'%';
2920 global $hookmanager;
2930 if (is_object($hookmanager)) {
2931 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2932 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2933 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2935 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code,
'sign' => $sign);
2937 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalexcltax', $parameters,
$object, $action);
2939 if (!empty($hookmanager->resPrint)) {
2940 $result .= $hookmanager->resPrint;
2943 if (empty($reshook)) {
2944 if (!empty(
$object->lines[$i]) &&
$object->lines[$i]->special_code == 3) {
2945 $result .= $outputlangs->transnoentities(
"Option");
2946 } elseif (empty($hidedetails) || $hidedetails > 1) {
2948 if (!empty(
$object->lines[$i]->situation_percent) &&
$object->lines[$i]->situation_percent > 0) {
2949 if (method_exists(
$object->lines[$i],
'getSituationRatio')) {
2950 $total_ht *=
$object->lines[$i]->getSituationRatio();
2953 $result .=
price($sign * $total_ht, 0, $outputlangs);
2970 global $hookmanager;
2980 if (is_object($hookmanager)) {
2981 $special_code = empty(
$object->lines[$i]->special_code) ?
'' :
$object->lines[$i]->special_code;
2982 if (!empty(
$object->lines[$i]->fk_parent_line) &&
$object->lines[$i]->fk_parent_line > 0) {
2983 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
2985 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2987 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalwithtax', $parameters,
$object, $action);
2989 if (!empty($hookmanager->resPrint)) {
2990 $result .= $hookmanager->resPrint;
2993 if (empty($reshook)) {
2994 if (
$object->lines[$i]->special_code == 3) {
2995 $result .= $outputlangs->transnoentities(
"Option");
2996 } elseif (empty($hidedetails) || $hidedetails > 1) {
2998 if (isset(
$object->lines[$i]->situation_percent) &&
$object->lines[$i]->situation_percent > 0) {
2999 $total_ttc *=
$object->lines[$i]->getSituationRatio();
3001 $result .=
price($sign * $total_ttc, 0, $outputlangs);
3026 if (!empty($objectSocId) && !empty($elementSocId) && $objectSocId != $elementSocId) {
3041function pdf_getLinkedObjects(
$object, $outputlangs)
3043 global
$db, $hookmanager;
3045 $linkedobjects = array();
3049 foreach (
$object->linkedObjects as $objecttype => $objects) {
3050 if ($objecttype ==
'facture') {
3052 } elseif ($objecttype ==
'propal' || $objecttype ==
'supplier_proposal') {
3053 '@phan-var-force array<Propal|SupplierProposal> $objects';
3055 $outputlangs->load(
'propal');
3057 foreach ($objects as $elementobject) {
3058 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefProposal");
3059 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
3060 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DatePropal");
3061 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
3063 } elseif ($objecttype ==
'commande' || $objecttype ==
'supplier_order' || $objecttype ==
'order_supplier') {
3064 $optiontohidelinkedorders =
"PDF_HIDE_LINKED_ORDERS_ON_SAME_THIRDPARTY";
3065 if ($objecttype ==
'supplier_order' || $objecttype ==
'order_supplier') {
3066 $optiontohidelinkedorders =
"PDF_HIDE_LINKED_PURCHASE_ORDERS_ON_SAME_THIRDPARTY";
3068 '@phan-var-force array<Commande|CommandeFournisseur> $objects';
3069 $outputlangs->load(
'orders');
3072 if (empty(
$object->context[
'DolPublicNoteAppendedGetLinkedObjects'])) {
3074 foreach ($objects as $elementobject) {
3076 $outputList =
dol_concatdesc($outputList, $outputlangs->transnoentities($elementobject->ref) . (empty($elementobject->ref_client) ?
'' :
' (' . $elementobject->ref_client .
')') . (empty($elementobject->ref_supplier) ?
'' :
' (' . $elementobject->ref_supplier .
')') .
' ');
3077 $outputList =
dol_concatdesc($outputList, $outputlangs->transnoentities(
"OrderDate") .
' : ' .
dol_print_date($elementobject->date,
'day',
'', $outputlangs));
3081 if (!empty($outputList)) {
3087 $elementobject = array_shift($objects);
3089 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder");
3090 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref).(!empty($elementobject->ref_client) ?
' ('.$elementobject->ref_client.
')' :
'').(!empty($elementobject->ref_supplier) ?
' ('.$elementobject->ref_supplier.
')' :
'');
3091 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"OrderDate");
3092 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
3095 } elseif ($objecttype ==
'contrat') {
3096 '@phan-var-force Contrat[] $objects';
3097 $outputlangs->load(
'contracts');
3098 foreach ($objects as $elementobject) {
3100 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefContract");
3101 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
3102 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DateContract");
3103 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date_contrat,
'day',
'', $outputlangs);
3106 } elseif ($objecttype ==
'fichinter') {
3107 '@phan-var-force Fichinter[] $objects';
3108 $outputlangs->load(
'interventions');
3109 foreach ($objects as $elementobject) {
3111 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"InterRef");
3112 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
3113 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"InterDate");
3114 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->datec,
'day',
'', $outputlangs);
3117 } elseif ($objecttype ==
'shipping') {
3118 '@phan-var-force Expedition[] $objects';
3119 $outputlangs->loadLangs(array(
"orders",
"sendings"));
3121 if (count($objects) > 1) {
3125 if (empty(
$object->linkedObjects[
'commande']) &&
$object->element !=
'commande') {
3126 $refListsTxt .= $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending").
' :';
3128 $refListsTxt .= $outputlangs->transnoentities(
"RefSending").
' :';
3131 foreach ($objects as $elementobject) {
3132 if (empty(
$object->linkedObjects[
'commande']) &&
$object->element !=
'commande') {
3133 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
3134 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
3135 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
3137 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
3143 $refListsTxt .= (!empty($refListsTxt) ?
' ' :
'');
3144 if (! is_object($order)) {
3145 $refListsTxt .= $outputlangs->transnoentities($elementobject->ref);
3147 $refListsTxt .= $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
'');
3148 $refListsTxt .=
' / '.$outputlangs->transnoentities($elementobject->ref);
3152 if (empty(
$object->context[
'DolPublicNoteAppendedGetLinkedObjects']) && !
getDolGlobalString(
"PDF_HIDE_LINKED_OBJECT_IN_PUBLIC_NOTE")) {
3155 } elseif (count($objects) == 1) {
3156 $elementobject = array_shift($objects);
3159 if (empty(
$object->linkedObjects[
'commande']) &&
$object->element !=
'commande') {
3160 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
3161 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
3162 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
3164 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
3171 if (! is_object($order)) {
3172 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefSending");
3173 if (empty($linkedobjects[$objecttype][
'ref_value'])) {
3174 $linkedobjects[$objecttype][
'ref_value'] =
'';
3176 $linkedobjects[$objecttype][
'ref_value'] .=
' / ';
3178 $linkedobjects[$objecttype][
'ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
3179 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
3181 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending");
3182 if (empty($linkedobjects[$objecttype][
'ref_value'])) {
3183 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
'');
3185 $linkedobjects[$objecttype][
'ref_value'] .=
' / '.$outputlangs->transnoentities($elementobject->ref);
3186 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
3192 $object->context[
'DolPublicNoteAppendedGetLinkedObjects'] = 1;
3195 if (is_object($hookmanager)) {
3196 $parameters = array(
'linkedobjects' => $linkedobjects,
'outputlangs' => $outputlangs);
3198 $reshook = $hookmanager->executeHooks(
'pdf_getLinkedObjects', $parameters,
$object, $action);
3199 if (empty($reshook)) {
3200 $linkedobjects = array_replace($linkedobjects, $hookmanager->resArray);
3201 } elseif ($reshook > 0) {
3203 $linkedobjects = $hookmanager->resArray;
3207 return $linkedobjects;
3220 $maxheight =
getDolGlobalInt(
'MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT', 32);
3222 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
3226 if ($tmp[
'height']) {
3227 $width = (int) round($maxheight * $tmp[
'width'] / $tmp[
'height']);
3228 if ($width > $maxwidth) {
3230 $height = (int) round($maxwidth * $tmp[
'height'] / $tmp[
'width']);
3232 $height = $maxheight;
3235 return array(
'width' => $width,
'height' => $height);
3251 global $hookmanager;
3257 if (
$object->lines[$i]->special_code == 3) {
3259 return $outputlangs->transnoentities(
"Option");
3261 if (is_object($hookmanager)) {
3262 $special_code =
$object->lines[$i]->special_code;
3263 if (!empty(
$object->lines[$i]->fk_parent_line)) {
3264 $special_code =
$object->getSpecialCode(
$object->lines[$i]->fk_parent_line);
3267 $parameters = array(
3269 'outputlangs' => $outputlangs,
3270 'hidedetails' => $hidedetails,
3271 'special_code' => $special_code,
3272 'multicurrency' => $multicurrency
3277 if ($hookmanager->executeHooks(
'getlinetotalremise', $parameters,
$object, $action) > 0) {
3278 if (isset($hookmanager->resArray[
'linetotalremise'])) {
3279 return (
float) $hookmanager->resArray[
'linetotalremise'];
3281 return (
float) $hookmanager->resPrint;
3286 if (empty($hidedetails) || $hidedetails > 1) {
3287 if (empty($multicurrency)) {
3289 return (
float)
price2num($diff,
'MT', 1);
3291 $diff = (float)
price2num($sign *
$object->lines[$i]->multicurrency_subprice * (
float)
$object->lines[$i]->qty,
'MT', 1) -
$object->lines[$i]->multicurrency_total_ht;
3292 return (
float)
price2num($diff,
'MT', 1);
3309 return "ERROR: FILE NOT FOUND OR NOT VALID";
3320 $content = preg_replace(
'/[^(\x20-\x7F)]*/',
'', $content);
3321 if (preg_match(
'/\/' . preg_quote($field,
'/') .
'\s*\((.*?)\)/', $content, $matches)) {
3322 return trim($matches[1]);
3324 return "ERROR: NOT FOUND";
3326 return "ERROR: FAILED TO READ PDF";
3357 bool $isSubtotal =
false,
3358 bool $applySubtotalLogic =
true
3360 $savePage = $pdf->getPage();
3361 $saveX = $pdf->GetX();
3362 $prevAlign = $generator->cols[
'desc'][
'content'][
'align'];
3364 if ($isSubtotal && $applySubtotalLogic &&
$object->lines[$i]->qty < 0) {
3365 $outputlangs->load(
"subtotals");
3366 $object->lines[$i]->desc =
getDolGlobalString(
"SUBTOTAL_LINE_TEXT_DOES_NOT_INCLUDE_TITLE_TEXT") ? $outputlangs->trans(
"SubTotal") : $outputlangs->trans(
"SubtotalOf",
$object->lines[$i]->desc);
3367 $generator->cols[
'desc'][
'content'][
'align'] = ($prevAlign ===
'L') ?
'R' :
'L';
3370 $pdf->startTransaction();
3371 $pdf->SetXY($saveX, $curY);
3373 $pageAfter = $pdf->getPage();
3374 $yAfter = $pdf->GetY();
3375 $pdf->rollbackTransaction(
true);
3377 $pdf->SetFillColor($bgColor[0], $bgColor[1], $bgColor[2]);
3378 $width = $generator->page_largeur - $generator->marge_droite - $generator->marge_gauche;
3380 $pdf->SetXY($generator->marge_gauche, $curY);
3381 if ($pageAfter === $savePage) {
3382 $pdf->MultiCell($width, max(0, $yAfter - $curY),
'', 0,
'',
true);
3384 $pdf->MultiCell($width, $pdf->getPageHeight() - $pdf->getBreakMargin() - $curY,
'', 0,
'',
true);
3386 $pdf->setPage($pageAfter);
3387 $pdf->SetXY($generator->marge_gauche, $pdf->getMargins()[
'top']);
3388 $pdf->MultiCell($width, max(0, $yAfter - $pdf->getMargins()[
'top']),
'', 0,
'',
true);
3390 $pdf->setPage($savePage);
3393 $pdf->SetTextColor(
colorIsLight(implode(
',', $bgColor)));
3394 $pdf->SetXY($saveX, $curY);
3398 $generator->cols[
'desc'][
'content'][
'align'] = $prevAlign;
if(! $sortfield) if(! $sortorder) $object
pdfWriteBlockedLogSignature(&$pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy)
Add some information from the blockedlog module.
pdfCertifMentionblockedLog(&$pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
Add legal mention.
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage categories.
Class to manage customers orders.
Parent class for documents (PDF, ODT, ...) generators.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
setAfterColsLinePositionsData(string $colId, float $y, int $pageNumb)
Used for to set afterColsLinePositions var in a pdf draw line loop.
Class to manage absolute discounts.
Class to manage warehouses.
File of class to manage predefined price products or services by customer.
Class to manage predefined suppliers products.
Class to manage products or services.
Manage record for batch number management.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
getState($id, $withcode='0', $dbtouse=null, $withregion=0, $outputlangs=null, $entconv=1)
Return state translated from an id.
getFormeJuridiqueLabel($code)
Return the name translated of juridical status.
dol_is_file($pathoffile)
Return if path is a file.
dol_print_reduction($reduction, $langs)
Returns formatted reduction.
dol_getDefaultFormat($outputlangs=null)
Try to guess default paper format according to language into $langs.
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_now($mode='gmt')
Return date for now.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getObjectSocId($obj)
Get the socid of an object, supporting legacy attribute names.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
colorIsLight($stringcolor)
Return true if the color is light.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png, bmp and webp)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_watermark($pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdfCertifMention($pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
Add legal certificate mention.
pdf_getlinedesc($object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
Return line description translated in outputlangs and encoded into htmlentities and with
pdf_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, $hidedetails=0, $multicurrency=0)
Return line total amount discount.
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdfExtractMetadata($file, $field='Keywords')
Function to extract metadata from a PDF file by doing a binary parsing of the PDF file.
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank information for PDF generation.
pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails=0)
Return line quantity shipped.
pdf_getlinenum($object, $i, $outputlangs, $hidedetails=0)
Return line num.
pdf_getEncryption($pathoffile)
Return if pdf file is protected/encrypted.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0, $align='J')
Output line description into PDF.
pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price including tax.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails=0)
Return line ref_supplier.
pdfWriteVATArray($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis, $object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl)
Add some information from the blockedlog module.
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdf_getlineprogress($object, $i, $outputlangs, $hidedetails=0, $hookmanager=null)
Return line percent.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
pdf_admin_prepare_head()
Return array head with list of tabs to view object information.
canDisplayLinkedObjectInPDF($object, $elementobject)
Check if a linked object can be displayed based on third-party privacy rules.
pdf_pagehead($pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdfGetHeightForHtmlContent($pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
pdf_pagefoot($pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_render_subtotals(TCPDF $pdf, CommonDocGenerator $generator, float $curY, CommonObject $object, int $i, Translate $outputlangs, int $hideref, int $hidedesc, array $bgColor, bool $isSubtotal=false, bool $applySubtotalLogic=true)
Render subtotals line with a colored background and adapted text color .
pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails=0)
Return line keep to ship quantity.
pdf_getlineref($object, $i, $outputlangs, $hidedetails=0)
Return line product ref.
pdfWriteAdditionnalTitle($pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy)
Add some information from the blockedlog module.
pdfWriteAlreadyPaid($docgenerator, &$index, $pdf, $outputlangs, $outputlangsbis, $object, $col1x, $col2x, $largcol2, $tab2_top, $tab2_hl, $deja_regle, $creditnoteamount, $depositsamount, $resteapayer, $resteapayer_origin)
Add some information from the blockedlog module.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formatted for output on PDF documents.
pdf_writeLogoOrCompanyName($pdf, $outputlangs, $emetteur, $logodir, $posx, $posy, $w, $default_font_size, $align)
Output company logo on top-left of a PDF page header, or the company name as fallback text if no logo...
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0)
Return line unit.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails=0)
Return line quantity asked.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.