diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d3704e9e9c4..9e0fb858902 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -38,8 +38,12 @@ require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); +if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); +if ($conf->projet->enabled) +{ + require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); + require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); +} $langs->load('bills'); //print 'ee'.$langs->trans('BillsCustomer');exit; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b2e2db358bb..a31a84c50f0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -253,6 +253,32 @@ class Facture extends CommonObject dol_print_error($this->db); $error++; } + + // TODO mutualiser + if ($origin == 'commande') + { + // On recupere les differents contact interne et externe + $order = new Commande($this->db); + $order->id = $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'); + } + } } }