Fix: Make propal pdf "azur" compatible with the two products images

storage system on use MAIN_GENERATE_PROPOSALS_WITH_PICTURE
This commit is contained in:
Juanjo Menent 2015-05-06 17:17:41 +02:00
parent 467ee7b771
commit ea95a461e2

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* 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)