From 0a8a8bafa0528f8dd32f9d44abbe24226e2c4fb7 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 9 Apr 2020 15:40:36 +0200 Subject: [PATCH] FIX print pictures in shipment docs --- .../expedition/doc/pdf_espadon.modules.php | 20 ++++++++++++++----- .../expedition/doc/pdf_rouget.modules.php | 13 +++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 0d702adab60..c4262f71f19 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -171,7 +171,8 @@ class pdf_espadon extends ModelePdfExpedition $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); + $realpatharray=array(); + $this->atleastonephoto = false; if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); @@ -183,8 +184,16 @@ class pdf_espadon extends ModelePdfExpedition $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; - $dir = $conf->product->dir_output.'/'.$pdir; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + } + else + { + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $dir = $conf->product->dir_output.'/'.$pdir; + } $realpath=''; @@ -206,7 +215,8 @@ class pdf_espadon extends ModelePdfExpedition $filename = $obj['photo']; } - $realpath = $dir.$filename; + $realpath = $dir.$filename; + $this->atleastonephoto = true; break; } @@ -1150,7 +1160,7 @@ class pdf_espadon extends ModelePdfExpedition 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto)) + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index ad0272f46a1..506e72ba1b0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -214,9 +214,16 @@ class pdf_rouget extends ModelePdfExpedition $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; - $dir = $conf->product->dir_output.'/'.$pdir; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $dir = $conf->product->dir_output.'/'.$pdir; + } + else + { + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $dir = $conf->product->dir_output.'/'.$pdir; + } $realpath = '';