diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 7d89551c8ad..2dfb60a255a 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1903,13 +1903,13 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow * \param info_bits Miscellanous information on vat * \return string Chaine avec montant formaté (19,6 ou 19,6% ou 8.5% *) */ -function vatrate($rate,$foundpercent=false,$info_bits=0) +function vatrate($rate,$addpercent=false,$info_bits=0) { // Test for compatibility if (eregi('%',$rate)) { $rate=eregi_replace('%','',$rate); - $foundpercent=true; + $addpercent=true; } if (eregi('\*',$rate) || eregi(MAIN_LABEL_MENTION_NPR,$rate)) { @@ -1917,7 +1917,7 @@ function vatrate($rate,$foundpercent=false,$info_bits=0) $info_bits |= 1; } - $ret=price($rate,0,'',0,0).($foundpercent?'%':''); + $ret=price($rate,0,'',0,0).($addpercent?'%':''); if ($info_bits & 1) $ret.=' '.MAIN_LABEL_MENTION_NPR; return $ret; } diff --git a/htdocs/product.class.php b/htdocs/product.class.php index c9ed533c8de..a51642c7a4b 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -43,7 +43,7 @@ class Product extends CommonObject //! Identifiant unique var $id ; - //! R�f�rence + //! Ref var $ref; var $libelle; var $description; @@ -761,40 +761,45 @@ class Product extends CommonObject /** - \brief Modifie le prix d'un produit/service - \param id Id du produit/service � modifier - \param newprice Nouveau prix - \param newpricebase HT ou TTC - \param user Objet utilisateur qui modifie le prix + * \brief Modifie le prix d'un produit/service + * \param id Id du produit/service a modifier + * \param newprice Nouveau prix + * \param newpricebase HT ou TTC + * \param user Objet utilisateur qui modifie le prix + * \param newvat New VAT Rate + * \return int <0 if KO, >0 if OK */ - function update_price($id, $newprice, $newpricebase, $user) + function update_price($id, $newprice, $newpricebase, $user, $newvat='') { //multiprix global $conf,$langs; dolibarr_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase); + if ($newvat == '') $newvat=$this->tva_tx; + if ($newprice) { if ($newpricebase == 'TTC') { $price_ttc = price2num($newprice,'MU'); - $price = price2num($newprice) / (1 + ($this->tva_tx / 100)); + $price = price2num($newprice) / (1 + ($newvat / 100)); $price = price2num($price,'MU'); } else { $price = price2num($newprice,'MU'); - $price_ttc = price2num($newprice) * (1 + ($this->tva_tx / 100)); + $price_ttc = price2num($newprice) * (1 + ($newvat / 100)); $price_ttc = price2num($price_ttc,'MU'); } // Ne pas mettre de quote sur le num�riques decimaux. // Ceci provoque des sotckage avec arrondis en base au lieu des valeurs exactes. - $sql = "UPDATE ".MAIN_DB_PREFIX."product "; - $sql .= " SET price=".$price.""; - $sql .= " , price_base_type='".$newpricebase."'"; - $sql .= " , price_ttc=".$price_ttc.""; - $sql .= " WHERE rowid = " . $id; + $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; + $sql.= " price_base_type='".$newpricebase."',"; + $sql.= " price=".$price.","; + $sql.= " price_ttc=".$price_ttc.","; + $sql.= " tva_tx='".price2num($newvat)."'"; + $sql.= " WHERE rowid = " . $id; dolibarr_syslog("Product::update_price sql=".$sql); $resql=$this->db->query($sql); @@ -803,7 +808,8 @@ class Product extends CommonObject $this->price = $price; $this->price_ttc = $price_ttc; $this->price_base_type = $newpricebase; - + $this->tva_tx = $newvat; + $this->_log_price($user); return 1; } diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index ad821a37675..120cee81bb7 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -136,9 +136,6 @@ if ($_POST["action"] == 'update' && { $product->ref = $_POST["ref"]; $product->libelle = $_POST["libelle"]; - if ( isset( $_POST["price"] ) ) - $product->price = $_POST["price"]; - $product->tva_tx = $_POST["tva_tx"]; $product->description = $_POST["desc"]; $product->note = $_POST["note"]; $product->status = $_POST["statut"]; @@ -572,34 +569,6 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) // Label print '
| '.$langs->trans("SellingPrice").' 1 | '; + print ''; + print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); + print ' |
| '.$langs->trans("SellingPrice").' '.$i.' | '; + print ''; + print $html->select_PriceBaseType($product->multiprices_base_type["$i"], "multiprices_base_type_".$i); + print ' |
| '.$langs->trans("SellingPrice").' | '; + print ''; + print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); + print ' |
| '.$langs->trans("VATRate").' | '; + print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); + print ' |