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/product.lib.php';
64 public $phpmin = array(5, 6);
70 public $version =
'dolibarr';
121 global $conf, $langs, $mysoc;
124 $this->
name =
"rouget";
125 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
129 $this->page_largeur = $formatarray[
'width'];
130 $this->page_hauteur = $formatarray[
'height'];
131 $this->format = array($this->page_largeur, $this->page_hauteur);
132 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
133 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
134 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
135 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
137 $this->option_logo = 1;
140 $this->emetteur = $mysoc;
141 if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2);
144 $this->posxdesc = $this->marge_gauche + 1;
145 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 82;
146 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 60;
147 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
148 $this->posxpuht = $this->page_largeur - $this->marge_droite;
150 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
151 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
152 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
153 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
154 $this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
155 $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
158 if (!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqtyordered;
160 $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
163 if ($this->page_largeur < 210) {
164 $this->posxweightvol -= 20;
165 $this->posxpicture -= 20;
166 $this->posxqtyordered -= 20;
167 $this->posxqtytoship -= 20;
170 if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
171 $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
172 $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
173 $this->posxqtyordered = $this->posxqtytoship;
189 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
192 global $user, $conf, $langs, $hookmanager;
194 $object->fetch_thirdparty();
196 if (!is_object($outputlangs)) $outputlangs = $langs;
198 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
201 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch"));
203 $nblines = count($object->lines);
206 $realpatharray = array();
207 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
211 for ($i = 0; $i < $nblines; $i++)
213 if (empty($object->lines[$i]->fk_product))
continue;
216 $objphoto->fetch($object->lines[$i]->fk_product);
217 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
219 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
220 $dir = $conf->product->dir_output.
'/'.$pdir;
222 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
223 $dir = $conf->product->dir_output.
'/'.$pdir;
228 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
229 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
231 if ($obj[
'photo_vignette'])
233 $filename = $obj[
'photo_vignette'];
235 $filename = $obj[
'photo'];
238 $filename = $obj[
'photo'];
241 $realpath = $dir.$filename;
245 if ($realpath) $realpatharray[$i] = $realpath;
249 if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
251 if ($conf->expedition->dir_output)
254 if ($object->specimen)
256 $dir = $conf->expedition->dir_output.
"/sending";
257 $file = $dir.
"/SPECIMEN.pdf";
260 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
261 $file = $dir.
"/".$expref.
".pdf";
264 if (!file_exists($dir))
268 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
273 if (file_exists($dir))
276 if (!is_object($hookmanager))
278 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
281 $hookmanager->initHooks(array(
'pdfgeneration'));
282 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
284 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
287 $nblines = count($object->lines);
291 $heightforinfotot = 8;
292 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
293 $heightforfooter = $this->marge_basse + 8;
294 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
295 $pdf->SetAutoPageBreak(1, 0);
297 if (class_exists(
'TCPDF'))
299 $pdf->setPrintHeader(
false);
300 $pdf->setPrintFooter(
false);
304 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
306 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
307 $tplidx = $pdf->importPage(1);
312 $pdf->SetDrawColor(128, 128, 128);
314 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
316 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
317 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
318 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
319 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
320 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
321 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
323 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
327 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
329 $this->
_pagehead($pdf, $object, 1, $outputlangs);
330 $pdf->SetFont(
'',
'', $default_font_size - 1);
331 $pdf->MultiCell(0, 3,
'');
332 $pdf->SetTextColor(0, 0, 0);
335 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
337 $tab_height_newpage = 150;
340 $height_incoterms = 0;
341 if (!empty($conf->incoterm->enabled))
343 $desc_incoterms = $object->getIncotermsForPDF();
348 $pdf->SetFont(
'',
'', $default_font_size - 1);
349 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
350 $nexY = $pdf->GetY();
351 $height_incoterms = $nexY - $tab_top;
354 $pdf->SetDrawColor(192, 192, 192);
355 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
357 $tab_top = $nexY + 6;
358 $height_incoterms += 4;
362 if (!empty($object->note_public) || !empty($object->tracking_number))
364 $tab_top = 88 + $height_incoterms;
365 $tab_top_alt = $tab_top;
367 $pdf->SetFont(
'',
'B', $default_font_size - 2);
372 if (!empty($object->tracking_number))
374 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
375 $tab_top_alt = $pdf->GetY();
377 $object->getUrlTrackingStatus($object->tracking_number);
378 if (!empty($object->tracking_url))
380 if ($object->shipping_method_id > 0)
383 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
385 if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
386 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
388 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_alt = $pdf->GetY();
402 if (!empty($object->note_public))
404 $pdf->SetFont(
'',
'', $default_font_size - 1);
405 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
408 $nexY = $pdf->GetY();
409 $height_note = $nexY - $tab_top;
412 $pdf->SetDrawColor(192, 192, 192);
413 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
415 $tab_height = $tab_height - $height_note;
416 $tab_top = $nexY + 6;
421 $iniY = $tab_top + 7;
422 $curY = $tab_top + 7;
423 $nexY = $tab_top + 7;
426 for ($i = 0; $i < $nblines; $i++)
429 $pdf->SetFont(
'',
'', $default_font_size - 1);
430 $pdf->SetTextColor(0, 0, 0);
433 $imglinesize = array();
436 $pdf->setTopMargin($tab_top_newpage);
437 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
438 $pageposbefore = $pdf->getPage();
440 $showpricebeforepagebreak = 1;
442 $posYAfterDescription = 0;
445 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
447 $pdf->AddPage(
'',
'',
true);
448 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
449 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
450 $pdf->setPage($pageposbefore + 1);
452 $curY = $tab_top_newpage;
455 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
456 $showpricebeforepagebreak = 1;
457 else $showpricebeforepagebreak = 0;
460 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']))
462 $curX = $this->posxpicture - 1;
463 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
465 $posYAfterImage = $curY + $imglinesize[
'height'];
469 $curX = $this->posxdesc - 1;
471 $pdf->startTransaction();
472 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
474 $pageposafter = $pdf->getPage();
475 if ($pageposafter > $pageposbefore)
477 $pdf->rollbackTransaction(
true);
478 $pageposafter = $pageposbefore;
480 $pdf->setPageOrientation(
'', 1, $heightforfooter);
481 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
483 $pageposafter = $pdf->getPage();
484 $posyafter = $pdf->GetY();
486 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
488 if ($i == ($nblines - 1))
490 $pdf->AddPage(
'',
'',
true);
491 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
492 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
493 $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();
509 $nexY = $pdf->GetY();
510 $pageposafter = $pdf->getPage();
512 $pdf->setPage($pageposbefore);
513 $pdf->setTopMargin($this->marge_haute);
514 $pdf->setPageOrientation(
'', 1, 0);
517 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
518 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
522 if ($pageposafter > $pageposbefore) {
523 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
526 $pdf->SetFont(
'',
'', $default_font_size - 1);
528 $pdf->SetXY($this->posxweightvol, $curY);
530 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight)
532 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
535 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume)
537 $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);
540 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
542 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
546 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
548 $pdf->SetXY($this->posxqtyordered, $curY);
549 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,
'',
'C');
552 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
554 $pdf->SetXY($this->posxqtytoship, $curY);
555 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,
'',
'C');
558 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
560 $pdf->SetXY($this->posxpuht, $curY);
561 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
563 $pdf->SetXY($this->posxtotalht, $curY);
564 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
568 if ($weighttxt && $voltxt) $nexY += 2;
571 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
573 $pdf->setPage($pageposafter);
574 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
576 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
577 $pdf->SetLineStyle(array(
'dash'=>0));
581 while ($pagenb < $pageposafter)
583 $pdf->setPage($pagenb);
586 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
588 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
590 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
592 $pdf->setPage($pagenb);
593 $pdf->setPageOrientation(
'', 1, 0);
594 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
596 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
600 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
602 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
604 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
607 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
609 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
616 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
617 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
619 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
620 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
624 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
627 $this->
_pagefoot($pdf, $object, $outputlangs);
628 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
632 $pdf->Output($file,
'F');
635 $hookmanager->initHooks(array(
'pdfgeneration'));
636 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
638 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
641 $this->error = $hookmanager->error;
642 $this->errors = $hookmanager->errors;
645 if (!empty($conf->global->MAIN_UMASK))
646 @chmod($file, octdec($conf->global->MAIN_UMASK));
648 $this->result = array(
'fullpath'=>$file);
652 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
656 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
673 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
676 global $conf, $mysoc;
684 $pdf->SetFont(
'',
'B', $default_font_size - 1);
687 $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
692 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
693 else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
698 $totalWeighttoshow =
'';
699 $totalVolumetoshow =
'';
702 $tmparray = $object->getTotalWeightVolume();
703 $totalWeight = $tmparray[
'weight'];
704 $totalVolume = $tmparray[
'volume'];
705 $totalOrdered = $tmparray[
'ordered'];
706 $totalToShip = $tmparray[
'toship'];
708 if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
710 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
711 $object->volume_units = $object->size_units * 3;
716 if (!empty($object->trueWeight)) $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
717 if (!empty($object->trueVolume)) $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
719 $pdf->SetFillColor(255, 255, 255);
720 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
721 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
723 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
725 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
726 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
729 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
731 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
732 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
735 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
737 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
738 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
740 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
741 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
744 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
747 if ($totalWeighttoshow)
749 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
750 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
754 if ($totalVolumetoshow)
756 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
757 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
761 if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
764 $pdf->SetTextColor(0, 0, 0);
766 return ($tab2_top + ($tab2_hl * $index));
782 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
788 if ($hidetop) $hidetop = -1;
793 $pdf->SetTextColor(0, 0, 0);
794 $pdf->SetFont(
'',
'', $default_font_size - 2);
797 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
799 $pdf->SetDrawColor(128, 128, 128);
800 $pdf->SetFont(
'',
'', $default_font_size - 1);
804 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
806 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
807 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
810 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
812 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
815 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
816 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
820 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
822 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
825 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
826 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
830 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
832 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
835 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
836 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
"QtyToShip"),
'',
'C');
840 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
841 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
844 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
845 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
848 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
851 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
852 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
867 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
869 global $conf, $langs, $mysoc;
871 $langs->load(
"orders");
878 if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
880 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
884 $pdf->SetTextColor(0, 0, 60);
885 $pdf->SetFont(
'',
'B', $default_font_size + 3);
889 $posy = $this->marge_haute;
890 $posx = $this->page_largeur - $this->marge_droite - $w;
892 $pdf->SetXY($this->marge_gauche, $posy);
895 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
896 if ($this->emetteur->logo)
898 if (is_readable($logo))
901 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
903 $pdf->SetTextColor(200, 0, 0);
904 $pdf->SetFont(
'',
'B', $default_font_size - 2);
905 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
906 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
909 $text = $this->emetteur->name;
910 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
914 if (!empty($conf->barcode->enabled))
918 $posx = $this->marge_gauche + 3;
921 if (!empty($conf->barcode->enabled))
928 $pdf->SetDrawColor(128, 128, 128);
929 if (!empty($conf->barcode->enabled))
937 $posx = $this->page_largeur - $w - $this->marge_droite;
938 $posy = $this->marge_haute;
940 $pdf->SetFont(
'',
'B', $default_font_size + 2);
941 $pdf->SetXY($posx, $posy);
942 $pdf->SetTextColor(0, 0, 60);
943 $title = $outputlangs->transnoentities(
"SendingSheet");
944 $pdf->MultiCell($w, 4, $title,
'',
'R');
946 $pdf->SetFont(
'',
'', $default_font_size + 1);
950 $pdf->SetXY($posx, $posy);
951 $pdf->SetTextColor(0, 0, 60);
952 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
955 if (!empty($object->date_delivery))
958 $pdf->SetXY($posx, $posy);
959 $pdf->SetTextColor(0, 0, 60);
960 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
963 if (!empty($object->thirdparty->code_client))
966 $pdf->SetXY($posx, $posy);
967 $pdf->SetTextColor(0, 0, 60);
968 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
972 $pdf->SetFont(
'',
'', $default_font_size + 3);
976 $origin = $object->origin;
977 $origin_id = $object->origin_id;
980 if (!empty($conf->$origin->enabled))
982 $outputlangs->load(
'orders');
984 $classname = ucfirst($origin);
985 $linkedobject =
new $classname($this->
db);
986 $result = $linkedobject->fetch($origin_id);
991 $pdf->SetFont(
'',
'', $default_font_size - 2);
992 $text = $linkedobject->ref;
993 if ($linkedobject->ref_client) $text .=
' ('.$linkedobject->ref_client.
')';
995 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
996 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
998 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
999 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1006 $carac_emetteur =
'';
1008 $arrayidcontact = array();
1009 if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1010 if (count($arrayidcontact) > 0)
1012 $object->fetch_user(reset($arrayidcontact));
1013 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1016 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1019 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1020 $posx = $this->marge_gauche;
1021 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1023 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1024 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1027 $pdf->SetTextColor(0, 0, 0);
1028 $pdf->SetFont(
'',
'', $default_font_size - 2);
1029 $pdf->SetXY($posx, $posy - 5);
1030 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1031 $pdf->SetXY($posx, $posy);
1032 $pdf->SetFillColor(230, 230, 230);
1033 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1034 $pdf->SetTextColor(0, 0, 60);
1035 $pdf->SetFillColor(255, 255, 255);
1038 $pdf->SetXY($posx + 2, $posy + 3);
1039 $pdf->SetFont(
'',
'B', $default_font_size);
1040 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1041 $posy = $pdf->getY();
1044 $pdf->SetXY($posx + 2, $posy);
1045 $pdf->SetFont(
'',
'', $default_font_size - 1);
1046 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1050 $usecontact =
false;
1051 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1052 if (count($arrayidcontact) > 0)
1055 $result = $object->fetch_contact($arrayidcontact[0]);
1059 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)))) {
1060 $thirdparty = $object->contact;
1062 $thirdparty = $object->thirdparty;
1067 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact,
'targetwithdetails', $object);
1070 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1071 if ($this->page_largeur < 210) $widthrecbox = 84;
1072 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1073 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1074 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1077 $pdf->SetTextColor(0, 0, 0);
1078 $pdf->SetFont(
'',
'', $default_font_size - 2);
1079 $pdf->SetXY($posx + 2, $posy - 5);
1080 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1081 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1084 $pdf->SetXY($posx + 2, $posy + 3);
1085 $pdf->SetFont(
'',
'B', $default_font_size);
1086 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1088 $posy = $pdf->getY();
1091 $pdf->SetFont(
'',
'', $default_font_size - 1);
1092 $pdf->SetXY($posx + 2, $posy);
1093 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1096 $pdf->SetTextColor(0, 0, 0);
1109 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1112 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1113 return pdf_pagefoot($pdf, $outputlangs,
'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
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.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
</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.
Parent class of sending receipts models.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
Class to build sending documents with model Rouget.
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...
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.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
$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...
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.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
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).
__construct($db=0)
Constructor.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
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.