From cff9fa0e6b4f4c13909f703f2cd646336cd48437 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 3 Mar 2017 12:01:58 +0100 Subject: [PATCH] FIX user odt --- .../core/class/commondocgenerator.class.php | 29 ++++++++++++++----- .../core/modules/user/modules_user.class.php | 28 ++++++++++++++++++ 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 51977bcb356..1d4cb508fb9 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -320,16 +320,29 @@ abstract class CommonDocGenerator + /** + * Define array with couple subtitution key => subtitution value + * + * @param Object $object Dolibarr Object + * @param Translate $outputlangs Language object for output + * @param boolean $recursive Want to fetch child array or child object + * @return array Array of substitution key->code + */ function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) { - foreach($object as $key => $value) { - if(!is_array($value) && !is_object($value)) { - $array_other['object_'.$key] = $value; - } - if(is_array($value) && $recursive){ - foreach($value as $key2 => $val) { - $array_other[$key][$key2] = $this->get_substitutionarray_each_var_object($val,$outputlangs,false); + $array_other = array(); + if(!empty($object)) { + foreach($object as $key => $value) { + if(!is_array($value) && !is_object($value)) { + $array_other['object_'.$key] = $value; } - } + if(is_array($value) && $recursive){ + if(!empty($value)) { + foreach($value as $key2 => $val) { + $array_other[$key][$key2] = $this->get_substitutionarray_each_var_object($val,$outputlangs,false); + } + } + } + } } return $array_other; } diff --git a/htdocs/core/modules/user/modules_user.class.php b/htdocs/core/modules/user/modules_user.class.php index 3e94ece9372..43660da1adb 100644 --- a/htdocs/core/modules/user/modules_user.class.php +++ b/htdocs/core/modules/user/modules_user.class.php @@ -55,6 +55,34 @@ abstract class ModelePDFUser extends CommonDocGenerator $type='user'; $liste=array(); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + return $liste; + } +} + +/** + * Parent class to manage intervention document templates + */ +abstract class ModelePDFUserGroup extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='usergroup'; + $liste=array(); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $liste=getListOfModels($db,$type,$maxfilenamelength); return $liste;