From 972b810379ea5ab4464758f656cfc3b6ccea9a39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Sep 2006 13:27:45 +0000 Subject: [PATCH] Fix: Lien entre facture et facture de remplacement ko --- htdocs/compta/facture.php | 2 +- htdocs/facture.class.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 5030902d1a7..be79afe3c02 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -278,7 +278,7 @@ if ($_POST['action'] == 'add') $result=$facture->fetch($_POST['fac_replacement']); //print "xxx".$result." ".$facture->socidp; - $facid = $facture->create_clone(1,$user); + $facid = $facture->create_clone('replace',$user); } else { diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 57dbfba84f4..fe18cf225ea 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -345,15 +345,22 @@ class Facture extends CommonObject * \param user Object utilisateur qui crée * \return int <0 si ko, >0 si ok */ - function create_clone($invertdetail=0,$user) + function create_clone($reason='',$user) { // Charge facture source $facture=new Facture($this->db); - $facture->fk_facture_source = $this->id; + if ($reason == 'replace') + { + $facture->fk_facture_source = $this->id; + $facture->type = 1; + } + else + { + $facture->type = $this->type; + } $facture->socidp = $this->socidp; - $facture->type = $this->type; $facture->number = $this->number; $facture->date = $this->date; $facture->note_public = $this->note_public;