From 22d5219866187b946235fda7b44c8bf809956456 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 5 Jan 2007 11:37:55 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20le=20HT=20=E9tait=20entr=E9=20en=20arron?= =?UTF-8?q?di=20=E0=20la=20cr=E9ation=20du=20produit=20lors=20d'une=20entr?= =?UTF-8?q?=E9e=20en=20TTC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture.php | 14 +++++------ htdocs/product.class.php | 51 +++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f1f724e1fdd..0b6552085bc 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -641,17 +641,17 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); - $price_base_type = $prod->price_base_type; + $price_base_type = $prod->price_base_type; // multiprix if ($conf->global->PRODUIT_MULTIPRICES == 1) { - $pu = $prod->multiprices[$soc->price_level]; + $pu = $prod->multiprices[$soc->price_level]; } else { - $pu = $prod->price; - $pu_ttc = $prod->price_ttc; + $pu = $prod->price; + $pu_ttc = $prod->price_ttc; } // La description de la ligne est celle saisie ou @@ -667,9 +667,9 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && } else { - $pu=$_POST['pu']; - $tva_tx=$_POST['tva_tx']; - $desc=$_POST['desc']; + $pu=$_POST['pu']; + $tva_tx=$_POST['tva_tx']; + $desc=$_POST['desc']; } // Insere ligne diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 2338fc7f649..c65c4362633 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * * This program is free software; you can redistribute it and/or modify @@ -150,36 +150,36 @@ class Product if ($this->tva_tx=='') $this->tva_tx = 0; if ($this->price=='') $this->price = 0; if ($this->status=='') $this->status = 0; - $this->price = price2num($this->price); + //$this->price = price2num($this->price); if (strlen(trim($this->price)) > 0 ) - { - if ($this->price_base_type == 'TTC') - { - $price_ttc = $this->price; - $price = $this->price / (1 + ($this->tva_tx / 100)); - } - else - { - $price = $this->price; - $price_ttc = $this->price * (1 + ($this->tva_tx / 100)); - } - } + { + if ($this->price_base_type == 'TTC') + { + $price_ttc = $this->price; + $price = $this->price / (1 + ($this->tva_tx / 100)); + } + else + { + $price = $this->price; + $price_ttc = $this->price * (1 + ($this->tva_tx / 100)); + } + } dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid); if (strlen($this->ref) > 0) - { - $this->db->begin(); + { + $this->db->begin(); - $sql = "SELECT count(*)"; - $sql .= " FROM ".MAIN_DB_PREFIX."product WHERE ref = '" .$this->ref."'"; + $sql = "SELECT count(*)"; + $sql .= " FROM ".MAIN_DB_PREFIX."product WHERE ref = '" .$this->ref."'"; - $result = $this->db->query($sql) ; - if ($result) - { - $row = $this->db->fetch_array($result); - if ($row[0] == 0) + $result = $this->db->query($sql) ; + if ($result) + { + $row = $this->db->fetch_array($result); + if ($row[0] == 0) { // Produit non deja existant $sql = "INSERT INTO ".MAIN_DB_PREFIX."product "; @@ -188,8 +188,11 @@ class Product $sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)"; $sql.= " VALUES (now(), "; if ($this->ref) $sql.= "'".$this->ref."', "; - $sql.= $user->id.", ".$this->type.", '" . $price . "', '".$price_ttc."', '" . $this->price_base_type . "','".$this->canvas."')"; + $sql.= $user->id.", ".$this->type.", '" . price2num($price) . "', '".$price_ttc."', '" . $this->price_base_type . "','".$this->canvas."')"; $result = $this->db->query($sql); + print 'HT '.$price.'
'; + print 'TTC '.$price_ttc.'
'; + print $sql; if ( $result ) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");