31 require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
32 require_once DOL_DOCUMENT_ROOT.
'/delivery/class/delivery.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
60 public $update_main_doc_field;
71 public $phpmin = array(5, 6);
77 public $version =
'dolibarr';
102 public $marge_droite;
127 global $conf, $langs, $mysoc;
130 $langs->loadLangs(array(
"main",
"bills",
"sendings",
"companies"));
133 $this->
name =
"Storm";
134 $this->
description = $langs->trans(
"DocumentModelStorm");
135 $this->update_main_doc_field = 1;
140 $this->page_largeur = $formatarray[
'width'];
141 $this->page_hauteur = $formatarray[
'height'];
142 $this->format = array($this->page_largeur, $this->page_hauteur);
143 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
144 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
145 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
146 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
148 $this->option_logo = 1;
149 $this->option_tva = 1;
152 $this->emetteur = $mysoc;
153 if (empty($this->emetteur->country_code)) {
154 $this->emetteur->country_code = substr($langs->defaultlang, -2);
157 $this->tva = array();
158 $this->tva_array = array();
159 $this->localtax1 = array();
160 $this->localtax2 = array();
161 $this->atleastoneratenotnull = 0;
162 $this->atleastonediscount = 0;
178 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
181 global $user, $langs, $conf, $mysoc, $hookmanager;
183 if (!is_object($outputlangs)) {
184 $outputlangs = $langs;
187 if (!empty($conf->global->MAIN_USE_FPDF)) {
188 $outputlangs->charset_output =
'ISO-8859-1';
192 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"sendings",
"deliveries"));
194 if ($conf->expedition->dir_output) {
195 $object->fetch_thirdparty();
198 if ($object->specimen) {
199 $dir = $conf->expedition->dir_output.
"/receipt";
200 $file = $dir.
"/SPECIMEN.pdf";
203 $dir = $conf->expedition->dir_output.
"/receipt/".$objectref;
204 $file = $dir.
"/".$objectref.
".pdf";
207 if (!file_exists($dir)) {
209 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
214 if (file_exists($dir)) {
216 if (!is_object($hookmanager)) {
217 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
220 $hookmanager->initHooks(array(
'pdfgeneration'));
221 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
223 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
225 $nblines = count($object->lines);
229 $realpatharray = array();
230 $this->atleastonephoto =
false;
231 if (!empty($conf->global->MAIN_GENERATE_DELIVERY_WITH_PICTURE)) {
234 for ($i = 0; $i < $nblines; $i++) {
235 if (empty($object->lines[$i]->fk_product)) {
239 $objphoto->fetch($object->lines[$i]->fk_product);
241 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
242 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
243 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
245 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
246 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
250 foreach ($pdir as $midir) {
252 $dir = $conf->product->dir_output.
'/'.$midir;
254 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
255 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
256 if ($obj[
'photo_vignette']) {
257 $filename = $obj[
'photo_vignette'];
259 $filename = $obj[
'photo'];
262 $filename = $obj[
'photo'];
265 $realpath = $dir.$filename;
267 $this->atleastonephoto =
true;
272 if ($realpath && $arephoto) {
273 $realpatharray[$i] = $realpath;
278 if (count($realpatharray) == 0) {
279 $this->posxpicture = $this->posxweightvol;
287 $heightforinfotot = 30;
288 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
289 $heightforfooter = $this->marge_basse + 8;
290 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
291 $heightforfooter += 6;
293 $pdf->SetAutoPageBreak(1, 0);
295 if (class_exists(
'TCPDF')) {
296 $pdf->setPrintHeader(
false);
297 $pdf->setPrintFooter(
false);
301 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
302 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
303 $tplidx = $pdf->importPage(1);
308 $result = $expedition->fetch($object->origin_id);
311 if ($expedition->origin ==
'commande') {
312 $commande->fetch($expedition->origin_id);
314 $object->commande = $commande;
315 $object->commande->loadExpeditions();
320 $pdf->SetDrawColor(128, 128, 128);
322 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
323 $pdf->SetSubject($outputlangs->transnoentities(
"DeliveryOrder"));
324 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
325 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
326 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"DeliveryOrder"));
327 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
328 $pdf->SetCompression(
false);
331 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
336 if (!empty($tplidx)) {
337 $pdf->useTemplate($tplidx);
340 $this->
_pagehead($pdf, $object, 1, $outputlangs);
341 $pdf->SetFont(
'',
'', $default_font_size - 1);
342 $pdf->MultiCell(0, 3,
'');
343 $pdf->SetTextColor(0, 0, 0);
346 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
348 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
350 $this->posxdesc = $this->marge_gauche + 1;
353 $height_incoterms = 0;
354 if (!empty($conf->incoterm->enabled)) {
355 $desc_incoterms = $object->getIncotermsForPDF();
356 if ($desc_incoterms) {
359 $pdf->SetFont(
'',
'', $default_font_size - 1);
360 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
361 $nexY = $pdf->GetY();
362 $height_incoterms = $nexY - $tab_top;
365 $pdf->SetDrawColor(192, 192, 192);
366 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
368 $tab_top = $nexY + 6;
369 $height_incoterms += 4;
374 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
377 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
378 if (!empty($extranote)) {
382 if (!empty($notetoshow)) {
383 $tab_top = 88 + $height_incoterms;
385 $pdf->SetFont(
'',
'', $default_font_size - 1);
386 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
387 $nexY = $pdf->GetY();
388 $height_note = $nexY - $tab_top;
391 $pdf->SetDrawColor(192, 192, 192);
392 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
394 $tab_height = $tab_height - $height_note;
395 $tab_top = $nexY + 6;
404 $pdf->startTransaction();
405 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, 0);
406 $pdf->rollbackTransaction(
true);
408 $iniY = $tab_top + $this->tabTitleHeight + 2;
409 $curY = $tab_top + $this->tabTitleHeight + 2;
410 $nexY = $tab_top + $this->tabTitleHeight + 2;
413 for ($i = 0; $i < $nblines; $i++) {
415 if (empty($object->lines[$i]->array_options)) {
416 $object->lines[$i]->fetch_optionals();
420 $pdf->SetFont(
'',
'', $default_font_size - 1);
421 $pdf->SetTextColor(0, 0, 0);
424 $imglinesize = array();
425 if (!empty($realpatharray[$i])) {
430 $pdf->setTopMargin($tab_top_newpage);
431 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
432 $pageposbefore = $pdf->getPage();
435 $curX = $this->posxdesc - 1;
437 $showpricebeforepagebreak = 1;
440 $posYAfterDescription = 0;
443 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
444 $pdf->AddPage(
'',
'',
true);
445 if (!empty($tplidx)) {
446 $pdf->useTemplate($tplidx);
449 $pdf->setPage($pageposbefore + 1);
451 $curY = $tab_top_newpage;
454 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
455 $showpricebeforepagebreak = 1;
457 $showpricebeforepagebreak = 0;
462 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
463 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
465 $posYAfterImage = $curY + $imglinesize[
'height'];
472 $pdf->startTransaction();
474 $pageposafter = $pdf->getPage();
475 if ($pageposafter > $pageposbefore) {
476 $pdf->rollbackTransaction(
true);
477 $pageposafter = $pageposbefore;
479 $pdf->setPageOrientation(
'', 1, $heightforfooter);
481 $posyafter = $pdf->GetY();
482 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
483 if ($i == ($nblines - 1)) {
484 $pdf->AddPage(
'',
'',
true);
485 if (!empty($tplidx)) {
486 $pdf->useTemplate($tplidx);
488 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
489 $this->
_pagehead($pdf, $object, 0, $outputlangs);
491 $pdf->setPage($pageposafter + 1);
496 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
497 $showpricebeforepagebreak = 1;
499 $showpricebeforepagebreak = 0;
504 $pdf->commitTransaction();
507 $posYAfterDescription = $pdf->GetY();
510 $nexY = $pdf->GetY();
511 $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);
519 $curY = $tab_top_newpage;
522 $pdf->SetFont(
'',
'', $default_font_size - 1);
528 $nexY = max($pdf->GetY(), $nexY);
533 $qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line];
535 $nexY = max($pdf->GetY(), $nexY);
538 $nexY = max($nexY, $posYAfterImage);
541 if (!empty($object->lines[$i]->array_options)) {
542 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
544 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
546 $nexY = max($pdf->GetY(), $nexY);
552 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
553 $pdf->setPage($pageposafter);
554 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
556 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
557 $pdf->SetLineStyle(array(
'dash'=>0));
563 while ($pagenb < $pageposafter) {
564 $pdf->setPage($pagenb);
566 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
568 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
570 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
572 $pdf->setPage($pagenb);
573 $pdf->setPageOrientation(
'', 1, 0);
574 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
575 $this->
_pagehead($pdf, $object, 0, $outputlangs);
577 if (!empty($tplidx)) {
578 $pdf->useTemplate($tplidx);
581 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
583 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
585 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
587 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
590 if (!empty($tplidx)) {
591 $pdf->useTemplate($tplidx);
594 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
595 $this->
_pagehead($pdf, $object, 0, $outputlangs);
602 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
603 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
605 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
606 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
610 $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
613 $this->
_pagefoot($pdf, $object, $outputlangs);
615 if (method_exists($pdf,
'AliasNbPages')) {
616 $pdf->AliasNbPages();
621 $pdf->Output($file,
'F');
624 if (!is_object($hookmanager)) {
625 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
628 $hookmanager->initHooks(array(
'pdfgeneration'));
629 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
631 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
633 $this->error = $hookmanager->error;
634 $this->errors = $hookmanager->errors;
637 if (!empty($conf->global->MAIN_UMASK)) {
638 @chmod($file, octdec($conf->global->MAIN_UMASK));
641 $this->result = array(
'fullpath'=>$file);
645 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
650 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"LIVRAISON_OUTPUTDIR");
668 global $conf, $mysoc;
671 $pdf->SetFont(
'',
'', $default_font_size);
672 $pdf->SetXY($this->marge_gauche, $posy);
674 $larg_sign = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 3;
675 $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25);
676 $pdf->SetXY($this->marge_gauche + 2, $posy + 2);
677 $pdf->MultiCell($larg_sign, 2, $outputlangs->trans(
"For").
' '.$outputlangs->convToOutputCharset($mysoc->name).
":",
'',
'L');
679 $pdf->Rect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25);
680 $pdf->SetXY(2 * $larg_sign + $this->marge_gauche + 2, $posy + 2);
681 $pdf->MultiCell($larg_sign, 2, $outputlangs->trans(
"ForCustomer").
':',
'',
'L');
698 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
708 $currency = !empty($currency) ? $currency : $conf->currency;
712 $pdf->SetTextColor(0, 0, 0);
713 $pdf->SetFont(
'',
'', $default_font_size - 2);
715 if (empty($hidetop)) {
717 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
718 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
722 $pdf->SetDrawColor(128, 128, 128);
723 $pdf->SetFont(
'',
'', $default_font_size - 1);
726 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
729 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
731 if (empty($hidetop)) {
732 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
746 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
748 global $conf, $langs, $hookmanager;
755 if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
756 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
759 $pdf->SetTextColor(0, 0, 60);
760 $pdf->SetFont(
'',
'B', $default_font_size + 3);
762 $posy = $this->marge_haute;
763 $posx = $this->page_largeur - $this->marge_droite - 100;
765 $pdf->SetXY($this->marge_gauche, $posy);
768 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
769 if ($this->emetteur->logo) {
770 if (is_readable($logo)) {
772 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
774 $pdf->SetTextColor(200, 0, 0);
775 $pdf->SetFont(
'',
'B', $default_font_size - 2);
776 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
777 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
780 $pdf->MultiCell(100, 4, $this->emetteur->name, 0,
'L');
783 $pdf->SetFont(
'',
'B', $default_font_size + 2);
784 $pdf->SetXY($posx, $posy);
785 $pdf->SetTextColor(0, 0, 60);
786 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DeliveryOrder").
" ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
788 $pdf->SetFont(
'',
'', $default_font_size + 2);
791 $pdf->SetXY($posx, $posy);
792 $pdf->SetTextColor(0, 0, 60);
793 if ($object->date_valid) {
794 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date($object->date_delivery,
"%d %b %Y",
false, $outputlangs,
true),
'',
'R');
796 $pdf->SetTextColor(255, 0, 0);
797 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"DeliveryNotValidated"),
'',
'R');
798 $pdf->SetTextColor(0, 0, 60);
801 if ($object->thirdparty->code_client) {
803 $pdf->SetXY($posx, $posy);
804 $pdf->SetTextColor(0, 0, 60);
805 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
808 $pdf->SetTextColor(0, 0, 60);
813 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
817 $carac_emetteur =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
821 $posx = $this->marge_gauche;
822 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
823 $posx = $this->page_largeur - $this->marge_droite - 80;
828 $pdf->SetTextColor(0, 0, 0);
829 $pdf->SetFont(
'',
'', $default_font_size - 2);
830 $pdf->SetXY($posx, $posy - 5);
831 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
832 $pdf->SetXY($posx, $posy);
833 $pdf->SetFillColor(230, 230, 230);
834 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
835 $pdf->SetTextColor(0, 0, 60);
838 $pdf->SetXY($posx + 2, $posy + 3);
839 $pdf->SetFont(
'',
'B', $default_font_size);
840 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
841 $posy = $pdf->getY();
844 $pdf->SetXY($posx + 2, $posy);
845 $pdf->SetFont(
'',
'', $default_font_size - 1);
846 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
851 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
852 $posx = $this->marge_gauche;
854 $pdf->SetTextColor(0, 0, 0);
855 $pdf->SetFont(
'',
'', $default_font_size - 2);
856 $pdf->SetXY($posx, $posy - 5);
857 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"DeliveryAddress"), 0,
'L');
861 $arrayidcontact = $object->commande->getIdContact(
'external',
'SHIPPING');
862 if (count($arrayidcontact) > 0) {
864 $result = $object->fetch_contact($arrayidcontact[0]);
868 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)))) {
869 $thirdparty = $object->contact;
871 $thirdparty = $object->thirdparty;
876 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
880 if ($this->page_largeur < 210) {
884 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
885 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
886 $posx = $this->marge_gauche;
890 $pdf->SetTextColor(0, 0, 0);
891 $pdf->SetFont(
'',
'', $default_font_size - 2);
892 $pdf->SetXY($posx + 2, $posy - 5);
894 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
897 $pdf->SetXY($posx + 2, $posy + 3);
898 $pdf->SetFont(
'',
'B', $default_font_size);
899 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
901 $posy = $pdf->getY();
904 $pdf->SetFont(
'',
'', $default_font_size - 1);
905 $pdf->SetXY($posx + 2, $posy);
906 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
909 $pdf->SetTextColor(0, 0, 60);
922 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
925 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
926 return pdf_pagefoot($pdf, $outputlangs,
'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
941 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
943 global $conf, $hookmanager;
946 $this->defaultContentsFieldsStyle = array(
948 'padding' => array(0.5, 0.5, 0.5, 0.5),
952 $this->defaultTitlesFieldsStyle = array(
954 'padding' => array(0.5, 0, 0.5, 0),
976 $this->cols[
'desc'] = array(
981 'textkey' =>
'Designation',
985 'padding' => array(0.5, 0.5, 0.5, 0.5),
993 $this->cols[
'photo'] = array(
995 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
998 'textkey' =>
'Photo',
1002 'padding' => array(0, 0, 0, 0),
1004 'border-left' =>
false,
1007 if (!empty($conf->global->MAIN_GENERATE_DELIVERY_WITH_PICTURE) && !empty($this->atleastonephoto)) {
1008 $this->cols[
'photo'][
'status'] =
true;
1013 $this->cols[
'Comments'] = array(
1018 'textkey' =>
'Comments'
1020 'border-left' =>
true,
1035 $this->cols[
'qty_shipped'] = array(
1040 'textkey' =>
'QtyShippedShort'
1042 'border-left' =>
true,
1046 $this->cols[
'qty_remaining'] = array(
1051 'textkey' =>
'KeepToShipShort'
1053 'border-left' =>
true,
1058 if (!empty($object->lines)) {
1059 $line = reset($object->lines);
1063 $parameters = array(
1064 'object' => $object,
1065 'outputlangs' => $outputlangs,
1066 'hidedetails' => $hidedetails,
1067 'hidedesc' => $hidedesc,
1068 'hideref' => $hideref
1071 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1074 } elseif (empty($reshook)) {
1075 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1077 $this->cols = $hookmanager->resArray;