Browse Source

FIX print pictures in shipment docs

Francis Appels 5 years ago
parent
commit
0a8a8bafa0

+ 15 - 5
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;
 	    }

+ 10 - 3
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 = '';