diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e23361c6d81..32d457b54ba 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -201,13 +201,10 @@ class HookManager if (! empty($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; - // TODO dead code to remove (do not enable this, but fix hook instead) - //if (is_array($result)) $this->resArray = array_merge($this->resArray, $result); // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string. we must use $actionclassinstance->resprints to return a string if (! is_array($result) && ! is_numeric($result)) { - //print 'Error: Bug into module '.get_class($actionclassinstance).' hook must not return a string but an int and set string into ->resprints'; - dol_syslog('Error: Bug into module '.get_class($actionclassinstance).' hook must not return a string but an int and set string into ->resprints', LOG_ERR); + dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); if (empty($actionclassinstance->resprints)) { $this->resPrint.=$result; $result=0; } } } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 826008036db..378ef395b36 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2008-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2014 Marcos GarcĂ­a + * Copyright (C) 2015 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -589,6 +590,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m global $conf; if (! is_object($objsoc)) $valueforccc=$objsoc; + else if($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; else $valueforccc=$objsoc->code_client; // Clean parameters diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 43292ae95c4..e6b2c87255c 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -152,7 +152,7 @@ abstract class ModelNumRefExpedition * @return int <=0 if KO, >0 if OK * @deprecated Use the new function generateDocument of Expedition class */ -function expedition_pdf_create(DoliDB $db, Expedition $object, $modele, $outputlangs) +function expedition_pdf_create(DoliDB $db, Expedition $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - return $object->generateDocument($modele, $outputlangs); + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 35953b8521f..daf6dfd7f37 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,28 +158,60 @@ 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; - $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product,2) . $object->lines[$i]->fk_product ."/photos/"; - $dir = $conf->product->dir_output.'/'.$pdir; - - $realpath=''; - foreach ($objphoto->liste_photos($dir,1) as $key => $obj) + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $filename=$obj['photo']; - //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; - $realpath = $dir.$filename; - break; + $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/"; } - if ($realpath) $realpatharray[$i]=$realpath; + $arephoto = false; + foreach ($pdir as $midir) + { + if (! $arephoto) + { + $dir = $conf->product->dir_output.'/'.$midir; + + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) + { + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + { + 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) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 73f23b930ac..7187506db14 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -381,7 +381,7 @@ if (empty($reshook)) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result = $object->generateDocument($object->modelpdf, $outputlangs); + $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 19450220824..a4a751a8aec 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1604,7 +1604,7 @@ class Expedition extends CommonObject * @param Translate $outputlangs Objet lang a utiliser pour traduction * @return int <=0 if KO, >0 if OK */ - public function generateDocument($modele, $outputlangs) + public function generateDocument($modele, $outputlangs,$hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$user,$langs; @@ -1627,7 +1627,7 @@ class Expedition extends CommonObject $this->fetch_origin(); - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, 0, 0, 0); + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2ac3eed44ef..979c1a935f9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1423,7 +1423,6 @@ class Product extends CommonObject else if ($ref_ext) $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; } - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ( $resql ) { @@ -3170,7 +3169,7 @@ class Product extends CommonObject function is_photo_available($sdir) { include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; - + global $conf; $dir = $sdir;