38 include_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
48 global $langs, $conf, $user;
53 $head[$h][0] = DOL_URL_ROOT.
'/admin/pdf.php';
54 $head[$h][1] = $langs->trans(
"Parameters");
55 $head[$h][2] =
'general';
64 if (!empty($conf->propal->enabled)) {
65 $head[$h][0] = DOL_URL_ROOT.
'/admin/pdf_other.php';
66 $head[$h][1] = $langs->trans(
"Other");
67 $head[$h][2] =
'other';
86 global $conf, $db, $langs;
88 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'));
95 if ($mode ==
'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT ==
'auto') {
96 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
99 $pdfformat = $conf->global->MAIN_PDF_FORMAT;
102 $sql =
"SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX.
"c_paper_format";
103 $sql .=
" WHERE code = '".$db->escape($pdfformat).
"'";
104 $resql = $db->query($sql);
106 $obj = $db->fetch_object(
$resql);
108 $width = (int) $obj->width;
109 $height = (
int) $obj->height;
115 return array(
'width'=>$width,
'height'=>$height,
'unit'=>$unit);
131 if (!defined(
'K_TCPDF_EXTERNAL_CONFIG')) {
132 define(
'K_TCPDF_EXTERNAL_CONFIG', 1);
133 define(
'K_PATH_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
134 define(
'K_PATH_URL_CACHE', DOL_DATA_ROOT.
'/admin/temp/');
136 define(
'K_BLANK_IMAGE',
'_blank.png');
137 define(
'PDF_PAGE_FORMAT',
'A4');
138 define(
'PDF_PAGE_ORIENTATION',
'P');
139 define(
'PDF_CREATOR',
'TCPDF');
140 define(
'PDF_AUTHOR',
'TCPDF');
141 define(
'PDF_HEADER_TITLE',
'TCPDF Example');
142 define(
'PDF_HEADER_STRING',
"by Dolibarr ERP CRM");
143 define(
'PDF_UNIT',
'mm');
144 define(
'PDF_MARGIN_HEADER', 5);
145 define(
'PDF_MARGIN_FOOTER', 10);
146 define(
'PDF_MARGIN_TOP', 27);
147 define(
'PDF_MARGIN_BOTTOM', 25);
148 define(
'PDF_MARGIN_LEFT', 15);
149 define(
'PDF_MARGIN_RIGHT', 15);
150 define(
'PDF_FONT_NAME_MAIN',
'helvetica');
151 define(
'PDF_FONT_SIZE_MAIN', 10);
152 define(
'PDF_FONT_NAME_DATA',
'helvetica');
153 define(
'PDF_FONT_SIZE_DATA', 8);
154 define(
'PDF_FONT_MONOSPACED',
'courier');
155 define(
'PDF_IMAGE_SCALE_RATIO', 1.25);
156 define(
'HEAD_MAGNIFICATION', 1.1);
157 define(
'K_CELL_HEIGHT_RATIO', 1.25);
158 define(
'K_TITLE_MAGNIFICATION', 1.3);
159 define(
'K_SMALL_RATIO', 2 / 3);
160 define(
'K_THAI_TOPCHARS',
true);
161 define(
'K_TCPDF_CALLS_IN_HTML',
true);
162 if (!empty($conf->global->TCPDF_THROW_ERRORS_INSTEAD_OF_DIE)) {
163 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
true);
165 define(
'K_TCPDF_THROW_EXCEPTION_ERROR',
false);
170 require_once TCPDF_PATH.
'tcpdf.php';
173 if (empty($conf->global->MAIN_DISABLE_TCPDI)) {
174 require_once TCPDI_PATH.
'tcpdi.php';
182 if (!empty($conf->global->PDF_USE_A)) {
183 $pdfa = $conf->global->PDF_USE_A;
186 if (class_exists(
'TCPDI')) {
187 $pdf =
new TCPDI($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
189 $pdf =
new TCPDF($pagetype, $metric, $format,
true,
'UTF-8',
false, $pdfa);
193 if (!empty($conf->global->PDF_SECURITY_ENCRYPTION)) {
207 $pdfrights = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS,
true) : array(
'modify',
'copy'));
210 $pdfuserpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS :
'');
213 $pdfownerpass = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS) ? $conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS :
null);
216 $encstrength = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH) ? $conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH : 0);
220 $pubkeys = (!empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS) ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS,
true) :
null);
222 $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys);
236 require_once TCPDF_PATH.
'tcpdf_parser.php';
238 $isencrypted =
false;
240 $content = file_get_contents($pathoffile);
243 @($parser = new \TCPDF_PARSER(ltrim($content)));
244 list($xref, $data) = $parser->getParsedData();
248 if (isset($xref[
'trailer'][
'encrypt'])) {
269 if (!empty($conf->global->MAIN_PDF_FORCE_FONT)) {
270 return $conf->global->MAIN_PDF_FORCE_FONT;
274 if (class_exists(
'TCPDF')) {
275 if ($outputlangs->trans(
'FONTFORPDF') !=
'FONTFORPDF') {
276 $font = $outputlangs->trans(
'FONTFORPDF');
293 if (class_exists(
'TCPDF')) {
294 if ($outputlangs->trans(
'FONTSIZEFORPDF') !=
'FONTSIZEFORPDF') {
295 $size = (int) $outputlangs->trans(
'FONTSIZEFORPDF');
298 if (!empty($conf->global->MAIN_PDF_FORCE_FONT_SIZE)) {
299 $size = $conf->global->MAIN_PDF_FORCE_FONT_SIZE;
316 $height = (empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? 20 : $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
318 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
320 if ($tmp[
'height']) {
321 $width = round($height * $tmp[
'width'] / $tmp[
'height']);
322 if ($width > $maxwidth) {
323 $height = $height * $maxwidth / $width;
341 $pdf->startTransaction();
343 $start_y = $pdf->GetY();
345 $start_page = $pdf->getPage();
347 $pdf->writeHTMLCell(0, 0, 0, $start_y, $htmlcontent, 0, 1,
false,
true,
'J',
true);
349 $end_y = $pdf->GetY();
350 $end_page = $pdf->getPage();
353 if ($end_page == $start_page) {
354 $height = $end_y - $start_y;
356 for ($page = $start_page; $page <= $end_page; ++$page) {
357 $pdf->setPage($page);
358 $tmpm = $pdf->getMargins();
359 $tMargin = $tmpm[
'top'];
360 if ($page == $start_page) {
362 $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin();
363 } elseif ($page == $end_page) {
365 $height = $end_y - $tMargin;
367 $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin();
372 $pdf = $pdf->rollbackTransaction();
393 if ($thirdparty instanceof
Societe) {
394 $socname = $thirdparty->name;
395 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
397 $socname = $thirdparty->name_alias.
" - ".$thirdparty->name;
399 $socname = $thirdparty->name.
" - ".$thirdparty->name_alias;
402 } elseif ($thirdparty instanceof
Contact) {
403 $socname = $thirdparty->socname;
404 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
408 throw new InvalidArgumentException(
'Parameter 1 $thirdparty is not a Societe nor Contact');
427 function pdf_build_address($outputlangs, $sourcecompany, $targetcompany =
'', $targetcontact =
'', $usecontact = 0, $mode =
'source', $object =
null)
429 global $conf, $hookmanager;
431 if ($mode ==
'source' && !is_object($sourcecompany)) {
434 if ($mode ==
'target' && !is_object($targetcompany)) {
438 if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
439 $sourcecompany->state =
getState($sourcecompany->state_id);
441 if (!empty($targetcompany->state_id) && empty($targetcompany->state)) {
442 $targetcompany->state =
getState($targetcompany->state_id);
447 if (is_object($hookmanager)) {
448 $parameters = array(
'sourcecompany' => &$sourcecompany,
'targetcompany' => &$targetcompany,
'targetcontact' => &$targetcontact,
'outputlangs' => $outputlangs,
'mode' => $mode,
'usecontact' => $usecontact);
450 $reshook = $hookmanager->executeHooks(
'pdf_build_address', $parameters, $object, $action);
451 $stringaddress .= $hookmanager->resPrint;
453 if (empty($reshook)) {
454 if ($mode ==
'source') {
456 if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
460 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($sourcecompany, $withCountry,
"\n", $outputlangs)).
"\n";
462 if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) {
464 if ($sourcecompany->phone) {
465 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"PhoneShort").
": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
468 if ($sourcecompany->fax) {
469 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
472 if ($sourcecompany->email) {
473 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($sourcecompany->email);
476 if ($sourcecompany->url) {
477 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($sourcecompany->url);
481 if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) {
482 if ($sourcecompany->tva_intra) {
483 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
488 if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) {
489 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $sourcecompany->country_code);
490 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
493 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
495 if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) {
496 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $sourcecompany->country_code);
497 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
500 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
502 if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) {
503 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $sourcecompany->country_code);
504 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
507 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
509 if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) {
510 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $sourcecompany->country_code);
511 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
514 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
516 if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) {
517 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $sourcecompany->country_code);
518 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
521 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
523 if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) {
524 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $sourcecompany->country_code);
525 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
528 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
530 if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) {
531 $stringaddress .= ($stringaddress ?
"\n" :
'').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS;
535 if ($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) {
537 if (is_object($targetcontact)) {
538 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
540 if (!empty($targetcontact->address)) {
541 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcontact));
543 $companytouseforaddress = $targetcompany;
546 if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
547 $targetcontact->fetch_thirdparty();
548 $companytouseforaddress = $targetcontact->thirdparty;
551 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($companytouseforaddress));
554 if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
555 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcontact->country_code));
556 } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
557 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
560 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode)) {
562 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
563 if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
564 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
566 if (!empty($targetcontact->phone_pro)) {
567 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
569 if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
570 $stringaddress .=
" / ";
572 if (!empty($targetcontact->phone_mobile)) {
573 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
577 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
578 if ($targetcontact->fax) {
579 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcontact->fax);
583 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
584 if ($targetcontact->email) {
585 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcontact->email);
589 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
590 if ($targetcontact->url) {
591 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcontact->url);
597 if (is_object($targetcompany)) {
598 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcompany));
600 if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
601 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
604 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode)) {
606 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
607 if (!empty($targetcompany->phone)) {
608 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
610 if (!empty($targetcompany->phone)) {
611 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
615 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
616 if ($targetcompany->fax) {
617 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcompany->fax);
621 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
622 if ($targetcompany->email) {
623 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcompany->email);
627 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
628 if ($targetcompany->url) {
629 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcompany->url);
637 if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) {
638 if ($targetcompany->tva_intra) {
639 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
644 if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) {
645 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $targetcompany->country_code);
646 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
649 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
651 if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) {
652 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $targetcompany->country_code);
653 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
656 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
658 if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) {
659 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $targetcompany->country_code);
660 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
663 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
665 if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) {
666 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $targetcompany->country_code);
667 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
670 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
672 if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) {
673 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $targetcompany->country_code);
674 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
677 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
679 if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) {
680 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $targetcompany->country_code);
681 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
684 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
688 if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) {
689 if ($mode ==
'source' && !empty($sourcecompany->note_public)) {
690 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($sourcecompany->note_public);
692 if (($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) {
693 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($targetcompany->note_public);
699 return $stringaddress;
716 if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF !=
'-1')) {
717 $filepath = $conf->mycompany->dir_output.
'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF;
718 if (file_exists($filepath)) {
719 $pdf->SetAutoPageBreak(0, 0);
720 $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);
722 $pdf->SetAutoPageBreak(1, 0);
740 $substitutionarray[
'__FROM_NAME__'] =
'__FROM_NAME__';
741 $substitutionarray[
'__FROM_EMAIL__'] =
'__FROM_EMAIL__';
742 return $substitutionarray;
759 global $langs, $mysoc, $user;
764 } elseif ($unit ==
'mm') {
766 } elseif ($unit ==
'cm') {
768 } elseif ($unit ==
'in') {
776 $text = $outputlangs->convToOutputCharset($text);
778 $savx = $pdf->getX();
779 $savy = $pdf->getY();
781 $watermark_angle = atan($h / $w) / 2;
782 $watermark_x_pos = 0;
783 $watermark_y_pos = $h / 3;
784 $watermark_x = $w / 2;
785 $watermark_y = $h / 3;
786 $pdf->SetFont(
'',
'B', 40);
787 $pdf->SetTextColor(255, 192, 203);
789 $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));
791 $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
792 $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text),
"", 2,
"C", 0);
796 $pdf->SetXY($savx, $savy);
812 function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
814 global $mysoc, $conf;
816 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbank.class.php';
818 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
819 $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT);
820 $pdf->SetXY($curx, $cury);
822 if (empty($onlynumber)) {
823 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
824 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByTransferOnThisBankAccount').
':', 0,
'L', 0);
828 $outputlangs->load(
"banks");
831 $bickey =
"BICNumber";
832 if ($account->getCountryCode() ==
'IN') {
837 $usedetailedbban = $account->useDetailedBBAN();
840 if ($usedetailedbban) {
843 if (empty($onlynumber)) {
844 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
845 $pdf->SetXY($curx, $cury);
846 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
850 if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) {
856 if (empty($onlynumber)) {
857 $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
861 foreach ($account->getFieldsToShow() as $val) {
862 $pdf->SetXY($curx, $cury + 4);
863 $pdf->SetFont(
'',
'', $default_font_size - 3);
865 if ($val ==
'BankCode') {
868 $content = $account->code_banque;
869 } elseif ($val ==
'DeskCode') {
872 $content = $account->code_guichet;
873 } elseif ($val ==
'BankAccountNumber') {
876 $content = $account->number;
877 } elseif ($val ==
'BankAccountNumberKey') {
880 $content = $account->cle_rib;
881 } elseif ($val ==
'IBAN' || $val ==
'BIC') {
886 dol_print_error($account->db,
'Unexpected value for getFieldsToShow: '.$val);
890 $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0,
'C', 0);
891 $pdf->SetXY($curx, $cury + 1);
893 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
894 $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0,
'C', 0);
895 if (empty($onlynumber)) {
896 $pdf->line($curx, $cury + 1, $curx, $cury + 7);
904 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
905 $pdf->SetXY($curx, $cury);
906 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
909 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
910 $pdf->SetXY($curx, $cury);
911 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"BankAccountNumber").
': '.$outputlangs->convToOutputCharset($account->number), 0,
'L', 0);
914 if ($diffsizecontent <= 2) {
919 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
921 if (empty($onlynumber) && !empty($account->domiciliation)) {
922 $pdf->SetXY($curx, $cury);
923 $val = $outputlangs->transnoentities(
"Residence").
': '.$outputlangs->convToOutputCharset($account->domiciliation);
924 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
927 $tmpy = $pdf->getStringHeight(100, $val);
931 if (!empty($account->proprio)) {
932 $pdf->SetXY($curx, $cury);
933 $val = $outputlangs->transnoentities(
"BankAccountOwner").
': '.$outputlangs->convToOutputCharset($account->proprio);
934 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
935 $tmpy = $pdf->getStringHeight(100, $val);
937 } elseif (!$usedetailedbban) {
944 if (!empty($account->iban)) {
946 $ibanDisplay_temp = str_replace(
' ',
'', $outputlangs->convToOutputCharset($account->iban));
949 $nbIbanDisplay_temp =
dol_strlen($ibanDisplay_temp);
950 for ($i = 0; $i < $nbIbanDisplay_temp; $i++) {
951 $ibanDisplay .= $ibanDisplay_temp[$i];
952 if ($i % 4 == 3 && $i > 0) {
957 $pdf->SetFont(
'',
'B', $default_font_size - 3);
958 $pdf->SetXY($curx, $cury);
959 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).
': '.$ibanDisplay, 0,
'L', 0);
963 if (!empty($account->bic)) {
964 $pdf->SetFont(
'',
'B', $default_font_size - 3);
965 $pdf->SetXY($curx, $cury);
966 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).
': '.$outputlangs->convToOutputCharset($account->bic), 0,
'L', 0);
989 function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark =
'')
991 global $conf, $user, $mysoc, $hookmanager;
993 $outputlangs->load(
"dict");
997 $dims = $pdf->getPageDimensions();
1000 if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) {
1003 $substitutionarray[
'__FROM_NAME__'] = $fromcompany->name;
1004 $substitutionarray[
'__FROM_EMAIL__'] = $fromcompany->email;
1006 $newfreetext =
make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs);
1012 $newfreetext = preg_replace(
'/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/',
'\1file:/'.DOL_DATA_ROOT.
'/medias/\2\3', $newfreetext);
1014 $line .= $outputlangs->convToOutputCharset($newfreetext);
1023 if ($showdetails == 1 || $showdetails == 3) {
1025 if ($fromcompany->name) {
1026 $line1 .= ($line1 ?
" - " :
"").$outputlangs->transnoentities(
"RegisteredOffice").
": ".$fromcompany->name;
1029 if ($fromcompany->address) {
1030 $line1 .= ($line1 ?
" - " :
"").str_replace(
"\n",
", ", $fromcompany->address);
1033 if ($fromcompany->zip) {
1034 $line1 .= ($line1 ?
" - " :
"").$fromcompany->zip;
1037 if ($fromcompany->town) {
1038 $line1 .= ($line1 ?
" " :
"").$fromcompany->town;
1041 if ($fromcompany->country) {
1042 $line1 .= ($line1 ?
", " :
"").$fromcompany->country;
1045 if ($fromcompany->phone) {
1046 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Phone").
": ".$fromcompany->phone;
1049 if ($fromcompany->fax) {
1050 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Fax").
": ".$fromcompany->fax;
1054 if ($fromcompany->url) {
1055 $line2 .= ($line2 ?
" - " :
"").$fromcompany->url;
1058 if ($fromcompany->email) {
1059 $line2 .= ($line2 ?
" - " :
"").$fromcompany->email;
1062 if ($showdetails == 2 || $showdetails == 3 || (!empty($fromcompany->country_code) && $fromcompany->country_code ==
'DE')) {
1064 if ($fromcompany->managers) {
1065 $line2 .= ($line2 ?
" - " :
"").$fromcompany->managers;
1071 if (!empty($fromcompany->forme_juridique_code) && $fromcompany->forme_juridique_code) {
1072 $line3 .= ($line3 ?
" - " :
"").$outputlangs->convToOutputCharset(
getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
1075 if (!empty($fromcompany->capital)) {
1076 $tmpamounttoshow =
price2num($fromcompany->capital);
1077 if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
1078 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf",
price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
1079 } elseif (!empty($fromcompany->capital)) {
1080 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf", $fromcompany->capital, $outputlangs);
1084 if (!empty($fromcompany->idprof1) && $fromcompany->idprof1 && ($fromcompany->country_code !=
'FR' || !$fromcompany->idprof2)) {
1085 $field = $outputlangs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
1086 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1089 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
1092 if (!empty($fromcompany->idprof2) && $fromcompany->idprof2) {
1093 $field = $outputlangs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
1094 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1097 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
1102 if (!empty($fromcompany->idprof3) && $fromcompany->idprof3) {
1103 $field = $outputlangs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
1104 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1107 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
1110 if (!empty($fromcompany->idprof4) && $fromcompany->idprof4) {
1111 $field = $outputlangs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
1112 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1115 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
1118 if (!empty($fromcompany->idprof5) && $fromcompany->idprof5) {
1119 $field = $outputlangs->transcountrynoentities(
"ProfId5", $fromcompany->country_code);
1120 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1123 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
1126 if (!empty($fromcompany->idprof6) && $fromcompany->idprof6) {
1127 $field = $outputlangs->transcountrynoentities(
"ProfId6", $fromcompany->country_code);
1128 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1131 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
1134 if (!empty($fromcompany->tva_intra) && $fromcompany->tva_intra !=
'') {
1135 $line4 .= ($line4 ?
" - " :
"").$outputlangs->transnoentities(
"VATIntraShort").
": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
1138 $pdf->SetFont(
'',
'', 7);
1139 $pdf->SetDrawColor(224, 224, 224);
1141 if (!empty($conf->global->PDF_FOOTER_TEXT_COLOR)) {
1142 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_TEXT_COLOR,
'%d, %d, %d');
1143 $pdf->SetTextColor($r, $g, $b);
1147 $freetextheight = 0;
1150 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
1153 if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
1157 $freetextheight = $pdf->getStringHeight($width, $line);
1165 if (is_object($hookmanager)) {
1166 $parameters = array(
'line1' => $line1,
'line2' => $line2,
'line3' => $line3,
'line4' => $line4,
'outputlangs'=>$outputlangs);
1168 $hookmanager->executeHooks(
'pdf_pagefoot', $parameters, $object, $action);
1169 if (!empty($hookmanager->resPrint) && $hidefreetext == 0) {
1170 $mycustomfooter = $hookmanager->resPrint;
1173 $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight;
1174 $posy = $marginwithfooter + 0;
1178 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR,
'%d, %d, %d');
1179 $pdf->SetAutoPageBreak(0, 0);
1180 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F',
'', $fill_color = array($r, $g, $b));
1181 $pdf->SetAutoPageBreak(1, 0);
1185 $pdf->SetXY($dims[
'lm'], -$posy);
1187 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1189 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1191 $posy -= $freetextheight;
1198 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1209 if (
getDolGlobalString(
'PDF_FOOTER_DISABLE_PAGEBREAK') ===
'1') { $pdf->SetAutoPageBreak(0, 0); }
1210 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims[
'lm'], $dims[
'hk'] - $posy,
dol_htmlentitiesbr($mycustomfooter, 1,
'UTF-8', 0));
1211 if (
getDolGlobalString(
'PDF_FOOTER_DISABLE_PAGEBREAK') ===
'1') { $pdf->SetAutoPageBreak(1, 0); }
1213 $posy -= $mycustomfooterheight - 3;
1216 $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
1217 $posy = $marginwithfooter + 0;
1221 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR,
'%d, %d, %d');
1222 $pdf->SetAutoPageBreak(0, 0);
1223 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F',
'', $fill_color = array($r, $g, $b));
1224 $pdf->SetAutoPageBreak(1, 0);
1228 $pdf->SetXY($dims[
'lm'], -$posy);
1230 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1232 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1234 $posy -= $freetextheight;
1241 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1252 if (!empty($line1)) {
1253 $pdf->SetFont(
'',
'B', 7);
1254 $pdf->SetXY($dims[
'lm'], -$posy);
1255 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line1, 0,
'C', 0);
1257 $pdf->SetFont(
'',
'', 7);
1260 if (!empty($line2)) {
1261 $pdf->SetFont(
'',
'B', 7);
1262 $pdf->SetXY($dims[
'lm'], -$posy);
1263 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line2, 0,
'C', 0);
1265 $pdf->SetFont(
'',
'', 7);
1268 if (!empty($line3)) {
1269 $pdf->SetXY($dims[
'lm'], -$posy);
1270 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line3, 0,
'C', 0);
1273 if (!empty($line4)) {
1275 $pdf->SetXY($dims[
'lm'], -$posy);
1276 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line4, 0,
'C', 0);
1282 $pdf->SetXY($dims[
'wk'] - $dims[
'rm'] - 15, -$posy);
1284 $pdf->MultiCell(15, 2, $pdf->PageNo().
'/'.$pdf->getAliasNbPages(), 0,
'R', 0);
1288 if (!empty($watermark)) {
1289 pdf_watermark($pdf, $outputlangs, $page_hauteur, $page_largeur,
'mm', $watermark);
1292 return $marginwithfooter;
1312 if (!empty($linkedobjects)) {
1313 foreach ($linkedobjects as $linkedobject) {
1314 $reftoshow = $linkedobject[
"ref_title"].
' : '.$linkedobject[
"ref_value"];
1315 if (!empty($linkedobject[
"date_value"])) {
1316 $reftoshow .=
' / '.$linkedobject[
"date_value"];
1320 $pdf->SetXY($posx, $posy);
1321 $pdf->SetFont(
'',
'', $default_font_size - 2);
1322 $pdf->MultiCell($w, $h, $reftoshow,
'', $align);
1326 return $pdf->getY();
1345 function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1347 global $db, $conf, $langs, $hookmanager;
1352 if (is_object($hookmanager)) {
1353 $special_code = empty($object->lines[$i]->special_code) ?
'' : $object->lines[$i]->special_code;
1354 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1355 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1357 $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);
1359 $reshook = $hookmanager->executeHooks(
'pdf_writelinedesc', $parameters, $object, $action);
1361 if (!empty($hookmanager->resPrint)) {
1362 $result .= $hookmanager->resPrint;
1365 if (empty($reshook)) {
1366 $labelproductservice =
pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
1373 $labelproductservice = preg_replace(
'/(<img[^>]*src=")([^"]*)(&)([^"]*")/',
'\1\2&\4', $labelproductservice, -1, $nbrep);
1378 $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1,
false,
true,
'J',
true);
1379 $result .= $labelproductservice;
1395 function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1397 global $db, $conf, $langs;
1399 $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product :
false);
1400 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label :
''));
1401 $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description :
''));
1402 $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn :
''));
1403 $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note :
'');
1404 $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch :
false);
1406 if ($issupplierline) {
1407 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1410 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1413 if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1414 include_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1419 $prodser->fetch($idprod);
1421 if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) {
1422 $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED));
1430 $textwasnotmodified = ($label == $prodser->label);
1431 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"label"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1432 $label = $prodser->multilangs[$outputlangs->defaultlang][
"label"];
1437 $textwasnotmodified =
false;
1441 $textwasnotmodified = ($desc == $prodser->description);
1443 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"description"])) {
1444 if ($textwasnotmodified) {
1445 $desc = str_replace($prodser->description, $prodser->multilangs[$outputlangs->defaultlang][
"description"], $desc);
1446 } elseif ($translatealsoifmodified) {
1447 $desc = $prodser->multilangs[$outputlangs->defaultlang][
"description"];
1452 $textwasnotmodified = ($note == $prodser->note_public);
1453 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"other"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1454 $note = $prodser->multilangs[$outputlangs->defaultlang][
"other"];
1457 } elseif (($object->element ==
'facture' || $object->element ==
'facturefourn') && preg_match(
'/^\(DEPOSIT\).+/', $desc)) {
1458 $desc = str_replace(
'(DEPOSIT)', $outputlangs->trans(
'Deposit'), $desc);
1461 if (empty($conf->global->PDF_HIDE_PRODUCT_LABEL_IN_SUPPLIER_LINES)) {
1463 $libelleproduitservice = $label;
1464 if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
1468 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1470 $libelleproduitservice =
'<b>'.$libelleproduitservice.
'</b>';
1476 if (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) {
1477 $prodser->get_sousproduits_arbo();
1478 if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
1479 $tmparrayofsubproducts = reset($prodser->sousprods);
1480 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) {
1481 foreach ($tmparrayofsubproducts as $subprodval) {
1482 $libelleproduitservice =
dol_concatdesc($libelleproduitservice,
" * ".$subprodval[3].
' ('.$subprodval[1].
')');
1485 foreach ($tmparrayofsubproducts as $subprodval) {
1486 $libelleproduitservice =
dol_concatdesc($libelleproduitservice,
" * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ?
' - ' :
'').$subprodval[3].
' ('.$subprodval[1].
')');
1493 if (!empty($desc) && ($desc != $label)) {
1494 if ($desc ==
'(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
1496 $discount->fetch($object->lines[$i]->fk_remise_except);
1497 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
1498 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromCreditNote", $sourceref);
1499 } elseif ($desc ==
'(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
1501 $discount->fetch($object->lines[$i]->fk_remise_except);
1502 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
1503 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromDeposit", $sourceref);
1505 if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
1506 $libelleproduitservice .=
' ('.dol_print_date($discount->datec,
'day',
'', $outputlangs).
')';
1508 } elseif ($desc ==
'(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) {
1510 $discount->fetch($object->lines[$i]->fk_remise_except);
1511 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessReceived", $discount->ref_facture_source);
1512 } elseif ($desc ==
'(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) {
1514 $discount->fetch($object->lines[$i]->fk_remise_except);
1515 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
1519 if (!empty($object->element)) {
1520 $tmpkey =
'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper($object->element);
1521 if (!empty($conf->global->$tmpkey)) {
1525 if (empty($hidedesc)) {
1526 if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) {
1527 $libelleproduitservice =
dol_concatdesc($desc, $libelleproduitservice);
1529 if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) {
1530 $libelleproduitservice = $desc;
1532 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desc);
1537 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desc);
1543 $prefix_prodserv =
"";
1545 if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
1546 if ($prodser->isService()) {
1547 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Service").
" ";
1549 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Product").
" ";
1553 if (empty($hideref)) {
1554 if ($issupplierline) {
1555 if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) {
1556 $ref_prodserv = $prodser->ref;
1557 if ($ref_supplier) {
1558 $ref_prodserv .= ($prodser->ref ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
"SupplierRef").
' '.$ref_supplier.($prodser->ref ?
')' :
'');
1560 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
1561 $ref_prodserv = $ref_supplier;
1562 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
1563 $ref_prodserv = $ref_supplier.
' ('.$outputlangs->transnoentitiesnoconv(
"InternalRef").
' '.$prodser->ref.
')';
1566 $ref_prodserv = $prodser->ref;
1568 if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1570 $filter = array(
'fk_product' => $idprod,
'fk_soc' => $object->socid);
1572 $nbCustomerPrices = $productCustomerPriceStatic->fetch_all(
'',
'', 1, 0, $filter);
1574 if ($nbCustomerPrices > 0) {
1575 $productCustomerPrice = $productCustomerPriceStatic->lines[0];
1577 if (! empty($productCustomerPrice->ref_customer)) {
1578 switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) {
1580 $ref_prodserv = $productCustomerPrice->ref_customer;
1584 $ref_prodserv = $productCustomerPrice->ref_customer .
' (' . $outputlangs->transnoentitiesnoconv(
'InternalRef') .
' ' . $ref_prodserv .
')';
1588 $ref_prodserv = $ref_prodserv .
' (' . $outputlangs->transnoentitiesnoconv(
'RefCustomer') .
' ' . $productCustomerPrice->ref_customer .
')';
1595 if (!empty($libelleproduitservice) && !empty($ref_prodserv)) {
1596 $ref_prodserv .=
" - ";
1600 if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1602 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1604 $ref_prodserv =
'<b>'.$ref_prodserv.
'</b>';
1607 $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
1610 if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) {
1611 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1614 $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
1615 foreach ($tblcateg as $cate) {
1617 $desccateg = $cate->description;
1619 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desccateg);
1624 if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) {
1628 if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
1629 $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)).
')';
1631 if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) {
1632 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($object->lines[$i]->date_start, $format,
false, $outputlangs)).
')';
1634 if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) {
1635 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($object->lines[$i]->date_end, $format,
false, $outputlangs)).
')';
1638 if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1640 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1642 $libelleproduitservice .=
'<br><b style="color:#333666;" ><em>'.$period.
'</em></b>';
1644 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $period);
1651 foreach ($dbatch as $detail) {
1653 if ($detail->eatby) {
1654 $dte[] = $outputlangs->transnoentitiesnoconv(
'printEatby',
dol_print_date($detail->eatby, $format,
false, $outputlangs));
1656 if ($detail->sellby) {
1657 $dte[] = $outputlangs->transnoentitiesnoconv(
'printSellby',
dol_print_date($detail->sellby, $format,
false, $outputlangs));
1659 if ($detail->batch) {
1660 $dte[] = $outputlangs->transnoentitiesnoconv(
'printBatch', $detail->batch);
1662 $dte[] = $outputlangs->transnoentitiesnoconv(
'printQty', $detail->qty);
1663 $libelleproduitservice .=
"__N__ ".implode(
" - ", $dte);
1669 $libelleproduitservice = preg_replace(
'/__N__/',
'<br>', $libelleproduitservice);
1671 $libelleproduitservice = preg_replace(
'/__N__/',
"\n", $libelleproduitservice);
1675 return $libelleproduitservice;
1689 global $hookmanager;
1694 if (is_object($hookmanager)) {
1695 $special_code = $object->lines[$i]->special_code;
1696 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1697 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1699 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1701 $reshook = $hookmanager->executeHooks(
'pdf_getlinenum', $parameters, $object, $action);
1702 $result .= $hookmanager->resPrint;
1704 if (empty($reshook)) {
1722 global $hookmanager;
1727 if (is_object($hookmanager)) {
1728 $special_code = $object->lines[$i]->special_code;
1729 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1730 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1732 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1734 $reshook = $hookmanager->executeHooks(
'pdf_getlineref', $parameters, $object, $action);
1735 $result .= $hookmanager->resPrint;
1737 if (empty($reshook)) {
1754 global $hookmanager;
1759 if (is_object($hookmanager)) {
1760 $special_code = $object->lines[$i]->special_code;
1761 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1762 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1764 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1766 $reshook = $hookmanager->executeHooks(
'pdf_getlineref_supplier', $parameters, $object, $action);
1767 $result .= $hookmanager->resPrint;
1769 if (empty($reshook)) {
1786 global $conf, $hookmanager, $mysoc;
1791 if (is_object($hookmanager)) {
1792 $special_code = empty($object->lines[$i]) ?
'' : $object->lines[$i]->special_code;
1793 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1794 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1796 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1798 $reshook = $hookmanager->executeHooks(
'pdf_getlinevatrate', $parameters, $object, $action);
1800 if (!empty($hookmanager->resPrint)) {
1801 $result .= $hookmanager->resPrint;
1804 if (empty($reshook)) {
1805 if (empty($hidedetails) || $hidedetails > 1) {
1808 $tmpresult .=
vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1);
1809 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) {
1810 if ($object->lines[$i]->total_localtax1 != 0) {
1811 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
1816 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax1_tx), 0);
1819 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) {
1820 if ($object->lines[$i]->total_localtax2 != 0) {
1821 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
1826 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax2_tx), 0);
1831 $result .= $tmpresult;
1848 global $conf, $hookmanager;
1851 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1858 if (is_object($hookmanager)) {
1859 $special_code = empty($object->lines[$i]) ?
'' : $object->lines[$i]->special_code;
1860 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1861 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1863 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1865 $reshook = $hookmanager->executeHooks(
'pdf_getlineupexcltax', $parameters, $object, $action);
1867 if (!empty($hookmanager->resPrint)) {
1868 $result .= $hookmanager->resPrint;
1871 if (empty($reshook)) {
1872 if (empty($hidedetails) || $hidedetails > 1) {
1873 $subprice = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
1874 $result .=
price($sign * $subprice, 0, $outputlangs);
1891 global $hookmanager, $conf;
1894 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1901 if (is_object($hookmanager)) {
1902 $special_code = $object->lines[$i]->special_code;
1903 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1904 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1906 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1908 $reshook = $hookmanager->executeHooks(
'pdf_getlineupwithtax', $parameters, $object, $action);
1910 if (!empty($hookmanager->resPrint)) {
1911 $result .= $hookmanager->resPrint;
1914 if (empty($reshook)) {
1915 if (empty($hidedetails) || $hidedetails > 1) {
1916 $result .=
price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
1933 global $hookmanager;
1938 if (is_object($hookmanager)) {
1939 $special_code = empty($object->lines[$i]) ?
'' : $object->lines[$i]->special_code;
1940 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1941 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1943 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1945 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty', $parameters, $object, $action);
1947 if (!empty($hookmanager->resPrint)) {
1948 $result = $hookmanager->resPrint;
1951 if (empty($reshook)) {
1952 if ($object->lines[$i]->special_code == 3) {
1955 if (empty($hidedetails) || $hidedetails > 1) {
1956 $result .= $object->lines[$i]->qty;
1973 global $hookmanager;
1978 if (is_object($hookmanager)) {
1979 $special_code = $object->lines[$i]->special_code;
1980 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
1981 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1983 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1985 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_asked', $parameters, $object, $action);
1987 if (!empty($hookmanager->resPrint)) {
1988 $result .= $hookmanager->resPrint;
1991 if (empty($reshook)) {
1992 if ($object->lines[$i]->special_code == 3) {
1995 if (empty($hidedetails) || $hidedetails > 1) {
1996 $result .= $object->lines[$i]->qty_asked;
2013 global $hookmanager;
2018 if (is_object($hookmanager)) {
2019 $special_code = $object->lines[$i]->special_code;
2020 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2021 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2023 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2025 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_shipped', $parameters, $object, $action);
2027 if (!empty($hookmanager->resPrint)) {
2028 $result .= $hookmanager->resPrint;
2031 if (empty($reshook)) {
2032 if ($object->lines[$i]->special_code == 3) {
2035 if (empty($hidedetails) || $hidedetails > 1) {
2036 $result .= $object->lines[$i]->qty_shipped;
2053 global $hookmanager;
2058 if (is_object($hookmanager)) {
2059 $special_code = $object->lines[$i]->special_code;
2060 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2061 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2063 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2065 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_keeptoship', $parameters, $object, $action);
2067 if (!empty($hookmanager->resPrint)) {
2068 $result .= $hookmanager->resPrint;
2071 if (empty($reshook)) {
2072 if ($object->lines[$i]->special_code == 3) {
2075 if (empty($hidedetails) || $hidedetails > 1) {
2076 $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
2092 function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager =
false)
2099 if (is_object($hookmanager)) {
2100 $special_code = $object->lines[$i]->special_code;
2101 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2102 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2104 $parameters = array(
2106 'outputlangs' => $outputlangs,
2107 'hidedetails' => $hidedetails,
2108 'special_code' => $special_code
2111 $reshook = $hookmanager->executeHooks(
'pdf_getlineunit', $parameters, $object, $action);
2113 if (!empty($hookmanager->resPrint)) {
2114 $result .= $hookmanager->resPrint;
2117 if (empty($reshook)) {
2118 if (empty($hidedetails) || $hidedetails > 1) {
2119 $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit(
'short'));
2137 global $hookmanager;
2139 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2144 if (is_object($hookmanager)) {
2145 $special_code = $object->lines[$i]->special_code;
2146 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2147 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2149 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2151 $reshook = $hookmanager->executeHooks(
'pdf_getlineremisepercent', $parameters, $object, $action);
2153 if (!empty($hookmanager->resPrint)) {
2154 $result .= $hookmanager->resPrint;
2157 if (empty($reshook)) {
2158 if ($object->lines[$i]->special_code == 3) {
2161 if (empty($hidedetails) || $hidedetails > 1) {
2180 if (empty($hookmanager)) {
2181 global $hookmanager;
2188 if (is_object($hookmanager)) {
2189 $special_code = $object->lines[$i]->special_code;
2190 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
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_getlineprogress', $parameters, $object, $action);
2197 if (!empty($hookmanager->resPrint)) {
2198 return $hookmanager->resPrint;
2201 if (empty($reshook)) {
2202 if ($object->lines[$i]->special_code == 3) {
2205 if (empty($hidedetails) || $hidedetails > 1) {
2206 if (!empty($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)) {
2208 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2209 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2211 $result = round($object->lines[$i]->situation_percent - $prev_progress, 1).
'%';
2213 $result = round($object->lines[$i]->situation_percent, 1).
'%';
2231 global $conf, $hookmanager;
2234 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2241 if (is_object($hookmanager)) {
2242 $special_code = empty($object->lines[$i]) ?
'' : $object->lines[$i]->special_code;
2243 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2244 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2246 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code,
'sign'=>$sign);
2248 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalexcltax', $parameters, $object, $action);
2250 if (!empty($hookmanager->resPrint)) {
2251 $result .= $hookmanager->resPrint;
2254 if (empty($reshook)) {
2255 if (!empty($object->lines[$i]) && $object->lines[$i]->special_code == 3) {
2256 $result .= $outputlangs->transnoentities(
"Option");
2257 } elseif (empty($hidedetails) || $hidedetails > 1) {
2258 $total_ht = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
2259 if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) {
2263 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2264 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2265 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2267 $result .=
price($sign * ($total_ht / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2269 $result .=
price($sign * $total_ht, 0, $outputlangs);
2287 global $hookmanager, $conf;
2290 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2297 if (is_object($hookmanager)) {
2298 $special_code = $object->lines[$i]->special_code;
2299 if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) {
2300 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2302 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2304 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalwithtax', $parameters, $object, $action);
2306 if (!empty($hookmanager->resPrint)) {
2307 $result .= $hookmanager->resPrint;
2310 if (empty($reshook)) {
2311 if ($object->lines[$i]->special_code == 3) {
2312 $result .= $outputlangs->transnoentities(
"Option");
2313 } elseif (empty($hidedetails) || $hidedetails > 1) {
2314 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
2315 if ($object->lines[$i]->situation_percent > 0) {
2319 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2320 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2321 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2323 $result .=
price($sign * ($total_ttc / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2325 $result .=
price($sign * $total_ttc, 0, $outputlangs);
2342 global $db, $hookmanager;
2344 $linkedobjects = array();
2346 $object->fetchObjectLinked();
2348 foreach ($object->linkedObjects as $objecttype => $objects) {
2349 if ($objecttype ==
'facture') {
2351 } elseif ($objecttype ==
'propal' || $objecttype ==
'supplier_proposal') {
2352 $outputlangs->load(
'propal');
2354 foreach ($objects as $elementobject) {
2355 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefProposal");
2356 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2357 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DatePropal");
2358 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2360 } elseif ($objecttype ==
'commande' || $objecttype ==
'supplier_order') {
2361 $outputlangs->load(
'orders');
2364 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefOrder").
' :');
2365 foreach ($objects as $elementobject) {
2366 $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.
')').
' ');
2367 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"OrderDate").
' : '.
dol_print_date($elementobject->date,
'day',
'', $outputlangs));
2369 } elseif (count($objects) == 1) {
2370 $elementobject = array_shift($objects);
2371 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder");
2372 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref).(!empty($elementobject->ref_client) ?
' ('.$elementobject->ref_client.
')' :
'').(!empty($elementobject->ref_supplier) ?
' ('.$elementobject->ref_supplier.
')' :
'');
2373 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"OrderDate");
2374 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2376 } elseif ($objecttype ==
'contrat') {
2377 $outputlangs->load(
'contracts');
2378 foreach ($objects as $elementobject) {
2379 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefContract");
2380 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2381 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DateContract");
2382 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date_contrat,
'day',
'', $outputlangs);
2384 } elseif ($objecttype ==
'fichinter') {
2385 $outputlangs->load(
'interventions');
2386 foreach ($objects as $elementobject) {
2387 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"InterRef");
2388 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2389 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"InterDate");
2390 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->datec,
'day',
'', $outputlangs);
2392 } elseif ($objecttype ==
'shipping') {
2393 $outputlangs->loadLangs(array(
"orders",
"sendings"));
2395 if (count($objects) > 1) {
2397 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2398 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending").
' :');
2400 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefSending").
' :');
2403 foreach ($objects as $elementobject) {
2404 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2405 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
2406 if (! empty($elementobject->linkedObjectsIds[
'commande'])) {
2407 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2409 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2416 if (! is_object($order)) {
2417 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref));
2419 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
''));
2420 $object->note_public =
dol_concatdesc($object->note_public,
' / '.$outputlangs->transnoentities($elementobject->ref));
2423 } elseif (count($objects) == 1) {
2424 $elementobject = array_shift($objects);
2427 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2428 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
2429 if (! empty($elementobject->linkedObjectsIds[
'commande'])) {
2430 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2432 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2439 if (! is_object($order)) {
2440 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefSending");
2441 if (! empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] .=
' / ';
2442 $linkedobjects[$objecttype][
'ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
2443 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
2445 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending");
2446 if (empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
'');
2447 $linkedobjects[$objecttype][
'ref_value'] .=
' / '.$outputlangs->transnoentities($elementobject->ref);
2448 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
2455 if (is_object($hookmanager)) {
2456 $parameters = array(
'linkedobjects' => $linkedobjects,
'outputlangs'=>$outputlangs);
2458 $hookmanager->executeHooks(
'pdf_getLinkedObjects', $parameters, $object, $action);
2459 if (!empty($hookmanager->resArray)) {
2460 $linkedobjects = $hookmanager->resArray;
2464 return $linkedobjects;
2478 $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
2479 $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
2480 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2482 if ($tmp[
'height']) {
2483 $width = (int) round($maxheight * $tmp[
'width'] / $tmp[
'height']);
2484 if ($width > $maxwidth) {
2486 $height = (int) round($maxwidth * $tmp[
'height'] / $tmp[
'width']);
2489 $height = $maxheight;
2492 return array(
'width'=>$width,
'height'=>$height);
2506 global $conf, $hookmanager;
2508 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2511 if ($object->lines[$i]->special_code == 3) {
2512 return $outputlangs->transnoentities(
"Option");
2514 if (is_object($hookmanager)) {
2515 $special_code = $object->lines[$i]->special_code;
2516 if (!empty($object->lines[$i]->fk_parent_line)) {
2517 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2520 $parameters = array(
2522 'outputlangs'=>$outputlangs,
2523 'hidedetails'=>$hidedetails,
2524 'special_code'=>$special_code
2529 if ($hookmanager->executeHooks(
'getlinetotalremise', $parameters, $object, $action) > 0) {
2530 return $hookmanager->resPrint;
2534 if (empty($hidedetails) || $hidedetails > 1) {
2535 return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht);