From b8d96efd74ac5caa9a15d7fb98807a90939239c0 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sun, 22 Jun 2003 09:57:42 +0000 Subject: [PATCH] =?UTF-8?q?Mise=20=E0=20NULL=20de=20projetid=20si=20il=20n?= =?UTF-8?q?'est=20pas=20sett=E9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/facture.class.php3 | 69 +++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/htdocs/facture.class.php3 b/htdocs/facture.class.php3 index 7b157d356a0..09c1941ecf3 100644 --- a/htdocs/facture.class.php3 +++ b/htdocs/facture.class.php3 @@ -67,39 +67,46 @@ class Facture { * */ - Function create($userid) { - /* - * Insertion dans la base - */ - $socid = $this->socidp; - $number = $this->number; - $amount = $this->amount; - $remise = $this->remise; - - if (! $remise) { - $remise = 0 ; - } - - $totalht = ($amount - $remise); - $tva = tva($totalht); - $total = $totalht + $tva; - - $sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, amount, remise, tva, total, datef, note, fk_user_author,fk_projet) "; - $sql .= " VALUES ('$number', $socid, now(), $totalht, $remise, $tva, $total, $this->date,'$note',$userid, $this->projetid);"; + Function create($userid) + { + /* + * Insertion dans la base + */ + $socid = $this->socidp; + $number = $this->number; + $amount = $this->amount; + $remise = $this->remise; - if ( $this->db->query($sql) ) - { - $this->id = $this->db->last_insert_id(); + if (! $remise) + { + $remise = 0 ; + } - return $this->id; - } - else - { - print $this->db->error() . '
'.$sql; - return 0; - } - - } + if (! $this->projetid) + { + $this->projetid = "NULL"; + } + + $totalht = ($amount - $remise); + $tva = tva($totalht); + $total = $totalht + $tva; + + $sql = "INSERT INTO $this->db_table (facnumber, fk_soc, datec, amount, remise, tva, total, datef, note, fk_user_author,fk_projet) "; + $sql .= " VALUES ('$number', $socid, now(), $totalht, $remise, $tva, $total, $this->date,'$note',$userid, $this->projetid);"; + + if ( $this->db->query($sql) ) + { + $this->id = $this->db->last_insert_id(); + + return $this->id; + } + else + { + print $this->db->error() . '
'.$sql; + return 0; + } + + } /* *