29 require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
57 public $update_main_doc_field;
68 public $phpmin = array(5, 6);
74 public $version =
'dolibarr';
125 global $conf, $langs, $mysoc;
128 $this->
name =
"espadon";
129 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
130 $this->update_main_doc_field = 1;
134 $this->page_largeur = $formatarray[
'width'];
135 $this->page_hauteur = $formatarray[
'height'];
136 $this->format = array($this->page_largeur, $this->page_hauteur);
137 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
138 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
139 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
140 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
142 $this->option_logo = 1;
143 $this->option_draft_watermark = 1;
144 $this->watermark =
'';
147 $this->emetteur = $mysoc;
148 if (!$this->emetteur->country_code) {
149 $this->emetteur->country_code = substr($langs->defaultlang, -2);
152 $this->tabTitleHeight = 5;
167 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
170 global $user, $conf, $langs, $hookmanager;
172 $object->fetch_thirdparty();
174 if (!is_object($outputlangs)) {
175 $outputlangs = $langs;
178 if (!empty($conf->global->MAIN_USE_FPDF)) {
179 $outputlangs->charset_output =
'ISO-8859-1';
183 $outputlangs->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
186 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
187 $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK;
190 global $outputlangsbis;
191 $outputlangsbis =
null;
192 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
193 $outputlangsbis =
new Translate(
'', $conf);
194 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
195 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
198 $nblines = count($object->lines);
201 $realpatharray = array();
202 $this->atleastonephoto =
false;
203 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
206 for ($i = 0; $i < $nblines; $i++) {
207 if (empty($object->lines[$i]->fk_product)) {
211 $objphoto->fetch($object->lines[$i]->fk_product);
213 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
214 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
215 $dir = $conf->product->dir_output.
'/'.$pdir;
217 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
218 $dir = $conf->product->dir_output.
'/'.$pdir;
223 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
224 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
225 if ($obj[
'photo_vignette']) {
226 $filename = $obj[
'photo_vignette'];
228 $filename = $obj[
'photo'];
231 $filename = $obj[
'photo'];
234 $realpath = $dir.$filename;
235 $this->atleastonephoto =
true;
240 $realpatharray[$i] = $realpath;
245 if (count($realpatharray) == 0) {
246 $this->posxpicture = $this->posxweightvol;
249 if ($conf->expedition->dir_output) {
251 if ($object->specimen) {
252 $dir = $conf->expedition->dir_output.
"/sending";
253 $file = $dir.
"/SPECIMEN.pdf";
256 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
257 $file = $dir.
"/".$expref.
".pdf";
260 if (!file_exists($dir)) {
262 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
267 if (file_exists($dir)) {
269 if (!is_object($hookmanager)) {
270 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
273 $hookmanager->initHooks(array(
'pdfgeneration'));
274 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
276 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
279 $nblines = count($object->lines);
283 $heightforinfotot = 8;
284 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
285 $heightforfooter = $this->marge_basse + 8;
286 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
287 $heightforfooter += 6;
289 $pdf->SetAutoPageBreak(1, 0);
291 if (class_exists(
'TCPDF')) {
292 $pdf->setPrintHeader(
false);
293 $pdf->setPrintFooter(
false);
297 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
298 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
299 $tplidx = $pdf->importPage(1);
304 $pdf->SetDrawColor(128, 128, 128);
306 if (method_exists($pdf,
'AliasNbPages')) {
307 $pdf->AliasNbPages();
310 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
311 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
312 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
313 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
314 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
315 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
316 $pdf->SetCompression(
false);
319 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
323 if (!empty($tplidx)) {
324 $pdf->useTemplate($tplidx);
327 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
328 $pdf->SetFont(
'',
'', $default_font_size - 1);
329 $pdf->MultiCell(0, 3,
'');
330 $pdf->SetTextColor(0, 0, 0);
333 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift: 10);
335 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
337 $this->posxdesc = $this->marge_gauche + 1;
340 $height_incoterms = 0;
341 if (!empty($conf->incoterm->enabled)) {
342 $desc_incoterms = $object->getIncotermsForPDF();
343 if ($desc_incoterms) {
346 $pdf->SetFont(
'',
'', $default_font_size - 1);
347 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
348 $nexY = $pdf->GetY();
349 $height_incoterms = $nexY - $tab_top;
352 $pdf->SetDrawColor(192, 192, 192);
353 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
355 $tab_top = $nexY + 6;
356 $height_incoterms += 4;
361 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
364 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
365 if (!empty($extranote)) {
369 if (!empty($notetoshow) || !empty($object->tracking_number)) {
371 $tab_topbeforetrackingnumber = $tab_top;
374 if (!empty($object->tracking_number)) {
375 $height_trackingnumber = 4;
377 $pdf->SetFont(
'',
'B', $default_font_size - 2);
378 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber") .
" : " . $object->tracking_number, 0, 1,
false,
true,
'L');
380 $tab_top_alt = $pdf->GetY();
381 $object->getUrlTrackingStatus($object->tracking_number);
382 if (!empty($object->tracking_url)) {
383 if ($object->shipping_method_id > 0) {
385 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
387 if ($object->tracking_url != $object->tracking_number) {
388 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
390 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
392 if ($object->tracking_url != $object->tracking_number) {
394 $label .= $object->tracking_url;
397 $height_trackingnumber += 4;
398 $pdf->SetFont(
'',
'B', $default_font_size - 2);
399 $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
402 $tab_top = $pdf->GetY();
407 $pagenb = $pdf->getPage();
408 if (!empty($notetoshow) || !empty($object->tracking_number)) {
411 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
412 $pageposbeforenote = $pagenb;
419 $pdf->startTransaction();
421 $pdf->SetFont(
'',
'', $default_font_size - 1);
422 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
424 $pageposafternote = $pdf->getPage();
425 $posyafter = $pdf->GetY();
427 if ($pageposafternote > $pageposbeforenote) {
428 $pdf->rollbackTransaction(
true);
431 while ($pagenb < $pageposafternote) {
434 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
435 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
437 $pdf->setTopMargin($tab_top_newpage);
439 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
443 $pdf->setPage($pageposbeforenote);
444 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
445 $pdf->SetFont(
'',
'', $default_font_size - 1);
446 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
447 $pageposafternote = $pdf->getPage();
449 $posyafter = $pdf->GetY();
451 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
452 $pdf->AddPage(
'',
'',
true);
455 $pdf->setPage($pageposafternote);
456 $pdf->setTopMargin($tab_top_newpage);
458 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
464 $i = $pageposbeforenote;
465 while ($i < $pageposafternote) {
469 $pdf->SetDrawColor(128, 128, 128);
471 if ($i > $pageposbeforenote) {
472 if (empty($height_trackingnumber)) {
473 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
475 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1;
476 $tab_top_newpage = $tab_topbeforetrackingnumber;
478 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2);
480 if (empty($height_trackingnumber)) {
481 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
483 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter)+ $height_trackingnumber + 1;
484 $tab_top = $tab_topbeforetrackingnumber;
486 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2);
490 $pdf->setPageOrientation(
'', 1, 0);
491 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
497 $pdf->setPage($pageposafternote);
498 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
499 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
500 $height_note = $posyafter - $tab_top_newpage;
501 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
504 $pdf->commitTransaction();
505 $posyafter = $pdf->GetY();
506 if (empty($height_trackingnumber)) {
507 $height_note = $posyafter - $tab_top + 1;
509 $height_note = $posyafter - $tab_top + $height_trackingnumber + 1;
510 $tab_top = $tab_topbeforetrackingnumber;
512 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2);
515 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
517 $pdf->AddPage(
'',
'',
true);
520 $pdf->setPage($pageposafternote);
521 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
522 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
524 $posyafter = $tab_top_newpage;
528 $tab_height = $tab_height - $height_note;
529 $tab_top = $posyafter + 6;
540 $pdf->startTransaction();
541 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
542 $pdf->rollbackTransaction(
true);
545 $nexY = $tab_top + $this->tabTitleHeight;
548 $pageposbeforeprintlines = $pdf->getPage();
549 $pagenb = $pageposbeforeprintlines;
550 for ($i = 0; $i < $nblines; $i++) {
552 $pdf->SetFont(
'',
'', $default_font_size - 1);
553 $pdf->SetTextColor(0, 0, 0);
556 $imglinesize = array();
557 if (!empty($realpatharray[$i])) {
561 $pdf->setTopMargin($tab_top_newpage);
562 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
563 $pageposbefore = $pdf->getPage();
565 $showpricebeforepagebreak = 1;
567 $posYAfterDescription = 0;
571 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
572 $pdf->AddPage(
'',
'',
true);
573 if (!empty($tplidx)) {
574 $pdf->useTemplate($tplidx);
577 $pdf->setPage($pageposbefore + 1);
579 $curY = $tab_top_newpage;
582 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
583 $showpricebeforepagebreak = 1;
585 $showpricebeforepagebreak = 0;
590 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
591 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
593 $posYAfterImage = $curY + $imglinesize[
'height'];
599 $pdf->startTransaction();
601 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
603 $pageposafter = $pdf->getPage();
604 if ($pageposafter > $pageposbefore) {
605 $pdf->rollbackTransaction(
true);
607 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
609 $pageposafter = $pdf->getPage();
610 $posyafter = $pdf->GetY();
612 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
613 if ($i == ($nblines - 1)) {
614 $pdf->AddPage(
'',
'',
true);
615 if (!empty($tplidx)) {
616 $pdf->useTemplate($tplidx);
619 $pdf->setPage($pageposafter + 1);
624 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
625 $showpricebeforepagebreak = 1;
627 $showpricebeforepagebreak = 0;
632 $pdf->commitTransaction();
634 $posYAfterDescription = $pdf->GetY();
637 $nexY = max($pdf->GetY(), $posYAfterImage);
638 $pageposafter = $pdf->getPage();
640 $pdf->setPage($pageposbefore);
641 $pdf->setTopMargin($this->marge_haute);
642 $pdf->setPageOrientation(
'', 1, 0);
645 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
646 $pdf->setPage($pageposafter);
647 $curY = $tab_top_newpage;
651 if ($pageposafter > $pageposbefore) {
652 $pdf->setPage($pageposafter);
653 $curY = $tab_top_newpage;
656 $pdf->SetFont(
'',
'', $default_font_size - 1);
661 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
662 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
665 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
666 $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);
671 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt);
672 $nexY = max($pdf->GetY(), $nexY);
677 $nexY = max($pdf->GetY(), $nexY);
682 $nexY = max($pdf->GetY(), $nexY);
687 $nexY = max($pdf->GetY(), $nexY);
692 $nexY = max($pdf->GetY(), $nexY);
696 if (!empty($object->lines[$i]->array_options)) {
697 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
699 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
701 $nexY = max($pdf->GetY(), $nexY);
707 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
708 $pdf->setPage($pageposafter);
709 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
711 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
712 $pdf->SetLineStyle(array(
'dash'=>0));
716 while ($pagenb < $pageposafter) {
717 $pdf->setPage($pagenb);
718 if ($pagenb == $pageposbeforeprintlines) {
719 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
721 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
723 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
725 $pdf->setPage($pagenb);
726 $pdf->setPageOrientation(
'', 1, 0);
727 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
728 $this->
_pagehead($pdf, $object, 0, $outputlangs);
730 if (!empty($tplidx)) {
731 $pdf->useTemplate($tplidx);
734 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
736 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
738 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
740 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
743 if (!empty($tplidx)) {
744 $pdf->useTemplate($tplidx);
747 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
748 $this->
_pagehead($pdf, $object, 0, $outputlangs);
755 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
756 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
758 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
759 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
763 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
766 $this->
_pagefoot($pdf, $object, $outputlangs);
767 if (method_exists($pdf,
'AliasNbPages')) {
768 $pdf->AliasNbPages();
773 $pdf->Output($file,
'F');
776 $hookmanager->initHooks(array(
'pdfgeneration'));
777 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
779 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
781 $this->error = $hookmanager->error;
782 $this->errors = $hookmanager->errors;
785 if (!empty($conf->global->MAIN_UMASK)) {
786 @chmod($file, octdec($conf->global->MAIN_UMASK));
789 $this->result = array(
'fullpath'=>$file);
793 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
797 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
814 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
817 global $conf, $mysoc;
825 $pdf->SetFont(
'',
'B', $default_font_size - 1);
828 $col1x = $this->posxweightvol - 50;
829 $col2x = $this->posxweightvol;
834 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
835 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
837 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
843 $totalWeighttoshow =
'';
844 $totalVolumetoshow =
'';
847 $tmparray = $object->getTotalWeightVolume();
848 $totalWeight = $tmparray[
'weight'];
849 $totalVolume = $tmparray[
'volume'];
850 $totalOrdered = $tmparray[
'ordered'];
851 $totalToShip = $tmparray[
'toship'];
853 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
854 $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth;
855 $object->volume_units = $object->size_units * 3;
858 if ($totalWeight !=
'') {
861 if ($totalVolume !=
'') {
864 if ($object->trueWeight) {
865 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
867 if ($object->trueVolume) {
868 if ($object->volume_units < 50) {
869 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
871 $totalVolumetoshow =
price($object->trueVolume, 0, $outputlangs, 0, 0).
' '.
measuringUnitString(0,
"volume", $object->volume_units);
881 if ($totalWeighttoshow) {
886 if ($totalVolumetoshow) {
887 $y = $tab2_top + ($tab2_hl * $index);
904 $pdf->SetTextColor(0, 0, 0);
906 return ($tab2_top + ($tab2_hl * $index));
922 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
932 $currency = !empty($currency) ? $currency : $conf->currency;
936 $pdf->SetTextColor(0, 0, 0);
937 $pdf->SetFont(
'',
'', $default_font_size - 2);
939 if (empty($hidetop)) {
941 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
942 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
946 $pdf->SetDrawColor(128, 128, 128);
947 $pdf->SetFont(
'',
'', $default_font_size - 1);
950 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
953 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
955 if (empty($hidetop)) {
956 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
970 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
972 global $conf, $langs, $mysoc;
974 $langs->load(
"orders");
981 $pdf->SetTextColor(0, 0, 60);
982 $pdf->SetFont(
'',
'B', $default_font_size + 3);
986 $posy = $this->marge_haute;
987 $posx = $this->page_largeur - $this->marge_droite - $w;
989 $pdf->SetXY($this->marge_gauche, $posy);
992 if ($this->emetteur->logo) {
993 $logodir = $conf->mycompany->dir_output;
994 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
995 $logodir = $conf->mycompany->multidir_output[$object->entity];
997 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
998 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1000 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1002 if (is_readable($logo)) {
1004 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1006 $pdf->SetTextColor(200, 0, 0);
1007 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1008 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1009 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1012 $text = $this->emetteur->name;
1013 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1017 if (!empty($conf->barcode->enabled)) {
1020 $posx = $this->marge_gauche + 3;
1023 if (!empty($conf->barcode->enabled)) {
1029 $pdf->SetDrawColor(128, 128, 128);
1030 if (!empty($conf->barcode->enabled)) {
1037 $posx = $this->page_largeur - $w - $this->marge_droite;
1038 $posy = $this->marge_haute;
1040 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1041 $pdf->SetXY($posx, $posy);
1042 $pdf->SetTextColor(0, 0, 60);
1043 $title = $outputlangs->transnoentities(
"SendingSheet");
1044 $pdf->MultiCell($w, 4, $title,
'',
'R');
1046 $pdf->SetFont(
'',
'', $default_font_size + 1);
1050 $pdf->SetXY($posx, $posy);
1051 $pdf->SetTextColor(0, 0, 60);
1052 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
1055 if (!empty($object->date_delivery)) {
1057 $pdf->SetXY($posx, $posy);
1058 $pdf->SetTextColor(0, 0, 60);
1059 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
1062 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1064 $pdf->SetXY($posx, $posy);
1065 $pdf->SetTextColor(0, 0, 60);
1066 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1070 $pdf->SetFont(
'',
'', $default_font_size + 3);
1074 $origin = $object->origin;
1075 $origin_id = $object->origin_id;
1078 if (!empty($conf->$origin->enabled)) {
1079 $outputlangs->load(
'orders');
1081 $classname = ucfirst($origin);
1082 $linkedobject =
new $classname($this->
db);
1083 $result = $linkedobject->fetch($origin_id);
1087 $pdf->SetFont(
'',
'', $default_font_size - 2);
1088 $text = $linkedobject->ref;
1089 if ($linkedobject->ref_client) {
1090 $text .=
' ('.$linkedobject->ref_client.
')';
1093 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1094 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1096 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1097 $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 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1114 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1117 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1118 $posx = $this->marge_gauche;
1119 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1120 $posx = $this->page_largeur - $this->marge_droite - 80;
1123 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1124 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1127 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1128 $pdf->SetTextColor(0, 0, 0);
1129 $pdf->SetFont(
'',
'', $default_font_size - 2);
1130 $pdf->SetXY($posx, $posy - 5);
1131 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1132 $pdf->SetXY($posx, $posy);
1133 $pdf->SetFillColor(230, 230, 230);
1134 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1135 $pdf->SetTextColor(0, 0, 60);
1136 $pdf->SetFillColor(255, 255, 255);
1140 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1141 $pdf->SetXY($posx + 2, $posy + 3);
1142 $pdf->SetFont(
'',
'B', $default_font_size);
1143 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1144 $posy = $pdf->getY();
1148 $pdf->SetXY($posx + 2, $posy);
1149 $pdf->SetFont(
'',
'', $default_font_size - 1);
1150 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1154 $usecontact =
false;
1155 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1156 if (count($arrayidcontact) > 0) {
1158 $result = $object->fetch_contact($arrayidcontact[0]);
1162 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)))) {
1163 $thirdparty = $object->contact;
1165 $thirdparty = $object->thirdparty;
1170 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1173 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1174 if ($this->page_largeur < 210) {
1177 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1178 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1179 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1180 $posx = $this->marge_gauche;
1184 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1185 $pdf->SetTextColor(0, 0, 0);
1186 $pdf->SetFont(
'',
'', $default_font_size - 2);
1187 $pdf->SetXY($posx + 2, $posy - 5);
1188 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1189 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1193 $pdf->SetXY($posx + 2, $posy + 3);
1194 $pdf->SetFont(
'',
'B', $default_font_size);
1195 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1197 $posy = $pdf->getY();
1200 $pdf->SetFont(
'',
'', $default_font_size - 1);
1201 $pdf->SetXY($posx + 2, $posy);
1202 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1205 $pdf->SetTextColor(0, 0, 0);
1218 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1221 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1222 return pdf_pagefoot($pdf, $outputlangs,
'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1235 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1237 global $conf, $hookmanager;
1240 $this->defaultContentsFieldsStyle = array(
1242 'padding' => array(1, 0.5, 1, 0.5),
1246 $this->defaultTitlesFieldsStyle = array(
1248 'padding' => array(0.5, 0, 0.5, 0),
1270 $this->cols[
'desc'] = array(
1275 'textkey' =>
'Designation',
1279 'padding' => array(0.5, 1, 0.5, 1.5),
1282 'padding' => array(1, 0.5, 1, 1.5),
1287 $this->cols[
'photo'] = array(
1289 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1292 'textkey' =>
'Photo',
1296 'padding' => array(0, 0, 0, 0),
1298 'border-left' =>
false,
1301 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto)) {
1302 $this->cols[
'photo'][
'status'] =
true;
1306 $this->cols[
'weight'] = array(
1311 'textkey' =>
'WeightVolShort'
1313 'border-left' =>
true,
1318 $this->cols[
'subprice'] = array(
1321 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1323 'textkey' =>
'PriceUHT'
1325 'border-left' =>
true,
1329 $this->cols[
'totalexcltax'] = array(
1332 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1334 'textkey' =>
'TotalHT'
1336 'border-left' =>
true,
1340 $this->cols[
'qty_asked'] = array(
1343 'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
1345 'textkey' =>
'QtyOrdered'
1347 'border-left' =>
true,
1354 $this->cols[
'unit_order'] = array(
1357 'status' => empty($conf->global->PRODUCT_USE_UNITS) ? 0 : 1,
1361 'border-left' =>
true,
1368 $this->cols[
'qty_shipped'] = array(
1373 'textkey' =>
'QtyToShip'
1375 'border-left' =>
true,
1382 if (!empty($object->lines)) {
1383 $line = reset($object->lines);
1387 $parameters = array(
1388 'object' => $object,
1389 'outputlangs' => $outputlangs,
1390 'hidedetails' => $hidedetails,
1391 'hidedesc' => $hidedesc,
1392 'hideref' => $hideref
1395 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1398 } elseif (empty($reshook)) {
1399 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1401 $this->cols = $hookmanager->resArray;