143 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
146 global $user, $conf, $langs, $hookmanager;
150 if (!is_object($outputlangs)) {
151 $outputlangs = $langs;
155 $outputlangs->charset_output =
'ISO-8859-1';
159 $outputlangs->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"other",
"propal",
"deliveries",
"sendings",
"productbatch",
"compta"));
166 global $outputlangsbis;
167 $outputlangsbis =
null;
169 $outputlangsbis =
new Translate(
'', $conf);
171 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"other",
"propal",
"deliveries",
"sendings",
"productbatch",
"compta"));
174 $nblines = count(
$object->lines);
177 $realpatharray = array();
178 $this->atleastonephoto =
false;
180 $objphoto =
new Product($this->db);
182 for ($i = 0; $i < $nblines; $i++) {
183 if (empty(
$object->lines[$i]->fk_product)) {
187 $objphoto->fetch(
$object->lines[$i]->fk_product);
190 $pdir =
get_exdir(
$object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
191 $dir = $conf->product->dir_output.
'/'.$pdir;
193 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
194 $dir = $conf->product->dir_output.
'/'.$pdir;
200 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
202 if ($obj[
'photo_vignette']) {
203 $filename = $obj[
'photo_vignette'];
205 $filename = $obj[
'photo'];
208 $filename = $obj[
'photo'];
211 $realpath = $dir.$filename;
213 $this->atleastonephoto =
true;
217 if ($realpath && $arephoto) {
218 $realpatharray[$i] = $realpath;
223 if (count($realpatharray) == 0) {
224 $this->posxpicture = $this->posxweightvol;
227 if ($conf->expedition->dir_output) {
230 $dir = $conf->expedition->dir_output.
"/sending";
231 $file = $dir.
"/SPECIMEN.pdf";
234 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
235 $file = $dir.
"/".$expref.
".pdf";
238 if (!file_exists($dir)) {
240 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
245 if (file_exists($dir)) {
247 if (!is_object($hookmanager)) {
248 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
251 $hookmanager->initHooks(array(
'pdfgeneration'));
252 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
254 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
261 $heightforinfotot = 8;
263 $heightforfooter = $this->marge_basse + 8;
265 $heightforfooter += 6;
267 $pdf->SetAutoPageBreak(1, 0);
269 if (class_exists(
'TCPDF')) {
270 $pdf->setPrintHeader(
false);
271 $pdf->setPrintFooter(
false);
276 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
277 $tplidx = $pdf->importPage(1);
282 $pdf->SetDrawColor(128, 128, 128);
284 if (method_exists($pdf,
'AliasNbPages')) {
285 $pdf->AliasNbPages();
288 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
289 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
290 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
291 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
292 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
294 $pdf->SetCompression(
false);
298 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
302 if (!empty($tplidx)) {
303 $pdf->useTemplate($tplidx);
307 $pdf->SetFont(
'',
'', $default_font_size - 1);
308 $pdf->MultiCell(0, 3,
'');
309 $pdf->SetTextColor(0, 0, 0);
312 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
314 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
316 $this->posxdesc = $this->marge_gauche + 1;
319 $height_incoterms = 0;
320 if (isModEnabled(
'incoterm')) {
321 $desc_incoterms =
$object->getIncotermsForPDF();
322 if ($desc_incoterms) {
325 $pdf->SetFont(
'',
'', $default_font_size - 1);
326 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
327 $nexY = $pdf->GetY();
328 $height_incoterms = $nexY - $tab_top;
331 $pdf->SetDrawColor(192, 192, 192);
332 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
334 $tab_top = $nexY + 6;
335 $height_incoterms += 4;
340 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
343 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
344 if (!empty($extranote)) {
348 if (!empty($notetoshow) || !empty(
$object->tracking_number)) {
350 $tab_topbeforetrackingnumber = $tab_top;
353 if (!empty(
$object->tracking_number)) {
354 $height_trackingnumber = 4;
356 $pdf->SetFont(
'',
'B', $default_font_size - 2);
357 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber") .
" : " .
$object->tracking_number, 0, 1,
false,
true,
'L');
358 $tab_top_alt = $pdf->GetY();
361 if (!empty(
$object->tracking_url)) {
362 if (
$object->shipping_method_id > 0) {
364 $code = $outputlangs->getLabelFromKey($this->db,
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
367 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
369 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
373 $label .=
$object->tracking_url;
376 $height_trackingnumber += 4;
377 $pdf->SetFont(
'',
'B', $default_font_size - 2);
378 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
381 $tab_top = $pdf->GetY();
385 $pagenb = $pdf->getPage();
386 if (!empty($notetoshow) || !empty(
$object->tracking_number)) {
389 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
390 $pageposbeforenote = $pagenb;
397 $pdf->startTransaction();
399 $pdf->SetFont(
'',
'', $default_font_size - 1);
400 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
402 $pageposafternote = $pdf->getPage();
403 $posyafter = $pdf->GetY();
405 if ($pageposafternote > $pageposbeforenote) {
406 $pdf->rollbackTransaction(
true);
409 while ($pagenb < $pageposafternote) {
412 if (!empty($tplidx)) {
413 $pdf->useTemplate($tplidx);
419 $pdf->setTopMargin($tab_top_newpage);
421 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
425 $pdf->setPage($pageposbeforenote);
426 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
427 $pdf->SetFont(
'',
'', $default_font_size - 1);
428 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
429 $pageposafternote = $pdf->getPage();
431 $posyafter = $pdf->GetY();
433 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
434 $pdf->AddPage(
'',
'',
true);
437 $pdf->setPage($pageposafternote);
438 $pdf->setTopMargin($tab_top_newpage);
440 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
446 $i = $pageposbeforenote;
447 while ($i < $pageposafternote) {
451 $pdf->SetDrawColor(128, 128, 128);
453 if ($i > $pageposbeforenote) {
454 if (empty($height_trackingnumber)) {
455 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
457 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
458 $tab_top_newpage = $tab_topbeforetrackingnumber;
460 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
462 if (empty($height_trackingnumber)) {
463 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
465 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter) + $height_trackingnumber + 1;
466 $tab_top = $tab_topbeforetrackingnumber;
468 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
472 $pdf->setPageOrientation(
'', 1, 0);
479 $pdf->setPage($pageposafternote);
480 if (!empty($tplidx)) {
481 $pdf->useTemplate($tplidx);
486 $height_note = $posyafter - $tab_top_newpage;
487 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
489 $pdf->commitTransaction();
490 $posyafter = $pdf->GetY();
491 if (empty($height_trackingnumber)) {
492 $height_note = $posyafter - $tab_top + 1;
494 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
495 $tab_top = $tab_topbeforetrackingnumber;
497 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
500 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
502 $pdf->AddPage(
'',
'',
true);
505 $pdf->setPage($pageposafternote);
506 if (!empty($tplidx)) {
507 $pdf->useTemplate($tplidx);
513 $posyafter = $tab_top_newpage;
517 $tab_height -= $height_note;
518 $tab_top = $posyafter + 6;
528 require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/doc/tcpdfbarcode.modules.php';
530 $encoding =
'QRCODE';
534 if ($module->encodingIsSupported($encoding)) {
535 $result = $module->writeBarCode(
$object->ref, $encoding);
539 if (!preg_match(
'/^\w+$/', $newcode) ||
dol_strlen($newcode) > 32) {
540 $newcode =
dol_hash($newcode,
'md5');
542 $barcode_path = $conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
548 $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20);
550 $nexY = $pdf->GetY();
551 $height_barcode = 20;
555 $this->error =
'Failed to generate barcode';
563 $pdf->startTransaction();
564 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
565 $pdf->rollbackTransaction(
true);
568 $nexY = $tab_top + $this->tabTitleHeight;
571 $pageposbeforeprintlines = $pdf->getPage();
572 $pagenb = $pageposbeforeprintlines;
573 for ($i = 0; $i < $nblines; $i++) {
575 $pdf->SetFont(
'',
'', $default_font_size - 1);
576 $pdf->SetTextColor(0, 0, 0);
579 $imglinesize = array();
580 if (!empty($realpatharray[$i])) {
584 $pdf->setTopMargin($tab_top_newpage);
585 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
586 $pageposbefore = $pdf->getPage();
588 $showpricebeforepagebreak = 1;
590 $posYAfterDescription = 0;
591 $heightforsignature = 0;
595 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
596 $pdf->AddPage(
'',
'',
true);
597 if (!empty($tplidx)) {
598 $pdf->useTemplate($tplidx);
601 $pdf->setPage($pageposbefore + 1);
603 $curY = $tab_top_newpage;
607 $showpricebeforepagebreak = 1;
609 $showpricebeforepagebreak = 0;
614 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
615 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
617 $posYAfterImage = $curY + $imglinesize[
'height'];
623 $pdf->startTransaction();
627 $pageposafter = $pdf->getPage();
628 if ($pageposafter > $pageposbefore) {
629 $pdf->rollbackTransaction(
true);
633 $pageposafter = $pdf->getPage();
634 $posyafter = $pdf->GetY();
636 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
637 if ($i == ($nblines - 1)) {
638 $pdf->AddPage(
'',
'',
true);
639 if (!empty($tplidx)) {
640 $pdf->useTemplate($tplidx);
643 $pdf->setPage($pageposafter + 1);
649 $showpricebeforepagebreak = 1;
651 $showpricebeforepagebreak = 0;
655 $pdf->commitTransaction();
657 $posYAfterDescription = $pdf->GetY();
660 $nexY = max($pdf->GetY(), $posYAfterImage);
661 $pageposafter = $pdf->getPage();
663 $pdf->setPage($pageposbefore);
664 $pdf->setTopMargin($this->marge_haute);
665 $pdf->setPageOrientation(
'', 1, 0);
668 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
669 $pdf->setPage($pageposafter);
670 $curY = $tab_top_newpage;
674 if ($pageposafter > $pageposbefore) {
675 $pdf->setPage($pageposafter);
676 $curY = $tab_top_newpage;
679 $pdf->SetFont(
'',
'', $default_font_size - 1);
688 if (empty(
$object->lines[$i]->fk_product_type) &&
$object->lines[$i]->weight) {
692 if (empty(
$object->lines[$i]->fk_product_type) &&
$object->lines[$i]->volume) {
698 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt);
699 $nexY = max($pdf->GetY(), $nexY);
704 $nexY = max($pdf->GetY(), $nexY);
709 $nexY = max($pdf->GetY(), $nexY);
714 $nexY = max($pdf->GetY(), $nexY);
719 $nexY = max($pdf->GetY(), $nexY);
723 if (!empty(
$object->lines[$i]->array_options)) {
724 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
728 $nexY = max($pdf->GetY(), $nexY);
735 $pdf->setPage($pageposafter);
736 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
738 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
739 $pdf->SetLineStyle(array(
'dash' => 0));
743 while ($pagenb < $pageposafter) {
744 $pdf->setPage($pagenb);
745 if ($pagenb == $pageposbeforeprintlines) {
746 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
748 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
752 $pdf->setPage($pagenb);
753 $pdf->setPageOrientation(
'', 1, 0);
757 if (!empty($tplidx)) {
758 $pdf->useTemplate($tplidx);
761 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
763 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
765 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
770 if (!empty($tplidx)) {
771 $pdf->useTemplate($tplidx);
782 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
783 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
785 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
786 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
794 if (method_exists($pdf,
'AliasNbPages')) {
795 $pdf->AliasNbPages();
800 $pdf->Output($file,
'F');
803 $hookmanager->initHooks(array(
'pdfgeneration'));
804 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
806 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
808 $this->error = $hookmanager->error;
809 $this->errors = $hookmanager->errors;
814 $this->result = array(
'fullpath' => $file);
818 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
822 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
998 global $conf, $mysoc;
1000 $ltrdirection =
'L';
1001 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1002 $ltrdirection =
'R';
1005 $outputlangs->load(
"orders");
1012 $pdf->SetTextColor(0, 0, 60);
1013 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1017 $posy = $this->marge_haute;
1018 $posx = $this->page_largeur - $this->marge_droite - $w;
1020 $pdf->SetXY($this->marge_gauche, $posy);
1023 if ($this->emetteur->logo) {
1024 $logodir = $conf->mycompany->dir_output;
1025 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1026 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1029 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1031 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1033 if (is_readable($logo)) {
1035 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1037 $pdf->SetTextColor(200, 0, 0);
1038 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1039 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1040 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1043 $text = $this->emetteur->name;
1044 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1047 $pdf->SetDrawColor(128, 128, 128);
1049 $posx = $this->page_largeur - $w - $this->marge_droite;
1050 $posy = $this->marge_haute;
1052 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1053 $pdf->SetXY($posx, $posy);
1054 $pdf->SetTextColor(0, 0, 60);
1055 $title = $outputlangs->transnoentities(
"SendingSheet");
1056 $pdf->MultiCell($w, 4, $title,
'',
'R');
1058 $pdf->SetFont(
'',
'', $default_font_size + 1);
1062 $pdf->SetXY($posx, $posy);
1063 $pdf->SetTextColor(0, 0, 60);
1064 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".
$object->ref,
'',
'R');
1067 if (!empty(
$object->date_delivery)) {
1069 $pdf->SetXY($posx, $posy);
1070 $pdf->SetTextColor(0, 0, 60);
1071 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
1076 $pdf->SetXY($posx, $posy);
1077 $pdf->SetTextColor(0, 0, 60);
1078 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1083 $pdf->SetXY($posx, $posy);
1084 $pdf->SetTextColor(0, 0, 60);
1085 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1088 $pdf->SetFont(
'',
'', $default_font_size + 3);
1093 $origin_id =
$object->origin_id;
1097 if (isModEnabled($origin)) {
1098 $outputlangs->load(
'orders');
1100 $classname = ucfirst($origin);
1101 $linkedobject =
new $classname($this->db);
1102 '@phan-var-force Commande|Facture $linkedobject';
1103 $result = $linkedobject->fetch($origin_id);
1107 $pdf->SetFont(
'',
'', $default_font_size - 2);
1108 $text = $linkedobject->ref;
1109 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
1110 $text .=
' ('.$linkedobject->ref_client.
')';
1113 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1114 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1116 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1117 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1133 $carac_emetteur =
'';
1135 $arrayidcontact = array();
1136 if (!empty($origin) && is_object(
$object->origin_object)) {
1137 $arrayidcontact =
$object->origin_object->getIdContact(
'internal',
'SALESREPFOLL');
1139 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1140 $object->fetch_user(reset($arrayidcontact));
1141 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1142 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1144 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1148 $carac_emetteur .=
"\n";
1155 $posx = $this->marge_gauche;
1157 $posx = $this->page_largeur - $this->marge_droite - 80;
1165 $pdf->SetTextColor(0, 0, 0);
1166 $pdf->SetFont(
'',
'', $default_font_size - 2);
1167 $pdf->SetXY($posx, $posy - 5);
1168 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0, $ltrdirection);
1169 $pdf->SetXY($posx, $posy);
1170 $pdf->SetFillColor(230, 230, 230);
1171 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1172 $pdf->SetTextColor(0, 0, 60);
1173 $pdf->SetFillColor(255, 255, 255);
1178 $pdf->SetXY($posx + 2, $posy + 3);
1179 $pdf->SetFont(
'',
'B', $default_font_size);
1180 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1181 $posy = $pdf->getY();
1185 $pdf->SetXY($posx + 2, $posy);
1186 $pdf->SetFont(
'',
'', $default_font_size - 1);
1187 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1191 $usecontact =
false;
1192 $arrayidcontact =
$object->origin_object->getIdContact(
'external',
'SHIPPING');
1193 if (count($arrayidcontact) > 0) {
1195 $result =
$object->fetch_contact($arrayidcontact[0]);
1199 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1200 $thirdparty =
$object->contact;
1202 $thirdparty =
$object->thirdparty;
1211 if ($this->page_largeur < 210) {
1215 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1217 $posx = $this->marge_gauche;
1222 $pdf->SetTextColor(0, 0, 0);
1223 $pdf->SetFont(
'',
'', $default_font_size - 2);
1224 $pdf->SetXY($posx + 2, $posy - 5);
1225 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0, $ltrdirection);
1226 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1230 $pdf->SetXY($posx + 2, $posy + 3);
1231 $pdf->SetFont(
'',
'B', $default_font_size);
1233 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1235 $posy = $pdf->getY();
1238 $pdf->SetXY($posx + 2, $posy);
1239 $pdf->SetFont(
'',
'', $default_font_size - 1);
1241 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1244 $pdf->SetTextColor(0, 0, 0);