From 077a9c65103616518f9ed99f47d815d09e8734af Mon Sep 17 00:00:00 2001 From: fmarcet Date: Mon, 4 May 2015 09:22:55 +0200 Subject: [PATCH 1/6] FIX: Bug on order and supplier invoice numeration mask when use supplier code --- htdocs/core/lib/functions2.lib.php | 2 ++ 1 file changed, 2 insertions(+) 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 From ea95a461e23e31de66aeecbe56c45149bc94b885 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 6 May 2015 17:17:41 +0200 Subject: [PATCH 2/6] 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) From 72c4337f4baea3b889677ea22bcb1d2bec3cca97 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 6 May 2015 12:16:36 +0200 Subject: [PATCH 3/6] Fix : shipment PDF was not using generation params Conflicts: htdocs/core/modules/expedition/modules_expedition.php htdocs/expedition/fiche.php --- htdocs/core/modules/expedition/modules_expedition.php | 4 ++-- htdocs/expedition/card.php | 2 +- htdocs/expedition/class/expedition.class.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) 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/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); } } From 36ebaf7a22c1c304fbe98a39defb73ddbbc6bcc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 May 2015 23:31:03 +0200 Subject: [PATCH 4/6] Clean code --- .../modules/propale/doc/pdf_azur.modules.php | 41 +++++-------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index b13ed6580e9..daf6dfd7f37 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -159,32 +159,12 @@ class pdf_azur extends ModelePDFPropales 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) - { - $filename=$obj['photo']; - //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; - $realpath = $dir.$filename; - break; - } - - 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); + + $objphoto->fetch($object->lines[$i]->fk_product); if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { @@ -196,18 +176,19 @@ class pdf_azur extends ModelePDFPropales $pdir[0] = dol_sanitizeFileName($objphoto->ref).'/'; $pdir[1] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/"; } + $arephoto = false; foreach ($pdir as $midir) { - if(!$arephoto) + 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 (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']) + if ($obj['photo_vignette']) { $filename= $obj['photo_vignette']; } @@ -220,17 +201,17 @@ class pdf_azur extends ModelePDFPropales { $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) From cc5968fbd514b3d60a7e110a764217c24a82229d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 May 2015 10:45:35 +0200 Subject: [PATCH 5/6] A more complete error message --- htdocs/core/class/hookmanager.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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; } } } From f197a94f598a6f7499841fd7b40e6ad5d9e95151 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 May 2015 10:52:41 +0200 Subject: [PATCH 6/6] Fix duplicate log --- htdocs/product/class/product.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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;