195 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
198 global $user, $conf, $langs, $hookmanager;
200 $object->fetch_thirdparty();
202 if (!is_object($outputlangs)) {
203 $outputlangs = $langs;
206 if (!empty($conf->global->MAIN_USE_FPDF)) {
207 $outputlangs->charset_output =
'ISO-8859-1';
211 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch",
"other"));
214 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
215 $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK;
218 $nblines = count($object->lines);
221 $realpatharray = array();
222 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
223 $objphoto =
new Product($this->db);
225 for ($i = 0; $i < $nblines; $i++) {
226 if (empty($object->lines[$i]->fk_product)) {
230 $objphoto =
new Product($this->db);
231 $objphoto->fetch($object->lines[$i]->fk_product);
233 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
234 $dir = $conf->product->dir_output.
'/'.$pdir;
236 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
237 $dir = $conf->product->dir_output.
'/'.$pdir;
242 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
245 if ($obj[
'photo_vignette']) {
246 $filename = $obj[
'photo_vignette'];
248 $filename = $obj[
'photo'];
251 $filename = $obj[
'photo'];
254 $realpath = $dir.$filename;
259 $realpatharray[$i] = $realpath;
264 if (count($realpatharray) == 0) {
265 $this->posxpicture = $this->posxweightvol;
268 if ($conf->expedition->dir_output) {
270 if ($object->specimen) {
271 $dir = $conf->expedition->dir_output.
"/sending";
272 $file = $dir.
"/SPECIMEN.pdf";
275 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
276 $file = $dir.
"/".$expref.
".pdf";
279 if (!file_exists($dir)) {
281 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
286 if (file_exists($dir)) {
288 if (!is_object($hookmanager)) {
289 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
292 $hookmanager->initHooks(array(
'pdfgeneration'));
293 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
295 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
298 $nblines = count($object->lines);
302 $heightforinfotot = 8;
303 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
304 $heightforfooter = $this->marge_basse + 8;
305 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
306 $heightforfooter += 6;
308 $pdf->SetAutoPageBreak(1, 0);
310 if (class_exists(
'TCPDF')) {
311 $pdf->setPrintHeader(
false);
312 $pdf->setPrintFooter(
false);
316 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
317 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
318 $tplidx = $pdf->importPage(1);
323 $pdf->SetDrawColor(128, 128, 128);
325 if (method_exists($pdf,
'AliasNbPages')) {
326 $pdf->AliasNbPages();
329 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
330 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
331 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
332 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
335 $pdf->SetCompression(
false);
338 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
342 if (!empty($tplidx)) {
343 $pdf->useTemplate($tplidx);
346 $this->
_pagehead($pdf, $object, 1, $outputlangs);
347 $pdf->SetFont(
'',
'', $default_font_size - 1);
348 $pdf->MultiCell(0, 3,
'');
349 $pdf->SetTextColor(0, 0, 0);
352 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
354 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
357 $height_incoterms = 0;
358 if (isModEnabled(
'incoterm')) {
359 $desc_incoterms = $object->getIncotermsForPDF();
360 if ($desc_incoterms) {
363 $pdf->SetFont(
'',
'', $default_font_size - 1);
364 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
365 $nexY = $pdf->GetY();
366 $height_incoterms = $nexY - $tab_top;
369 $pdf->SetDrawColor(192, 192, 192);
370 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
372 $tab_top = $nexY + 6;
373 $height_incoterms += 4;
377 if (!empty($object->note_public) || !empty($object->tracking_number)) {
378 $tab_top = 88 + $height_incoterms;
379 $tab_top_alt = $tab_top;
381 $pdf->SetFont(
'',
'B', $default_font_size - 2);
386 if (!empty($object->tracking_number)) {
387 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
388 $tab_top_alt = $pdf->GetY();
390 $object->getUrlTrackingStatus($object->tracking_number);
391 if (!empty($object->tracking_url)) {
392 if ($object->shipping_method_id > 0) {
394 $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
396 if ($object->tracking_url != $object->tracking_number) {
397 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
399 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
401 if ($object->tracking_url != $object->tracking_number) {
403 $label .= $object->tracking_url;
405 $pdf->SetFont(
'',
'B', $default_font_size - 2);
406 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
408 $tab_top_alt = $pdf->GetY();
414 if (!empty($object->note_public)) {
415 $pdf->SetFont(
'',
'', $default_font_size - 1);
416 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
419 $nexY = $pdf->GetY();
420 $height_note = $nexY - $tab_top;
423 $pdf->SetDrawColor(192, 192, 192);
424 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
426 $tab_height = $tab_height - $height_note;
427 $tab_top = $nexY + 6;
432 $iniY = $tab_top + 7;
433 $curY = $tab_top + 7;
434 $nexY = $tab_top + 7;
437 for ($i = 0; $i < $nblines; $i++) {
439 $pdf->SetFont(
'',
'', $default_font_size - 1);
440 $pdf->SetTextColor(0, 0, 0);
443 $imglinesize = array();
444 if (!empty($realpatharray[$i])) {
448 $pdf->setTopMargin($tab_top_newpage);
449 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
450 $pageposbefore = $pdf->getPage();
452 $showpricebeforepagebreak = 1;
454 $posYAfterDescription = 0;
457 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
458 $pdf->AddPage(
'',
'',
true);
459 if (!empty($tplidx)) {
460 $pdf->useTemplate($tplidx);
463 $this->
_pagehead($pdf, $object, 0, $outputlangs);
465 $pdf->setPage($pageposbefore + 1);
467 $curY = $tab_top_newpage;
470 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
471 $showpricebeforepagebreak = 1;
473 $showpricebeforepagebreak = 0;
477 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
478 $curX = $this->posxpicture - 1;
479 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
481 $posYAfterImage = $curY + $imglinesize[
'height'];
485 $curX = $this->posxdesc - 1;
487 $pdf->startTransaction();
488 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
490 $pageposafter = $pdf->getPage();
491 if ($pageposafter > $pageposbefore) {
492 $pdf->rollbackTransaction(
true);
493 $pageposafter = $pageposbefore;
495 $pdf->setPageOrientation(
'', 1, $heightforfooter);
496 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
498 $pageposafter = $pdf->getPage();
499 $posyafter = $pdf->GetY();
501 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
502 if ($i == ($nblines - 1)) {
503 $pdf->AddPage(
'',
'',
true);
504 if (!empty($tplidx)) {
505 $pdf->useTemplate($tplidx);
508 $this->
_pagehead($pdf, $object, 0, $outputlangs);
510 $pdf->setPage($pageposafter + 1);
516 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
517 $showpricebeforepagebreak = 1;
519 $showpricebeforepagebreak = 0;
524 $pdf->commitTransaction();
526 $posYAfterDescription = $pdf->GetY();
528 $nexY = $pdf->GetY();
529 $pageposafter = $pdf->getPage();
531 $pdf->setPage($pageposbefore);
532 $pdf->setTopMargin($this->marge_haute);
533 $pdf->setPageOrientation(
'', 1, 0);
536 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
537 $pdf->setPage($pageposafter);
538 $curY = $tab_top_newpage;
542 if ($pageposafter > $pageposbefore) {
543 $pdf->setPage($pageposafter);
544 $curY = $tab_top_newpage;
547 $pdf->SetFont(
'',
'', $default_font_size - 1);
549 $pdf->SetXY($this->posxweightvol, $curY);
551 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight) {
552 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
555 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume) {
556 $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);
559 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
560 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
564 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
565 $pdf->SetXY($this->posxqtyordered, $curY);
566 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,
'',
'C');
569 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
570 $pdf->SetXY($this->posxqtytoship, $curY);
571 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,
'',
'C');
574 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
575 $pdf->SetXY($this->posxpuht, $curY);
576 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
578 $pdf->SetXY($this->posxtotalht, $curY);
579 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
583 if ($weighttxt && $voltxt) {
588 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
589 $pdf->setPage($pageposafter);
590 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
592 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
593 $pdf->SetLineStyle(array(
'dash'=>0));
597 while ($pagenb < $pageposafter) {
598 $pdf->setPage($pagenb);
600 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
602 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
604 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
606 $pdf->setPage($pagenb);
607 $pdf->setPageOrientation(
'', 1, 0);
609 $this->
_pagehead($pdf, $object, 0, $outputlangs);
611 if (!empty($tplidx)) {
612 $pdf->useTemplate($tplidx);
615 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
617 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
619 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
621 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
624 if (!empty($tplidx)) {
625 $pdf->useTemplate($tplidx);
629 $this->
_pagehead($pdf, $object, 0, $outputlangs);
636 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
637 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
639 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
640 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
644 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
647 $this->
_pagefoot($pdf, $object, $outputlangs);
648 if (method_exists($pdf,
'AliasNbPages')) {
649 $pdf->AliasNbPages();
654 $pdf->Output($file,
'F');
657 $hookmanager->initHooks(array(
'pdfgeneration'));
658 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
660 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
662 $this->error = $hookmanager->error;
663 $this->errors = $hookmanager->errors;
668 $this->result = array(
'fullpath'=>$file);
672 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
676 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
693 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
696 global $conf, $mysoc;
704 $pdf->SetFont(
'',
'B', $default_font_size - 1);
707 $col1x = $this->posxweightvol - 50;
708 $col2x = $this->posxweightvol;
713 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
714 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
716 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
722 $totalWeighttoshow =
'';
723 $totalVolumetoshow =
'';
726 $tmparray = $object->getTotalWeightVolume();
727 $totalWeight = $tmparray[
'weight'];
728 $totalVolume = $tmparray[
'volume'];
729 $totalOrdered = $tmparray[
'ordered'];
730 $totalToShip = $tmparray[
'toship'];
732 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
733 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
734 $object->volume_units = $object->size_units * 3;
737 if (!empty($totalWeight)) {
740 if (!empty($totalVolume)) {
743 if (!empty($object->trueWeight)) {
744 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
746 if (!empty($object->trueVolume)) {
747 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
750 $pdf->SetFillColor(255, 255, 255);
751 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
752 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
754 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
755 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
756 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
759 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
760 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
761 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
764 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
765 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
766 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
768 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
769 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
772 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
774 if ($totalWeighttoshow) {
775 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
776 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
780 if ($totalVolumetoshow) {
781 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
782 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
786 if (!$totalWeighttoshow && !$totalVolumetoshow) {
791 $pdf->SetTextColor(0, 0, 0);
793 return ($tab2_top + ($tab2_hl * $index));
809 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
822 $pdf->SetTextColor(0, 0, 0);
823 $pdf->SetFont(
'',
'', $default_font_size - 2);
826 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
828 $pdf->SetDrawColor(128, 128, 128);
829 $pdf->SetFont(
'',
'', $default_font_size - 1);
831 if (empty($hidetop)) {
832 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
834 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
835 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
838 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
839 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
840 if (empty($hidetop)) {
841 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
842 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
846 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
847 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
848 if (empty($hidetop)) {
849 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
850 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
854 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
855 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
856 if (empty($hidetop)) {
857 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
858 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
"QtyToShip"),
'',
'C');
862 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
863 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
864 if (empty($hidetop)) {
865 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
866 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
869 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
870 if (empty($hidetop)) {
871 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
872 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
887 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
889 global $conf, $langs, $mysoc;
891 $langs->load(
"orders");
898 $pdf->SetTextColor(0, 0, 60);
899 $pdf->SetFont(
'',
'B', $default_font_size + 3);
903 $posy = $this->marge_haute;
904 $posx = $this->page_largeur - $this->marge_droite - $w;
906 $pdf->SetXY($this->marge_gauche, $posy);
909 if ($this->emetteur->logo) {
910 $logodir = $conf->mycompany->dir_output;
911 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
912 $logodir = $conf->mycompany->multidir_output[$object->entity];
915 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
917 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
919 if (is_readable($logo)) {
921 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
923 $pdf->SetTextColor(200, 0, 0);
924 $pdf->SetFont(
'',
'B', $default_font_size - 2);
925 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
926 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
929 $text = $this->emetteur->name;
930 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
934 if (isModEnabled(
'barcode')) {
937 $posx = $this->marge_gauche + 3;
940 if (isModEnabled(
'barcode')) {
946 $pdf->SetDrawColor(128, 128, 128);
947 if (isModEnabled(
'barcode')) {
954 $posx = $this->page_largeur - $w - $this->marge_droite;
955 $posy = $this->marge_haute;
957 $pdf->SetFont(
'',
'B', $default_font_size + 2);
958 $pdf->SetXY($posx, $posy);
959 $pdf->SetTextColor(0, 0, 60);
960 $title = $outputlangs->transnoentities(
"SendingSheet");
961 $pdf->MultiCell($w, 4, $title,
'',
'R');
963 $pdf->SetFont(
'',
'', $default_font_size + 1);
967 $pdf->SetXY($posx, $posy);
968 $pdf->SetTextColor(0, 0, 60);
969 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
972 if (!empty($object->date_delivery)) {
974 $pdf->SetXY($posx, $posy);
975 $pdf->SetTextColor(0, 0, 60);
976 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
979 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
981 $pdf->SetXY($posx, $posy);
982 $pdf->SetTextColor(0, 0, 60);
983 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
987 $pdf->SetFont(
'',
'', $default_font_size + 3);
991 $origin = $object->origin;
992 $origin_id = $object->origin_id;
995 if (!empty($conf->$origin->enabled)) {
996 $outputlangs->load(
'orders');
998 $classname = ucfirst($origin);
999 $linkedobject =
new $classname($this->db);
1000 $result = $linkedobject->fetch($origin_id);
1004 $pdf->SetFont(
'',
'', $default_font_size - 2);
1005 $text = $linkedobject->ref;
1006 if ($linkedobject->ref_client) {
1007 $text .=
' ('.$linkedobject->ref_client.
')';
1010 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1011 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1013 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1014 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1030 $carac_emetteur =
'';
1032 $arrayidcontact = array();
1033 if (!empty($origin) && is_object($object->$origin)) {
1034 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1036 if (count($arrayidcontact) > 0) {
1037 $object->fetch_user(reset($arrayidcontact));
1038 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1039 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1041 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1043 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1045 $carac_emetteur .=
"\n";
1048 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1051 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1052 $posx = $this->marge_gauche;
1053 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1054 $posx = $this->page_largeur - $this->marge_droite - 80;
1057 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1058 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1061 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1062 $pdf->SetTextColor(0, 0, 0);
1063 $pdf->SetFont(
'',
'', $default_font_size - 2);
1064 $pdf->SetXY($posx, $posy - 5);
1065 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1066 $pdf->SetXY($posx, $posy);
1067 $pdf->SetFillColor(230, 230, 230);
1068 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1069 $pdf->SetTextColor(0, 0, 60);
1070 $pdf->SetFillColor(255, 255, 255);
1074 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1075 $pdf->SetXY($posx + 2, $posy + 3);
1076 $pdf->SetFont(
'',
'B', $default_font_size);
1077 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1078 $posy = $pdf->getY();
1082 $pdf->SetXY($posx + 2, $posy);
1083 $pdf->SetFont(
'',
'', $default_font_size - 1);
1084 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1088 $usecontact =
false;
1089 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1090 if (count($arrayidcontact) > 0) {
1092 $result = $object->fetch_contact($arrayidcontact[0]);
1096 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)))) {
1097 $thirdparty = $object->contact;
1099 $thirdparty = $object->thirdparty;
1104 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1107 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1108 if ($this->page_largeur < 210) {
1111 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1112 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1113 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1114 $posx = $this->marge_gauche;
1118 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1119 $pdf->SetTextColor(0, 0, 0);
1120 $pdf->SetFont(
'',
'', $default_font_size - 2);
1121 $pdf->SetXY($posx + 2, $posy - 5);
1122 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1123 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1127 $pdf->SetXY($posx + 2, $posy + 3);
1128 $pdf->SetFont(
'',
'B', $default_font_size);
1129 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1131 $posy = $pdf->getY();
1134 $pdf->SetFont(
'',
'', $default_font_size - 1);
1135 $pdf->SetXY($posx + 2, $posy);
1136 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1139 $pdf->SetTextColor(0, 0, 0);