forked from Wavyzz/dolibarr
New: add possibility to linked other objects from external modules
This commit is contained in:
@@ -86,6 +86,7 @@ class Commande extends CommonObject
|
||||
|
||||
var $origin;
|
||||
var $origin_id;
|
||||
var $linked_objects=array();
|
||||
|
||||
var $user_author_id;
|
||||
|
||||
@@ -706,37 +707,44 @@ class Commande extends CommonObject
|
||||
if ($this->id)
|
||||
{
|
||||
$this->ref="(PROV".$this->id.")";
|
||||
|
||||
// Add linked object
|
||||
if ($this->origin && $this->origin_id)
|
||||
|
||||
// Add object linked
|
||||
if (is_array($this->linked_objects) && ! empty($this->linked_objects))
|
||||
{
|
||||
$ret = $this->add_object_linked();
|
||||
if (! $ret) dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// TODO mutualiser
|
||||
if ($this->origin == 'propal' && $this->origin_id)
|
||||
{
|
||||
// On recupere les differents contact interne et externe
|
||||
$prop = new Propal($this->db, $this->socid, $this->origin_id);
|
||||
|
||||
// On recupere le commercial suivi propale
|
||||
$this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
|
||||
|
||||
if ($this->userid)
|
||||
{
|
||||
//On passe le commercial suivi propale en commercial suivi commande
|
||||
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
|
||||
}
|
||||
|
||||
// On recupere le contact client suivi propale
|
||||
$this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
|
||||
|
||||
if ($this->contactid)
|
||||
{
|
||||
//On passe le contact client suivi propale en contact client suivi commande
|
||||
$this->add_contact($this->contactid[0], 'CUSTOMER', 'external');
|
||||
}
|
||||
foreach($this->linked_objects as $origin => $origin_id)
|
||||
{
|
||||
$ret = $this->add_object_linked($origin, $origin_id);
|
||||
if (! $ret)
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$error++;
|
||||
}
|
||||
|
||||
// TODO mutualiser
|
||||
if ($origin == 'propal' && $origin_id)
|
||||
{
|
||||
// On recupere les differents contact interne et externe
|
||||
$prop = new Propal($this->db, $this->socid, $origin_id);
|
||||
|
||||
// On recupere le commercial suivi propale
|
||||
$this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
|
||||
|
||||
if ($this->userid)
|
||||
{
|
||||
//On passe le commercial suivi propale en commercial suivi commande
|
||||
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal');
|
||||
}
|
||||
|
||||
// On recupere le contact client suivi propale
|
||||
$this->contactid = $prop->getIdcontact('external', 'CUSTOMER');
|
||||
|
||||
if ($this->contactid)
|
||||
{
|
||||
//On passe le contact client suivi propale en contact client suivi commande
|
||||
$this->add_contact($this->contactid[0], 'CUSTOMER', 'external');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user