From 19d4147fcd6e266c526b1da3f467d17c8afc9783 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 11 Mar 2012 11:34:20 +0100 Subject: [PATCH] Fix: missing contacts with order to invoice --- htdocs/commande/class/commande.class.php | 50 +++++++++---------- htdocs/compta/facture/class/facture.class.php | 25 ++++++++++ 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index cc00e37ad79..fa035920386 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -700,35 +700,35 @@ class Commande extends CommonObject { $this->ref="(PROV".$this->id.")"; - // Add linked object + // Add linked object and contacts if ($this->origin && $this->origin_id) { $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'); + + // TODO mutualiser + if ($this->origin == 'propal') + { + // 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'); + } } } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f96490b1c81..d58515b7db9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -275,6 +275,31 @@ class Facture extends CommonObject dol_print_error($this->db); $error++; } + + // TODO mutualiser + if ($this->origin == 'commande') + { + // On recupere les differents contact interne et externe + $order = new Commande($this->db, $this->socid, $this->origin_id); + + // On recupere le commercial suivi propale + $this->userid = $order->getIdcontact('internal', 'SALESREPFOLL'); + + if ($this->userid) + { + //On passe le commercial suivi commande en commercial suivi paiement + $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); + } + + // On recupere le contact client facturation commande + $this->contactid = $order->getIdcontact('external', 'BILLING'); + + if ($this->contactid) + { + //On passe le contact client facturation commande en contact client facturation + $this->add_contact($this->contactid[0], 'BILLING', 'external'); + } + } } /*