125 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
128 global $user, $conf, $langs, $hookmanager;
130 $object->fetch_thirdparty();
132 if (!is_object($outputlangs)) {
133 $outputlangs = $langs;
137 $outputlangs->charset_output =
'ISO-8859-1';
141 $outputlangs->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
144 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'SHIPPING_DRAFT_WATERMARK'))) {
145 $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK;
148 global $outputlangsbis;
149 $outputlangsbis =
null;
150 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
151 $outputlangsbis =
new Translate(
'', $conf);
152 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
153 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
156 $nblines = count($object->lines);
159 $realpatharray = array();
160 $this->atleastonephoto =
false;
162 $objphoto =
new Product($this->db);
164 for ($i = 0; $i < $nblines; $i++) {
165 if (empty($object->lines[$i]->fk_product)) {
169 $objphoto->fetch($object->lines[$i]->fk_product);
172 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
173 $dir = $conf->product->dir_output.
'/'.$pdir;
175 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
176 $dir = $conf->product->dir_output.
'/'.$pdir;
181 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
183 if ($obj[
'photo_vignette']) {
184 $filename = $obj[
'photo_vignette'];
186 $filename = $obj[
'photo'];
189 $filename = $obj[
'photo'];
192 $realpath = $dir.$filename;
193 $this->atleastonephoto =
true;
198 $realpatharray[$i] = $realpath;
203 if (count($realpatharray) == 0) {
204 $this->posxpicture = $this->posxweightvol;
207 if ($conf->expedition->dir_output) {
209 if ($object->specimen) {
210 $dir = $conf->expedition->dir_output.
"/sending";
211 $file = $dir.
"/SPECIMEN.pdf";
214 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
215 $file = $dir.
"/".$expref.
".pdf";
218 if (!file_exists($dir)) {
220 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
225 if (file_exists($dir)) {
227 if (!is_object($hookmanager)) {
228 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
231 $hookmanager->initHooks(array(
'pdfgeneration'));
232 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
234 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
237 $nblines = count($object->lines);
241 $heightforinfotot = 8;
242 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
243 $heightforfooter = $this->marge_basse + 8;
245 $heightforfooter += 6;
247 $pdf->SetAutoPageBreak(1, 0);
249 if (class_exists(
'TCPDF')) {
250 $pdf->setPrintHeader(
false);
251 $pdf->setPrintFooter(
false);
256 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
257 $tplidx = $pdf->importPage(1);
262 $pdf->SetDrawColor(128, 128, 128);
264 if (method_exists($pdf,
'AliasNbPages')) {
265 $pdf->AliasNbPages();
268 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
269 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
270 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
271 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
272 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
274 $pdf->SetCompression(
false);
277 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
281 if (!empty($tplidx)) {
282 $pdf->useTemplate($tplidx);
285 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
286 $pdf->SetFont(
'',
'', $default_font_size - 1);
287 $pdf->MultiCell(0, 3,
'');
288 $pdf->SetTextColor(0, 0, 0);
291 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
293 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
295 $this->posxdesc = $this->marge_gauche + 1;
298 $height_incoterms = 0;
299 if (isModEnabled(
'incoterm')) {
300 $desc_incoterms = $object->getIncotermsForPDF();
301 if ($desc_incoterms) {
304 $pdf->SetFont(
'',
'', $default_font_size - 1);
305 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
306 $nexY = $pdf->GetY();
307 $height_incoterms = $nexY - $tab_top;
310 $pdf->SetDrawColor(192, 192, 192);
311 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
313 $tab_top = $nexY + 6;
314 $height_incoterms += 4;
319 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
322 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
323 if (!empty($extranote)) {
327 if (!empty($notetoshow) || !empty($object->tracking_number)) {
329 $tab_topbeforetrackingnumber = $tab_top;
332 if (!empty($object->tracking_number)) {
333 $height_trackingnumber = 4;
335 $pdf->SetFont(
'',
'B', $default_font_size - 2);
336 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber") .
" : " . $object->tracking_number, 0, 1,
false,
true,
'L');
338 $tab_top_alt = $pdf->GetY();
339 $object->getUrlTrackingStatus($object->tracking_number);
340 if (!empty($object->tracking_url)) {
341 if ($object->shipping_method_id > 0) {
343 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
345 if ($object->tracking_url != $object->tracking_number) {
346 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
348 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
350 if ($object->tracking_url != $object->tracking_number) {
352 $label .= $object->tracking_url;
355 $height_trackingnumber += 4;
356 $pdf->SetFont(
'',
'B', $default_font_size - 2);
357 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
360 $tab_top = $pdf->GetY();
365 $pagenb = $pdf->getPage();
366 if (!empty($notetoshow) || !empty($object->tracking_number)) {
369 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
370 $pageposbeforenote = $pagenb;
377 $pdf->startTransaction();
379 $pdf->SetFont(
'',
'', $default_font_size - 1);
380 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
382 $pageposafternote = $pdf->getPage();
383 $posyafter = $pdf->GetY();
385 if ($pageposafternote > $pageposbeforenote) {
386 $pdf->rollbackTransaction(
true);
389 while ($pagenb < $pageposafternote) {
392 if (!empty($tplidx)) {
393 $pdf->useTemplate($tplidx);
396 $this->
_pagehead($pdf, $object, 0, $outputlangs);
399 $pdf->setTopMargin($tab_top_newpage);
401 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
405 $pdf->setPage($pageposbeforenote);
406 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
407 $pdf->SetFont(
'',
'', $default_font_size - 1);
408 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
409 $pageposafternote = $pdf->getPage();
411 $posyafter = $pdf->GetY();
413 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
414 $pdf->AddPage(
'',
'',
true);
417 $pdf->setPage($pageposafternote);
418 $pdf->setTopMargin($tab_top_newpage);
420 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
426 $i = $pageposbeforenote;
427 while ($i < $pageposafternote) {
431 $pdf->SetDrawColor(128, 128, 128);
433 if ($i > $pageposbeforenote) {
434 if (empty($height_trackingnumber)) {
435 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
437 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
438 $tab_top_newpage = $tab_topbeforetrackingnumber;
440 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2);
442 if (empty($height_trackingnumber)) {
443 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
445 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter)+ $height_trackingnumber + 1;
446 $tab_top = $tab_topbeforetrackingnumber;
448 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2);
452 $pdf->setPageOrientation(
'', 1, 0);
453 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
459 $pdf->setPage($pageposafternote);
460 if (!empty($tplidx)) {
461 $pdf->useTemplate($tplidx);
464 $this->
_pagehead($pdf, $object, 0, $outputlangs);
466 $height_note = $posyafter - $tab_top_newpage;
467 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
469 $pdf->commitTransaction();
470 $posyafter = $pdf->GetY();
471 if (empty($height_trackingnumber)) {
472 $height_note = $posyafter - $tab_top + 1;
474 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
475 $tab_top = $tab_topbeforetrackingnumber;
477 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2);
480 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
482 $pdf->AddPage(
'',
'',
true);
485 $pdf->setPage($pageposafternote);
486 if (!empty($tplidx)) {
487 $pdf->useTemplate($tplidx);
490 $this->
_pagehead($pdf, $object, 0, $outputlangs);
493 $posyafter = $tab_top_newpage;
497 $tab_height = $tab_height - $height_note;
498 $tab_top = $posyafter + 6;
509 $pdf->startTransaction();
510 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
511 $pdf->rollbackTransaction(
true);
514 $nexY = $tab_top + $this->tabTitleHeight;
517 $pageposbeforeprintlines = $pdf->getPage();
518 $pagenb = $pageposbeforeprintlines;
519 for ($i = 0; $i < $nblines; $i++) {
521 $pdf->SetFont(
'',
'', $default_font_size - 1);
522 $pdf->SetTextColor(0, 0, 0);
525 $imglinesize = array();
526 if (!empty($realpatharray[$i])) {
530 $pdf->setTopMargin($tab_top_newpage);
531 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
532 $pageposbefore = $pdf->getPage();
534 $showpricebeforepagebreak = 1;
536 $posYAfterDescription = 0;
537 $heightforsignature = 0;
541 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
542 $pdf->AddPage(
'',
'',
true);
543 if (!empty($tplidx)) {
544 $pdf->useTemplate($tplidx);
547 $pdf->setPage($pageposbefore + 1);
549 $curY = $tab_top_newpage;
553 $showpricebeforepagebreak = 1;
555 $showpricebeforepagebreak = 0;
560 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
561 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
563 $posYAfterImage = $curY + $imglinesize[
'height'];
569 $pdf->startTransaction();
571 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
573 $pageposafter = $pdf->getPage();
574 if ($pageposafter > $pageposbefore) {
575 $pdf->rollbackTransaction(
true);
577 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
579 $pageposafter = $pdf->getPage();
580 $posyafter = $pdf->GetY();
582 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
583 if ($i == ($nblines - 1)) {
584 $pdf->AddPage(
'',
'',
true);
585 if (!empty($tplidx)) {
586 $pdf->useTemplate($tplidx);
589 $pdf->setPage($pageposafter + 1);
595 $showpricebeforepagebreak = 1;
597 $showpricebeforepagebreak = 0;
601 $pdf->commitTransaction();
603 $posYAfterDescription = $pdf->GetY();
606 $nexY = max($pdf->GetY(), $posYAfterImage);
607 $pageposafter = $pdf->getPage();
609 $pdf->setPage($pageposbefore);
610 $pdf->setTopMargin($this->marge_haute);
611 $pdf->setPageOrientation(
'', 1, 0);
614 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
615 $pdf->setPage($pageposafter);
616 $curY = $tab_top_newpage;
620 if ($pageposafter > $pageposbefore) {
621 $pdf->setPage($pageposafter);
622 $curY = $tab_top_newpage;
625 $pdf->SetFont(
'',
'', $default_font_size - 1);
630 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
631 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
634 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
635 $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
640 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt);
641 $nexY = max($pdf->GetY(), $nexY);
646 $nexY = max($pdf->GetY(), $nexY);
651 $nexY = max($pdf->GetY(), $nexY);
656 $nexY = max($pdf->GetY(), $nexY);
661 $nexY = max($pdf->GetY(), $nexY);
665 if (!empty($object->lines[$i]->array_options)) {
666 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
668 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
670 $nexY = max($pdf->GetY(), $nexY);
677 $pdf->setPage($pageposafter);
678 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
680 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
681 $pdf->SetLineStyle(array(
'dash'=>0));
685 while ($pagenb < $pageposafter) {
686 $pdf->setPage($pagenb);
687 if ($pagenb == $pageposbeforeprintlines) {
688 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
690 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
692 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
694 $pdf->setPage($pagenb);
695 $pdf->setPageOrientation(
'', 1, 0);
697 $this->
_pagehead($pdf, $object, 0, $outputlangs);
699 if (!empty($tplidx)) {
700 $pdf->useTemplate($tplidx);
703 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
705 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
707 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
709 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
712 if (!empty($tplidx)) {
713 $pdf->useTemplate($tplidx);
717 $this->
_pagehead($pdf, $object, 0, $outputlangs);
724 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
725 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
727 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
728 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
732 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
735 $this->
_pagefoot($pdf, $object, $outputlangs);
736 if (method_exists($pdf,
'AliasNbPages')) {
737 $pdf->AliasNbPages();
742 $pdf->Output($file,
'F');
745 $hookmanager->initHooks(array(
'pdfgeneration'));
746 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
748 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
750 $this->error = $hookmanager->error;
751 $this->errors = $hookmanager->errors;
756 $this->result = array(
'fullpath'=>$file);
760 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
764 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
939 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
941 global $conf, $langs, $mysoc;
943 $langs->load(
"orders");
950 $pdf->SetTextColor(0, 0, 60);
951 $pdf->SetFont(
'',
'B', $default_font_size + 3);
955 $posy = $this->marge_haute;
956 $posx = $this->page_largeur - $this->marge_droite - $w;
958 $pdf->SetXY($this->marge_gauche, $posy);
961 if ($this->emetteur->logo) {
962 $logodir = $conf->mycompany->dir_output;
963 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
964 $logodir = $conf->mycompany->multidir_output[$object->entity];
967 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
969 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
971 if (is_readable($logo)) {
973 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
975 $pdf->SetTextColor(200, 0, 0);
976 $pdf->SetFont(
'',
'B', $default_font_size - 2);
977 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
978 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
981 $text = $this->emetteur->name;
982 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
986 if (isModEnabled(
'barcode')) {
989 $posx = $this->marge_gauche + 3;
992 if (isModEnabled(
'barcode')) {
998 $pdf->SetDrawColor(128, 128, 128);
1000 $posx = $this->page_largeur - $w - $this->marge_droite;
1001 $posy = $this->marge_haute;
1003 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1004 $pdf->SetXY($posx, $posy);
1005 $pdf->SetTextColor(0, 0, 60);
1006 $title = $outputlangs->transnoentities(
"SendingSheet");
1007 $pdf->MultiCell($w, 4, $title,
'',
'R');
1009 $pdf->SetFont(
'',
'', $default_font_size + 1);
1013 $pdf->SetXY($posx, $posy);
1014 $pdf->SetTextColor(0, 0, 60);
1015 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
1018 if (!empty($object->date_delivery)) {
1020 $pdf->SetXY($posx, $posy);
1021 $pdf->SetTextColor(0, 0, 60);
1022 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
1025 if (!
getDolGlobalString(
'MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) {
1027 $pdf->SetXY($posx, $posy);
1028 $pdf->SetTextColor(0, 0, 60);
1029 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1033 $pdf->SetFont(
'',
'', $default_font_size + 3);
1037 $origin = $object->origin;
1038 $origin_id = $object->origin_id;
1041 if (!empty($conf->$origin->enabled)) {
1042 $outputlangs->load(
'orders');
1044 $classname = ucfirst($origin);
1045 $linkedobject =
new $classname($this->db);
1046 $result = $linkedobject->fetch($origin_id);
1050 $pdf->SetFont(
'',
'', $default_font_size - 2);
1051 $text = $linkedobject->ref;
1052 if ($linkedobject->ref_client) {
1053 $text .=
' ('.$linkedobject->ref_client.
')';
1056 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1057 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1059 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1060 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1074 $carac_emetteur =
'';
1076 $arrayidcontact = array();
1077 if (!empty($origin) && is_object($object->$origin)) {
1078 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1080 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1081 $object->fetch_user(reset($arrayidcontact));
1082 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1083 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1085 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1087 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1089 $carac_emetteur .=
"\n";
1092 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1096 $posx = $this->marge_gauche;
1098 $posx = $this->page_largeur - $this->marge_droite - 80;
1106 $pdf->SetTextColor(0, 0, 0);
1107 $pdf->SetFont(
'',
'', $default_font_size - 2);
1108 $pdf->SetXY($posx, $posy - 5);
1109 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1110 $pdf->SetXY($posx, $posy);
1111 $pdf->SetFillColor(230, 230, 230);
1112 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1113 $pdf->SetTextColor(0, 0, 60);
1114 $pdf->SetFillColor(255, 255, 255);
1119 $pdf->SetXY($posx + 2, $posy + 3);
1120 $pdf->SetFont(
'',
'B', $default_font_size);
1121 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1122 $posy = $pdf->getY();
1126 $pdf->SetXY($posx + 2, $posy);
1127 $pdf->SetFont(
'',
'', $default_font_size - 1);
1128 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1132 $usecontact =
false;
1133 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1134 if (count($arrayidcontact) > 0) {
1136 $result = $object->fetch_contact($arrayidcontact[0]);
1140 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1141 $thirdparty = $object->contact;
1143 $thirdparty = $object->thirdparty;
1148 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1152 if ($this->page_largeur < 210) {
1156 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1158 $posx = $this->marge_gauche;
1163 $pdf->SetTextColor(0, 0, 0);
1164 $pdf->SetFont(
'',
'', $default_font_size - 2);
1165 $pdf->SetXY($posx + 2, $posy - 5);
1166 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1167 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1171 $pdf->SetXY($posx + 2, $posy + 3);
1172 $pdf->SetFont(
'',
'B', $default_font_size);
1173 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1175 $posy = $pdf->getY();
1178 $pdf->SetFont(
'',
'', $default_font_size - 1);
1179 $pdf->SetXY($posx + 2, $posy);
1180 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1183 $pdf->SetTextColor(0, 0, 0);