diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e1cbcd25717..5950a36ba3e 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1558,7 +1558,13 @@ if ($id > 0 || ! empty($ref)) foreach($object->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + $element = $subelement = $linked_object; + if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if($conf->$element->enabled && $element != $object->element) { $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index ecb1add0890..5fd122a8513 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1860,7 +1860,13 @@ else foreach($object->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + $element = $subelement = $linked_object; + if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if($conf->$element->enabled && $element != $object->element) { $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 02edd86a6df..af4678ff3c5 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2762,7 +2762,13 @@ else foreach($object->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + $element = $subelement = $linked_object; + if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if($conf->$element->enabled && $element != $object->element) { $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1d71f5f27e6..0c18414f56e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1366,16 +1366,22 @@ class CommonObject $num = sizeof($this->objectid); if ($num) { - $classpath = $objecttype.'/class'; - $tplpath = $objecttype; - if ($objecttype == 'facture') { $tplpath = 'compta/'.$objecttype; $classpath = $tplpath.'/class'; } // To work with non standard path - if ($objecttype == 'propal') { $tplpath = 'comm/'.$objecttype; $classpath = $tplpath.'/class'; } // To work with non standard path - if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path - if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path + $element = $subelement = $objecttype; + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + $classpath = $element.'/class'; + $tplpath = $element; + if ($element == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path + if ($element == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path + if ($element == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path + if ($element == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path - $classfile = strtolower($objecttype); $classname = ucfirst($objecttype); - if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; } - if ($objecttype == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; } + $classfile = strtolower($subelement); $classname = ucfirst($subelement); + if ($subelement == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; } + if ($subelement == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; } //print $classfile." - ".$classpath." - ".$tplpath; if(!class_exists($classname)) {