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';
58 public $update_main_doc_field;
69 public $phpmin = array(7, 0);
75 public $version =
'dolibarr';
100 public $marge_droite;
126 global $conf, $langs, $mysoc;
129 $this->
name =
"rouget";
130 $this->
description = $langs->trans(
"DocumentModelStandardPDF").
' ('.$langs->trans(
"OldImplementation").
')';
131 $this->update_main_doc_field = 1;
135 $this->page_largeur = $formatarray[
'width'];
136 $this->page_hauteur = $formatarray[
'height'];
137 $this->format = array($this->page_largeur, $this->page_hauteur);
143 $this->option_logo = 1;
144 $this->option_draft_watermark = 1;
145 $this->watermark =
'';
148 $this->emetteur = $mysoc;
149 if (!$this->emetteur->country_code) {
150 $this->emetteur->country_code = substr($langs->defaultlang, -2);
154 $this->posxdesc = $this->marge_gauche + 1;
155 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 82;
156 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 60;
157 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
158 $this->posxpuht = $this->page_largeur - $this->marge_droite;
160 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
161 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
162 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
163 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
164 $this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
165 $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
168 if (!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
169 $this->posxweightvol = $this->posxqtyordered;
172 $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
175 if ($this->page_largeur < 210) {
176 $this->posxweightvol -= 20;
177 $this->posxpicture -= 20;
178 $this->posxqtyordered -= 20;
179 $this->posxqtytoship -= 20;
182 if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
183 $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
184 $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
185 $this->posxqtyordered = $this->posxqtytoship;
201 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
204 global $user, $conf, $langs, $hookmanager;
206 $object->fetch_thirdparty();
208 if (!is_object($outputlangs)) {
209 $outputlangs = $langs;
212 if (!empty($conf->global->MAIN_USE_FPDF)) {
213 $outputlangs->charset_output =
'ISO-8859-1';
217 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch",
"other"));
220 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
221 $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK;
224 $nblines = count($object->lines);
227 $realpatharray = array();
228 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
231 for ($i = 0; $i < $nblines; $i++) {
232 if (empty($object->lines[$i]->fk_product)) {
237 $objphoto->fetch($object->lines[$i]->fk_product);
239 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
240 $dir = $conf->product->dir_output.
'/'.$pdir;
242 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
243 $dir = $conf->product->dir_output.
'/'.$pdir;
248 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
251 if ($obj[
'photo_vignette']) {
252 $filename = $obj[
'photo_vignette'];
254 $filename = $obj[
'photo'];
257 $filename = $obj[
'photo'];
260 $realpath = $dir.$filename;
265 $realpatharray[$i] = $realpath;
270 if (count($realpatharray) == 0) {
271 $this->posxpicture = $this->posxweightvol;
274 if ($conf->expedition->dir_output) {
276 if ($object->specimen) {
277 $dir = $conf->expedition->dir_output.
"/sending";
278 $file = $dir.
"/SPECIMEN.pdf";
281 $dir = $conf->expedition->dir_output.
"/sending/".$expref;
282 $file = $dir.
"/".$expref.
".pdf";
285 if (!file_exists($dir)) {
287 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
292 if (file_exists($dir)) {
294 if (!is_object($hookmanager)) {
295 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
298 $hookmanager->initHooks(array(
'pdfgeneration'));
299 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
301 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
304 $nblines = count($object->lines);
308 $heightforinfotot = 8;
309 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
310 $heightforfooter = $this->marge_basse + 8;
311 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
312 $heightforfooter += 6;
314 $pdf->SetAutoPageBreak(1, 0);
316 if (class_exists(
'TCPDF')) {
317 $pdf->setPrintHeader(
false);
318 $pdf->setPrintFooter(
false);
322 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
323 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
324 $tplidx = $pdf->importPage(1);
329 $pdf->SetDrawColor(128, 128, 128);
331 if (method_exists($pdf,
'AliasNbPages')) {
332 $pdf->AliasNbPages();
335 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
336 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
337 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
338 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
339 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
341 $pdf->SetCompression(
false);
344 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
348 if (!empty($tplidx)) {
349 $pdf->useTemplate($tplidx);
352 $this->
_pagehead($pdf, $object, 1, $outputlangs);
353 $pdf->SetFont(
'',
'', $default_font_size - 1);
354 $pdf->MultiCell(0, 3,
'');
355 $pdf->SetTextColor(0, 0, 0);
358 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
360 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
363 $height_incoterms = 0;
365 $desc_incoterms = $object->getIncotermsForPDF();
366 if ($desc_incoterms) {
369 $pdf->SetFont(
'',
'', $default_font_size - 1);
370 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
371 $nexY = $pdf->GetY();
372 $height_incoterms = $nexY - $tab_top;
375 $pdf->SetDrawColor(192, 192, 192);
376 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
378 $tab_top = $nexY + 6;
379 $height_incoterms += 4;
383 if (!empty($object->note_public) || !empty($object->tracking_number)) {
384 $tab_top = 88 + $height_incoterms;
385 $tab_top_alt = $tab_top;
387 $pdf->SetFont(
'',
'B', $default_font_size - 2);
392 if (!empty($object->tracking_number)) {
393 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
394 $tab_top_alt = $pdf->GetY();
396 $object->getUrlTrackingStatus($object->tracking_number);
397 if (!empty($object->tracking_url)) {
398 if ($object->shipping_method_id > 0) {
400 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
402 if ($object->tracking_url != $object->tracking_number) {
403 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
405 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
407 if ($object->tracking_url != $object->tracking_number) {
409 $label .= $object->tracking_url;
411 $pdf->SetFont(
'',
'B', $default_font_size - 2);
412 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
414 $tab_top_alt = $pdf->GetY();
420 if (!empty($object->note_public)) {
421 $pdf->SetFont(
'',
'', $default_font_size - 1);
422 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
425 $nexY = $pdf->GetY();
426 $height_note = $nexY - $tab_top;
429 $pdf->SetDrawColor(192, 192, 192);
430 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
432 $tab_height = $tab_height - $height_note;
433 $tab_top = $nexY + 6;
438 $iniY = $tab_top + 7;
439 $curY = $tab_top + 7;
440 $nexY = $tab_top + 7;
443 for ($i = 0; $i < $nblines; $i++) {
445 $pdf->SetFont(
'',
'', $default_font_size - 1);
446 $pdf->SetTextColor(0, 0, 0);
449 $imglinesize = array();
450 if (!empty($realpatharray[$i])) {
454 $pdf->setTopMargin($tab_top_newpage);
455 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
456 $pageposbefore = $pdf->getPage();
458 $showpricebeforepagebreak = 1;
460 $posYAfterDescription = 0;
463 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
464 $pdf->AddPage(
'',
'',
true);
465 if (!empty($tplidx)) {
466 $pdf->useTemplate($tplidx);
469 $this->
_pagehead($pdf, $object, 0, $outputlangs);
471 $pdf->setPage($pageposbefore + 1);
473 $curY = $tab_top_newpage;
476 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
477 $showpricebeforepagebreak = 1;
479 $showpricebeforepagebreak = 0;
483 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
484 $curX = $this->posxpicture - 1;
485 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
487 $posYAfterImage = $curY + $imglinesize[
'height'];
491 $curX = $this->posxdesc - 1;
493 $pdf->startTransaction();
494 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
496 $pageposafter = $pdf->getPage();
497 if ($pageposafter > $pageposbefore) {
498 $pdf->rollbackTransaction(
true);
499 $pageposafter = $pageposbefore;
501 $pdf->setPageOrientation(
'', 1, $heightforfooter);
502 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
504 $pageposafter = $pdf->getPage();
505 $posyafter = $pdf->GetY();
507 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
508 if ($i == ($nblines - 1)) {
509 $pdf->AddPage(
'',
'',
true);
510 if (!empty($tplidx)) {
511 $pdf->useTemplate($tplidx);
514 $this->
_pagehead($pdf, $object, 0, $outputlangs);
516 $pdf->setPage($pageposafter + 1);
522 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
523 $showpricebeforepagebreak = 1;
525 $showpricebeforepagebreak = 0;
530 $pdf->commitTransaction();
532 $posYAfterDescription = $pdf->GetY();
534 $nexY = $pdf->GetY();
535 $pageposafter = $pdf->getPage();
537 $pdf->setPage($pageposbefore);
538 $pdf->setTopMargin($this->marge_haute);
539 $pdf->setPageOrientation(
'', 1, 0);
542 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
543 $pdf->setPage($pageposafter);
544 $curY = $tab_top_newpage;
548 if ($pageposafter > $pageposbefore) {
549 $pdf->setPage($pageposafter);
550 $curY = $tab_top_newpage;
553 $pdf->SetFont(
'',
'', $default_font_size - 1);
555 $pdf->SetXY($this->posxweightvol, $curY);
557 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight) {
558 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
561 if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume) {
562 $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);
565 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
566 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
570 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
571 $pdf->SetXY($this->posxqtyordered, $curY);
572 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,
'',
'C');
575 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
576 $pdf->SetXY($this->posxqtytoship, $curY);
577 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,
'',
'C');
580 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
581 $pdf->SetXY($this->posxpuht, $curY);
582 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
584 $pdf->SetXY($this->posxtotalht, $curY);
585 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
589 if ($weighttxt && $voltxt) {
594 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
595 $pdf->setPage($pageposafter);
596 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
598 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
599 $pdf->SetLineStyle(array(
'dash'=>0));
603 while ($pagenb < $pageposafter) {
604 $pdf->setPage($pagenb);
606 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
608 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
610 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
612 $pdf->setPage($pagenb);
613 $pdf->setPageOrientation(
'', 1, 0);
615 $this->
_pagehead($pdf, $object, 0, $outputlangs);
617 if (!empty($tplidx)) {
618 $pdf->useTemplate($tplidx);
621 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
623 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
625 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
627 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
630 if (!empty($tplidx)) {
631 $pdf->useTemplate($tplidx);
635 $this->
_pagehead($pdf, $object, 0, $outputlangs);
642 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
643 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
645 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
646 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
650 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
653 $this->
_pagefoot($pdf, $object, $outputlangs);
654 if (method_exists($pdf,
'AliasNbPages')) {
655 $pdf->AliasNbPages();
660 $pdf->Output($file,
'F');
663 $hookmanager->initHooks(array(
'pdfgeneration'));
664 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
666 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
668 $this->error = $hookmanager->error;
669 $this->errors = $hookmanager->errors;
672 if (!empty($conf->global->MAIN_UMASK)) {
673 @chmod($file, octdec($conf->global->MAIN_UMASK));
676 $this->result = array(
'fullpath'=>$file);
680 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
684 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
701 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
704 global $conf, $mysoc;
712 $pdf->SetFont(
'',
'B', $default_font_size - 1);
715 $col1x = $this->posxweightvol - 50;
716 $col2x = $this->posxweightvol;
721 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
722 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
724 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
730 $totalWeighttoshow =
'';
731 $totalVolumetoshow =
'';
734 $tmparray = $object->getTotalWeightVolume();
735 $totalWeight = $tmparray[
'weight'];
736 $totalVolume = $tmparray[
'volume'];
737 $totalOrdered = $tmparray[
'ordered'];
738 $totalToShip = $tmparray[
'toship'];
740 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
741 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
742 $object->volume_units = $object->size_units * 3;
745 if ($totalWeight !=
'') {
748 if ($totalVolume !=
'') {
751 if (!empty($object->trueWeight)) {
752 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
754 if (!empty($object->trueVolume)) {
755 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
758 $pdf->SetFillColor(255, 255, 255);
759 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
760 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
762 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
763 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
764 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
767 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
768 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
769 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
772 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
773 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
774 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
776 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
777 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
780 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
782 if ($totalWeighttoshow) {
783 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
784 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
788 if ($totalVolumetoshow) {
789 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
790 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
794 if (!$totalWeighttoshow && !$totalVolumetoshow) {
799 $pdf->SetTextColor(0, 0, 0);
801 return ($tab2_top + ($tab2_hl * $index));
817 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
830 $pdf->SetTextColor(0, 0, 0);
831 $pdf->SetFont(
'',
'', $default_font_size - 2);
834 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
836 $pdf->SetDrawColor(128, 128, 128);
837 $pdf->SetFont(
'',
'', $default_font_size - 1);
839 if (empty($hidetop)) {
840 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
842 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
843 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
846 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
847 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
848 if (empty($hidetop)) {
849 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
850 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
854 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
855 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
856 if (empty($hidetop)) {
857 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
858 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
862 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
863 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
864 if (empty($hidetop)) {
865 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
866 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
"QtyToShip"),
'',
'C');
870 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
871 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
872 if (empty($hidetop)) {
873 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
874 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
877 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
878 if (empty($hidetop)) {
879 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
880 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
895 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
897 global $conf, $langs, $mysoc;
899 $langs->load(
"orders");
906 $pdf->SetTextColor(0, 0, 60);
907 $pdf->SetFont(
'',
'B', $default_font_size + 3);
911 $posy = $this->marge_haute;
912 $posx = $this->page_largeur - $this->marge_droite - $w;
914 $pdf->SetXY($this->marge_gauche, $posy);
917 if ($this->emetteur->logo) {
918 $logodir = $conf->mycompany->dir_output;
919 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
920 $logodir = $conf->mycompany->multidir_output[$object->entity];
923 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
925 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
927 if (is_readable($logo)) {
929 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
931 $pdf->SetTextColor(200, 0, 0);
932 $pdf->SetFont(
'',
'B', $default_font_size - 2);
933 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
934 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
937 $text = $this->emetteur->name;
938 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
945 $posx = $this->marge_gauche + 3;
954 $pdf->SetDrawColor(128, 128, 128);
962 $posx = $this->page_largeur - $w - $this->marge_droite;
963 $posy = $this->marge_haute;
965 $pdf->SetFont(
'',
'B', $default_font_size + 2);
966 $pdf->SetXY($posx, $posy);
967 $pdf->SetTextColor(0, 0, 60);
968 $title = $outputlangs->transnoentities(
"SendingSheet");
969 $pdf->MultiCell($w, 4, $title,
'',
'R');
971 $pdf->SetFont(
'',
'', $default_font_size + 1);
975 $pdf->SetXY($posx, $posy);
976 $pdf->SetTextColor(0, 0, 60);
977 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
980 if (!empty($object->date_delivery)) {
982 $pdf->SetXY($posx, $posy);
983 $pdf->SetTextColor(0, 0, 60);
984 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
987 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
989 $pdf->SetXY($posx, $posy);
990 $pdf->SetTextColor(0, 0, 60);
991 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
995 $pdf->SetFont(
'',
'', $default_font_size + 3);
999 $origin = $object->origin;
1000 $origin_id = $object->origin_id;
1003 if (!empty($conf->$origin->enabled)) {
1004 $outputlangs->load(
'orders');
1006 $classname = ucfirst($origin);
1007 $linkedobject =
new $classname($this->
db);
1008 $result = $linkedobject->fetch($origin_id);
1012 $pdf->SetFont(
'',
'', $default_font_size - 2);
1013 $text = $linkedobject->ref;
1014 if ($linkedobject->ref_client) {
1015 $text .=
' ('.$linkedobject->ref_client.
')';
1018 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1019 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1021 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1022 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1038 $carac_emetteur =
'';
1040 $arrayidcontact = array();
1041 if (!empty($origin) && is_object($object->$origin)) {
1042 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1044 if (count($arrayidcontact) > 0) {
1045 $object->fetch_user(reset($arrayidcontact));
1046 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1049 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1052 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1053 $posx = $this->marge_gauche;
1054 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1055 $posx = $this->page_largeur - $this->marge_droite - 80;
1058 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1059 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1062 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1063 $pdf->SetTextColor(0, 0, 0);
1064 $pdf->SetFont(
'',
'', $default_font_size - 2);
1065 $pdf->SetXY($posx, $posy - 5);
1066 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1067 $pdf->SetXY($posx, $posy);
1068 $pdf->SetFillColor(230, 230, 230);
1069 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1070 $pdf->SetTextColor(0, 0, 60);
1071 $pdf->SetFillColor(255, 255, 255);
1075 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1076 $pdf->SetXY($posx + 2, $posy + 3);
1077 $pdf->SetFont(
'',
'B', $default_font_size);
1078 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1079 $posy = $pdf->getY();
1083 $pdf->SetXY($posx + 2, $posy);
1084 $pdf->SetFont(
'',
'', $default_font_size - 1);
1085 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1089 $usecontact =
false;
1090 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1091 if (count($arrayidcontact) > 0) {
1093 $result = $object->fetch_contact($arrayidcontact[0]);
1097 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)))) {
1098 $thirdparty = $object->contact;
1100 $thirdparty = $object->thirdparty;
1105 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1108 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1109 if ($this->page_largeur < 210) {
1112 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1113 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1114 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1115 $posx = $this->marge_gauche;
1119 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1120 $pdf->SetTextColor(0, 0, 0);
1121 $pdf->SetFont(
'',
'', $default_font_size - 2);
1122 $pdf->SetXY($posx + 2, $posy - 5);
1123 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1124 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1128 $pdf->SetXY($posx + 2, $posy + 3);
1129 $pdf->SetFont(
'',
'B', $default_font_size);
1130 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1132 $posy = $pdf->getY();
1135 $pdf->SetFont(
'',
'', $default_font_size - 1);
1136 $pdf->SetXY($posx + 2, $posy);
1137 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1140 $pdf->SetTextColor(0, 0, 0);
1154 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1156 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1157 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);
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage Dolibarr database access.
Parent class of sending receipts models.
Class to manage products or services.
Class to build sending documents with model Rouget.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct(DoliDB $db)
Constructor.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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.
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_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
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_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.