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;
674 $this->result = array(
'fullpath'=>$file);
678 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
682 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
699 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
702 global $conf, $mysoc;
710 $pdf->SetFont(
'',
'B', $default_font_size - 1);
713 $col1x = $this->posxweightvol - 50;
714 $col2x = $this->posxweightvol;
719 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
720 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
722 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
728 $totalWeighttoshow =
'';
729 $totalVolumetoshow =
'';
732 $tmparray = $object->getTotalWeightVolume();
733 $totalWeight = $tmparray[
'weight'];
734 $totalVolume = $tmparray[
'volume'];
735 $totalOrdered = $tmparray[
'ordered'];
736 $totalToShip = $tmparray[
'toship'];
738 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
739 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
740 $object->volume_units = $object->size_units * 3;
743 if ($totalWeight !=
'') {
746 if ($totalVolume !=
'') {
749 if (!empty($object->trueWeight)) {
750 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
752 if (!empty($object->trueVolume)) {
753 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
756 $pdf->SetFillColor(255, 255, 255);
757 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
758 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
760 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
761 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
762 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
765 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
766 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
767 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
770 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
771 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
772 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
774 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
775 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
778 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
780 if ($totalWeighttoshow) {
781 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
782 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
786 if ($totalVolumetoshow) {
787 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
788 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
792 if (!$totalWeighttoshow && !$totalVolumetoshow) {
797 $pdf->SetTextColor(0, 0, 0);
799 return ($tab2_top + ($tab2_hl * $index));
815 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
828 $pdf->SetTextColor(0, 0, 0);
829 $pdf->SetFont(
'',
'', $default_font_size - 2);
832 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
834 $pdf->SetDrawColor(128, 128, 128);
835 $pdf->SetFont(
'',
'', $default_font_size - 1);
837 if (empty($hidetop)) {
838 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
840 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
841 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
844 if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) {
845 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
846 if (empty($hidetop)) {
847 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
848 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
852 if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
853 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
854 if (empty($hidetop)) {
855 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
856 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
860 if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) {
861 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
862 if (empty($hidetop)) {
863 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
864 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
"QtyToShip"),
'',
'C');
868 if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
869 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
870 if (empty($hidetop)) {
871 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
872 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
875 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
876 if (empty($hidetop)) {
877 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
878 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
893 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
895 global $conf, $langs, $mysoc;
897 $langs->load(
"orders");
904 $pdf->SetTextColor(0, 0, 60);
905 $pdf->SetFont(
'',
'B', $default_font_size + 3);
909 $posy = $this->marge_haute;
910 $posx = $this->page_largeur - $this->marge_droite - $w;
912 $pdf->SetXY($this->marge_gauche, $posy);
915 if ($this->emetteur->logo) {
916 $logodir = $conf->mycompany->dir_output;
917 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
918 $logodir = $conf->mycompany->multidir_output[$object->entity];
921 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
923 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
925 if (is_readable($logo)) {
927 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
929 $pdf->SetTextColor(200, 0, 0);
930 $pdf->SetFont(
'',
'B', $default_font_size - 2);
931 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
932 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
935 $text = $this->emetteur->name;
936 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
943 $posx = $this->marge_gauche + 3;
952 $pdf->SetDrawColor(128, 128, 128);
960 $posx = $this->page_largeur - $w - $this->marge_droite;
961 $posy = $this->marge_haute;
963 $pdf->SetFont(
'',
'B', $default_font_size + 2);
964 $pdf->SetXY($posx, $posy);
965 $pdf->SetTextColor(0, 0, 60);
966 $title = $outputlangs->transnoentities(
"SendingSheet");
967 $pdf->MultiCell($w, 4, $title,
'',
'R');
969 $pdf->SetFont(
'',
'', $default_font_size + 1);
973 $pdf->SetXY($posx, $posy);
974 $pdf->SetTextColor(0, 0, 60);
975 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefSending").
" : ".$object->ref,
'',
'R');
978 if (!empty($object->date_delivery)) {
980 $pdf->SetXY($posx, $posy);
981 $pdf->SetTextColor(0, 0, 60);
982 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
985 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
987 $pdf->SetXY($posx, $posy);
988 $pdf->SetTextColor(0, 0, 60);
989 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
993 $pdf->SetFont(
'',
'', $default_font_size + 3);
997 $origin = $object->origin;
998 $origin_id = $object->origin_id;
1001 if (!empty($conf->$origin->enabled)) {
1002 $outputlangs->load(
'orders');
1004 $classname = ucfirst($origin);
1005 $linkedobject =
new $classname($this->
db);
1006 $result = $linkedobject->fetch($origin_id);
1010 $pdf->SetFont(
'',
'', $default_font_size - 2);
1011 $text = $linkedobject->ref;
1012 if ($linkedobject->ref_client) {
1013 $text .=
' ('.$linkedobject->ref_client.
')';
1016 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1017 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1019 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1020 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1036 $carac_emetteur =
'';
1038 $arrayidcontact = array();
1039 if (!empty($origin) && is_object($object->$origin)) {
1040 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
1042 if (count($arrayidcontact) > 0) {
1043 $object->fetch_user(reset($arrayidcontact));
1044 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1047 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1050 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1051 $posx = $this->marge_gauche;
1052 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1053 $posx = $this->page_largeur - $this->marge_droite - 80;
1056 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1057 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1060 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1061 $pdf->SetTextColor(0, 0, 0);
1062 $pdf->SetFont(
'',
'', $default_font_size - 2);
1063 $pdf->SetXY($posx, $posy - 5);
1064 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1065 $pdf->SetXY($posx, $posy);
1066 $pdf->SetFillColor(230, 230, 230);
1067 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1068 $pdf->SetTextColor(0, 0, 60);
1069 $pdf->SetFillColor(255, 255, 255);
1073 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1074 $pdf->SetXY($posx + 2, $posy + 3);
1075 $pdf->SetFont(
'',
'B', $default_font_size);
1076 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1077 $posy = $pdf->getY();
1081 $pdf->SetXY($posx + 2, $posy);
1082 $pdf->SetFont(
'',
'', $default_font_size - 1);
1083 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1087 $usecontact =
false;
1088 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1089 if (count($arrayidcontact) > 0) {
1091 $result = $object->fetch_contact($arrayidcontact[0]);
1095 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)))) {
1096 $thirdparty = $object->contact;
1098 $thirdparty = $object->thirdparty;
1103 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1106 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1107 if ($this->page_largeur < 210) {
1110 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1111 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1112 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1113 $posx = $this->marge_gauche;
1117 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1118 $pdf->SetTextColor(0, 0, 0);
1119 $pdf->SetFont(
'',
'', $default_font_size - 2);
1120 $pdf->SetXY($posx + 2, $posy - 5);
1121 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1122 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1126 $pdf->SetXY($posx + 2, $posy + 3);
1127 $pdf->SetFont(
'',
'B', $default_font_size);
1128 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1130 $posy = $pdf->getY();
1133 $pdf->SetFont(
'',
'', $default_font_size - 1);
1134 $pdf->SetXY($posx + 2, $posy);
1135 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1138 $pdf->SetTextColor(0, 0, 0);
1152 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1154 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1155 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);