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';
63 public $phpmin = array(5, 6);
69 public $version =
'dolibarr';
120 global $conf, $langs, $mysoc;
123 $this->
name =
"espadon";
124 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
128 $this->page_largeur = $formatarray[
'width'];
129 $this->page_hauteur = $formatarray[
'height'];
130 $this->format = array($this->page_largeur, $this->page_hauteur);
131 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
132 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
133 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
134 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
136 $this->option_logo = 1;
139 $this->emetteur = $mysoc;
140 if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2);
142 $this->tabTitleHeight = 5;
157 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
160 global $user, $conf, $langs, $hookmanager;
162 $object->fetch_thirdparty();
164 if (!is_object($outputlangs)) $outputlangs = $langs;
166 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
169 $outputlangs->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
171 global $outputlangsbis;
172 $outputlangsbis = null;
173 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
174 $outputlangsbis =
new Translate(
'', $conf);
175 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
176 $outputlangsbis->loadLangs(array(
"main",
"bills",
"orders",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
179 $nblines = count($object->lines);
182 $realpatharray = array();
183 $this->atleastonephoto =
false;
184 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
188 for ($i = 0; $i < $nblines; $i++)
190 if (empty($object->lines[$i]->fk_product))
continue;
193 $objphoto->fetch($object->lines[$i]->fk_product);
195 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
197 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
198 $dir = $conf->product->dir_output.
'/'.$pdir;
200 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
201 $dir = $conf->product->dir_output.
'/'.$pdir;
206 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
208 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))
210 if ($obj[
'photo_vignette'])
212 $filename = $obj[
'photo_vignette'];
214 $filename = $obj[
'photo'];
217 $filename = $obj[
'photo'];
220 $realpath = $dir.$filename;
221 $this->atleastonephoto =
true;
225 if ($realpath) $realpatharray[$i] = $realpath;
229 if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
231 if ($conf->expedition->dir_output)
234 if ($object->specimen)
236 $dir = $conf->expedition->dir_output.
"/sending";
237 $file = $dir.
"/SPECIMEN.pdf";
240 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
241 $file = $dir.
"/".$expref.
".pdf";
244 if (!file_exists($dir))
248 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
253 if (file_exists($dir))
256 if (!is_object($hookmanager))
258 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
261 $hookmanager->initHooks(array(
'pdfgeneration'));
262 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
264 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
267 $nblines = count($object->lines);
271 $heightforinfotot = 8;
272 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
273 $heightforfooter = $this->marge_basse + 8;
274 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
275 $pdf->SetAutoPageBreak(1, 0);
277 if (class_exists(
'TCPDF'))
279 $pdf->setPrintHeader(
false);
280 $pdf->setPrintFooter(
false);
284 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
286 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
287 $tplidx = $pdf->importPage(1);
292 $pdf->SetDrawColor(128, 128, 128);
294 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
296 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
297 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
298 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
299 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
300 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
301 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
303 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
307 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
309 $this->
_pagehead($pdf, $object, 1, $outputlangs);
310 $pdf->SetFont(
'',
'', $default_font_size - 1);
311 $pdf->MultiCell(0, 3,
'');
312 $pdf->SetTextColor(0, 0, 0);
315 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
317 $tab_height_newpage = 150;
319 $this->posxdesc = $this->marge_gauche + 1;
322 $height_incoterms = 0;
323 if (!empty($conf->incoterm->enabled))
325 $desc_incoterms = $object->getIncotermsForPDF();
330 $pdf->SetFont(
'',
'', $default_font_size - 1);
331 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
332 $nexY = $pdf->GetY();
333 $height_incoterms = $nexY - $tab_top;
336 $pdf->SetDrawColor(192, 192, 192);
337 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
339 $tab_top = $nexY + 6;
340 $height_incoterms += 4;
345 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
348 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
349 if (!empty($extranote))
354 if (!empty($notetoshow) || !empty($object->tracking_number))
356 $tab_top = 88 + $height_incoterms;
357 $tab_top_alt = $tab_top;
359 $pdf->SetFont(
'',
'B', $default_font_size - 2);
360 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
362 $tab_top_alt = $pdf->GetY();
366 if (!empty($object->tracking_number))
368 $object->getUrlTrackingStatus($object->tracking_number);
369 if (!empty($object->tracking_url))
371 if ($object->shipping_method_id > 0)
374 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
376 if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
377 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
379 if ($object->tracking_url != $object->tracking_number)
382 $label .= $object->tracking_url;
384 $pdf->SetFont(
'',
'B', $default_font_size - 2);
385 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
387 $tab_top_alt = $pdf->GetY();
393 if (!empty($notetoshow))
395 $pdf->SetFont(
'',
'', $default_font_size - 1);
396 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($notetoshow), 0, 1);
399 $nexY = $pdf->GetY();
400 $height_note = $nexY - $tab_top;
403 $pdf->SetDrawColor(192, 192, 192);
404 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
406 $tab_height = $tab_height - $height_note;
407 $tab_top = $nexY + 6;
417 $pdf->startTransaction();
418 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
419 $pdf->rollbackTransaction(
true);
422 $nexY = $tab_top + $this->tabTitleHeight;
425 for ($i = 0; $i < $nblines; $i++)
428 $pdf->SetFont(
'',
'', $default_font_size - 1);
429 $pdf->SetTextColor(0, 0, 0);
432 $imglinesize = array();
435 $pdf->setTopMargin($tab_top_newpage);
436 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
437 $pageposbefore = $pdf->getPage();
439 $showpricebeforepagebreak = 1;
441 $posYAfterDescription = 0;
446 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))
448 $pdf->AddPage(
'',
'',
true);
449 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
451 $pdf->setPage($pageposbefore + 1);
453 $curY = $tab_top_newpage;
456 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
457 $showpricebeforepagebreak = 1;
458 else $showpricebeforepagebreak = 0;
462 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height']))
464 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
466 $posYAfterImage = $curY + $imglinesize[
'height'];
473 $pdf->startTransaction();
475 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
477 $pageposafter = $pdf->getPage();
478 if ($pageposafter > $pageposbefore)
480 $pdf->rollbackTransaction(
true);
482 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
484 $pageposafter = $pdf->getPage();
485 $posyafter = $pdf->GetY();
487 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))
489 if ($i == ($nblines - 1))
491 $pdf->AddPage(
'',
'',
true);
492 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
494 $pdf->setPage($pageposafter + 1);
499 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
500 $showpricebeforepagebreak = 1;
501 else $showpricebeforepagebreak = 0;
505 $pdf->commitTransaction();
507 $posYAfterDescription = $pdf->GetY();
510 $nexY = $pdf->GetY();
511 $pageposafter = $pdf->getPage();
513 $pdf->setPage($pageposbefore);
514 $pdf->setTopMargin($this->marge_haute);
515 $pdf->setPageOrientation(
'', 1, 0);
518 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
519 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
523 if ($pageposafter > $pageposbefore) {
524 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
527 $pdf->SetFont(
'',
'', $default_font_size - 1);
532 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
534 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
537 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
539 $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);
545 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, array(
'html'=>1));
546 $nexY = max($pdf->GetY(), $nexY);
552 $nexY = max($pdf->GetY(), $nexY);
558 $nexY = max($pdf->GetY(), $nexY);
564 $nexY = max($pdf->GetY(), $nexY);
568 if (!empty($object->lines[$i]->array_options)) {
569 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
574 $nexY = max($pdf->GetY(), $nexY);
580 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
582 $pdf->setPage($pageposafter);
583 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
585 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
586 $pdf->SetLineStyle(array(
'dash'=>0));
590 while ($pagenb < $pageposafter)
592 $pdf->setPage($pagenb);
595 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
597 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
599 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
601 $pdf->setPage($pagenb);
602 $pdf->setPageOrientation(
'', 1, 0);
603 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
605 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
609 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
611 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
613 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
616 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
618 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
625 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
626 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
628 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
629 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
633 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
636 $this->
_pagefoot($pdf, $object, $outputlangs);
637 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
641 $pdf->Output($file,
'F');
644 $hookmanager->initHooks(array(
'pdfgeneration'));
645 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
647 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
650 $this->error = $hookmanager->error;
651 $this->errors = $hookmanager->errors;
654 if (!empty($conf->global->MAIN_UMASK))
655 @chmod($file, octdec($conf->global->MAIN_UMASK));
657 $this->result = array(
'fullpath'=>$file);
661 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
665 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
682 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
685 global $conf, $mysoc;
693 $pdf->SetFont(
'',
'B', $default_font_size - 1);
696 $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
701 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
702 else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
707 $totalWeighttoshow =
'';
708 $totalVolumetoshow =
'';
711 $tmparray = $object->getTotalWeightVolume();
712 $totalWeight = $tmparray[
'weight'];
713 $totalVolume = $tmparray[
'volume'];
714 $totalOrdered = $tmparray[
'ordered'];
715 $totalToShip = $tmparray[
'toship'];
717 if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
719 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
720 $object->volume_units = $object->size_units * 3;
725 if ($object->trueWeight) $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
726 if ($object->trueVolume) $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
739 if ($totalWeighttoshow)
745 if ($totalVolumetoshow)
747 $y = $tab2_top + ($tab2_hl * $index);
767 $pdf->SetTextColor(0, 0, 0);
769 return ($tab2_top + ($tab2_hl * $index));
785 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
791 if ($hidetop) $hidetop = -1;
793 $currency = !empty($currency) ? $currency : $conf->currency;
797 $pdf->SetTextColor(0, 0, 0);
798 $pdf->SetFont(
'',
'', $default_font_size - 2);
803 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
804 $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));
808 $pdf->SetDrawColor(128, 128, 128);
809 $pdf->SetFont(
'',
'', $default_font_size - 1);
812 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
815 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
817 if (empty($hidetop)) {
818 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
832 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
834 global $conf, $langs, $mysoc;
836 $langs->load(
"orders");
843 if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
845 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
849 $pdf->SetTextColor(0, 0, 60);
850 $pdf->SetFont(
'',
'B', $default_font_size + 3);
854 $posy = $this->marge_haute;
855 $posx = $this->page_largeur - $this->marge_droite - $w;
857 $pdf->SetXY($this->marge_gauche, $posy);
860 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
861 if ($this->emetteur->logo)
863 if (is_readable($logo))
866 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
868 $pdf->SetTextColor(200, 0, 0);
869 $pdf->SetFont(
'',
'B', $default_font_size - 2);
870 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
871 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
874 $text = $this->emetteur->name;
875 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
879 if (!empty($conf->barcode->enabled))
883 $posx = $this->marge_gauche + 3;
886 if (!empty($conf->barcode->enabled))
893 $pdf->SetDrawColor(128, 128, 128);
894 if (!empty($conf->barcode->enabled))
902 $posx = $this->page_largeur - $w - $this->marge_droite;
903 $posy = $this->marge_haute;
905 $pdf->SetFont(
'',
'B', $default_font_size + 2);
906 $pdf->SetXY($posx, $posy);
907 $pdf->SetTextColor(0, 0, 60);
908 $title = $outputlangs->transnoentities(
"SendingSheet");
909 $pdf->MultiCell($w, 4, $title,
'',
'R');
911 $pdf->SetFont(
'',
'', $default_font_size + 1);
915 $pdf->SetXY($posx, $posy);
916 $pdf->SetTextColor(0, 0, 60);
917 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
920 if (!empty($object->date_delivery))
923 $pdf->SetXY($posx, $posy);
924 $pdf->SetTextColor(0, 0, 60);
925 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
928 if (!empty($object->thirdparty->code_client))
931 $pdf->SetXY($posx, $posy);
932 $pdf->SetTextColor(0, 0, 60);
933 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
937 $pdf->SetFont(
'',
'', $default_font_size + 3);
941 $origin = $object->origin;
942 $origin_id = $object->origin_id;
945 if (!empty($conf->$origin->enabled))
947 $outputlangs->load(
'orders');
949 $classname = ucfirst($origin);
950 $linkedobject =
new $classname($this->
db);
951 $result = $linkedobject->fetch($origin_id);
956 $pdf->SetFont(
'',
'', $default_font_size - 2);
957 $text = $linkedobject->ref;
958 if ($linkedobject->ref_client) $text .=
' ('.$linkedobject->ref_client.
')';
960 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
961 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
963 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
964 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
971 $carac_emetteur =
'';
973 $arrayidcontact = array();
974 if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
975 if (is_array($arrayidcontact) && count($arrayidcontact) > 0)
977 $object->fetch_user(reset($arrayidcontact));
978 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
981 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
984 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
985 $posx = $this->marge_gauche;
986 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
988 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
989 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
992 $pdf->SetTextColor(0, 0, 0);
993 $pdf->SetFont(
'',
'', $default_font_size - 2);
994 $pdf->SetXY($posx, $posy - 5);
995 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
996 $pdf->SetXY($posx, $posy);
997 $pdf->SetFillColor(230, 230, 230);
998 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
999 $pdf->SetTextColor(0, 0, 60);
1000 $pdf->SetFillColor(255, 255, 255);
1003 $pdf->SetXY($posx + 2, $posy + 3);
1004 $pdf->SetFont(
'',
'B', $default_font_size);
1005 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1006 $posy = $pdf->getY();
1009 $pdf->SetXY($posx + 2, $posy);
1010 $pdf->SetFont(
'',
'', $default_font_size - 1);
1011 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1015 $usecontact =
false;
1016 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1017 if (count($arrayidcontact) > 0)
1020 $result = $object->fetch_contact($arrayidcontact[0]);
1024 if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1025 $thirdparty = $object->contact;
1027 $thirdparty = $object->thirdparty;
1032 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact,
'targetwithdetails', $object);
1035 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1036 if ($this->page_largeur < 210) $widthrecbox = 84;
1037 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1038 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1039 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1042 $pdf->SetTextColor(0, 0, 0);
1043 $pdf->SetFont(
'',
'', $default_font_size - 2);
1044 $pdf->SetXY($posx + 2, $posy - 5);
1045 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1046 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1049 $pdf->SetXY($posx + 2, $posy + 3);
1050 $pdf->SetFont(
'',
'B', $default_font_size);
1051 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1053 $posy = $pdf->getY();
1056 $pdf->SetFont(
'',
'', $default_font_size - 1);
1057 $pdf->SetXY($posx + 2, $posy);
1058 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1061 $pdf->SetTextColor(0, 0, 0);
1074 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1077 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1078 return pdf_pagefoot($pdf, $outputlangs,
'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1091 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1093 global $conf, $hookmanager;
1096 $this->defaultContentsFieldsStyle = array(
1098 'padding' => array(1, 0.5, 1, 0.5),
1102 $this->defaultTitlesFieldsStyle = array(
1104 'padding' => array(0.5, 0, 0.5, 0),
1126 $this->cols[
'desc'] = array(
1131 'textkey' =>
'Designation',
1135 'padding' => array(0.5, 1, 0.5, 1.5),
1138 'padding' => array(1, 0.5, 1, 1.5),
1143 $this->cols[
'photo'] = array(
1145 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1148 'textkey' =>
'Photo',
1152 'padding' => array(0, 0, 0, 0),
1154 'border-left' =>
false,
1157 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto))
1159 $this->cols[
'photo'][
'status'] =
true;
1163 $this->cols[
'weight'] = array(
1168 'textkey' =>
'WeightVolShort'
1170 'border-left' =>
true,
1175 $this->cols[
'subprice'] = array(
1178 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1180 'textkey' =>
'PriceUHT'
1182 'border-left' =>
true,
1186 $this->cols[
'totalexcltax'] = array(
1189 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1191 'textkey' =>
'TotalHT'
1193 'border-left' =>
true,
1197 $this->cols[
'qty_asked'] = array(
1200 'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
1202 'textkey' =>
'QtyOrdered'
1204 'border-left' =>
true,
1211 $this->cols[
'qty_shipped'] = array(
1216 'textkey' =>
'QtyToShip'
1218 'border-left' =>
true,
1225 if (!empty($object->lines)) {
1226 $line = reset($object->lines);
1230 $parameters = array(
1231 'object' => $object,
1232 'outputlangs' => $outputlangs,
1233 'hidedetails' => $hidedetails,
1234 'hidedesc' => $hidedesc,
1235 'hideref' => $hideref
1238 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1242 } elseif (empty($reshook))
1244 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1246 $this->cols = $hookmanager->resArray;
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
getExtrafieldContent($object, $extrafieldKey)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
Parent class of sending receipts models.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
printStdColumnContent($pdf, &$curY, $colKey, $columnText= '')
print standard column content
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
$conf db
API class for accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
getColumnStatus($colKey)
get column status from column key
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no')
Output a dimension with best unit.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
__construct($db=0)
Constructor.
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
Class to build sending documents with model espadon.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.