39 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
49 global $langs, $conf, $user;
54 $head[$h][0] = DOL_URL_ROOT.
'/admin/pdf.php';
55 $head[$h][1] = $langs->trans(
"Parameters");
56 $head[$h][2] =
'general';
66 $head[$h][0] = DOL_URL_ROOT.
'/admin/pdf_other.php';
67 $head[$h][1] = $langs->trans(
"Others");
68 $head[$h][2] =
'other';
87 global $conf, $db, $langs;
89 dol_syslog(
"pdf_getFormat Get paper format with mode=".$mode.
" MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT) ?
'null' : $conf->global->MAIN_PDF_FORMAT).
" outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null').
" and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang :
'null'));
96 if ($mode ==
'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT ==
'auto') {
97 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
100 $pdfformat = $conf->global->MAIN_PDF_FORMAT;
103 $sql =
"SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX.
"c_paper_format";
104 $sql .=
" WHERE code = '".$db->escape($pdfformat).
"'";
105 $resql = $db->query(
$sql);
107 $obj = $db->fetch_object($resql);
109 $width = (int) $obj->width;
110 $height = (
int) $obj->height;
116 return array(
'width'=>$width,
'height'=>$height,
'unit'=>$unit);
132 if (!defined(
'K_TCPDF_EXTERNAL_CONFIG')) {
133 define(
'K_TCPDF_EXTERNAL_CONFIG', 1);
134 define(
'K_PATH_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
135 define(
'K_PATH_URL_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
137 define(
'K_BLANK_IMAGE',
'_blank.png');
138 define(
'PDF_PAGE_FORMAT',
'A4');
139 define(
'PDF_PAGE_ORIENTATION',
'P');
140 define(
'PDF_CREATOR',
'TCPDF');
141 define(
'PDF_AUTHOR',
'TCPDF');
142 define(
'PDF_HEADER_TITLE',
'TCPDF Example');
143 define(
'PDF_HEADER_STRING',
"by Dolibarr ERP CRM");
144 define(
'PDF_UNIT',
'mm');
145 define(
'PDF_MARGIN_HEADER', 5);
146 define(
'PDF_MARGIN_FOOTER', 10);
147 define(
'PDF_MARGIN_TOP', 27);
148 define(
'PDF_MARGIN_BOTTOM', 25);
149 define(
'PDF_MARGIN_LEFT', 15);
150 define(
'PDF_MARGIN_RIGHT', 15);
151 define(
'PDF_FONT_NAME_MAIN',
'helvetica');
152 define(
'PDF_FONT_SIZE_MAIN', 10);
153 define(
'PDF_FONT_NAME_DATA',
'helvetica');
154 define(
'PDF_FONT_SIZE_DATA', 8);
155 define(
'PDF_FONT_MONOSPACED',
'courier');
156 define(
'PDF_IMAGE_SCALE_RATIO', 1.25);
157 define(
'HEAD_MAGNIFICATION', 1.1);
158 define(
'K_CELL_HEIGHT_RATIO', 1.25);
159 define(
'K_TITLE_MAGNIFICATION', 1.3);
160 define(
'K_SMALL_RATIO', 2 / 3);
161 define(
'K_THAI_TOPCHARS',
true);
162 define(
'K_TCPDF_CALLS_IN_HTML',
true);
163 if (!empty($conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE)) {
164 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
true);
166 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
false);
171 require_once TCPDF_PATH.
'tcpdf.php';
174 if (empty($conf->global->MAIN_DISABLE_TCPDI)) {
175 require_once TCPDI_PATH.
'tcpdi.php';
183 if (!empty($conf->global->PDF_USE_A)) {
184 $pdfa = $conf->global->PDF_USE_A;
187 if (class_exists(
'TCPDI')) {
188 $pdf =
new TCPDI($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
190 $pdf =
new TCPDF($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
194 if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) {
208 $pdfrights = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS,
true) : array(
'modify',
'copy'));
211 $pdfuserpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS :
'');
214 $pdfownerpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS :
null);
217 $encstrength = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH) ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0);
221 $pubkeys = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS,
true) :
null);
223 $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys);
237 require_once TCPDF_PATH.
'tcpdf_parser.php';
239 $isencrypted =
false;
241 $content = file_get_contents($pathoffile);
244 @($parser = new \TCPDF_PARSER(ltrim($content)));
245 list($xref, $data) = $parser->getParsedData();
249 if (isset($xref[
'trailer'][
'encrypt'])) {
270 if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) {
271 return $conf->global->MAIN_PDF_FORCE_FONT;
275 if (class_exists(
'TCPDF')) {
276 if ($outputlangs->trans(
'FONTFORPDF') !=
'FONTFORPDF') {
277 $font = $outputlangs->trans(
'FONTFORPDF');
294 if (class_exists(
'TCPDF')) {
295 if ($outputlangs->trans(
'FONTSIZEFORPDF') !=
'FONTSIZEFORPDF') {
296 $size = (int) $outputlangs->trans(
'FONTSIZEFORPDF');
299 if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) {
300 $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE;
317 $height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 20 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
319 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
321 if ($tmp[
'height']) {
322 $width = round($height * $tmp[
'width'] / $tmp[
'height']);
323 if ($width > $maxwidth) {
324 $height = $height * $maxwidth / $width;
342 $pdf->startTransaction();
344 $start_y = $pdf->GetY();
346 $start_page = $pdf->getPage();
348 $pdf->writeHTMLCell(0, 0, 0, $start_y, $htmlcontent, 0, 1,
false,
true,
'J',
true);
350 $end_y = $pdf->GetY();
351 $end_page = $pdf->getPage();
354 if ($end_page == $start_page) {
355 $height = $end_y - $start_y;
357 for ($page = $start_page; $page <= $end_page; ++$page) {
358 $pdf->setPage($page);
359 $tmpm = $pdf->getMargins();
360 $tMargin = $tmpm[
'top'];
361 if ($page == $start_page) {
363 $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin();
364 } elseif ($page == $end_page) {
366 $height = $end_y - $tMargin;
368 $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin();
373 $pdf = $pdf->rollbackTransaction();
394 if ($thirdparty instanceof
Societe) {
395 $socname = $thirdparty->name;
396 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
398 $socname = $thirdparty->name_alias.
" - ".$thirdparty->name;
400 $socname = $thirdparty->name.
" - ".$thirdparty->name_alias;
403 } elseif ($thirdparty instanceof
Contact) {
404 if ($thirdparty->socid > 0) {
405 $thirdparty->fetch_thirdparty();
406 $socname = $thirdparty->thirdparty->name;
407 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->thirdparty->name_alias)) {
409 $socname = $thirdparty->thirdparty->name_alias.
" - ".$thirdparty->thirdparty->name;
411 $socname = $thirdparty->thirdparty->name.
" - ".$thirdparty->thirdparty->name_alias;
416 throw new InvalidArgumentException(
'Parameter 1 $thirdparty is not a Societe nor Contact');
435 function pdf_build_address($outputlangs, $sourcecompany, $targetcompany =
'', $targetcontact =
'', $usecontact = 0, $mode =
'source', $object =
null)
437 global $conf, $hookmanager;
439 if ($mode ==
'source' && !is_object($sourcecompany)) {
442 if ($mode ==
'target' && !is_object($targetcompany)) {
446 if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
447 $sourcecompany->state =
getState($sourcecompany->state_id);
449 if (!empty($targetcompany->state_id) && empty($targetcompany->state)) {
450 $targetcompany->state =
getState($targetcompany->state_id);
455 if (is_object($hookmanager)) {
456 $parameters = array(
'sourcecompany' => &$sourcecompany,
'targetcompany' => &$targetcompany,
'targetcontact' => &$targetcontact,
'outputlangs' => $outputlangs,
'mode' => $mode,
'usecontact' => $usecontact);
458 $reshook = $hookmanager->executeHooks(
'pdf_build_address', $parameters, $object, $action);
459 $stringaddress .= $hookmanager->resPrint;
461 if (empty($reshook)) {
462 if ($mode ==
'source') {
464 if (isset($targetcompany->country_code) && !empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
468 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($sourcecompany, $withCountry,
"\n", $outputlangs)).
"\n";
470 if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) {
472 if ($sourcecompany->phone) {
473 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"PhoneShort").
": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
476 if ($sourcecompany->fax) {
477 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
480 if ($sourcecompany->email) {
481 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($sourcecompany->email);
484 if ($sourcecompany->url) {
485 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($sourcecompany->url);
489 if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) {
490 if ($sourcecompany->tva_intra) {
491 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
496 if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) {
497 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $sourcecompany->country_code);
498 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
501 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
503 if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) {
504 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $sourcecompany->country_code);
505 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
508 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
510 if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) {
511 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $sourcecompany->country_code);
512 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
515 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
517 if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) {
518 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $sourcecompany->country_code);
519 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
522 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
524 if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) {
525 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $sourcecompany->country_code);
526 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
529 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
531 if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) {
532 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $sourcecompany->country_code);
533 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
536 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
538 if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) {
539 $stringaddress .= ($stringaddress ?
"\n" :
'').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS;
543 if ($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) {
545 if (is_object($targetcontact)) {
546 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
548 if (!empty($targetcontact->address)) {
549 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcontact)).
"\n";
551 $companytouseforaddress = $targetcompany;
554 if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
555 $targetcontact->fetch_thirdparty();
556 $companytouseforaddress = $targetcontact->thirdparty;
559 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($companytouseforaddress)).
"\n";
562 if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
563 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcontact->country_code));
564 } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
565 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
568 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode)) {
570 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
571 if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
572 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
574 if (!empty($targetcontact->phone_pro)) {
575 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
577 if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
578 $stringaddress .=
" / ";
580 if (!empty($targetcontact->phone_mobile)) {
581 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
585 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
586 if ($targetcontact->fax) {
587 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcontact->fax);
591 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
592 if ($targetcontact->email) {
593 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcontact->email);
597 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
598 if ($targetcontact->url) {
599 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcontact->url);
605 if (is_object($targetcompany)) {
606 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcompany)).
"\n";
608 if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
609 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
612 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode)) {
614 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
615 if (!empty($targetcompany->phone)) {
616 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
618 if (!empty($targetcompany->phone)) {
619 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
623 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
624 if ($targetcompany->fax) {
625 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcompany->fax);
629 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
630 if ($targetcompany->email) {
631 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcompany->email);
635 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
636 if ($targetcompany->url) {
637 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcompany->url);
645 if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) {
646 if ($targetcompany->tva_intra) {
647 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
652 if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) {
653 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $targetcompany->country_code);
654 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
657 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
659 if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) {
660 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $targetcompany->country_code);
661 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
664 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
666 if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) {
667 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $targetcompany->country_code);
668 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
671 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
673 if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) {
674 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $targetcompany->country_code);
675 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
678 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
680 if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) {
681 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $targetcompany->country_code);
682 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
685 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
687 if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) {
688 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $targetcompany->country_code);
689 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
692 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
696 if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) {
697 if ($mode ==
'source' && !empty($sourcecompany->note_public)) {
698 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($sourcecompany->note_public);
700 if (($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) {
701 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($targetcompany->note_public);
707 return $stringaddress;
724 if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF !=
'-1')) {
725 $filepath = $conf->mycompany->dir_output.
'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF;
726 if (file_exists($filepath)) {
727 $pdf->SetAutoPageBreak(0, 0);
728 if (
getDolGlobalString(
'MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); }
729 $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height);
732 $pdf->SetAutoPageBreak(1, 0);
754 $substitutionarray[
'__FROM_NAME__'] =
'__FROM_NAME__';
755 $substitutionarray[
'__FROM_EMAIL__'] =
'__FROM_EMAIL__';
756 return $substitutionarray;
773 global $langs, $mysoc, $user;
778 } elseif ($unit ==
'mm') {
780 } elseif ($unit ==
'cm') {
782 } elseif ($unit ==
'in') {
790 $text = $outputlangs->convToOutputCharset($text);
792 $savx = $pdf->getX();
793 $savy = $pdf->getY();
795 $watermark_angle = atan($h / $w) / 2;
796 $watermark_x_pos = 0;
797 $watermark_y_pos = $h / 3;
798 $watermark_x = $w / 2;
799 $watermark_y = $h / 3;
800 $pdf->SetFont(
'',
'B', 40);
801 $pdf->SetTextColor(255, 192, 203);
803 $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));
805 $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
806 $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text),
"", 2,
"C", 0);
810 $pdf->SetXY($savx, $savy);
826 function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
828 global $mysoc, $conf;
830 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbank.class.php';
832 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
833 $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT);
834 $pdf->SetXY($curx, $cury);
836 if (empty($onlynumber)) {
837 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
838 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByTransferOnThisBankAccount').
':', 0,
'L', 0);
842 $outputlangs->load(
"banks");
845 $bickey =
"BICNumber";
846 if ($account->getCountryCode() ==
'IN') {
851 $usedetailedbban = $account->useDetailedBBAN();
854 if ($usedetailedbban) {
857 if (empty($onlynumber)) {
858 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
859 $pdf->SetXY($curx, $cury);
860 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
864 if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) {
870 if (empty($onlynumber)) {
871 $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
875 foreach ($account->getFieldsToShow() as $val) {
876 $pdf->SetXY($curx, $cury + 4);
877 $pdf->SetFont(
'',
'', $default_font_size - 3);
879 if ($val ==
'BankCode') {
882 $content = $account->code_banque;
883 } elseif ($val ==
'DeskCode') {
886 $content = $account->code_guichet;
887 } elseif ($val ==
'BankAccountNumber') {
890 $content = $account->number;
891 } elseif ($val ==
'BankAccountNumberKey') {
894 $content = $account->cle_rib;
895 } elseif ($val ==
'IBAN' || $val ==
'BIC') {
900 dol_print_error($account->db,
'Unexpected value for getFieldsToShow: '.$val);
904 $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0,
'C', 0);
905 $pdf->SetXY($curx, $cury + 1);
907 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
908 $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0,
'C', 0);
909 if (empty($onlynumber)) {
910 $pdf->line($curx, $cury + 1, $curx, $cury + 7);
918 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
919 $pdf->SetXY($curx, $cury);
920 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
923 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
924 $pdf->SetXY($curx, $cury);
925 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"BankAccountNumber").
': '.$outputlangs->convToOutputCharset($account->number), 0,
'L', 0);
928 if ($diffsizecontent <= 2) {
933 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
935 if (empty($onlynumber) && !empty($account->domiciliation)) {
936 $pdf->SetXY($curx, $cury);
937 $val = $outputlangs->transnoentities(
"Residence").
': '.$outputlangs->convToOutputCharset($account->domiciliation);
938 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
941 $tmpy = $pdf->getStringHeight(100, $val);
945 if (!empty($account->proprio)) {
946 $pdf->SetXY($curx, $cury);
947 $val = $outputlangs->transnoentities(
"BankAccountOwner").
': '.$outputlangs->convToOutputCharset($account->proprio);
948 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
949 $tmpy = $pdf->getStringHeight(100, $val);
951 } elseif (!$usedetailedbban) {
958 if (!empty($account->iban)) {
960 $ibanDisplay_temp = str_replace(
' ',
'', $outputlangs->convToOutputCharset($account->iban));
963 $nbIbanDisplay_temp =
dol_strlen($ibanDisplay_temp);
964 for ($i = 0; $i < $nbIbanDisplay_temp; $i++) {
965 $ibanDisplay .= $ibanDisplay_temp[$i];
966 if ($i % 4 == 3 && $i > 0) {
971 $pdf->SetFont(
'',
'B', $default_font_size - 3);
972 $pdf->SetXY($curx, $cury);
973 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).
': '.$ibanDisplay, 0,
'L', 0);
977 if (!empty($account->bic)) {
978 $pdf->SetFont(
'',
'B', $default_font_size - 3);
979 $pdf->SetXY($curx, $cury);
980 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).
': '.$outputlangs->convToOutputCharset($account->bic), 0,
'L', 0);
1003 function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark =
'')
1005 global $conf, $user, $mysoc, $hookmanager;
1007 $outputlangs->load(
"dict");
1011 $dims = $pdf->getPageDimensions();
1014 if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) {
1017 $substitutionarray[
'__FROM_NAME__'] = $fromcompany->name;
1018 $substitutionarray[
'__FROM_EMAIL__'] = $fromcompany->email;
1020 $newfreetext =
make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs);
1026 $newfreetext = preg_replace(
'/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/',
'\1file:/'.DOL_DATA_ROOT.
'/medias/\2\3', $newfreetext);
1028 $line .= $outputlangs->convToOutputCharset($newfreetext);
1037 if ($showdetails == 1 || $showdetails == 3) {
1039 if ($fromcompany->name) {
1040 $line1 .= ($line1 ?
" - " :
"").$outputlangs->transnoentities(
"RegisteredOffice").
": ".$fromcompany->name;
1043 if ($fromcompany->address) {
1044 $line1 .= ($line1 ?
" - " :
"").str_replace(
"\n",
", ", $fromcompany->address);
1047 if ($fromcompany->zip) {
1048 $line1 .= ($line1 ?
" - " :
"").$fromcompany->zip;
1051 if ($fromcompany->town) {
1052 $line1 .= ($line1 ?
" " :
"").$fromcompany->town;
1055 if ($fromcompany->country) {
1056 $line1 .= ($line1 ?
", " :
"").$fromcompany->country;
1059 if ($fromcompany->phone) {
1060 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Phone").
": ".$fromcompany->phone;
1063 if ($fromcompany->fax) {
1064 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Fax").
": ".$fromcompany->fax;
1068 if ($fromcompany->url) {
1069 $line2 .= ($line2 ?
" - " :
"").$fromcompany->url;
1072 if ($fromcompany->email) {
1073 $line2 .= ($line2 ?
" - " :
"").$fromcompany->email;
1076 if ($showdetails == 2 || $showdetails == 3 || (!empty($fromcompany->country_code) && $fromcompany->country_code ==
'DE')) {
1078 if ($fromcompany->managers) {
1079 $line2 .= ($line2 ?
" - " :
"").$fromcompany->managers;
1085 if (!empty($fromcompany->forme_juridique_code) && $fromcompany->forme_juridique_code) {
1086 $line3 .= ($line3 ?
" - " :
"").$outputlangs->convToOutputCharset(
getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
1089 if (!empty($fromcompany->capital)) {
1090 $tmpamounttoshow =
price2num($fromcompany->capital);
1091 if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
1092 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf",
price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
1093 } elseif (!empty($fromcompany->capital)) {
1094 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf", $fromcompany->capital, $outputlangs);
1098 if (!empty($fromcompany->idprof1) && $fromcompany->idprof1 && ($fromcompany->country_code !=
'FR' || !$fromcompany->idprof2)) {
1099 $field = $outputlangs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
1100 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1103 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
1106 if (!empty($fromcompany->idprof2) && $fromcompany->idprof2) {
1107 $field = $outputlangs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
1108 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1111 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
1116 if (!empty($fromcompany->idprof3) && $fromcompany->idprof3) {
1117 $field = $outputlangs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
1118 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1121 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
1124 if (!empty($fromcompany->idprof4) && $fromcompany->idprof4) {
1125 $field = $outputlangs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
1126 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1129 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
1132 if (!empty($fromcompany->idprof5) && $fromcompany->idprof5) {
1133 $field = $outputlangs->transcountrynoentities(
"ProfId5", $fromcompany->country_code);
1134 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1137 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
1140 if (!empty($fromcompany->idprof6) && $fromcompany->idprof6) {
1141 $field = $outputlangs->transcountrynoentities(
"ProfId6", $fromcompany->country_code);
1142 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1145 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
1148 if (!empty($fromcompany->tva_intra) && $fromcompany->tva_intra !=
'') {
1149 $line4 .= ($line4 ?
" - " :
"").$outputlangs->transnoentities(
"VATIntraShort").
": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
1152 $pdf->SetFont(
'',
'', 7);
1153 $pdf->SetDrawColor(224, 224, 224);
1155 if (!empty($conf->global->PDF_FOOTER_TEXT_COLOR)) {
1156 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_TEXT_COLOR,
'%d, %d, %d');
1157 $pdf->SetTextColor($r, $g, $b);
1161 $freetextheight = 0;
1164 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
1167 if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
1171 $freetextheight = $pdf->getStringHeight($width, $line);
1179 if (is_object($hookmanager)) {
1180 $parameters = array(
'line1' => $line1,
'line2' => $line2,
'line3' => $line3,
'line4' => $line4,
'outputlangs'=>$outputlangs);
1182 $hookmanager->executeHooks(
'pdf_pagefoot', $parameters, $object, $action);
1183 if (!empty($hookmanager->resPrint) && $hidefreetext == 0) {
1184 $mycustomfooter = $hookmanager->resPrint;
1187 $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight;
1188 $posy = (
float) $marginwithfooter;
1192 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR,
'%d, %d, %d');
1193 $pdf->SetAutoPageBreak(0, 0);
1194 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F',
'', $fill_color = array($r, $g, $b));
1195 $pdf->SetAutoPageBreak(1, 0);
1198 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); }
1200 $pdf->SetXY($dims[
'lm'], -$posy);
1202 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1204 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1206 $posy -= $freetextheight;
1208 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); }
1214 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1224 if (
getDolGlobalInt(
'PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); }
1225 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims[
'lm'], $dims[
'hk'] - $posy,
dol_htmlentitiesbr($mycustomfooter, 1,
'UTF-8', 0));
1226 if (
getDolGlobalInt(
'PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); }
1228 $posy -= $mycustomfooterheight - 3;
1231 $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
1232 $posy = (
float) $marginwithfooter;
1236 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR,
'%d, %d, %d');
1237 $pdf->SetAutoPageBreak(0, 0);
1238 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F',
'', $fill_color = array($r, $g, $b));
1239 $pdf->SetAutoPageBreak(1, 0);
1242 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); }
1244 $pdf->SetXY($dims[
'lm'], -$posy);
1246 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1248 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1250 $posy -= $freetextheight;
1252 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); }
1260 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1270 if (!empty($line1)) {
1271 $pdf->SetFont(
'',
'B', 7);
1272 $pdf->SetXY($dims[
'lm'], -$posy);
1273 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line1, 0,
'C', 0);
1275 $pdf->SetFont(
'',
'', 7);
1278 if (!empty($line2)) {
1279 $pdf->SetFont(
'',
'B', 7);
1280 $pdf->SetXY($dims[
'lm'], -$posy);
1281 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line2, 0,
'C', 0);
1283 $pdf->SetFont(
'',
'', 7);
1286 if (!empty($line3)) {
1287 $pdf->SetXY($dims[
'lm'], -$posy);
1288 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line3, 0,
'C', 0);
1291 if (!empty($line4)) {
1293 $pdf->SetXY($dims[
'lm'], -$posy);
1294 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line4, 0,
'C', 0);
1301 $pdf->SetXY($dims[
'wk'] - $dims[
'rm'] - 18 -
getDolGlobalInt(
'PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy -
getDolGlobalInt(
'PDF_FOOTER_PAGE_NUMBER_Y', 0));
1305 $pagination = $pdf->PageNo().
' / '.$pdf->getNumPages();
1306 $pdf->MultiCell(18, 2, $pagination, 0,
'R', 0);
1310 if (!empty($watermark)) {
1311 pdf_watermark($pdf, $outputlangs, $page_hauteur, $page_largeur,
'mm', $watermark);
1314 return $marginwithfooter;
1334 if (!empty($linkedobjects)) {
1335 foreach ($linkedobjects as $linkedobject) {
1336 $reftoshow = $linkedobject[
"ref_title"].
' : '.$linkedobject[
"ref_value"];
1337 if (!empty($linkedobject[
"date_value"])) {
1338 $reftoshow .=
' / '.$linkedobject[
"date_value"];
1342 $pdf->SetXY($posx, $posy);
1343 $pdf->SetFont(
'',
'', $default_font_size - 2);
1344 $pdf->MultiCell($w, $h, $reftoshow,
'', $align);
1348 return $pdf->getY();
1367 function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1369 global $db, $conf, $langs, $hookmanager;
1374 if (is_object($hookmanager)) {
1375 $special_code = empty($object->lines[$i]->special_code) ?
'' : $object->lines[$i]->special_code;
1376 if (!empty($object->lines[$i]->fk_parent_line)) {
1377 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1379 $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);
1381 $reshook = $hookmanager->executeHooks(
'pdf_writelinedesc', $parameters, $object, $action);
1383 if (!empty($hookmanager->resPrint)) {
1384 $result .= $hookmanager->resPrint;
1387 if (empty($reshook)) {
1388 $labelproductservice =
pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
1395 $labelproductservice = preg_replace(
'/(<img[^>]*src=")([^"]*)(&)([^"]*")/',
'\1\2&\4', $labelproductservice, -1, $nbrep);
1400 $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1,
false,
true,
'J',
true);
1401 $result .= $labelproductservice;
1417 function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1419 global $db, $conf, $langs;
1421 $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product :
false);
1422 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label :
''));
1423 $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description :
''));
1424 $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn :
''));
1425 $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note :
'');
1426 $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch :
false);
1428 if ($issupplierline) {
1429 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1432 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1435 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1436 include_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1441 $prodser->fetch($idprod);
1443 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) {
1444 $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED));
1452 $textwasnotmodified = ($label == $prodser->label);
1453 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"label"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1454 $label = $prodser->multilangs[$outputlangs->defaultlang][
"label"];
1459 $textwasnotmodified =
false;
1463 $textwasnotmodified = ($desc == $prodser->description);
1465 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"description"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1466 $desc = $prodser->multilangs[$outputlangs->defaultlang][
"description"];
1470 $textwasnotmodified = ($note == $prodser->note_public);
1471 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"other"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1472 $note = $prodser->multilangs[$outputlangs->defaultlang][
"other"];
1475 } elseif (($object->element ==
'facture' || $object->element ==
'facturefourn') && preg_match(
'/^\(DEPOSIT\).+/', $desc)) {
1476 $desc = str_replace(
'(DEPOSIT)', $outputlangs->trans(
'Deposit'), $desc);
1479 if (empty($conf->global->PDF_HIDE_PRODUCT_LABEL_IN_SUPPLIER_LINES)) {
1481 $libelleproduitservice = $label;
1482 if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
1486 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1488 $libelleproduitservice =
'<b>'.$libelleproduitservice.
'</b>';
1494 if (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) {
1495 $prodser->get_sousproduits_arbo();
1496 if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
1497 $tmparrayofsubproducts = reset($prodser->sousprods);
1498 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) {
1499 foreach ($tmparrayofsubproducts as $subprodval) {
1500 $libelleproduitservice =
dol_concatdesc($libelleproduitservice,
" * ".$subprodval[3].
' ('.$subprodval[1].
')');
1503 foreach ($tmparrayofsubproducts as $subprodval) {
1504 $libelleproduitservice =
dol_concatdesc($libelleproduitservice,
" * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ?
' - ' :
'').$subprodval[3].
' ('.$subprodval[1].
')');
1511 if (!empty($desc) && ($desc != $label)) {
1512 if ($desc ==
'(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
1514 $discount->fetch($object->lines[$i]->fk_remise_except);
1515 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
1516 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromCreditNote", $sourceref);
1517 } elseif ($desc ==
'(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
1519 $discount->fetch($object->lines[$i]->fk_remise_except);
1520 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
1521 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromDeposit", $sourceref);
1523 if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
1524 $libelleproduitservice .=
' ('.dol_print_date($discount->datec,
'day',
'', $outputlangs).
')';
1526 } elseif ($desc ==
'(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) {
1528 $discount->fetch($object->lines[$i]->fk_remise_except);
1529 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessReceived", $discount->ref_facture_source);
1530 } elseif ($desc ==
'(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) {
1532 $discount->fetch($object->lines[$i]->fk_remise_except);
1533 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
1537 if (!empty($object->element)) {
1538 $tmpkey =
'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper($object->element);
1539 if (!empty($conf->global->$tmpkey)) {
1543 if (empty($hidedesc)) {
1544 if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) {
1545 $libelleproduitservice =
dol_concatdesc($desc, $libelleproduitservice);
1547 if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) {
1548 $libelleproduitservice = $desc;
1550 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desc);
1555 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desc);
1561 $prefix_prodserv =
"";
1563 if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
1564 if ($prodser->isService()) {
1565 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Service").
" ";
1567 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Product").
" ";
1571 if (empty($hideref)) {
1572 if ($issupplierline) {
1573 if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) {
1574 $ref_prodserv = $prodser->ref;
1575 if ($ref_supplier) {
1576 $ref_prodserv .= ($prodser->ref ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
"SupplierRef").
' '.$ref_supplier.($prodser->ref ?
')' :
'');
1578 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
1579 $ref_prodserv = $ref_supplier;
1580 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
1581 $ref_prodserv = $ref_supplier.
' ('.$outputlangs->transnoentitiesnoconv(
"InternalRef").
' '.$prodser->ref.
')';
1584 $ref_prodserv = $prodser->ref;
1586 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1588 $filter = array(
'fk_product' => $idprod,
'fk_soc' => $object->socid);
1590 $nbCustomerPrices = $productCustomerPriceStatic->fetchAll(
'',
'', 1, 0, $filter);
1592 if ($nbCustomerPrices > 0) {
1593 $productCustomerPrice = $productCustomerPriceStatic->lines[0];
1595 if (!empty($productCustomerPrice->ref_customer)) {
1596 switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) {
1598 $ref_prodserv = $productCustomerPrice->ref_customer;
1602 $ref_prodserv = $productCustomerPrice->ref_customer .
' (' . $outputlangs->transnoentitiesnoconv(
'InternalRef') .
' ' . $ref_prodserv .
')';
1606 $ref_prodserv = $ref_prodserv .
' (' . $outputlangs->transnoentitiesnoconv(
'RefCustomer') .
' ' . $productCustomerPrice->ref_customer .
')';
1613 if (!empty($libelleproduitservice) && !empty($ref_prodserv)) {
1614 $ref_prodserv .=
" - ";
1618 if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1620 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1622 $ref_prodserv =
'<b>'.$ref_prodserv.
'</b>';
1625 $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
1628 if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod &&
isModEnabled(
'categorie')) {
1629 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1632 $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
1633 foreach ($tblcateg as $cate) {
1635 $desccateg = $cate->description;
1637 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desccateg);
1642 if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) {
1646 if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
1647 $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)).
')';
1649 if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) {
1650 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($object->lines[$i]->date_start, $format,
false, $outputlangs)).
')';
1652 if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) {
1653 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($object->lines[$i]->date_end, $format,
false, $outputlangs)).
')';
1656 if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1658 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1660 $libelleproduitservice .=
'<br><b style="color:#333666;" ><em>'.$period.
'</em></b>';
1662 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $period);
1668 if (!empty($dbatch)) {
1673 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1674 include_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
1679 foreach ($dbatch as $detail) {
1681 if ($detail->eatby) {
1682 $dte[] = $outputlangs->transnoentitiesnoconv(
'printEatby',
dol_print_date($detail->eatby, $format,
false, $outputlangs));
1684 if ($detail->sellby) {
1685 $dte[] = $outputlangs->transnoentitiesnoconv(
'printSellby',
dol_print_date($detail->sellby, $format,
false, $outputlangs));
1687 if ($detail->batch) {
1688 $dte[] = $outputlangs->transnoentitiesnoconv(
'printBatch', $detail->batch);
1690 $dte[] = $outputlangs->transnoentitiesnoconv(
'printQty', $detail->qty);
1693 if ($object->element ==
'shipping' && $detail->fk_origin_stock > 0 &&
getDolGlobalInt(
'PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT')) {
1694 $resproductbatch = $tmpproductbatch->fetch($detail->fk_origin_stock);
1695 if ($resproductbatch > 0) {
1696 $reswarehouse = $tmpwarehouse->fetch($tmpproductbatch->warehouseid);
1697 if ($reswarehouse > 0) {
1698 $dte[] = $tmpwarehouse->ref;
1703 $libelleproduitservice .=
"__N__ ".implode(
" - ", $dte);
1713 $libelleproduitservice = preg_replace(
'/__N__/',
'<br>', $libelleproduitservice);
1715 $libelleproduitservice = preg_replace(
'/__N__/',
"\n", $libelleproduitservice);
1719 return $libelleproduitservice;
1733 global $hookmanager;
1738 if (is_object($hookmanager)) {
1739 $special_code = $object->lines[$i]->special_code;
1740 if (!empty($object->lines[$i]->fk_parent_line)) {
1741 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1743 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1745 $reshook = $hookmanager->executeHooks(
'pdf_getlinenum', $parameters, $object, $action);
1746 $result .= $hookmanager->resPrint;
1748 if (empty($reshook)) {
1766 global $hookmanager;
1771 if (is_object($hookmanager)) {
1772 $special_code = $object->lines[$i]->special_code;
1773 if (!empty($object->lines[$i]->fk_parent_line)) {
1774 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1776 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1778 $reshook = $hookmanager->executeHooks(
'pdf_getlineref', $parameters, $object, $action);
1779 $result .= $hookmanager->resPrint;
1781 if (empty($reshook)) {
1798 global $hookmanager;
1803 if (is_object($hookmanager)) {
1804 $special_code = $object->lines[$i]->special_code;
1805 if (!empty($object->lines[$i]->fk_parent_line)) {
1806 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1808 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1810 $reshook = $hookmanager->executeHooks(
'pdf_getlineref_supplier', $parameters, $object, $action);
1811 $result .= $hookmanager->resPrint;
1813 if (empty($reshook)) {
1830 global $conf, $hookmanager, $mysoc;
1835 if (is_object($hookmanager)) {
1836 $special_code = $object->lines[$i]->special_code;
1837 if (!empty($object->lines[$i]->fk_parent_line)) {
1838 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1840 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1842 $reshook = $hookmanager->executeHooks(
'pdf_getlinevatrate', $parameters, $object, $action);
1844 if (!empty($hookmanager->resPrint)) {
1845 $result .= $hookmanager->resPrint;
1848 if (empty($reshook)) {
1849 if (empty($hidedetails) || $hidedetails > 1) {
1852 $tmpresult .=
vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1);
1853 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) {
1854 if ($object->lines[$i]->total_localtax1 != 0) {
1855 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
1860 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax1_tx), 0);
1863 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) {
1864 if ($object->lines[$i]->total_localtax2 != 0) {
1865 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
1870 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax2_tx), 0);
1875 $result .= $tmpresult;
1892 global $conf, $hookmanager;
1895 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1902 if (is_object($hookmanager)) {
1903 $special_code = $object->lines[$i]->special_code;
1904 if (!empty($object->lines[$i]->fk_parent_line)) {
1905 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1907 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1909 $reshook = $hookmanager->executeHooks(
'pdf_getlineupexcltax', $parameters, $object, $action);
1911 if (!empty($hookmanager->resPrint)) {
1912 $result .= $hookmanager->resPrint;
1915 if (empty($reshook)) {
1916 if (empty($hidedetails) || $hidedetails > 1) {
1917 $subprice = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
1918 $result .=
price($sign * $subprice, 0, $outputlangs);
1935 global $hookmanager, $conf;
1938 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1945 if (is_object($hookmanager)) {
1946 $special_code = $object->lines[$i]->special_code;
1947 if (!empty($object->lines[$i]->fk_parent_line)) {
1948 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1950 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1952 $reshook = $hookmanager->executeHooks(
'pdf_getlineupwithtax', $parameters, $object, $action);
1954 if (!empty($hookmanager->resPrint)) {
1955 $result .= $hookmanager->resPrint;
1958 if (empty($reshook)) {
1959 if (empty($hidedetails) || $hidedetails > 1) {
1960 $result .=
price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
1977 global $hookmanager;
1982 if (is_object($hookmanager)) {
1983 $special_code = $object->lines[$i]->special_code;
1984 if (!empty($object->lines[$i]->fk_parent_line)) {
1985 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1987 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1989 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty', $parameters, $object, $action);
1991 if (!empty($hookmanager->resPrint)) {
1992 $result = $hookmanager->resPrint;
1995 if (empty($reshook)) {
1996 if ($object->lines[$i]->special_code == 3) {
1999 if (empty($hidedetails) || $hidedetails > 1) {
2000 $result .= $object->lines[$i]->qty;
2017 global $hookmanager;
2022 if (is_object($hookmanager)) {
2023 $special_code = $object->lines[$i]->special_code;
2024 if (!empty($object->lines[$i]->fk_parent_line)) {
2025 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2027 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2029 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_asked', $parameters, $object, $action);
2031 if (!empty($hookmanager->resPrint)) {
2032 $result .= $hookmanager->resPrint;
2035 if (empty($reshook)) {
2036 if ($object->lines[$i]->special_code == 3) {
2039 if (empty($hidedetails) || $hidedetails > 1) {
2040 $result .= $object->lines[$i]->qty_asked;
2057 global $hookmanager;
2062 if (is_object($hookmanager)) {
2063 $special_code = $object->lines[$i]->special_code;
2064 if (!empty($object->lines[$i]->fk_parent_line)) {
2065 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2067 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2069 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_shipped', $parameters, $object, $action);
2071 if (!empty($hookmanager->resPrint)) {
2072 $result .= $hookmanager->resPrint;
2075 if (empty($reshook)) {
2076 if ($object->lines[$i]->special_code == 3) {
2079 if (empty($hidedetails) || $hidedetails > 1) {
2080 $result .= $object->lines[$i]->qty_shipped;
2097 global $hookmanager;
2102 if (is_object($hookmanager)) {
2103 $special_code = $object->lines[$i]->special_code;
2104 if (!empty($object->lines[$i]->fk_parent_line)) {
2105 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2107 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2109 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_keeptoship', $parameters, $object, $action);
2111 if (!empty($hookmanager->resPrint)) {
2112 $result .= $hookmanager->resPrint;
2115 if (empty($reshook)) {
2116 if ($object->lines[$i]->special_code == 3) {
2119 if (empty($hidedetails) || $hidedetails > 1) {
2120 $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
2136 function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager =
false)
2143 if (is_object($hookmanager)) {
2144 $special_code = $object->lines[$i]->special_code;
2145 if (!empty($object->lines[$i]->fk_parent_line)) {
2146 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2148 $parameters = array(
2150 'outputlangs' => $outputlangs,
2151 'hidedetails' => $hidedetails,
2152 'special_code' => $special_code
2155 $reshook = $hookmanager->executeHooks(
'pdf_getlineunit', $parameters, $object, $action);
2157 if (!empty($hookmanager->resPrint)) {
2158 $result .= $hookmanager->resPrint;
2161 if (empty($reshook)) {
2162 if (empty($hidedetails) || $hidedetails > 1) {
2163 $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit(
'short'));
2181 global $hookmanager;
2183 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2188 if (is_object($hookmanager)) {
2189 $special_code = $object->lines[$i]->special_code;
2190 if (!empty($object->lines[$i]->fk_parent_line)) {
2191 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2193 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2195 $reshook = $hookmanager->executeHooks(
'pdf_getlineremisepercent', $parameters, $object, $action);
2197 if (!empty($hookmanager->resPrint)) {
2198 $result .= $hookmanager->resPrint;
2201 if (empty($reshook)) {
2202 if ($object->lines[$i]->special_code == 3) {
2205 if (empty($hidedetails) || $hidedetails > 1) {
2224 if (empty($hookmanager)) {
2225 global $hookmanager;
2232 if (is_object($hookmanager)) {
2233 $special_code = $object->lines[$i]->special_code;
2234 if (!empty($object->lines[$i]->fk_parent_line)) {
2235 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2237 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2239 $reshook = $hookmanager->executeHooks(
'pdf_getlineprogress', $parameters, $object, $action);
2241 if (!empty($hookmanager->resPrint)) {
2242 return $hookmanager->resPrint;
2245 if (empty($reshook)) {
2246 if ($object->lines[$i]->special_code == 3) {
2249 if (empty($hidedetails) || $hidedetails > 1) {
2250 if (!empty($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)) {
2252 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2253 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2255 $result = round($object->lines[$i]->situation_percent - $prev_progress, 1).
'%';
2257 $result = round($object->lines[$i]->situation_percent, 1).
'%';
2275 global $conf, $hookmanager;
2278 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2285 if (is_object($hookmanager)) {
2286 $special_code = $object->lines[$i]->special_code;
2287 if (!empty($object->lines[$i]->fk_parent_line)) {
2288 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2290 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code,
'sign'=>$sign);
2292 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalexcltax', $parameters, $object, $action);
2294 if (!empty($hookmanager->resPrint)) {
2295 $result .= $hookmanager->resPrint;
2298 if (empty($reshook)) {
2299 if ($object->lines[$i]->special_code == 3) {
2300 $result .= $outputlangs->transnoentities(
"Option");
2301 } elseif (empty($hidedetails) || $hidedetails > 1) {
2302 $total_ht = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
2303 if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) {
2307 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2308 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2309 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2311 $result .=
price($sign * ($total_ht / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2313 $result .=
price($sign * $total_ht, 0, $outputlangs);
2331 global $hookmanager, $conf;
2334 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2341 if (is_object($hookmanager)) {
2342 $special_code = $object->lines[$i]->special_code;
2343 if (!empty($object->lines[$i]->fk_parent_line)) {
2344 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2346 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2348 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalwithtax', $parameters, $object, $action);
2350 if (!empty($hookmanager->resPrint)) {
2351 $result .= $hookmanager->resPrint;
2354 if (empty($reshook)) {
2355 if ($object->lines[$i]->special_code == 3) {
2356 $result .= $outputlangs->transnoentities(
"Option");
2357 } elseif (empty($hidedetails) || $hidedetails > 1) {
2358 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
2359 if ($object->lines[$i]->situation_percent > 0) {
2363 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2364 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2365 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2367 $result .=
price($sign * ($total_ttc / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2369 $result .=
price($sign * $total_ttc, 0, $outputlangs);
2386 global $db, $hookmanager;
2388 $linkedobjects = array();
2390 $object->fetchObjectLinked();
2392 foreach ($object->linkedObjects as $objecttype => $objects) {
2393 if ($objecttype ==
'facture') {
2395 } elseif ($objecttype ==
'propal' || $objecttype ==
'supplier_proposal') {
2396 $outputlangs->load(
'propal');
2398 foreach ($objects as $elementobject) {
2399 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefProposal");
2400 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2401 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DatePropal");
2402 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2404 } elseif ($objecttype ==
'commande' || $objecttype ==
'supplier_order') {
2405 $outputlangs->load(
'orders');
2408 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefOrder").
' :');
2409 foreach ($objects as $elementobject) {
2410 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).(empty($elementobject->ref_client) ?
'' :
' ('.$elementobject->ref_client.
')').(empty($elementobject->ref_supplier) ?
'' :
' ('.$elementobject->ref_supplier.
')').
' ');
2411 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"OrderDate").
' : '.
dol_print_date($elementobject->date,
'day',
'', $outputlangs));
2413 } elseif (count($objects) == 1) {
2414 $elementobject = array_shift($objects);
2415 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder");
2416 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref).(!empty($elementobject->ref_client) ?
' ('.$elementobject->ref_client.
')' :
'').(!empty($elementobject->ref_supplier) ?
' ('.$elementobject->ref_supplier.
')' :
'');
2417 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"OrderDate");
2418 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2420 } elseif ($objecttype ==
'contrat') {
2421 $outputlangs->load(
'contracts');
2422 foreach ($objects as $elementobject) {
2423 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefContract");
2424 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2425 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DateContract");
2426 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date_contrat,
'day',
'', $outputlangs);
2428 } elseif ($objecttype ==
'fichinter') {
2429 $outputlangs->load(
'interventions');
2430 foreach ($objects as $elementobject) {
2431 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"InterRef");
2432 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2433 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"InterDate");
2434 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->datec,
'day',
'', $outputlangs);
2436 } elseif ($objecttype ==
'shipping') {
2437 $outputlangs->loadLangs(array(
"orders",
"sendings"));
2439 if (count($objects) > 1) {
2441 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2442 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending").
' :');
2444 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefSending").
' :');
2447 foreach ($objects as $elementobject) {
2448 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2449 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
2450 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
2451 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2453 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2460 if (! is_object($order)) {
2461 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref));
2463 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
''));
2464 $object->note_public =
dol_concatdesc($object->note_public,
' / '.$outputlangs->transnoentities($elementobject->ref));
2467 } elseif (count($objects) == 1) {
2468 $elementobject = array_shift($objects);
2471 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2472 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
2473 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
2474 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2476 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2483 if (! is_object($order)) {
2484 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefSending");
2485 if (!empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] .=
' / ';
2486 $linkedobjects[$objecttype][
'ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
2487 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
2489 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending");
2490 if (empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
'');
2491 $linkedobjects[$objecttype][
'ref_value'] .=
' / '.$outputlangs->transnoentities($elementobject->ref);
2492 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
2499 if (is_object($hookmanager)) {
2500 $parameters = array(
'linkedobjects' => $linkedobjects,
'outputlangs'=>$outputlangs);
2502 $hookmanager->executeHooks(
'pdf_getLinkedObjects', $parameters, $object, $action);
2503 if (!empty($hookmanager->resArray)) {
2504 $linkedobjects = $hookmanager->resArray;
2508 return $linkedobjects;
2522 $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
2523 $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
2524 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2528 if ($tmp[
'height']) {
2529 $width = (int) round($maxheight * $tmp[
'width'] / $tmp[
'height']);
2530 if ($width > $maxwidth) {
2532 $height = (int) round($maxwidth * $tmp[
'height'] / $tmp[
'width']);
2535 $height = $maxheight;
2538 return array(
'width'=>$width,
'height'=>$height);
2552 global $conf, $hookmanager;
2554 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2557 if ($object->lines[$i]->special_code == 3) {
2558 return $outputlangs->transnoentities(
"Option");
2560 if (is_object($hookmanager)) {
2561 $special_code = $object->lines[$i]->special_code;
2562 if (!empty($object->lines[$i]->fk_parent_line)) {
2563 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2566 $parameters = array(
2568 'outputlangs'=>$outputlangs,
2569 'hidedetails'=>$hidedetails,
2570 'special_code'=>$special_code
2575 if ($hookmanager->executeHooks(
'getlinetotalremise', $parameters, $object, $action) > 0) {
2576 return $hookmanager->resPrint;
2580 if (empty($hidedetails) || $hidedetails > 1) {
2581 return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht);