From ea95a461e23e31de66aeecbe56c45149bc94b885 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 6 May 2015 17:17:41 +0200 Subject: [PATCH] Fix: Make propal pdf "azur" compatible with the two products images storage system on use MAIN_GENERATE_PROPOSALS_WITH_PICTURE --- .../modules/propale/doc/pdf_azur.modules.php | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 35953b8521f..b13ed6580e9 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -158,9 +158,11 @@ class pdf_azur extends ModelePDFPropales $realpatharray=array(); if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) { + $objphoto = new Product($this->db); + for ($i = 0 ; $i < $nblignes ; $i++) { - if (empty($object->lines[$i]->fk_product)) continue; + /*if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); @@ -177,9 +179,58 @@ class pdf_azur extends ModelePDFPropales break; } - if ($realpath) $realpatharray[$i]=$realpath; + if ($realpath) $realpatharray[$i]=$realpath;*/ + + $objphoto->fetch($object->lines[$i]->fk_product); + + if (empty($object->lines[$i]->fk_product)) continue; + else $objphoto->fetch($object->lines[$i]->fk_product); + + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir[0] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/"; + $pdir[1] = dol_sanitizeFileName($objphoto->ref).'/'; + } + else + { + $pdir[0] = dol_sanitizeFileName($objphoto->ref).'/'; + $pdir[1] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/"; + } + $arephoto = false; + foreach ($pdir as $midir) + { + if(!$arephoto) + { + $dir = $conf->product->dir_output.'/'.$midir; + + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) + { + if($conf->global->CAT_HIGH_QUALITY_IMAGES == 0) + { + if ( $obj['photo_vignette']) + { + $filename= $obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + } + else + { + $filename=$obj['photo']; + } + + $realpath = $dir.$filename; + $arephoto = true; + } + } + } + + if ($realpath && $arephoto) $realpatharray[$i]=$realpath; } } + if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; if ($conf->propal->dir_output)