From 5f50893b4861af3f6ef475db193a9ca45d664307 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jan 2009 14:30:42 +0000 Subject: [PATCH] Fix: Errors with price lower than 0 with some languages --- htdocs/admin/syslog.php | 4 +++- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + htdocs/product.class.php | 25 ++++++++++++++----------- htdocs/product/fiche.php | 23 +++++++++++------------ htdocs/product/price.php | 18 +++++++----------- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 7e10f691a4d..5f8d114ef23 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -120,7 +120,9 @@ print ''; $var=!$var; print " ".$langs->trans("SyslogSimpleFile").""; -print ''.$langs->trans("SyslogFilename").': '; +print ''.$langs->trans("SyslogFilename").': '; +print ' '.img_info($langs->trans("YouCanUseDOL_DATA_ROOT")); +print ''; print "\n"; print "\n"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 86fb9fba3f3..18ccb9f7eb9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -871,6 +871,7 @@ SyslogFacility=Facility SyslogLevel=Level SyslogSimpleFile=File SyslogFilename=File name and path +YouCanUseDOL_DATA_ROOT=You can user DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr documents directory. ErrorUnknownSyslogConstant=Constant %s is not a known syslog constant ##### Donations ##### DonationsSetup=Donation module setup diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index a12b8a0b6c0..5f3713b7f3f 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -873,6 +873,7 @@ SyslogFacility=Facility SyslogLevel=Niveau SyslogSimpleFile=Fichier SyslogFilename=Nom et chemin du fichier +YouCanUseDOL_DATA_ROOT=Vous pouvez utiliser DOL_DATA_ROOT/dolibarr.log pour une log dans le répertoire 'documents' de Dolibarr. ErrorUnknownSyslogConstant=La constante %s n'est pas une constante syslog connue ##### Donations ##### DonationsSetup=Configuration du module Dons diff --git a/htdocs/product.class.php b/htdocs/product.class.php index ca989f5eb89..2b6598bbc91 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -165,6 +165,10 @@ class Product extends CommonObject // Clean parameters $this->ref = dol_string_nospecial(trim($this->ref)); $this->libelle = trim($this->libelle); + $this->price_ttc=price2num($this->price_ttc); + $this->price=price2num($this->price); + $this->price_min_ttc=price2num($this->price_min_ttc); + $this->price_min=price2num($this->price_min); if (empty($this->tva_tx)) $this->tva_tx = 0; if (empty($this->price)) $this->price = 0; if (empty($this->price_min)) $this->price_min = 0; @@ -185,13 +189,12 @@ class Product extends CommonObject $price_ht = price2num($this->price,'MU'); $price_ttc = price2num($this->price * (1 + ($this->tva_tx / 100)),'MU'); } - - if (($this->price_min_ttc > 0)&&($this->price_base_type == 'TTC')) + if (($this->price_min_ttc > 0) && ($this->price_base_type == 'TTC')) { $price_min_ttc = price2num($this->price_min_ttc,'MU'); $price_min_ht = price2num($this->price_min_ttc / (1 + ($this->tva_tx / 100)),'MU'); } - if (($this->price_min > 0)&&($this->price_base_type != 'TTC')) + if (($this->price_min > 0) && ($this->price_base_type != 'TTC')) { $price_min_ht = price2num($this->price_min,'MU'); $price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)),'MU'); @@ -204,7 +207,7 @@ class Product extends CommonObject return -1; } - dolibarr_syslog("Product::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Categorie : ".$this->catid); + dolibarr_syslog("Product::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG); if ($this->ref) { @@ -795,7 +798,7 @@ class Product extends CommonObject function update_price($id, $newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0) { global $conf,$langs; - + dolibarr_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level, LOG_DEBUG); if ($newvat == '') $newvat=$this->tva_tx; @@ -990,7 +993,7 @@ class Product extends CommonObject if ( $result ) { $result = $this->db->fetch_array(); - + $this->multiprices[$i]=$result["price"]; $this->multiprices_ttc[$i]=$result["price_ttc"]; $this->multiprices_min[$i]=$result["price_min"]; @@ -1003,7 +1006,7 @@ class Product extends CommonObject return -1; } } - + } $res=$this->load_stock(); @@ -1654,7 +1657,7 @@ class Product extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur "; $sql .= " (datec, fk_product, fk_soc, ref_fourn, fk_user_author)"; $sql .= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", ".$id_fourn.", '".$ref_fourn."', ".$user->id.")"; - + if ($this->db->query($sql)) { $this->product_fourn_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur"); @@ -2312,7 +2315,7 @@ class Product extends CommonObject $this->stock_reel = $this->stock_reel + $row[0]; $i++; } - + $this->no_stock = 0; } else @@ -2580,10 +2583,10 @@ class Product extends CommonObject $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette $filename = eregi_replace($dir,'',$file); // Nom du fichier - + // On efface l'image d'origine unlink($file); - + // Si elle existe, on efface la vignette if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$filename,$regs)) { diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 88961283f9c..b6a6a2016e8 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -112,8 +112,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) { if($_POST["price_".$i]) { - $price = price2num($_POST["price_".$i]); - $product->multiprices["$i"] = $price; + $product->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); $product->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; } else @@ -128,7 +127,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) // Produit spécifique // $_POST n'est pas utilise dans la classe Product // mais dans des classes qui hérite de Product - $id = $product->create($user, $_POST); + $id = $product->create($user); if ($id > 0) { @@ -240,7 +239,7 @@ if ($_GET["action"] == 'clone' && $user->rights->produit->creer) $_error = 1; $_GET["action"] = ""; - + $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$product->ref).'
'; //dolibarr_print_error($product->db); } @@ -641,7 +640,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) $html->select_array('finished',$statutarray,$_POST["finished"]); print ''; } - + //Duration if ($_GET["type"] == 1) { @@ -868,7 +867,7 @@ if ($_GET["id"] || $_GET["ref"]) print ' '.$langs->trans($product->price_base_type); } print ''; - + // Prix mini print ''.$langs->trans("MinPrice").' '.$i.''; if ($product->multiprices_base_type["$i"] == 'TTC') @@ -879,7 +878,7 @@ if ($_GET["id"] || $_GET["ref"]) { print price($product->multiprices_min["$i"]).' '.$langs->trans($product->multiprices_base_type["$i"]); } - print ''; + print ''; } } else @@ -895,7 +894,7 @@ if ($_GET["id"] || $_GET["ref"]) print price($product->price).' '.$langs->trans($product->price_base_type); } print ''; - + // Prix mini print ''.$langs->trans("MinPrice").''; if ($product->price_base_type == 'TTC') @@ -916,7 +915,7 @@ if ($_GET["id"] || $_GET["ref"]) print ''.$langs->trans("Status").''; print $product->getLibStatut(2); print ''; - + // Description print ''.$langs->trans("Description").''.nl2br($product->description).''; @@ -927,7 +926,7 @@ if ($_GET["id"] || $_GET["ref"]) print $product->getLibFinished(); print ''; } - + if ($product->isservice()) { // Duration @@ -969,7 +968,7 @@ if ($_GET["id"] || $_GET["ref"]) } print "\n"; } - + // Note print ''.$langs->trans("Note").''.nl2br($product->note).''; @@ -1019,7 +1018,7 @@ if ($_GET["id"] || $_GET["ref"]) } print ''; print ''; - + // Description (utilisé dans facture, propale...) print ''.$langs->trans("Description").''; print "\n"; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 39f1f4263ab..e0a40b5bb14 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -154,7 +154,7 @@ if ($conf->global->PRODUIT_MULTIPRICES) print ' '.$langs->trans($product->price_base_type); } print ''; - + // Prix minimum print ''.$langs->trans("MinPrice").' '.$i.''; if ($product->multiprices_base_type["$i"] == 'TTC') @@ -236,7 +236,7 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) { print_fiche_titre($langs->trans("NewPrice"),'',''); - if (! $conf->global->PRODUIT_MULTIPRICES) + if (empty($conf->global->PRODUIT_MULTIPRICES)) { print '
'; print ''; @@ -266,7 +266,7 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) print ''; } print ''; - + print '' ; $text=$langs->trans('MinPrice') ; print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1); @@ -325,22 +325,18 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) print ''; } print ''; - + // VAT print ''.$langs->trans("VATRate").''; print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,''); print ''; - + print ' '; print ''; print ''; print '
'; } - print ' '; - print ''; - print ''; - print ''; } } @@ -406,7 +402,7 @@ if ($result) print ""; // Date print "".dolibarr_print_date($objp->dp,"dayhour").""; - + // Price level if ($conf->global->PRODUIT_MULTIPRICES) {