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(7, 0);
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);
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);
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) {
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"));
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 = (!
getDolGlobalInt(
'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;
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)) {
373 if (!empty($object->tracking_number)) {
374 $pdf->SetFont(
'',
'B', $default_font_size - 2);
375 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber") .
" : " . $object->tracking_number, 0, 1,
false,
true,
'L');
377 $tab_top_alt = $pdf->GetY();
378 $object->getUrlTrackingStatus($object->tracking_number);
379 if (!empty($object->tracking_url)) {
380 if ($object->shipping_method_id > 0) {
382 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
384 if ($object->tracking_url != $object->tracking_number) {
385 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
387 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
389 if ($object->tracking_url != $object->tracking_number) {
391 $label .= $object->tracking_url;
393 $pdf->SetFont(
'',
'B', $default_font_size - 2);
394 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
396 $tab_top = $pdf->GetY();
403 $pagenb = $pdf->getPage();
404 if (!empty($notetoshow)) {
407 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
408 $pageposbeforenote = $pagenb;
415 $pdf->startTransaction();
417 $pdf->SetFont(
'',
'', $default_font_size - 1);
418 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
420 $pageposafternote = $pdf->getPage();
421 $posyafter = $pdf->GetY();
423 if ($pageposafternote > $pageposbeforenote) {
424 $pdf->rollbackTransaction(
true);
427 while ($pagenb < $pageposafternote) {
430 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
433 $pdf->setTopMargin($tab_top_newpage);
435 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
439 $pdf->setPage($pageposbeforenote);
440 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
441 $pdf->SetFont(
'',
'', $default_font_size - 1);
442 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
443 $pageposafternote = $pdf->getPage();
445 $posyafter = $pdf->GetY();
447 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
448 $pdf->AddPage(
'',
'',
true);
451 $pdf->setPage($pageposafternote);
452 $pdf->setTopMargin($tab_top_newpage);
454 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
460 $i = $pageposbeforenote;
461 while ($i < $pageposafternote) {
465 $pdf->SetDrawColor(128, 128, 128);
467 if ($i > $pageposbeforenote) {
468 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
469 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
471 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
472 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
476 $pdf->setPageOrientation(
'', 1, 0);
477 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
483 $pdf->setPage($pageposafternote);
484 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
486 $height_note = $posyafter - $tab_top_newpage;
487 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
490 $pdf->commitTransaction();
491 $posyafter = $pdf->GetY();
492 $height_note = $posyafter - $tab_top;
493 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
496 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
498 $pdf->AddPage(
'',
'',
true);
501 $pdf->setPage($pageposafternote);
502 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
505 $posyafter = $tab_top_newpage;
509 $tab_height = $tab_height - $height_note;
510 $tab_top = $posyafter + 6;
521 $pdf->startTransaction();
522 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs);
523 $pdf->rollbackTransaction(
true);
526 $nexY = $tab_top + $this->tabTitleHeight;
529 $pageposbeforeprintlines = $pdf->getPage();
530 $pagenb = $pageposbeforeprintlines;
531 for ($i = 0; $i < $nblines; $i++) {
533 $pdf->SetFont(
'',
'', $default_font_size - 1);
534 $pdf->SetTextColor(0, 0, 0);
537 $imglinesize = array();
538 if (!empty($realpatharray[$i])) {
542 $pdf->setTopMargin($tab_top_newpage);
543 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
544 $pageposbefore = $pdf->getPage();
546 $showpricebeforepagebreak = 1;
548 $posYAfterDescription = 0;
552 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
553 $pdf->AddPage(
'',
'',
true);
554 if (!empty($tplidx)) {
555 $pdf->useTemplate($tplidx);
558 $pdf->setPage($pageposbefore + 1);
560 $curY = $tab_top_newpage;
563 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
564 $showpricebeforepagebreak = 1;
566 $showpricebeforepagebreak = 0;
571 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
572 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
574 $posYAfterImage = $curY + $imglinesize[
'height'];
580 $pdf->startTransaction();
582 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
584 $pageposafter = $pdf->getPage();
585 if ($pageposafter > $pageposbefore) {
586 $pdf->rollbackTransaction(
true);
588 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
590 $pageposafter = $pdf->getPage();
591 $posyafter = $pdf->GetY();
593 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
594 if ($i == ($nblines - 1)) {
595 $pdf->AddPage(
'',
'',
true);
596 if (!empty($tplidx)) {
597 $pdf->useTemplate($tplidx);
600 $pdf->setPage($pageposafter + 1);
605 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
606 $showpricebeforepagebreak = 1;
608 $showpricebeforepagebreak = 0;
613 $pdf->commitTransaction();
615 $posYAfterDescription = $pdf->GetY();
618 $nexY = max($pdf->GetY(), $posYAfterImage);
619 $pageposafter = $pdf->getPage();
621 $pdf->setPage($pageposbefore);
622 $pdf->setTopMargin($this->marge_haute);
623 $pdf->setPageOrientation(
'', 1, 0);
626 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
627 $pdf->setPage($pageposafter);
628 $curY = $tab_top_newpage;
632 if ($pageposafter > $pageposbefore) {
633 $pdf->setPage($pageposafter);
634 $curY = $tab_top_newpage;
637 $pdf->SetFont(
'',
'', $default_font_size - 1);
642 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
643 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
646 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
647 $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);
652 $this->
printStdColumnContent($pdf, $curY,
'weight', $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt);
653 $nexY = max($pdf->GetY(), $nexY);
658 $nexY = max($pdf->GetY(), $nexY);
663 $nexY = max($pdf->GetY(), $nexY);
668 $nexY = max($pdf->GetY(), $nexY);
673 $nexY = max($pdf->GetY(), $nexY);
677 if (!empty($object->lines[$i]->array_options)) {
678 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
680 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
682 $nexY = max($pdf->GetY(), $nexY);
688 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
689 $pdf->setPage($pageposafter);
690 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
692 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
693 $pdf->SetLineStyle(array(
'dash'=>0));
697 while ($pagenb < $pageposafter) {
698 $pdf->setPage($pagenb);
699 if ($pagenb == $pageposbeforeprintlines) {
700 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
702 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
704 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
706 $pdf->setPage($pagenb);
707 $pdf->setPageOrientation(
'', 1, 0);
709 $this->
_pagehead($pdf, $object, 0, $outputlangs);
711 if (!empty($tplidx)) {
712 $pdf->useTemplate($tplidx);
715 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
717 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
719 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
721 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
724 if (!empty($tplidx)) {
725 $pdf->useTemplate($tplidx);
729 $this->
_pagehead($pdf, $object, 0, $outputlangs);
736 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
737 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
739 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
740 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
744 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
747 $this->
_pagefoot($pdf, $object, $outputlangs);
748 if (method_exists($pdf,
'AliasNbPages')) {
749 $pdf->AliasNbPages();
754 $pdf->Output($file,
'F');
757 $hookmanager->initHooks(array(
'pdfgeneration'));
758 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
760 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
762 $this->error = $hookmanager->error;
763 $this->errors = $hookmanager->errors;
766 if (!empty($conf->global->MAIN_UMASK)) {
767 @chmod($file, octdec($conf->global->MAIN_UMASK));
770 $this->result = array(
'fullpath'=>$file);
774 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
778 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
795 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
798 global $conf, $mysoc;
806 $pdf->SetFont(
'',
'B', $default_font_size - 1);
809 $col1x = $this->posxweightvol - 50;
810 $col2x = $this->posxweightvol;
815 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
816 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
818 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
824 $totalWeighttoshow =
'';
825 $totalVolumetoshow =
'';
828 $tmparray = $object->getTotalWeightVolume();
829 $totalWeight = $tmparray[
'weight'];
830 $totalVolume = $tmparray[
'volume'];
831 $totalOrdered = $tmparray[
'ordered'];
832 $totalToShip = $tmparray[
'toship'];
834 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
835 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
836 $object->volume_units = $object->size_units * 3;
839 if ($totalWeight !=
'') {
842 if ($totalVolume !=
'') {
845 if ($object->trueWeight) {
846 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
848 if ($object->trueVolume) {
849 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
861 if ($totalWeighttoshow) {
866 if ($totalVolumetoshow) {
867 $y = $tab2_top + ($tab2_hl * $index);
884 $pdf->SetTextColor(0, 0, 0);
886 return ($tab2_top + ($tab2_hl * $index));
902 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
912 $currency = !empty($currency) ? $currency : $conf->currency;
916 $pdf->SetTextColor(0, 0, 0);
917 $pdf->SetFont(
'',
'', $default_font_size - 2);
919 if (empty($hidetop)) {
921 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
922 $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));
926 $pdf->SetDrawColor(128, 128, 128);
927 $pdf->SetFont(
'',
'', $default_font_size - 1);
930 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
933 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
935 if (empty($hidetop)) {
936 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
950 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
952 global $conf, $langs, $mysoc;
954 $langs->load(
"orders");
961 $pdf->SetTextColor(0, 0, 60);
962 $pdf->SetFont(
'',
'B', $default_font_size + 3);
966 $posy = $this->marge_haute;
967 $posx = $this->page_largeur - $this->marge_droite - $w;
969 $pdf->SetXY($this->marge_gauche, $posy);
972 if ($this->emetteur->logo) {
973 $logodir = $conf->mycompany->dir_output;
974 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
975 $logodir = $conf->mycompany->multidir_output[$object->entity];
978 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
980 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
982 if (is_readable($logo)) {
984 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
986 $pdf->SetTextColor(200, 0, 0);
987 $pdf->SetFont(
'',
'B', $default_font_size - 2);
988 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
989 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
992 $text = $this->emetteur->name;
993 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1000 $posx = $this->marge_gauche + 3;
1009 $pdf->SetDrawColor(128, 128, 128);
1017 $posx = $this->page_largeur - $w - $this->marge_droite;
1018 $posy = $this->marge_haute;
1020 $pdf->SetFont(
'',
'B', $default_font_size + 2);
1021 $pdf->SetXY($posx, $posy);
1022 $pdf->SetTextColor(0, 0, 60);
1023 $title = $outputlangs->transnoentities(
"SendingSheet");
1024 $pdf->MultiCell($w, 4, $title,
'',
'R');
1026 $pdf->SetFont(
'',
'', $default_font_size + 1);
1030 $pdf->SetXY($posx, $posy);
1031 $pdf->SetTextColor(0, 0, 60);
1032 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
1035 if (!empty($object->date_delivery)) {
1037 $pdf->SetXY($posx, $posy);
1038 $pdf->SetTextColor(0, 0, 60);
1039 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
1042 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1044 $pdf->SetXY($posx, $posy);
1045 $pdf->SetTextColor(0, 0, 60);
1046 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1050 $pdf->SetFont(
'',
'', $default_font_size + 3);
1054 $origin = $object->origin;
1055 $origin_id = $object->origin_id;
1058 if (!empty($conf->$origin->enabled)) {
1059 $outputlangs->load(
'orders');
1061 $classname = ucfirst($origin);
1062 $linkedobject =
new $classname($this->
db);
1063 $result = $linkedobject->fetch($origin_id);
1067 $pdf->SetFont(
'',
'', $default_font_size - 2);
1068 $text = $linkedobject->ref;
1069 if ($linkedobject->ref_client) {
1070 $text .=
' ('.$linkedobject->ref_client.
')';
1073 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1074 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1076 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1077 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1091 $carac_emetteur =
'';
1093 $arrayidcontact = array();
1094 if (!empty($origin) && is_object($object->$origin)) {
1095 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1097 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1098 $object->fetch_user(reset($arrayidcontact));
1099 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1102 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1105 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1106 $posx = $this->marge_gauche;
1107 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1108 $posx = $this->page_largeur - $this->marge_droite - 80;
1111 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1112 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1115 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1116 $pdf->SetTextColor(0, 0, 0);
1117 $pdf->SetFont(
'',
'', $default_font_size - 2);
1118 $pdf->SetXY($posx, $posy - 5);
1119 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1120 $pdf->SetXY($posx, $posy);
1121 $pdf->SetFillColor(230, 230, 230);
1122 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1123 $pdf->SetTextColor(0, 0, 60);
1124 $pdf->SetFillColor(255, 255, 255);
1128 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1129 $pdf->SetXY($posx + 2, $posy + 3);
1130 $pdf->SetFont(
'',
'B', $default_font_size);
1131 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1132 $posy = $pdf->getY();
1136 $pdf->SetXY($posx + 2, $posy);
1137 $pdf->SetFont(
'',
'', $default_font_size - 1);
1138 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1142 $usecontact =
false;
1143 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1144 if (count($arrayidcontact) > 0) {
1146 $result = $object->fetch_contact($arrayidcontact[0]);
1150 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)))) {
1151 $thirdparty = $object->contact;
1153 $thirdparty = $object->thirdparty;
1158 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1161 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1162 if ($this->page_largeur < 210) {
1165 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1166 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1167 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1168 $posx = $this->marge_gauche;
1172 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1173 $pdf->SetTextColor(0, 0, 0);
1174 $pdf->SetFont(
'',
'', $default_font_size - 2);
1175 $pdf->SetXY($posx + 2, $posy - 5);
1176 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1177 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1181 $pdf->SetXY($posx + 2, $posy + 3);
1182 $pdf->SetFont(
'',
'B', $default_font_size);
1183 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1185 $posy = $pdf->getY();
1188 $pdf->SetFont(
'',
'', $default_font_size - 1);
1189 $pdf->SetXY($posx + 2, $posy);
1190 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1193 $pdf->SetTextColor(0, 0, 0);
1207 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1209 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1210 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);
1223 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1225 global $conf, $hookmanager;
1228 $this->defaultContentsFieldsStyle = array(
1230 'padding' => array(1, 0.5, 1, 0.5),
1234 $this->defaultTitlesFieldsStyle = array(
1236 'padding' => array(0.5, 0, 0.5, 0),
1258 $this->cols[
'desc'] = array(
1263 'textkey' =>
'Designation',
1267 'padding' => array(0.5, 1, 0.5, 1.5),
1270 'padding' => array(1, 0.5, 1, 1.5),
1275 $this->cols[
'photo'] = array(
1277 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1280 'textkey' =>
'Photo',
1284 'padding' => array(0, 0, 0, 0),
1286 'border-left' =>
false,
1289 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto)) {
1290 $this->cols[
'photo'][
'status'] =
true;
1294 $this->cols[
'weight'] = array(
1299 'textkey' =>
'WeightVolShort'
1301 'border-left' =>
true,
1306 $this->cols[
'subprice'] = array(
1309 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1311 'textkey' =>
'PriceUHT'
1313 'border-left' =>
true,
1317 $this->cols[
'totalexcltax'] = array(
1320 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
1322 'textkey' =>
'TotalHT'
1324 'border-left' =>
true,
1328 $this->cols[
'qty_asked'] = array(
1331 'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
1333 'textkey' =>
'QtyOrdered'
1335 'border-left' =>
true,
1342 $this->cols[
'unit_order'] = array(
1345 'status' => empty($conf->global->PRODUCT_USE_UNITS) ? 0 : 1,
1349 'border-left' =>
true,
1356 $this->cols[
'qty_shipped'] = array(
1361 'textkey' =>
'QtyToShip'
1363 'border-left' =>
true,
1370 if (!empty($object->lines)) {
1371 $line = reset($object->lines);
1375 $parameters = array(
1376 'object' => $object,
1377 'outputlangs' => $outputlangs,
1378 'hidedetails' => $hidedetails,
1379 'hidedesc' => $hidedesc,
1380 'hideref' => $hideref
1383 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1386 } elseif (empty($reshook)) {
1387 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1389 $this->cols = $hookmanager->resArray;
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
getColumnStatus($colKey)
get column status from column key
printStdColumnContent($pdf, &$curY, $colKey, $columnText='')
print standard column content
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
getExtrafieldContent($object, $extrafieldKey, $outputlangs=null)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
Class to manage Dolibarr database access.
Parent class of sending receipts models.
Class to manage products or services.
Class to manage translations.
Class to build sending documents with model espadon.
__construct(DoliDB $db)
Constructor.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
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...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.