Fix: error with linked element

This commit is contained in:
Regis Houssin 2010-04-30 06:57:28 +00:00
parent 38701cda84
commit 85d7bf3d2b

View File

@ -77,6 +77,9 @@ class Commande extends CommonObject
var $info_bits; var $info_bits;
var $source; // Origin of order var $source; // Origin of order
var $origin;
var $origin_id;
var $user_author_id; var $user_author_id;
var $lines = array(); var $lines = array();
@ -665,37 +668,38 @@ class Commande extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if ($this->id && $this->propale_id) if ($this->id)
{ {
// Add proposal link // Add linked object
// TODO normaliser ? if ($this->origin && $this->origin_id)
$this->origin_id = $this->propale_id;
$this->origin = "propal";
$ret = $this->add_object_linked();
if (! $ret)
{ {
dol_print_error($this->db); $ret = $this->add_object_linked();
if (! $ret) dol_print_error($this->db);
} }
// On recupere les differents contact interne et externe // TODO mutualiser
$prop = New Propal($this->db, $this->socid, $this->propale_id); if ($this->origin == 'propal' && $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 // On recupere les differents contact interne et externe
$this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); $prop = New Propal($this->db, $this->socid, $this->origin_id);
}
// On recupere le contact client suivi propale // On recupere le commercial suivi propale
$this->contactid = $prop->getIdcontact('external', 'CUSTOMER'); $this->userid = $prop->getIdcontact('internal', 'SALESREPFOLL');
if ($this->contactid) if ($this->userid)
{ {
//On passe le contact client suivi propale en contact client suivi commande //On passe le commercial suivi propale en commercial suivi commande
$this->add_contact($this->contactid[0], 'CUSTOMER', 'external'); $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');
}
} }
} }