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';
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 if ($thirdparty->socid > 0) {
404 $thirdparty->fetch_thirdparty();
405 $socname = $thirdparty->thirdparty->name;
406 if (($includealias ||
getDolGlobalInt(
'PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->thirdparty->name_alias)) {
408 $socname = $thirdparty->thirdparty->name_alias.
" - ".$thirdparty->thirdparty->name;
410 $socname = $thirdparty->thirdparty->name.
" - ".$thirdparty->thirdparty->name_alias;
415 throw new InvalidArgumentException(
'Parameter 1 $thirdparty is not a Societe nor Contact');
434 function pdf_build_address($outputlangs, $sourcecompany, $targetcompany =
'', $targetcontact =
'', $usecontact = 0, $mode =
'source', $object =
null)
436 global $conf, $hookmanager;
438 if ($mode ==
'source' && !is_object($sourcecompany)) {
441 if ($mode ==
'target' && !is_object($targetcompany)) {
445 if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
446 $sourcecompany->state =
getState($sourcecompany->state_id);
448 if (!empty($targetcompany->state_id) && empty($targetcompany->state)) {
449 $targetcompany->state =
getState($targetcompany->state_id);
454 if (is_object($hookmanager)) {
455 $parameters = array(
'sourcecompany' => &$sourcecompany,
'targetcompany' => &$targetcompany,
'targetcontact' => &$targetcontact,
'outputlangs' => $outputlangs,
'mode' => $mode,
'usecontact' => $usecontact);
457 $reshook = $hookmanager->executeHooks(
'pdf_build_address', $parameters, $object, $action);
458 $stringaddress .= $hookmanager->resPrint;
460 if (empty($reshook)) {
461 if ($mode ==
'source') {
463 if (isset($targetcompany->country_code) && !empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
467 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($sourcecompany, $withCountry,
"\n", $outputlangs)).
"\n";
469 if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) {
471 if ($sourcecompany->phone) {
472 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"PhoneShort").
": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
475 if ($sourcecompany->fax) {
476 $stringaddress .= ($stringaddress ? ($sourcecompany->phone ?
" - " :
"\n") :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
479 if ($sourcecompany->email) {
480 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($sourcecompany->email);
483 if ($sourcecompany->url) {
484 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($sourcecompany->url);
488 if (!empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) {
489 if ($sourcecompany->tva_intra) {
490 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra);
495 if (!empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof1)) {
496 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $sourcecompany->country_code);
497 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
500 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1);
502 if (!empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof2)) {
503 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $sourcecompany->country_code);
504 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
507 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2);
509 if (!empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof3)) {
510 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $sourcecompany->country_code);
511 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
514 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3);
516 if (!empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof4)) {
517 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $sourcecompany->country_code);
518 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
521 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4);
523 if (!empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof5)) {
524 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $sourcecompany->country_code);
525 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
528 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5);
530 if (!empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && !empty($sourcecompany->idprof6)) {
531 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $sourcecompany->country_code);
532 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
535 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6);
537 if (!empty($conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS)) {
538 $stringaddress .= ($stringaddress ?
"\n" :
'').$conf->global->PDF_ADD_MORE_AFTER_SOURCE_ADDRESS;
542 if ($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) {
544 if (is_object($targetcontact)) {
545 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
547 if (!empty($targetcontact->address)) {
548 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcontact)).
"\n";
550 $companytouseforaddress = $targetcompany;
553 if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) {
554 $targetcontact->fetch_thirdparty();
555 $companytouseforaddress = $targetcontact->thirdparty;
558 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($companytouseforaddress)).
"\n";
561 if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
562 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcontact->country_code));
563 } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
564 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
567 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode)) {
569 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
570 if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
571 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
573 if (!empty($targetcontact->phone_pro)) {
574 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
576 if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
577 $stringaddress .=
" / ";
579 if (!empty($targetcontact->phone_mobile)) {
580 $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
584 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
585 if ($targetcontact->fax) {
586 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcontact->fax);
590 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
591 if ($targetcontact->email) {
592 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcontact->email);
596 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
597 if ($targetcontact->url) {
598 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcontact->url);
604 if (is_object($targetcompany)) {
605 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset(
dol_format_address($targetcompany)).
"\n";
607 if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
608 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$targetcompany->country_code));
611 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match(
'/targetwithdetails/', $mode)) {
613 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_phone/', $mode)) {
614 if (!empty($targetcompany->phone)) {
615 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Phone").
": ";
617 if (!empty($targetcompany->phone)) {
618 $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
622 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_fax/', $mode)) {
623 if ($targetcompany->fax) {
624 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Fax").
": ".$outputlangs->convToOutputCharset($targetcompany->fax);
628 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_email/', $mode)) {
629 if ($targetcompany->email) {
630 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Email").
": ".$outputlangs->convToOutputCharset($targetcompany->email);
634 if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode ==
'targetwithdetails' || preg_match(
'/targetwithdetails_url/', $mode)) {
635 if ($targetcompany->url) {
636 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"Web").
": ".$outputlangs->convToOutputCharset($targetcompany->url);
644 if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) {
645 if ($targetcompany->tva_intra) {
646 $stringaddress .= ($stringaddress ?
"\n" :
'').$outputlangs->transnoentities(
"VATIntraShort").
': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
651 if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) {
652 $tmp = $outputlangs->transcountrynoentities(
"ProfId1", $targetcompany->country_code);
653 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
656 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
658 if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) {
659 $tmp = $outputlangs->transcountrynoentities(
"ProfId2", $targetcompany->country_code);
660 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
663 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
665 if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) {
666 $tmp = $outputlangs->transcountrynoentities(
"ProfId3", $targetcompany->country_code);
667 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
670 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
672 if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) {
673 $tmp = $outputlangs->transcountrynoentities(
"ProfId4", $targetcompany->country_code);
674 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
677 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
679 if (!empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && !empty($targetcompany->idprof5)) {
680 $tmp = $outputlangs->transcountrynoentities(
"ProfId5", $targetcompany->country_code);
681 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
684 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof5);
686 if (!empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && !empty($targetcompany->idprof6)) {
687 $tmp = $outputlangs->transcountrynoentities(
"ProfId6", $targetcompany->country_code);
688 if (preg_match(
'/\((.+)\)/', $tmp, $reg)) {
691 $stringaddress .= ($stringaddress ?
"\n" :
'').$tmp.
': '.$outputlangs->convToOutputCharset($targetcompany->idprof6);
695 if (!empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) {
696 if ($mode ==
'source' && !empty($sourcecompany->note_public)) {
697 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($sourcecompany->note_public);
699 if (($mode ==
'target' || preg_match(
'/targetwithdetails/', $mode)) && !empty($targetcompany->note_public)) {
700 $stringaddress .= ($stringaddress ?
"\n" :
'').
dol_string_nohtmltag($targetcompany->note_public);
706 return $stringaddress;
723 if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF !=
'-1')) {
724 $filepath = $conf->mycompany->dir_output.
'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF;
725 if (file_exists($filepath)) {
726 $pdf->SetAutoPageBreak(0, 0);
727 $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);
729 $pdf->SetAutoPageBreak(1, 0);
747 $substitutionarray[
'__FROM_NAME__'] =
'__FROM_NAME__';
748 $substitutionarray[
'__FROM_EMAIL__'] =
'__FROM_EMAIL__';
749 return $substitutionarray;
766 global $langs, $mysoc, $user;
771 } elseif ($unit ==
'mm') {
773 } elseif ($unit ==
'cm') {
775 } elseif ($unit ==
'in') {
783 $text = $outputlangs->convToOutputCharset($text);
785 $savx = $pdf->getX();
786 $savy = $pdf->getY();
788 $watermark_angle = atan($h / $w) / 2;
789 $watermark_x_pos = 0;
790 $watermark_y_pos = $h / 3;
791 $watermark_x = $w / 2;
792 $watermark_y = $h / 3;
793 $pdf->SetFont(
'',
'B', 40);
794 $pdf->SetTextColor(255, 192, 203);
796 $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));
798 $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
799 $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text),
"", 2,
"C", 0);
803 $pdf->SetXY($savx, $savy);
819 function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, $default_font_size = 10)
821 global $mysoc, $conf;
823 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbank.class.php';
825 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
826 $diffsizecontent = (empty($conf->global->PDF_DIFFSIZE_CONTENT) ? 4 : $conf->global->PDF_DIFFSIZE_CONTENT);
827 $pdf->SetXY($curx, $cury);
829 if (empty($onlynumber)) {
830 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
831 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByTransferOnThisBankAccount').
':', 0,
'L', 0);
835 $outputlangs->load(
"banks");
838 $bickey =
"BICNumber";
839 if ($account->getCountryCode() ==
'IN') {
844 $usedetailedbban = $account->useDetailedBBAN();
847 if ($usedetailedbban) {
850 if (empty($onlynumber)) {
851 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
852 $pdf->SetXY($curx, $cury);
853 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
857 if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) {
863 if (empty($onlynumber)) {
864 $pdf->line($curx + 1, $cury + 1, $curx + 1, $cury + 6);
868 foreach ($account->getFieldsToShow() as $val) {
869 $pdf->SetXY($curx, $cury + 4);
870 $pdf->SetFont(
'',
'', $default_font_size - 3);
872 if ($val ==
'BankCode') {
875 $content = $account->code_banque;
876 } elseif ($val ==
'DeskCode') {
879 $content = $account->code_guichet;
880 } elseif ($val ==
'BankAccountNumber') {
883 $content = $account->number;
884 } elseif ($val ==
'BankAccountNumberKey') {
887 $content = $account->cle_rib;
888 } elseif ($val ==
'IBAN' || $val ==
'BIC') {
893 dol_print_error($account->db,
'Unexpected value for getFieldsToShow: '.$val);
897 $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0,
'C', 0);
898 $pdf->SetXY($curx, $cury + 1);
900 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
901 $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0,
'C', 0);
902 if (empty($onlynumber)) {
903 $pdf->line($curx, $cury + 1, $curx, $cury + 7);
911 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
912 $pdf->SetXY($curx, $cury);
913 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Bank").
': '.$outputlangs->convToOutputCharset($account->bank), 0,
'L', 0);
916 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizecontent);
917 $pdf->SetXY($curx, $cury);
918 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"BankAccountNumber").
': '.$outputlangs->convToOutputCharset($account->number), 0,
'L', 0);
921 if ($diffsizecontent <= 2) {
926 $pdf->SetFont(
'',
'', $default_font_size - $diffsizecontent);
928 if (empty($onlynumber) && !empty($account->domiciliation)) {
929 $pdf->SetXY($curx, $cury);
930 $val = $outputlangs->transnoentities(
"Residence").
': '.$outputlangs->convToOutputCharset($account->domiciliation);
931 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
934 $tmpy = $pdf->getStringHeight(100, $val);
938 if (!empty($account->proprio)) {
939 $pdf->SetXY($curx, $cury);
940 $val = $outputlangs->transnoentities(
"BankAccountOwner").
': '.$outputlangs->convToOutputCharset($account->proprio);
941 $pdf->MultiCell(100, 3, $val, 0,
'L', 0);
942 $tmpy = $pdf->getStringHeight(100, $val);
944 } elseif (!$usedetailedbban) {
951 if (!empty($account->iban)) {
953 $ibanDisplay_temp = str_replace(
' ',
'', $outputlangs->convToOutputCharset($account->iban));
956 $nbIbanDisplay_temp =
dol_strlen($ibanDisplay_temp);
957 for ($i = 0; $i < $nbIbanDisplay_temp; $i++) {
958 $ibanDisplay .= $ibanDisplay_temp[$i];
959 if ($i % 4 == 3 && $i > 0) {
964 $pdf->SetFont(
'',
'B', $default_font_size - 3);
965 $pdf->SetXY($curx, $cury);
966 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).
': '.$ibanDisplay, 0,
'L', 0);
970 if (!empty($account->bic)) {
971 $pdf->SetFont(
'',
'B', $default_font_size - 3);
972 $pdf->SetXY($curx, $cury);
973 $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).
': '.$outputlangs->convToOutputCharset($account->bic), 0,
'L', 0);
996 function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark =
'')
998 global $conf, $user, $mysoc, $hookmanager;
1000 $outputlangs->load(
"dict");
1004 $dims = $pdf->getPageDimensions();
1007 if (empty($hidefreetext) && !empty($conf->global->$paramfreetext)) {
1010 $substitutionarray[
'__FROM_NAME__'] = $fromcompany->name;
1011 $substitutionarray[
'__FROM_EMAIL__'] = $fromcompany->email;
1013 $newfreetext =
make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs);
1019 $newfreetext = preg_replace(
'/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/',
'\1file:/'.DOL_DATA_ROOT.
'/medias/\2\3', $newfreetext);
1021 $line .= $outputlangs->convToOutputCharset($newfreetext);
1030 if ($showdetails == 1 || $showdetails == 3) {
1032 if ($fromcompany->name) {
1033 $line1 .= ($line1 ?
" - " :
"").$outputlangs->transnoentities(
"RegisteredOffice").
": ".$fromcompany->name;
1036 if ($fromcompany->address) {
1037 $line1 .= ($line1 ?
" - " :
"").str_replace(
"\n",
", ", $fromcompany->address);
1040 if ($fromcompany->zip) {
1041 $line1 .= ($line1 ?
" - " :
"").$fromcompany->zip;
1044 if ($fromcompany->town) {
1045 $line1 .= ($line1 ?
" " :
"").$fromcompany->town;
1048 if ($fromcompany->country) {
1049 $line1 .= ($line1 ?
", " :
"").$fromcompany->country;
1052 if ($fromcompany->phone) {
1053 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Phone").
": ".$fromcompany->phone;
1056 if ($fromcompany->fax) {
1057 $line2 .= ($line2 ?
" - " :
"").$outputlangs->transnoentities(
"Fax").
": ".$fromcompany->fax;
1061 if ($fromcompany->url) {
1062 $line2 .= ($line2 ?
" - " :
"").$fromcompany->url;
1065 if ($fromcompany->email) {
1066 $line2 .= ($line2 ?
" - " :
"").$fromcompany->email;
1069 if ($showdetails == 2 || $showdetails == 3 || (!empty($fromcompany->country_code) && $fromcompany->country_code ==
'DE')) {
1071 if ($fromcompany->managers) {
1072 $line2 .= ($line2 ?
" - " :
"").$fromcompany->managers;
1078 if (!empty($fromcompany->forme_juridique_code) && $fromcompany->forme_juridique_code) {
1079 $line3 .= ($line3 ?
" - " :
"").$outputlangs->convToOutputCharset(
getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
1082 if (!empty($fromcompany->capital)) {
1083 $tmpamounttoshow =
price2num($fromcompany->capital);
1084 if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
1085 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf",
price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
1086 } elseif (!empty($fromcompany->capital)) {
1087 $line3 .= ($line3 ?
" - " :
"").$outputlangs->transnoentities(
"CapitalOf", $fromcompany->capital, $outputlangs);
1091 if (!empty($fromcompany->idprof1) && $fromcompany->idprof1 && ($fromcompany->country_code !=
'FR' || !$fromcompany->idprof2)) {
1092 $field = $outputlangs->transcountrynoentities(
"ProfId1", $fromcompany->country_code);
1093 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1096 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
1099 if (!empty($fromcompany->idprof2) && $fromcompany->idprof2) {
1100 $field = $outputlangs->transcountrynoentities(
"ProfId2", $fromcompany->country_code);
1101 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1104 $line3 .= ($line3 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
1109 if (!empty($fromcompany->idprof3) && $fromcompany->idprof3) {
1110 $field = $outputlangs->transcountrynoentities(
"ProfId3", $fromcompany->country_code);
1111 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1114 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
1117 if (!empty($fromcompany->idprof4) && $fromcompany->idprof4) {
1118 $field = $outputlangs->transcountrynoentities(
"ProfId4", $fromcompany->country_code);
1119 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1122 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
1125 if (!empty($fromcompany->idprof5) && $fromcompany->idprof5) {
1126 $field = $outputlangs->transcountrynoentities(
"ProfId5", $fromcompany->country_code);
1127 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1130 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof5);
1133 if (!empty($fromcompany->idprof6) && $fromcompany->idprof6) {
1134 $field = $outputlangs->transcountrynoentities(
"ProfId6", $fromcompany->country_code);
1135 if (preg_match(
'/\((.*)\)/i', $field, $reg)) {
1138 $line4 .= ($line4 ?
" - " :
"").$field.
": ".$outputlangs->convToOutputCharset($fromcompany->idprof6);
1141 if (!empty($fromcompany->tva_intra) && $fromcompany->tva_intra !=
'') {
1142 $line4 .= ($line4 ?
" - " :
"").$outputlangs->transnoentities(
"VATIntraShort").
": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
1145 $pdf->SetFont(
'',
'', 7);
1146 $pdf->SetDrawColor(224, 224, 224);
1148 if (!empty($conf->global->PDF_FOOTER_TEXT_COLOR)) {
1149 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_TEXT_COLOR,
'%d, %d, %d');
1150 $pdf->SetTextColor($r, $g, $b);
1154 $freetextheight = 0;
1157 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
1160 if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
1164 $freetextheight = $pdf->getStringHeight($width, $line);
1172 if (is_object($hookmanager)) {
1173 $parameters = array(
'line1' => $line1,
'line2' => $line2,
'line3' => $line3,
'line4' => $line4,
'outputlangs'=>$outputlangs);
1175 $hookmanager->executeHooks(
'pdf_pagefoot', $parameters, $object, $action);
1176 if (!empty($hookmanager->resPrint) && $hidefreetext == 0) {
1177 $mycustomfooter = $hookmanager->resPrint;
1180 $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight;
1181 $posy = $marginwithfooter + 0;
1185 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR,
'%d, %d, %d');
1186 $pdf->SetAutoPageBreak(0, 0);
1187 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F',
'', $fill_color = array($r, $g, $b));
1188 $pdf->SetAutoPageBreak(1, 0);
1191 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); }
1193 $pdf->SetXY($dims[
'lm'], -$posy);
1195 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1197 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1199 $posy -= $freetextheight;
1201 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); }
1207 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1217 if (
getDolGlobalInt(
'PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); }
1218 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims[
'lm'], $dims[
'hk'] - $posy,
dol_htmlentitiesbr($mycustomfooter, 1,
'UTF-8', 0));
1219 if (
getDolGlobalInt(
'PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); }
1221 $posy -= $mycustomfooterheight - 3;
1224 $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0);
1225 $posy = $marginwithfooter + 0;
1229 list($r, $g, $b) = sscanf($conf->global->PDF_FOOTER_BACKGROUND_COLOR,
'%d, %d, %d');
1230 $pdf->SetAutoPageBreak(0, 0);
1231 $pdf->Rect(0, $dims[
'hk'] - $posy + $freetextheight, $dims[
'wk'] + 1, $marginwithfooter + 1,
'F',
'', $fill_color = array($r, $g, $b));
1232 $pdf->SetAutoPageBreak(1, 0);
1235 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); }
1237 $pdf->SetXY($dims[
'lm'], -$posy);
1239 $pdf->MultiCell(0, 3, $line, 0, $align, 0);
1241 $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims[
'lm'], $dims[
'hk'] - $marginwithfooter,
dol_htmlentitiesbr($line, 1,
'UTF-8', 0));
1243 $posy -= $freetextheight;
1245 if (
getDolGlobalInt(
'PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); }
1251 $pdf->line($dims[
'lm'], $dims[
'hk'] - $posy, $dims[
'wk'] - $dims[
'rm'], $dims[
'hk'] - $posy);
1261 if (!empty($line1)) {
1262 $pdf->SetFont(
'',
'B', 7);
1263 $pdf->SetXY($dims[
'lm'], -$posy);
1264 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line1, 0,
'C', 0);
1266 $pdf->SetFont(
'',
'', 7);
1269 if (!empty($line2)) {
1270 $pdf->SetFont(
'',
'B', 7);
1271 $pdf->SetXY($dims[
'lm'], -$posy);
1272 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line2, 0,
'C', 0);
1274 $pdf->SetFont(
'',
'', 7);
1277 if (!empty($line3)) {
1278 $pdf->SetXY($dims[
'lm'], -$posy);
1279 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line3, 0,
'C', 0);
1282 if (!empty($line4)) {
1284 $pdf->SetXY($dims[
'lm'], -$posy);
1285 $pdf->MultiCell($dims[
'wk'] - $dims[
'rm'] - $dims[
'lm'], 2, $line4, 0,
'C', 0);
1291 $pdf->SetXY($dims[
'wk'] - $dims[
'rm'] - 18, -$posy);
1293 $pdf->MultiCell(18, 2, $pdf->PageNo().
' / '.$pdf->getAliasNbPages(), 0,
'R', 0);
1297 if (!empty($watermark)) {
1298 pdf_watermark($pdf, $outputlangs, $page_hauteur, $page_largeur,
'mm', $watermark);
1301 return $marginwithfooter;
1321 if (!empty($linkedobjects)) {
1322 foreach ($linkedobjects as $linkedobject) {
1323 $reftoshow = $linkedobject[
"ref_title"].
' : '.$linkedobject[
"ref_value"];
1324 if (!empty($linkedobject[
"date_value"])) {
1325 $reftoshow .=
' / '.$linkedobject[
"date_value"];
1329 $pdf->SetXY($posx, $posy);
1330 $pdf->SetFont(
'',
'', $default_font_size - 2);
1331 $pdf->MultiCell($w, $h, $reftoshow,
'', $align);
1335 return $pdf->getY();
1354 function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1356 global $db, $conf, $langs, $hookmanager;
1361 if (is_object($hookmanager)) {
1362 $special_code = empty($object->lines[$i]->special_code) ?
'' : $object->lines[$i]->special_code;
1363 if (!empty($object->lines[$i]->fk_parent_line)) {
1364 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1366 $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);
1368 $reshook = $hookmanager->executeHooks(
'pdf_writelinedesc', $parameters, $object, $action);
1370 if (!empty($hookmanager->resPrint)) {
1371 $result .= $hookmanager->resPrint;
1374 if (empty($reshook)) {
1375 $labelproductservice =
pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
1382 $labelproductservice = preg_replace(
'/(<img[^>]*src=")([^"]*)(&)([^"]*")/',
'\1\2&\4', $labelproductservice, -1, $nbrep);
1387 $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1,
false,
true,
'J',
true);
1388 $result .= $labelproductservice;
1404 function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
1406 global $db, $conf, $langs;
1408 $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product :
false);
1409 $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label :
''));
1410 $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description :
''));
1411 $ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn :
''));
1412 $note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note :
'');
1413 $dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch :
false);
1415 if ($issupplierline) {
1416 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
1419 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1422 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1423 include_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1428 $prodser->fetch($idprod);
1430 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) {
1431 $translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED));
1439 $textwasnotmodified = ($label == $prodser->label);
1440 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"label"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1441 $label = $prodser->multilangs[$outputlangs->defaultlang][
"label"];
1446 $textwasnotmodified =
false;
1450 $textwasnotmodified = ($desc == $prodser->description);
1452 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"description"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1453 $desc = $prodser->multilangs[$outputlangs->defaultlang][
"description"];
1457 $textwasnotmodified = ($note == $prodser->note_public);
1458 if (!empty($prodser->multilangs[$outputlangs->defaultlang][
"other"]) && ($textwasnotmodified || $translatealsoifmodified)) {
1459 $note = $prodser->multilangs[$outputlangs->defaultlang][
"other"];
1462 } elseif (($object->element ==
'facture' || $object->element ==
'facturefourn') && preg_match(
'/^\(DEPOSIT\).+/', $desc)) {
1463 $desc = str_replace(
'(DEPOSIT)', $outputlangs->trans(
'Deposit'), $desc);
1466 if (empty($conf->global->PDF_HIDE_PRODUCT_LABEL_IN_SUPPLIER_LINES)) {
1468 $libelleproduitservice = $label;
1469 if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) {
1473 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1475 $libelleproduitservice =
'<b>'.$libelleproduitservice.
'</b>';
1481 if (!empty($conf->global->SHOW_SUBPRODUCT_REF_IN_PDF)) {
1482 $prodser->get_sousproduits_arbo();
1483 if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) {
1484 $tmparrayofsubproducts = reset($prodser->sousprods);
1485 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF)) {
1486 foreach ($tmparrayofsubproducts as $subprodval) {
1487 $libelleproduitservice =
dol_concatdesc($libelleproduitservice,
" * ".$subprodval[3].
' ('.$subprodval[1].
')');
1490 foreach ($tmparrayofsubproducts as $subprodval) {
1491 $libelleproduitservice =
dol_concatdesc($libelleproduitservice,
" * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ?
' - ' :
'').$subprodval[3].
' ('.$subprodval[1].
')');
1498 if (!empty($desc) && ($desc != $label)) {
1499 if ($desc ==
'(CREDIT_NOTE)' && $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(
"DiscountFromCreditNote", $sourceref);
1504 } elseif ($desc ==
'(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
1506 $discount->fetch($object->lines[$i]->fk_remise_except);
1507 $sourceref = !empty($discount->discount_type) ? $discount->ref_invoice_supplier_source : $discount->ref_facture_source;
1508 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromDeposit", $sourceref);
1510 if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
1511 $libelleproduitservice .=
' ('.dol_print_date($discount->datec,
'day',
'', $outputlangs).
')';
1513 } elseif ($desc ==
'(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) {
1515 $discount->fetch($object->lines[$i]->fk_remise_except);
1516 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessReceived", $discount->ref_facture_source);
1517 } elseif ($desc ==
'(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) {
1519 $discount->fetch($object->lines[$i]->fk_remise_except);
1520 $libelleproduitservice = $outputlangs->transnoentitiesnoconv(
"DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
1524 if (!empty($object->element)) {
1525 $tmpkey =
'MAIN_DOCUMENTS_HIDE_DESCRIPTION_FOR_'.strtoupper($object->element);
1526 if (!empty($conf->global->$tmpkey)) {
1530 if (empty($hidedesc)) {
1531 if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) {
1532 $libelleproduitservice =
dol_concatdesc($desc, $libelleproduitservice);
1534 if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) {
1535 $libelleproduitservice = $desc;
1537 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desc);
1542 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desc);
1548 $prefix_prodserv =
"";
1550 if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
1551 if ($prodser->isService()) {
1552 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Service").
" ";
1554 $prefix_prodserv = $outputlangs->transnoentitiesnoconv(
"Product").
" ";
1558 if (empty($hideref)) {
1559 if ($issupplierline) {
1560 if (empty($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES)) {
1561 $ref_prodserv = $prodser->ref;
1562 if ($ref_supplier) {
1563 $ref_prodserv .= ($prodser->ref ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
"SupplierRef").
' '.$ref_supplier.($prodser->ref ?
')' :
'');
1565 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) {
1566 $ref_prodserv = $ref_supplier;
1567 } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) {
1568 $ref_prodserv = $ref_supplier.
' ('.$outputlangs->transnoentitiesnoconv(
"InternalRef").
' '.$prodser->ref.
')';
1571 $ref_prodserv = $prodser->ref;
1573 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1575 $filter = array(
'fk_product' => $idprod,
'fk_soc' => $object->socid);
1577 $nbCustomerPrices = $productCustomerPriceStatic->fetchAll(
'',
'', 1, 0, $filter);
1579 if ($nbCustomerPrices > 0) {
1580 $productCustomerPrice = $productCustomerPriceStatic->lines[0];
1582 if (!empty($productCustomerPrice->ref_customer)) {
1583 switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) {
1585 $ref_prodserv = $productCustomerPrice->ref_customer;
1589 $ref_prodserv = $productCustomerPrice->ref_customer .
' (' . $outputlangs->transnoentitiesnoconv(
'InternalRef') .
' ' . $ref_prodserv .
')';
1593 $ref_prodserv = $ref_prodserv .
' (' . $outputlangs->transnoentitiesnoconv(
'RefCustomer') .
' ' . $productCustomerPrice->ref_customer .
')';
1600 if (!empty($libelleproduitservice) && !empty($ref_prodserv)) {
1601 $ref_prodserv .=
" - ";
1605 if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1607 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1609 $ref_prodserv =
'<b>'.$ref_prodserv.
'</b>';
1612 $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
1615 if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod &&
isModEnabled(
'categorie')) {
1616 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1619 $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
1620 foreach ($tblcateg as $cate) {
1622 $desccateg = $cate->description;
1624 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $desccateg);
1629 if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) {
1633 if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
1634 $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)).
')';
1636 if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) {
1637 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($object->lines[$i]->date_start, $format,
false, $outputlangs)).
')';
1639 if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) {
1640 $period =
'('.$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($object->lines[$i]->date_end, $format,
false, $outputlangs)).
')';
1643 if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
1645 $libelleproduitservice = str_replace(
"\n",
'<br>', $libelleproduitservice);
1647 $libelleproduitservice .=
'<br><b style="color:#333666;" ><em>'.$period.
'</em></b>';
1649 $libelleproduitservice =
dol_concatdesc($libelleproduitservice, $period);
1660 include_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1661 include_once DOL_DOCUMENT_ROOT.
'/product/class/productbatch.class.php';
1666 foreach ($dbatch as $detail) {
1668 if ($detail->eatby) {
1669 $dte[] = $outputlangs->transnoentitiesnoconv(
'printEatby',
dol_print_date($detail->eatby, $format,
false, $outputlangs));
1671 if ($detail->sellby) {
1672 $dte[] = $outputlangs->transnoentitiesnoconv(
'printSellby',
dol_print_date($detail->sellby, $format,
false, $outputlangs));
1674 if ($detail->batch) {
1675 $dte[] = $outputlangs->transnoentitiesnoconv(
'printBatch', $detail->batch);
1677 $dte[] = $outputlangs->transnoentitiesnoconv(
'printQty', $detail->qty);
1680 if ($object->element ==
'shipping' && $detail->fk_origin_stock > 0 &&
getDolGlobalInt(
'PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT')) {
1681 $resproductbatch = $tmpproductbatch->fetch($detail->fk_origin_stock);
1682 if ($resproductbatch > 0) {
1683 $reswarehouse = $tmpwarehouse->fetch($tmpproductbatch->warehouseid);
1684 if ($reswarehouse > 0) {
1685 $dte[] = $tmpwarehouse->ref;
1690 $libelleproduitservice .=
"__N__ ".implode(
" - ", $dte);
1700 $libelleproduitservice = preg_replace(
'/__N__/',
'<br>', $libelleproduitservice);
1702 $libelleproduitservice = preg_replace(
'/__N__/',
"\n", $libelleproduitservice);
1706 return $libelleproduitservice;
1720 global $hookmanager;
1725 if (is_object($hookmanager)) {
1726 $special_code = $object->lines[$i]->special_code;
1727 if (!empty($object->lines[$i]->fk_parent_line)) {
1728 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1730 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1732 $reshook = $hookmanager->executeHooks(
'pdf_getlinenum', $parameters, $object, $action);
1733 $result .= $hookmanager->resPrint;
1735 if (empty($reshook)) {
1753 global $hookmanager;
1758 if (is_object($hookmanager)) {
1759 $special_code = $object->lines[$i]->special_code;
1760 if (!empty($object->lines[$i]->fk_parent_line)) {
1761 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1763 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1765 $reshook = $hookmanager->executeHooks(
'pdf_getlineref', $parameters, $object, $action);
1766 $result .= $hookmanager->resPrint;
1768 if (empty($reshook)) {
1785 global $hookmanager;
1790 if (is_object($hookmanager)) {
1791 $special_code = $object->lines[$i]->special_code;
1792 if (!empty($object->lines[$i]->fk_parent_line)) {
1793 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1795 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1797 $reshook = $hookmanager->executeHooks(
'pdf_getlineref_supplier', $parameters, $object, $action);
1798 $result .= $hookmanager->resPrint;
1800 if (empty($reshook)) {
1817 global $conf, $hookmanager, $mysoc;
1822 if (is_object($hookmanager)) {
1823 $special_code = $object->lines[$i]->special_code;
1824 if (!empty($object->lines[$i]->fk_parent_line)) {
1825 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1827 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1829 $reshook = $hookmanager->executeHooks(
'pdf_getlinevatrate', $parameters, $object, $action);
1831 if (!empty($hookmanager->resPrint)) {
1832 $result .= $hookmanager->resPrint;
1835 if (empty($reshook)) {
1836 if (empty($hidedetails) || $hidedetails > 1) {
1839 $tmpresult .=
vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1);
1840 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) {
1841 if ($object->lines[$i]->total_localtax1 != 0) {
1842 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
1847 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax1_tx), 0);
1850 if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) {
1851 if ($object->lines[$i]->total_localtax2 != 0) {
1852 if (preg_replace(
'/[\s0%]/',
'', $tmpresult)) {
1857 $tmpresult .=
vatrate(abs($object->lines[$i]->localtax2_tx), 0);
1862 $result .= $tmpresult;
1879 global $conf, $hookmanager;
1882 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1889 if (is_object($hookmanager)) {
1890 $special_code = $object->lines[$i]->special_code;
1891 if (!empty($object->lines[$i]->fk_parent_line)) {
1892 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1894 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1896 $reshook = $hookmanager->executeHooks(
'pdf_getlineupexcltax', $parameters, $object, $action);
1898 if (!empty($hookmanager->resPrint)) {
1899 $result .= $hookmanager->resPrint;
1902 if (empty($reshook)) {
1903 if (empty($hidedetails) || $hidedetails > 1) {
1904 $subprice = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice);
1905 $result .=
price($sign * $subprice, 0, $outputlangs);
1922 global $hookmanager, $conf;
1925 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1932 if (is_object($hookmanager)) {
1933 $special_code = $object->lines[$i]->special_code;
1934 if (!empty($object->lines[$i]->fk_parent_line)) {
1935 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1937 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1939 $reshook = $hookmanager->executeHooks(
'pdf_getlineupwithtax', $parameters, $object, $action);
1941 if (!empty($hookmanager->resPrint)) {
1942 $result .= $hookmanager->resPrint;
1945 if (empty($reshook)) {
1946 if (empty($hidedetails) || $hidedetails > 1) {
1947 $result .=
price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice) * ($object->lines[$i]->tva_tx) / 100), 0, $outputlangs);
1964 global $hookmanager;
1969 if (is_object($hookmanager)) {
1970 $special_code = $object->lines[$i]->special_code;
1971 if (!empty($object->lines[$i]->fk_parent_line)) {
1972 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
1974 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
1976 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty', $parameters, $object, $action);
1978 if (!empty($hookmanager->resPrint)) {
1979 $result = $hookmanager->resPrint;
1982 if (empty($reshook)) {
1983 if ($object->lines[$i]->special_code == 3) {
1986 if (empty($hidedetails) || $hidedetails > 1) {
1987 $result .= $object->lines[$i]->qty;
2004 global $hookmanager;
2009 if (is_object($hookmanager)) {
2010 $special_code = $object->lines[$i]->special_code;
2011 if (!empty($object->lines[$i]->fk_parent_line)) {
2012 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2014 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2016 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_asked', $parameters, $object, $action);
2018 if (!empty($hookmanager->resPrint)) {
2019 $result .= $hookmanager->resPrint;
2022 if (empty($reshook)) {
2023 if ($object->lines[$i]->special_code == 3) {
2026 if (empty($hidedetails) || $hidedetails > 1) {
2027 $result .= $object->lines[$i]->qty_asked;
2044 global $hookmanager;
2049 if (is_object($hookmanager)) {
2050 $special_code = $object->lines[$i]->special_code;
2051 if (!empty($object->lines[$i]->fk_parent_line)) {
2052 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2054 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2056 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_shipped', $parameters, $object, $action);
2058 if (!empty($hookmanager->resPrint)) {
2059 $result .= $hookmanager->resPrint;
2062 if (empty($reshook)) {
2063 if ($object->lines[$i]->special_code == 3) {
2066 if (empty($hidedetails) || $hidedetails > 1) {
2067 $result .= $object->lines[$i]->qty_shipped;
2084 global $hookmanager;
2089 if (is_object($hookmanager)) {
2090 $special_code = $object->lines[$i]->special_code;
2091 if (!empty($object->lines[$i]->fk_parent_line)) {
2092 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2094 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2096 $reshook = $hookmanager->executeHooks(
'pdf_getlineqty_keeptoship', $parameters, $object, $action);
2098 if (!empty($hookmanager->resPrint)) {
2099 $result .= $hookmanager->resPrint;
2102 if (empty($reshook)) {
2103 if ($object->lines[$i]->special_code == 3) {
2106 if (empty($hidedetails) || $hidedetails > 1) {
2107 $result .= ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
2123 function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager =
false)
2130 if (is_object($hookmanager)) {
2131 $special_code = $object->lines[$i]->special_code;
2132 if (!empty($object->lines[$i]->fk_parent_line)) {
2133 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2135 $parameters = array(
2137 'outputlangs' => $outputlangs,
2138 'hidedetails' => $hidedetails,
2139 'special_code' => $special_code
2142 $reshook = $hookmanager->executeHooks(
'pdf_getlineunit', $parameters, $object, $action);
2144 if (!empty($hookmanager->resPrint)) {
2145 $result .= $hookmanager->resPrint;
2148 if (empty($reshook)) {
2149 if (empty($hidedetails) || $hidedetails > 1) {
2150 $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit(
'short'));
2168 global $hookmanager;
2170 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2175 if (is_object($hookmanager)) {
2176 $special_code = $object->lines[$i]->special_code;
2177 if (!empty($object->lines[$i]->fk_parent_line)) {
2178 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2180 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2182 $reshook = $hookmanager->executeHooks(
'pdf_getlineremisepercent', $parameters, $object, $action);
2184 if (!empty($hookmanager->resPrint)) {
2185 $result .= $hookmanager->resPrint;
2188 if (empty($reshook)) {
2189 if ($object->lines[$i]->special_code == 3) {
2192 if (empty($hidedetails) || $hidedetails > 1) {
2211 if (empty($hookmanager)) {
2212 global $hookmanager;
2219 if (is_object($hookmanager)) {
2220 $special_code = $object->lines[$i]->special_code;
2221 if (!empty($object->lines[$i]->fk_parent_line)) {
2222 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2224 $parameters = array(
'i' => $i,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails,
'special_code' => $special_code);
2226 $reshook = $hookmanager->executeHooks(
'pdf_getlineprogress', $parameters, $object, $action);
2228 if (!empty($hookmanager->resPrint)) {
2229 return $hookmanager->resPrint;
2232 if (empty($reshook)) {
2233 if ($object->lines[$i]->special_code == 3) {
2236 if (empty($hidedetails) || $hidedetails > 1) {
2237 if (!empty($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)) {
2239 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2240 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2242 $result = round($object->lines[$i]->situation_percent - $prev_progress, 1).
'%';
2244 $result = round($object->lines[$i]->situation_percent, 1).
'%';
2262 global $conf, $hookmanager;
2265 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2272 if (is_object($hookmanager)) {
2273 $special_code = $object->lines[$i]->special_code;
2274 if (!empty($object->lines[$i]->fk_parent_line)) {
2275 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2277 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code,
'sign'=>$sign);
2279 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalexcltax', $parameters, $object, $action);
2281 if (!empty($hookmanager->resPrint)) {
2282 $result .= $hookmanager->resPrint;
2285 if (empty($reshook)) {
2286 if ($object->lines[$i]->special_code == 3) {
2287 $result .= $outputlangs->transnoentities(
"Option");
2288 } elseif (empty($hidedetails) || $hidedetails > 1) {
2289 $total_ht = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht);
2290 if (!empty($object->lines[$i]->situation_percent) && $object->lines[$i]->situation_percent > 0) {
2294 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2295 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2296 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2298 $result .=
price($sign * ($total_ht / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2300 $result .=
price($sign * $total_ht, 0, $outputlangs);
2318 global $hookmanager, $conf;
2321 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2328 if (is_object($hookmanager)) {
2329 $special_code = $object->lines[$i]->special_code;
2330 if (!empty($object->lines[$i]->fk_parent_line)) {
2331 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2333 $parameters = array(
'i'=>$i,
'outputlangs'=>$outputlangs,
'hidedetails'=>$hidedetails,
'special_code'=>$special_code);
2335 $reshook = $hookmanager->executeHooks(
'pdf_getlinetotalwithtax', $parameters, $object, $action);
2337 if (!empty($hookmanager->resPrint)) {
2338 $result .= $hookmanager->resPrint;
2341 if (empty($reshook)) {
2342 if ($object->lines[$i]->special_code == 3) {
2343 $result .= $outputlangs->transnoentities(
"Option");
2344 } elseif (empty($hidedetails) || $hidedetails > 1) {
2345 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc);
2346 if ($object->lines[$i]->situation_percent > 0) {
2350 if (method_exists($object->lines[$i],
'get_prev_progress')) {
2351 $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
2352 $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100;
2354 $result .=
price($sign * ($total_ttc / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs);
2356 $result .=
price($sign * $total_ttc, 0, $outputlangs);
2373 global $db, $hookmanager;
2375 $linkedobjects = array();
2377 $object->fetchObjectLinked();
2379 foreach ($object->linkedObjects as $objecttype => $objects) {
2380 if ($objecttype ==
'facture') {
2382 } elseif ($objecttype ==
'propal' || $objecttype ==
'supplier_proposal') {
2383 $outputlangs->load(
'propal');
2385 foreach ($objects as $elementobject) {
2386 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefProposal");
2387 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2388 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DatePropal");
2389 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2391 } elseif ($objecttype ==
'commande' || $objecttype ==
'supplier_order') {
2392 $outputlangs->load(
'orders');
2395 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefOrder").
' :');
2396 foreach ($objects as $elementobject) {
2397 $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.
')').
' ');
2398 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"OrderDate").
' : '.
dol_print_date($elementobject->date,
'day',
'', $outputlangs));
2400 } elseif (count($objects) == 1) {
2401 $elementobject = array_shift($objects);
2402 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder");
2403 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref).(!empty($elementobject->ref_client) ?
' ('.$elementobject->ref_client.
')' :
'').(!empty($elementobject->ref_supplier) ?
' ('.$elementobject->ref_supplier.
')' :
'');
2404 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"OrderDate");
2405 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date,
'day',
'', $outputlangs);
2407 } elseif ($objecttype ==
'contrat') {
2408 $outputlangs->load(
'contracts');
2409 foreach ($objects as $elementobject) {
2410 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefContract");
2411 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2412 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"DateContract");
2413 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->date_contrat,
'day',
'', $outputlangs);
2415 } elseif ($objecttype ==
'fichinter') {
2416 $outputlangs->load(
'interventions');
2417 foreach ($objects as $elementobject) {
2418 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"InterRef");
2419 $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->transnoentities($elementobject->ref);
2420 $linkedobjects[$objecttype][
'date_title'] = $outputlangs->transnoentities(
"InterDate");
2421 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date($elementobject->datec,
'day',
'', $outputlangs);
2423 } elseif ($objecttype ==
'shipping') {
2424 $outputlangs->loadLangs(array(
"orders",
"sendings"));
2426 if (count($objects) > 1) {
2428 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2429 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending").
' :');
2431 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities(
"RefSending").
' :');
2434 foreach ($objects as $elementobject) {
2435 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2436 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
2437 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
2438 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2440 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2447 if (! is_object($order)) {
2448 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref));
2450 $object->note_public =
dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
''));
2451 $object->note_public =
dol_concatdesc($object->note_public,
' / '.$outputlangs->transnoentities($elementobject->ref));
2454 } elseif (count($objects) == 1) {
2455 $elementobject = array_shift($objects);
2458 if (empty($object->linkedObjects[
'commande']) && $object->element !=
'commande') {
2459 $elementobject->fetchObjectLinked(
null,
'',
null,
'',
'OR', 1,
'sourcetype', 0);
2460 if (!empty($elementobject->linkedObjectsIds[
'commande'])) {
2461 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
2463 $ret = $order->fetch(reset($elementobject->linkedObjectsIds[
'commande']));
2470 if (! is_object($order)) {
2471 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefSending");
2472 if (!empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] .=
' / ';
2473 $linkedobjects[$objecttype][
'ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
2474 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
2476 $linkedobjects[$objecttype][
'ref_title'] = $outputlangs->transnoentities(
"RefOrder").
' / '.$outputlangs->transnoentities(
"RefSending");
2477 if (empty($linkedobjects[$objecttype][
'ref_value'])) $linkedobjects[$objecttype][
'ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ?
' ('.$order->ref_client.
')' :
'');
2478 $linkedobjects[$objecttype][
'ref_value'] .=
' / '.$outputlangs->transnoentities($elementobject->ref);
2479 $linkedobjects[$objecttype][
'date_value'] =
dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping,
'day',
'', $outputlangs);
2486 if (is_object($hookmanager)) {
2487 $parameters = array(
'linkedobjects' => $linkedobjects,
'outputlangs'=>$outputlangs);
2489 $hookmanager->executeHooks(
'pdf_getLinkedObjects', $parameters, $object, $action);
2490 if (!empty($hookmanager->resArray)) {
2491 $linkedobjects = $hookmanager->resArray;
2495 return $linkedobjects;
2509 $maxwidth = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
2510 $maxheight = (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
2511 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2515 if ($tmp[
'height']) {
2516 $width = (int) round($maxheight * $tmp[
'width'] / $tmp[
'height']);
2517 if ($width > $maxwidth) {
2519 $height = (int) round($maxwidth * $tmp[
'height'] / $tmp[
'width']);
2522 $height = $maxheight;
2525 return array(
'width'=>$width,
'height'=>$height);
2539 global $conf, $hookmanager;
2541 if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
2544 if ($object->lines[$i]->special_code == 3) {
2545 return $outputlangs->transnoentities(
"Option");
2547 if (is_object($hookmanager)) {
2548 $special_code = $object->lines[$i]->special_code;
2549 if (!empty($object->lines[$i]->fk_parent_line)) {
2550 $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
2553 $parameters = array(
2555 'outputlangs'=>$outputlangs,
2556 'hidedetails'=>$hidedetails,
2557 'special_code'=>$special_code
2562 if ($hookmanager->executeHooks(
'getlinetotalremise', $parameters, $object, $action) > 0) {
2563 return $hookmanager->resPrint;
2567 if (empty($hidedetails) || $hidedetails > 1) {
2568 return $sign * (($object->lines[$i]->subprice * $object->lines[$i]->qty) - $object->lines[$i]->total_ht);