Fix: uniformize code
This commit is contained in:
parent
c721d9362c
commit
030ee2113b
@ -2025,7 +2025,7 @@ else
|
|||||||
/*
|
/*
|
||||||
* Linked object block
|
* Linked object block
|
||||||
*/
|
*/
|
||||||
$object->load_object_linked($object->id,$object->element);
|
$object->load_object_linked();
|
||||||
|
|
||||||
foreach($object->linked_object as $linked_object => $linked_objectid)
|
foreach($object->linked_object as $linked_object => $linked_objectid)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1225,39 +1225,43 @@ class CommonObject
|
|||||||
|
|
||||||
$this->load_object_linked($sourceid,$sourcetype,$targetid,$targettype,$clause);
|
$this->load_object_linked($sourceid,$sourcetype,$targetid,$targettype,$clause);
|
||||||
|
|
||||||
foreach($this->linked_object as $key => $value)
|
foreach($this->linked_object as $objecttype => $objects)
|
||||||
{
|
{
|
||||||
// Parse element/subelement (ex: project_task)
|
// Parse element/subelement (ex: project_task)
|
||||||
$element = $subelement = $key;
|
$element = $subelement = $objecttype;
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i',$key,$regs))
|
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
||||||
{
|
{
|
||||||
$element = $regs[1];
|
$element = $regs[1];
|
||||||
$subelement = $regs[2];
|
$subelement = $regs[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// For compatibility
|
$classpath = $element.'/class';
|
||||||
if ($element == 'facture') { $element = 'compta/facture'; $subelement = 'facture'; }
|
|
||||||
if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; }
|
// To work with non standard path
|
||||||
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; }
|
||||||
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; }
|
||||||
if ($element == 'shipping') { $element = $subelement = 'expedition'; }
|
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; }
|
||||||
if ($element == 'delivery') { $element = $subelement = 'livraison'; }
|
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; }
|
||||||
|
if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; }
|
||||||
|
if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; }
|
||||||
|
|
||||||
|
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||||
|
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; }
|
||||||
|
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; }
|
||||||
|
|
||||||
if ($conf->$element->enabled)
|
if ($conf->$element->enabled)
|
||||||
{
|
{
|
||||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
|
||||||
|
|
||||||
$classname = ucfirst($subelement);
|
|
||||||
|
|
||||||
$num=sizeof($value);
|
$num=sizeof($objects);
|
||||||
|
|
||||||
for ($i=0;$i<$num;$i++)
|
for ($i=0;$i<$num;$i++)
|
||||||
{
|
{
|
||||||
$object = new $classname($this->db);
|
$object = new $classname($this->db);
|
||||||
$ret = $object->fetch($value[$i]);
|
$ret = $object->fetch($objects[$i]);
|
||||||
if ($ret >= 0)
|
if ($ret >= 0)
|
||||||
{
|
{
|
||||||
$this->linkedObjects[$key][$i] = $object;
|
$this->linkedObjects[$objecttype][$i] = $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1470,10 +1474,14 @@ class CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$classpath = $element.'/class';
|
$classpath = $element.'/class';
|
||||||
if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path
|
|
||||||
if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path
|
// To work with non standard path
|
||||||
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path
|
if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; }
|
||||||
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path
|
if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; }
|
||||||
|
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; }
|
||||||
|
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; }
|
||||||
|
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; }
|
||||||
|
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; }
|
||||||
|
|
||||||
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
|
||||||
if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; }
|
if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user