161 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
164 global $user, $conf, $langs, $hookmanager;
166 $object->fetch_thirdparty();
168 if (!is_object($outputlangs)) {
169 $outputlangs = $langs;
172 if (!empty($conf->global->MAIN_USE_FPDF)) {
173 $outputlangs->charset_output =
'ISO-8859-1';
177 $outputlangs->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
180 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
181 $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK;
184 global $outputlangsbis;
185 $outputlangsbis =
null;
186 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
187 $outputlangsbis =
new Translate(
'', $conf);
188 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
189 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
192 $nblines = count($object->lines);
195 $realpatharray = array();
196 $this->atleastonephoto =
false;
197 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
198 $objphoto =
new Product($this->db);
200 for ($i = 0; $i < $nblines; $i++) {
201 if (empty($object->lines[$i]->fk_product)) {
205 $objphoto->fetch($object->lines[$i]->fk_product);
208 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
209 $dir = $conf->product->dir_output.
'/'.$pdir;
211 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
212 $dir = $conf->product->dir_output.
'/'.$pdir;
217 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
219 if ($obj[
'photo_vignette']) {
220 $filename = $obj[
'photo_vignette'];
222 $filename = $obj[
'photo'];
225 $filename = $obj[
'photo'];
228 $realpath = $dir.$filename;
229 $this->atleastonephoto =
true;
234 $realpatharray[$i] = $realpath;
239 if (count($realpatharray) == 0) {
240 $this->posxpicture = $this->posxweightvol;
243 if ($conf->expedition->dir_output) {
245 if ($object->specimen) {
246 $dir = $conf->expedition->dir_output.
"/sending";
247 $file = $dir.
"/SPECIMEN.pdf";
250 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
251 $file = $dir.
"/".$expref.
".pdf";
254 if (!file_exists($dir)) {
256 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
261 if (file_exists($dir)) {
263 if (!is_object($hookmanager)) {
264 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
267 $hookmanager->initHooks(array(
'pdfgeneration'));
268 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
270 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
273 $nblines = count($object->lines);
277 $heightforinfotot = 8;
278 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
279 $heightforfooter = $this->marge_basse + 8;
280 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
281 $heightforfooter += 6;
283 $pdf->SetAutoPageBreak(1, 0);
285 if (class_exists(
'TCPDF')) {
286 $pdf->setPrintHeader(
false);
287 $pdf->setPrintFooter(
false);
291 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
292 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
293 $tplidx = $pdf->importPage(1);
298 $pdf->SetDrawColor(128, 128, 128);
300 if (method_exists($pdf,
'AliasNbPages')) {
301 $pdf->AliasNbPages();
304 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
305 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
306 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
307 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
308 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
310 $pdf->SetCompression(
false);
313 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
317 if (!empty($tplidx)) {
318 $pdf->useTemplate($tplidx);
321 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
322 $pdf->SetFont(
'',
'', $default_font_size - 1);
323 $pdf->MultiCell(0, 3,
'');
324 $pdf->SetTextColor(0, 0, 0);
327 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift: 10);
329 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
331 $this->posxdesc = $this->marge_gauche + 1;
334 $height_incoterms = 0;
335 if (isModEnabled(
'incoterm')) {
336 $desc_incoterms = $object->getIncotermsForPDF();
337 if ($desc_incoterms) {
340 $pdf->SetFont(
'',
'', $default_font_size - 1);
341 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
342 $nexY = $pdf->GetY();
343 $height_incoterms = $nexY - $tab_top;
346 $pdf->SetDrawColor(192, 192, 192);
347 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
349 $tab_top = $nexY + 6;
350 $height_incoterms += 4;
355 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
358 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
359 if (!empty($extranote)) {
363 if (!empty($notetoshow) || !empty($object->tracking_number)) {
365 $tab_topbeforetrackingnumber = $tab_top;
368 if (!empty($object->tracking_number)) {
369 $height_trackingnumber = 4;
371 $pdf->SetFont(
'',
'B', $default_font_size - 2);
372 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber") .
" : " . $object->tracking_number, 0, 1,
false,
true,
'L');
374 $tab_top_alt = $pdf->GetY();
375 $object->getUrlTrackingStatus($object->tracking_number);
376 if (!empty($object->tracking_url)) {
377 if ($object->shipping_method_id > 0) {
379 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
381 if ($object->tracking_url != $object->tracking_number) {
382 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
384 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
386 if ($object->tracking_url != $object->tracking_number) {
388 $label .= $object->tracking_url;
391 $height_trackingnumber += 4;
392 $pdf->SetFont(
'',
'B', $default_font_size - 2);
393 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
396 $tab_top = $pdf->GetY();
401 $pagenb = $pdf->getPage();
402 if (!empty($notetoshow) || !empty($object->tracking_number)) {
405 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
406 $pageposbeforenote = $pagenb;
413 $pdf->startTransaction();
415 $pdf->SetFont(
'',
'', $default_font_size - 1);
416 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
418 $pageposafternote = $pdf->getPage();
419 $posyafter = $pdf->GetY();
421 if ($pageposafternote > $pageposbeforenote) {
422 $pdf->rollbackTransaction(
true);
425 while ($pagenb < $pageposafternote) {
428 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
431 $pdf->setTopMargin($tab_top_newpage);
433 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
437 $pdf->setPage($pageposbeforenote);
438 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
439 $pdf->SetFont(
'',
'', $default_font_size - 1);
440 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
441 $pageposafternote = $pdf->getPage();
443 $posyafter = $pdf->GetY();
445 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
446 $pdf->AddPage(
'',
'',
true);
449 $pdf->setPage($pageposafternote);
450 $pdf->setTopMargin($tab_top_newpage);
452 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
458 $i = $pageposbeforenote;
459 while ($i < $pageposafternote) {
463 $pdf->SetDrawColor(128, 128, 128);
465 if ($i > $pageposbeforenote) {
466 if (empty($height_trackingnumber)) {
467 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
469 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
470 $tab_top_newpage = $tab_topbeforetrackingnumber;
472 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2);
474 if (empty($height_trackingnumber)) {
475 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
477 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter)+ $height_trackingnumber + 1;
478 $tab_top = $tab_topbeforetrackingnumber;
480 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2);
484 $pdf->setPageOrientation(
'', 1, 0);
485 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
491 $pdf->setPage($pageposafternote);
492 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
494 $height_note = $posyafter - $tab_top_newpage;
495 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
498 $pdf->commitTransaction();
499 $posyafter = $pdf->GetY();
500 if (empty($height_trackingnumber)) {
501 $height_note = $posyafter - $tab_top + 1;
503 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
504 $tab_top = $tab_topbeforetrackingnumber;
506 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2);
509 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
511 $pdf->AddPage(
'',
'',
true);
514 $pdf->setPage($pageposafternote);
515 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
518 $posyafter = $tab_top_newpage;
522 $tab_height = $tab_height - $height_note;
523 $tab_top = $posyafter + 6;
534 $pdf->startTransaction();
535 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
536 $pdf->rollbackTransaction(
true);
539 $nexY = $tab_top + $this->tabTitleHeight;
542 $pageposbeforeprintlines = $pdf->getPage();
543 $pagenb = $pageposbeforeprintlines;
544 for ($i = 0; $i < $nblines; $i++) {
546 $pdf->SetFont(
'',
'', $default_font_size - 1);
547 $pdf->SetTextColor(0, 0, 0);
550 $imglinesize = array();
551 if (!empty($realpatharray[$i])) {
555 $pdf->setTopMargin($tab_top_newpage);
556 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
557 $pageposbefore = $pdf->getPage();
559 $showpricebeforepagebreak = 1;
561 $posYAfterDescription = 0;
565 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
566 $pdf->AddPage(
'',
'',
true);
567 if (!empty($tplidx)) {
568 $pdf->useTemplate($tplidx);
571 $pdf->setPage($pageposbefore + 1);
573 $curY = $tab_top_newpage;
576 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
577 $showpricebeforepagebreak = 1;
579 $showpricebeforepagebreak = 0;
584 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
585 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
587 $posYAfterImage = $curY + $imglinesize[
'height'];
593 $pdf->startTransaction();
595 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
597 $pageposafter = $pdf->getPage();
598 if ($pageposafter > $pageposbefore) {
599 $pdf->rollbackTransaction(
true);
601 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
603 $pageposafter = $pdf->getPage();
604 $posyafter = $pdf->GetY();
606 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
607 if ($i == ($nblines - 1)) {
608 $pdf->AddPage(
'',
'',
true);
609 if (!empty($tplidx)) {
610 $pdf->useTemplate($tplidx);
613 $pdf->setPage($pageposafter + 1);
618 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
619 $showpricebeforepagebreak = 1;
621 $showpricebeforepagebreak = 0;
626 $pdf->commitTransaction();
628 $posYAfterDescription = $pdf->GetY();
631 $nexY = max($pdf->GetY(), $posYAfterImage);
632 $pageposafter = $pdf->getPage();
634 $pdf->setPage($pageposbefore);
635 $pdf->setTopMargin($this->marge_haute);
636 $pdf->setPageOrientation(
'', 1, 0);
639 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
640 $pdf->setPage($pageposafter);
641 $curY = $tab_top_newpage;
645 if ($pageposafter > $pageposbefore) {
646 $pdf->setPage($pageposafter);
647 $curY = $tab_top_newpage;
650 $pdf->SetFont(
'',
'', $default_font_size - 1);
655 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
656 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
659 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
660 $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);
665 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt);
666 $nexY = max($pdf->GetY(), $nexY);
671 $nexY = max($pdf->GetY(), $nexY);
676 $nexY = max($pdf->GetY(), $nexY);
681 $nexY = max($pdf->GetY(), $nexY);
686 $nexY = max($pdf->GetY(), $nexY);
690 if (!empty($object->lines[$i]->array_options)) {
691 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
693 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
695 $nexY = max($pdf->GetY(), $nexY);
701 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
702 $pdf->setPage($pageposafter);
703 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
705 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
706 $pdf->SetLineStyle(array(
'dash'=>0));
710 while ($pagenb < $pageposafter) {
711 $pdf->setPage($pagenb);
712 if ($pagenb == $pageposbeforeprintlines) {
713 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
715 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
717 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
719 $pdf->setPage($pagenb);
720 $pdf->setPageOrientation(
'', 1, 0);
722 $this->
_pagehead($pdf, $object, 0, $outputlangs);
724 if (!empty($tplidx)) {
725 $pdf->useTemplate($tplidx);
728 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
730 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
732 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
734 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
737 if (!empty($tplidx)) {
738 $pdf->useTemplate($tplidx);
742 $this->
_pagehead($pdf, $object, 0, $outputlangs);
749 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
750 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
752 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
753 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
757 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
760 $this->
_pagefoot($pdf, $object, $outputlangs);
761 if (method_exists($pdf,
'AliasNbPages')) {
762 $pdf->AliasNbPages();
767 $pdf->Output($file,
'F');
770 $hookmanager->initHooks(array(
'pdfgeneration'));
771 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
773 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
775 $this->error = $hookmanager->error;
776 $this->errors = $hookmanager->errors;
781 $this->result = array(
'fullpath'=>$file);
785 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
789 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
962 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
964 global $conf, $langs, $mysoc;
966 $langs->load(
"orders");
973 $pdf->SetTextColor(0, 0, 60);
974 $pdf->SetFont(
'',
'B', $default_font_size + 3);
978 $posy = $this->marge_haute;
979 $posx = $this->page_largeur - $this->marge_droite - $w;
981 $pdf->SetXY($this->marge_gauche, $posy);
984 if ($this->emetteur->logo) {
985 $logodir = $conf->mycompany->dir_output;
986 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
987 $logodir = $conf->mycompany->multidir_output[$object->entity];
990 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
992 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
994 if (is_readable($logo)) {
996 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
998 $pdf->SetTextColor(200, 0, 0);
999 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1000 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1001 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1004 $text = $this->emetteur->name;
1005 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1009 if (isModEnabled(
'barcode')) {
1012 $posx = $this->marge_gauche + 3;
1015 if (isModEnabled(
'barcode')) {
1021 $pdf->SetDrawColor(128, 128, 128);
1022 if (isModEnabled(
'barcode')) {
1029 $posx = $this->page_largeur - $w - $this->marge_droite;
1030 $posy = $this->marge_haute;
1032 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1033 $pdf->SetXY($posx, $posy);
1034 $pdf->SetTextColor(0, 0, 60);
1035 $title = $outputlangs->transnoentities(
"SendingSheet");
1036 $pdf->MultiCell($w, 4, $title,
'',
'R');
1038 $pdf->SetFont(
'',
'', $default_font_size + 1);
1042 $pdf->SetXY($posx, $posy);
1043 $pdf->SetTextColor(0, 0, 60);
1044 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
1047 if (!empty($object->date_delivery)) {
1049 $pdf->SetXY($posx, $posy);
1050 $pdf->SetTextColor(0, 0, 60);
1051 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
1054 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1056 $pdf->SetXY($posx, $posy);
1057 $pdf->SetTextColor(0, 0, 60);
1058 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1062 $pdf->SetFont(
'',
'', $default_font_size + 3);
1066 $origin = $object->origin;
1067 $origin_id = $object->origin_id;
1070 if (!empty($conf->$origin->enabled)) {
1071 $outputlangs->load(
'orders');
1073 $classname = ucfirst($origin);
1074 $linkedobject =
new $classname($this->db);
1075 $result = $linkedobject->fetch($origin_id);
1079 $pdf->SetFont(
'',
'', $default_font_size - 2);
1080 $text = $linkedobject->ref;
1081 if ($linkedobject->ref_client) {
1082 $text .=
' ('.$linkedobject->ref_client.
')';
1085 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1086 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1088 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1089 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1103 $carac_emetteur =
'';
1105 $arrayidcontact = array();
1106 if (!empty($origin) && is_object($object->$origin)) {
1107 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1109 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1110 $object->fetch_user(reset($arrayidcontact));
1111 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1112 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1114 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1116 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1118 $carac_emetteur .=
"\n";
1121 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1124 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1125 $posx = $this->marge_gauche;
1126 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1127 $posx = $this->page_largeur - $this->marge_droite - 80;
1130 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1131 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1134 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1135 $pdf->SetTextColor(0, 0, 0);
1136 $pdf->SetFont(
'',
'', $default_font_size - 2);
1137 $pdf->SetXY($posx, $posy - 5);
1138 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1139 $pdf->SetXY($posx, $posy);
1140 $pdf->SetFillColor(230, 230, 230);
1141 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1142 $pdf->SetTextColor(0, 0, 60);
1143 $pdf->SetFillColor(255, 255, 255);
1147 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1148 $pdf->SetXY($posx + 2, $posy + 3);
1149 $pdf->SetFont(
'',
'B', $default_font_size);
1150 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1151 $posy = $pdf->getY();
1155 $pdf->SetXY($posx + 2, $posy);
1156 $pdf->SetFont(
'',
'', $default_font_size - 1);
1157 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1161 $usecontact =
false;
1162 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1163 if (count($arrayidcontact) > 0) {
1165 $result = $object->fetch_contact($arrayidcontact[0]);
1169 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1170 $thirdparty = $object->contact;
1172 $thirdparty = $object->thirdparty;
1177 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1180 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1181 if ($this->page_largeur < 210) {
1184 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1185 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1186 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1187 $posx = $this->marge_gauche;
1191 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1192 $pdf->SetTextColor(0, 0, 0);
1193 $pdf->SetFont(
'',
'', $default_font_size - 2);
1194 $pdf->SetXY($posx + 2, $posy - 5);
1195 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1196 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1200 $pdf->SetXY($posx + 2, $posy + 3);
1201 $pdf->SetFont(
'',
'B', $default_font_size);
1202 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1204 $posy = $pdf->getY();
1207 $pdf->SetFont(
'',
'', $default_font_size - 1);
1208 $pdf->SetXY($posx + 2, $posy);
1209 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1212 $pdf->SetTextColor(0, 0, 0);