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;
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(
true, 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;
351 $height_trackingnumber = 0;
354 if (!empty(
$object->tracking_number)) {
355 $tracking_block_start_y = $tab_top;
357 $pdf->SetFont(
'',
'B', $default_font_size - 2);
358 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber") .
" : " .
$object->tracking_number, 0, 1,
false,
true,
'L');
359 $tab_top_alt = $pdf->GetY();
362 if (!empty(
$object->tracking_url)) {
363 if (
$object->shipping_method_id > 0) {
365 $code = $outputlangs->getLabelFromKey($this->db, (
string)
$object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
368 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
370 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
374 $label .=
$object->tracking_url;
377 $pdf->SetFont(
'',
'B', $default_font_size - 2);
378 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
381 $tab_top = $pdf->GetY();
382 $height_trackingnumber = $tab_top - $tracking_block_start_y;
383 if ($height_trackingnumber < 4) {
384 $height_trackingnumber = 4;
389 $pagenb = $pdf->getPage();
390 if (!empty($notetoshow) || !empty(
$object->tracking_number)) {
393 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
394 $pageposbeforenote = $pagenb;
398 $notetoshow =
make_substitutions((
string) $notetoshow, $substitutionarray, $outputlangs);
401 $pdf->startTransaction();
403 $pdf->SetFont(
'',
'', $default_font_size - 1);
404 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
406 $pageposafternote = $pdf->getPage();
407 $posyafter = $pdf->GetY();
409 if ($pageposafternote > $pageposbeforenote) {
410 $pdf->rollbackTransaction(
true);
413 while ($pagenb < $pageposafternote) {
416 if (!empty($tplidx)) {
417 $pdf->useTemplate($tplidx);
423 $pdf->setTopMargin($tab_top_newpage);
425 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
429 $pdf->setPage($pageposbeforenote);
430 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
431 $pdf->SetFont(
'',
'', $default_font_size - 1);
432 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
433 $pageposafternote = $pdf->getPage();
435 $posyafter = $pdf->GetY();
437 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
438 $pdf->AddPage(
'',
'',
true);
441 $pdf->setPage($pageposafternote);
442 $pdf->setTopMargin($tab_top_newpage);
444 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext);
450 $i = $pageposbeforenote;
451 while ($i < $pageposafternote) {
455 $pdf->SetDrawColor(128, 128, 128);
457 if ($i > $pageposbeforenote) {
458 if (empty($height_trackingnumber)) {
459 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
461 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
462 $tab_top_newpage = $tab_topbeforetrackingnumber;
464 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
466 if (empty($height_trackingnumber)) {
467 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
469 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter) + $height_trackingnumber + 1;
470 $tab_top = $tab_topbeforetrackingnumber;
472 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
476 $pdf->setPageOrientation(
'',
true, 0);
483 $pdf->setPage($pageposafternote);
484 if (!empty($tplidx)) {
485 $pdf->useTemplate($tplidx);
490 $height_note = $posyafter - $tab_top_newpage;
491 $pdf->RoundedRect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1, $this->corner_radius,
'1234',
'D');
493 $pdf->commitTransaction();
494 $posyafter = $pdf->GetY();
495 if (empty($height_trackingnumber)) {
496 $height_note = $posyafter - $tab_top + 1;
498 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
499 $tab_top = $tab_topbeforetrackingnumber;
501 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2, $this->corner_radius,
'1234',
'D');
504 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
506 $pdf->AddPage(
'',
'',
true);
509 $pdf->setPage($pageposafternote);
510 if (!empty($tplidx)) {
511 $pdf->useTemplate($tplidx);
517 $posyafter = $tab_top_newpage;
521 $tab_height -= $height_note;
522 $tab_top = $posyafter + 6;
532 require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/doc/tcpdfbarcode.modules.php';
534 $encoding =
'QRCODE';
538 if ($module->encodingIsSupported($encoding)) {
539 $result = $module->writeBarCode(
$object->ref, $encoding);
543 if (!preg_match(
'/^\w+$/', $newcode) ||
dol_strlen($newcode) > 32) {
544 $newcode =
dol_hash($newcode,
'md5');
546 $barcode_path =
$conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
552 $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20);
554 $nexY = $pdf->GetY();
555 $height_barcode = 20;
559 $this->error =
'Failed to generate barcode';
567 $pdf->startTransaction();
568 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
569 $pdf->rollbackTransaction(
true);
572 $nexY = $tab_top + $this->tabTitleHeight;
575 $pageposbeforeprintlines = $pdf->getPage();
576 $pagenb = $pageposbeforeprintlines;
577 for ($i = 0; $i < $nblines; $i++) {
580 $sub_options =
$object->lines[$i]->extraparams[
"subtotal"] ?? array();
582 if (($curY + 6) > ($this->page_hauteur - $heightforfooter) || isset($sub_options[
'titleforcepagebreak']) && !($pdf->getNumPages() == 1 && $curY == $tab_top + $this->tabTitleHeight)) {
584 if (!empty($tplidx)) {
585 $pdf->useTemplate($tplidx);
588 $pdf->setPage($pdf->getNumPages());
589 $nexY = $curY = $tab_top_newpage;
592 $pdf->SetFont(
'',
'', $default_font_size - 1);
593 $pdf->SetTextColor(0, 0, 0);
596 $imglinesize = array();
597 if (!empty($realpatharray[$i])) {
601 $pdf->setTopMargin($tab_top_newpage);
602 $pdf->setPageOrientation(
'',
true, $heightforfooter + $heightforfreetext + $heightforinfotot);
603 $pageposbefore = $pdf->getPage();
605 $showpricebeforepagebreak = 1;
607 $posYAfterDescription = 0;
608 $heightforsignature = 0;
612 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
613 $pdf->AddPage(
'',
'',
true);
614 if (!empty($tplidx)) {
615 $pdf->useTemplate($tplidx);
618 $pdf->setPage($pageposbefore + 1);
620 $curY = $tab_top_newpage;
624 $showpricebeforepagebreak = 1;
626 $showpricebeforepagebreak = 0;
631 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
632 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
634 $posYAfterImage = $curY + $imglinesize[
'height'];
640 if (
$object->lines[$i]->special_code == SUBTOTALS_SPECIAL_CODE) {
642 pdf_render_subtotals($pdf, $this, $curY,
$object, $i, $outputlangs, $hideref, $hidedesc, $bg_color,
true,
true);
644 $pdf->startTransaction();
648 $pageposafter = $pdf->getPage();
649 if ($pageposafter > $pageposbefore) {
650 $pdf->rollbackTransaction(
true);
654 $pageposafter = $pdf->getPage();
655 $posyafter = $pdf->GetY();
657 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
658 if ($i == ($nblines - 1)) {
659 $pdf->AddPage(
'',
'',
true);
660 if (!empty($tplidx)) {
661 $pdf->useTemplate($tplidx);
664 $pdf->setPage($pageposafter + 1);
670 $showpricebeforepagebreak = 1;
672 $showpricebeforepagebreak = 0;
676 $pdf->commitTransaction();
678 $posYAfterDescription = $pdf->GetY();
682 $nexY = max($pdf->GetY(), $posYAfterImage);
683 $pageposafter = $pdf->getPage();
685 $pdf->setPage($pageposbefore);
686 $pdf->setTopMargin($this->marge_haute);
687 $pdf->setPageOrientation(
'',
true, 0);
690 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
691 $pdf->setPage($pageposafter);
692 $curY = $tab_top_newpage;
696 if ($pageposafter > $pageposbefore) {
697 $pdf->setPage($pageposafter);
698 $curY = $tab_top_newpage;
701 $pdf->SetFont(
'',
'', $default_font_size - 1);
710 if (empty(
$object->lines[$i]->fk_product_type) &&
$object->lines[$i]->weight &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
714 if (empty(
$object->lines[$i]->fk_product_type) &&
$object->lines[$i]->volume && !
getDolGlobalString(
'SHIPPING_PDF_HIDE_VOLUME') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
720 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt);
721 $nexY = max($pdf->GetY(), $nexY);
726 $nexY = max($pdf->GetY(), $nexY);
731 $nexY = max($pdf->GetY(), $nexY);
734 if ($this->
getColumnStatus(
'qty_shipped') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
736 $nexY = max($pdf->GetY(), $nexY);
741 $nexY = max($pdf->GetY(), $nexY);
744 if ($this->
getColumnStatus(
'totalexcltax') &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
746 $nexY = max($pdf->GetY(), $nexY);
750 if (!empty(
$object->lines[$i]->array_options) &&
$object->lines[$i]->special_code != SUBTOTALS_SPECIAL_CODE) {
751 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
755 $nexY = max($pdf->GetY(), $nexY);
766 'outputlangs' => $outputlangs,
767 'hidedetails' => $hidedetails
769 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
773 $pdf->setPage($pageposafter);
774 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
776 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
777 $pdf->SetLineStyle(array(
'dash' => 0));
781 while ($pagenb < $pageposafter) {
782 $pdf->setPage($pagenb);
783 if ($pagenb == $pageposbeforeprintlines) {
784 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
786 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
790 $pdf->setPage($pagenb);
791 $pdf->setPageOrientation(
'',
true, 0);
795 if (!empty($tplidx)) {
796 $pdf->useTemplate($tplidx);
799 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
801 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
803 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
808 if (!empty($tplidx)) {
809 $pdf->useTemplate($tplidx);
820 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
821 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
823 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
824 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
832 if (method_exists($pdf,
'AliasNbPages')) {
833 $pdf->AliasNbPages();
838 $pdf->Output($file,
'F');
841 $hookmanager->initHooks(array(
'pdfgeneration'));
842 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
844 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
846 $this->error = $hookmanager->error;
847 $this->errors = $hookmanager->errors;
852 $this->result = array(
'fullpath' => $file);
856 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
860 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
1036 global
$conf, $mysoc;
1038 $ltrdirection =
'L';
1039 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1040 $ltrdirection =
'R';
1043 $outputlangs->load(
"orders");
1050 $pdf->SetTextColor(0, 0, 60);
1051 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1055 $posy = $this->marge_haute;
1056 $posx = $this->page_largeur - $this->marge_droite - $w;
1058 $pdf->SetXY($this->marge_gauche, $posy);
1061 if ($this->emetteur->logo) {
1062 $logodir =
$conf->mycompany->dir_output;
1063 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1064 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1067 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1069 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1071 if (is_readable($logo)) {
1073 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1075 $pdf->SetTextColor(200, 0, 0);
1076 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1077 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1078 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1081 $text = $this->emetteur->name;
1082 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1085 $pdf->SetDrawColor(128, 128, 128);
1087 $posx = $this->page_largeur - $w - $this->marge_droite;
1088 $posy = $this->marge_haute;
1090 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1091 $pdf->SetXY($posx, $posy);
1092 $pdf->SetTextColor(0, 0, 60);
1093 $title = $outputlangs->transnoentities(
"SendingSheet");
1094 $pdf->MultiCell($w, 4, $title,
'',
'R');
1096 $pdf->SetFont(
'',
'', $default_font_size + 1);
1100 $pdf->SetXY($posx, $posy);
1101 $pdf->SetTextColor(0, 0, 60);
1102 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".
$object->ref,
'',
'R');
1105 if (!empty(
$object->date_delivery)) {
1107 $pdf->SetXY($posx, $posy);
1108 $pdf->SetTextColor(0, 0, 60);
1109 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
1114 if (!empty(
$object->project->ref)) {
1116 $pdf->SetXY($posx, $posy);
1117 $pdf->SetTextColor(0, 0, 60);
1118 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1124 if (!empty(
$object->project->ref)) {
1125 $outputlangs->load(
"projects");
1127 $pdf->SetXY($posx, $posy);
1128 $pdf->SetTextColor(0, 0, 60);
1129 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1135 $pdf->SetXY($posx, $posy);
1136 $pdf->SetTextColor(0, 0, 60);
1137 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1142 $pdf->SetXY($posx, $posy);
1143 $pdf->SetTextColor(0, 0, 60);
1144 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1147 $pdf->SetFont(
'',
'', $default_font_size + 3);
1152 $origin_id =
$object->origin_id;
1156 if (isModEnabled($origin)) {
1157 $outputlangs->load(
'orders');
1159 $classname = ucfirst($origin);
1160 $linkedobject =
new $classname($this->db);
1161 '@phan-var-force Commande|Facture $linkedobject';
1162 $result = $linkedobject->fetch($origin_id);
1166 $pdf->SetFont(
'',
'', $default_font_size - 2);
1167 $text = $linkedobject->ref;
1168 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
1169 $text .=
' ('.$linkedobject->ref_client.
')';
1172 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1173 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1175 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1176 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1192 $carac_emetteur =
'';
1194 $arrayidcontact = array();
1195 if (!empty($origin) && is_object(
$object->origin_object)) {
1196 $arrayidcontact =
$object->origin_object->getIdContact(
'internal',
'SALESREPFOLL');
1198 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1199 $object->fetch_user(reset($arrayidcontact));
1200 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1201 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1203 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1207 $carac_emetteur .=
"\n";
1214 $posx = $this->marge_gauche;
1216 $posx = $this->page_largeur - $this->marge_droite - 80;
1224 $pdf->SetTextColor(0, 0, 0);
1225 $pdf->SetFont(
'',
'', $default_font_size - 2);
1226 $pdf->SetXY($posx, $posy - 5);
1227 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0, $ltrdirection);
1228 $pdf->SetXY($posx, $posy);
1229 $pdf->SetFillColor(230, 230, 230);
1230 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
1231 $pdf->SetTextColor(0, 0, 60);
1232 $pdf->SetFillColor(255, 255, 255);
1237 $pdf->SetXY($posx + 2, $posy + 3);
1238 $pdf->SetFont(
'',
'B', $default_font_size);
1239 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1240 $posy = $pdf->getY();
1244 $pdf->SetXY($posx + 2, $posy);
1245 $pdf->SetFont(
'',
'', $default_font_size - 1);
1246 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
1250 $usecontact =
false;
1251 $arrayidcontact =
$object->origin_object->getIdContact(
'external',
'SHIPPING');
1252 if (count($arrayidcontact) > 0) {
1254 $result =
$object->fetch_contact($arrayidcontact[0]);
1258 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1259 $thirdparty =
$object->contact;
1261 $thirdparty =
$object->thirdparty;
1270 if ($this->page_largeur < 210) {
1274 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1276 $posx = $this->marge_gauche;
1281 $pdf->SetTextColor(0, 0, 0);
1282 $pdf->SetFont(
'',
'', $default_font_size - 2);
1283 $pdf->SetXY($posx + 2, $posy - 5);
1284 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0, $ltrdirection);
1285 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1289 $pdf->SetXY($posx + 2, $posy + 3);
1290 $pdf->SetFont(
'',
'B', $default_font_size);
1292 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1294 $posy = $pdf->getY();
1297 $pdf->SetXY($posx + 2, $posy);
1298 $pdf->SetFont(
'',
'', $default_font_size - 1);
1300 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1303 $pdf->SetTextColor(0, 0, 0);