Qual: Replace ereg_replace(",","." by price2num

This commit is contained in:
Laurent Destailleur 2008-12-09 21:02:58 +00:00
parent 6abe23f15c
commit d3283a798a
7 changed files with 564 additions and 571 deletions

View File

@ -110,11 +110,11 @@ else if ($_POST["action"] == 'confirmDeleteProdLineInForm')
} }
else if ($_POST["action"] == 'ProductCanvasAbility') else if ($_POST["action"] == 'ProductCanvasAbility')
{ {
dolibarr_set_const($db, "PRODUCT_CANVAS_ABILITY", $_POST["ProductCanvasAbility"]);
dolibarr_set_const($db, "MAIN_NEED_SMARTY", $_POST["ProductCanvasAbility"]);
// Create temp directory for smarty // Create temp directory for smarty
if (! empty($dolibarr_smarty_compile)) create_exdir($dolibarr_smarty_compile); if (! empty($dolibarr_smarty_compile)) create_exdir($dolibarr_smarty_compile);
if (! empty($dolibarr_smarty_cache)) create_exdir($dolibarr_smarty_cache); if (! empty($dolibarr_smarty_cache)) create_exdir($dolibarr_smarty_cache);
dolibarr_set_const($db, "MAIN_NEED_SMARTY", $_POST["ProductCanvasAbility"]);
} }
else if ($_POST["action"] == 'usesearchtoselectproduct') else if ($_POST["action"] == 'usesearchtoselectproduct')
{ {
@ -122,6 +122,10 @@ else if ($_POST["action"] == 'usesearchtoselectproduct')
} }
else if ($_GET["action"] == 'set') else if ($_GET["action"] == 'set')
{ {
// Create temp directory for smarty
if (! empty($dolibarr_smarty_compile)) create_exdir($dolibarr_smarty_compile);
if (! empty($dolibarr_smarty_cache)) create_exdir($dolibarr_smarty_cache);
$const = "PRODUIT_SPECIAL_".strtoupper($_GET["spe"]); $const = "PRODUIT_SPECIAL_".strtoupper($_GET["spe"]);
if ($_GET["value"]) dolibarr_set_const($db, $const, $_GET["value"]); if ($_GET["value"]) dolibarr_set_const($db, $const, $_GET["value"]);
else dolibarr_del_const($db, $const); else dolibarr_del_const($db, $const);
@ -277,8 +281,8 @@ print '</tr>';
print '</form>'; print '</form>';
// Only rodolphe and auguria menu manage canvas menu (auguria not correctly yet) // Old canvas feature
if (eregi('^rodolphe',$conf->left_menu) || eregi('^auguria',$conf->left_menu)) if ($conf->global->PRODUCT_CANVAS_ABILITY)
{ {
// Propose utilisation de canvas. // Propose utilisation de canvas.
// Ces derniers ne sont geres que par le menu default // Ces derniers ne sont geres que par le menu default
@ -289,17 +293,6 @@ if (eregi('^rodolphe',$conf->left_menu) || eregi('^auguria',$conf->left_menu))
print " <td align=\"right\" width=\"60\">".$langs->trans("Value")."</td>\n"; print " <td align=\"right\" width=\"60\">".$langs->trans("Value")."</td>\n";
print " <td width=\"80\">&nbsp;</td></tr>\n"; print " <td width=\"80\">&nbsp;</td></tr>\n";
print '<form method="post" action="produit.php">';
print '<input type="hidden" name="action" value="ProductCanvasAbility">';
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("ProductCanvasAbility").'</td>';
print '<td width="60" align="right">';
print $html->selectyesno("ProductCanvasAbility",$conf->global->PRODUCT_CANVAS_ABILITY,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td>";
print '</tr></form>';
require_once(DOL_DOCUMENT_ROOT . "/product.class.php"); require_once(DOL_DOCUMENT_ROOT . "/product.class.php");
$dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; $dir = DOL_DOCUMENT_ROOT . "/product/canvas/";

View File

@ -118,7 +118,7 @@ class RejetPrelevement
// certaines install de PHP renvoie uniquement la partie // certaines install de PHP renvoie uniquement la partie
// entiere negative // entiere negative
$pai->amounts[$facs[$i]] = ereg_replace(",",".",($fac->total_ttc * -1)); $pai->amounts[$facs[$i]] = price2num($fac->total_ttc * -1);
$pai->datepaye = $this->db->idate($date_rejet); $pai->datepaye = $this->db->idate($date_rejet);
$pai->paiementid = 3; // prélèvement $pai->paiementid = 3; // prélèvement
$pai->num_paiement = "Rejet"; $pai->num_paiement = "Rejet";

View File

@ -504,9 +504,6 @@ else // Si utilisateur externe
$conf->left_menu=$conf->global->MAIN_MENUFRONT_BARRELEFT; $conf->left_menu=$conf->global->MAIN_MENUFRONT_BARRELEFT;
} }
// Only rodolphe and auguria menu manage canvas menu (auguria not correctly yet)
if (! eregi('^rodolphe',$conf->left_menu) && ! eregi('^auguria',$conf->left_menu)) $conf->global->PRODUCT_CANVAS_ABILITY=0;
// For modules using Smarty // For modules using Smarty
if ($conf->global->MAIN_NEED_SMARTY) if ($conf->global->MAIN_NEED_SMARTY)

View File

@ -372,6 +372,7 @@ class Product extends CommonObject
$this->volume_units = trim($this->volume_units); $this->volume_units = trim($this->volume_units);
if (empty($this->tva_tx)) $this->tva_tx = 0; if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->finished)) $this->finished = 0; if (empty($this->finished)) $this->finished = 0;
if (empty($this->seuil_stock_alerte)) $this->seuil_stock_alerte = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."product "; $sql = "UPDATE ".MAIN_DB_PREFIX."product ";
$sql .= " SET label = '" . addslashes($this->libelle) ."'"; $sql .= " SET label = '" . addslashes($this->libelle) ."'";
@ -383,7 +384,7 @@ class Product extends CommonObject
$sql .= ",weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null'); $sql .= ",weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null');
$sql .= ",volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null'); $sql .= ",volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null');
$sql .= ",volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null'); $sql .= ",volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null');
$sql .= ",seuil_stock_alerte = '" . $this->seuil_stock_alerte."'"; $sql .= ",seuil_stock_alerte = " . ($this->seuil_stock_alerte!='' ? $this->seuil_stock_alerte : "null");
$sql .= ",description = '" . addslashes($this->description) ."'"; $sql .= ",description = '" . addslashes($this->description) ."'";
$sql .= ",stock_loc = '" . addslashes($this->stock_loc) ."'"; $sql .= ",stock_loc = '" . addslashes($this->stock_loc) ."'";
$sql .= ",note = '" . addslashes($this->note) ."'"; $sql .= ",note = '" . addslashes($this->note) ."'";

View File

@ -15,29 +15,27 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/product/canvas/product.livre.class.php * \file htdocs/product/canvas/product.livre.class.php
\ingroup produit * \ingroup produit
\brief Fichier de la classe des produits specifiques de type livre * \brief Fichier de la classe des produits specifiques de type livre
\version $Revision$ * \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT.'/product/canvas/product.livrecontrat.class.php'); require_once(DOL_DOCUMENT_ROOT.'/product/canvas/product.livrecontrat.class.php');
/**
\class ProductLivre
\brief Classe permettant la gestion des livres, cette classe surcharge la classe produit
*/
/**
* \class ProductLivre
* \brief Classe permettant la gestion des livres, cette classe surcharge la classe produit
*/
class ProductLivre extends Product class ProductLivre extends Product
{ {
//! Numero d'erreur Plage 1280-1535 //! Numero d'erreur Plage 1280-1535
var $errno = 0; var $errno = 0;
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB Handler accès base de données * \param DB Handler accès base de données
@ -103,9 +101,9 @@ class ProductLivre extends Product
$id = parent::Create($user); $id = parent::Create($user);
$this->pages = abs(trim($datas["pages"])); $this->pages = abs(trim($datas["pages"]));
$this->px_feuillet = str_replace(',','.',trim($datas["px_feuillet"])); $this->px_feuillet = price2num($datas["px_feuillet"]);
$this->px_reliure = str_replace(',','.',trim($datas["px_reliure"])); $this->px_reliure = price2num($datas["px_reliure"]);
$this->px_couverture = str_replace(',','.',trim($datas["px_couverture"])); $this->px_couverture = price2num($datas["px_couverture"]);
$this->stock_loc = trim($datas["stock_loc"]); $this->stock_loc = trim($datas["stock_loc"]);
if ($id > 0) if ($id > 0)
@ -250,6 +248,8 @@ class ProductLivre extends Product
return $result; return $result;
} }
/** /**
* \brief Mise a jour des donnees dans la base * \brief Mise a jour des donnees dans la base
* \param datas Tableau de donnees * \param datas Tableau de donnees
@ -273,13 +273,13 @@ class ProductLivre extends Product
$ean = $ean . $this->calculate_ean_key($ean); $ean = $ean . $this->calculate_ean_key($ean);
$this->pages = abs(trim($datas["pages"])); $this->pages = abs(trim($datas["pages"]));
$this->px_feuillet = str_replace(',','.',trim($datas["px_feuillet"])); $this->px_feuillet = price2num($datas["px_feuillet"]);
$this->px_reliure = str_replace(',','.',trim($datas["px_reliure"])); $this->px_reliure = price2num($datas["px_reliure"]);
$this->px_couverture = str_replace(',','.',trim($datas["px_couverture"])); $this->px_couverture = price2num($datas["px_couverture"]);
$price_ht = $this->price / (1 + ($this->tva_tx / 100)); $price_ht = $this->price / (1 + ($this->tva_tx / 100));
$contrat_taux = str_replace(',','.',trim($datas["contrat_taux"])); $contrat_taux = price2num($datas["contrat_taux"]);
$this->px_revient = $this->_calculate_prix_revient($this->pages, $this->px_couverture, $this->px_feuillet, $price_ht, $this->px_reliure, $contrat_taux); $this->px_revient = $this->_calculate_prix_revient($this->pages, $this->px_couverture, $this->px_feuillet, $price_ht, $this->px_reliure, $contrat_taux);
@ -290,16 +290,17 @@ class ProductLivre extends Product
$sql.= " SET isbn = '$isbn'"; $sql.= " SET isbn = '$isbn'";
$sql.= " , ean = '$ean'"; $sql.= " , ean = '$ean'";
$sql.= " , pages = '".$this->pages."'"; $sql.= " , pages = '".$this->pages."'";
$sql.= " , px_feuillet = '".$this->px_feuillet."'"; $sql.= " , px_feuillet = ".($this->px_feuillet?price2num($this->px_feuillet):'null');
$sql.= " , px_revient = '".ereg_replace(",",".",$this->px_revient)."'"; $sql.= " , px_revient = ".($this->px_revient?price2num($this->px_revient):'null');
$sql.= " , px_reliure = '".ereg_replace(",",".",$this->px_reliure)."'"; $sql.= " , px_reliure = ".($this->px_reliure?price2num($this->px_reliure):'null');
$sql.= " , px_couverture = '".ereg_replace(",",".",$this->px_couverture)."'"; $sql.= " , px_couverture = ".($this->px_couverture?price2num($this->px_couverture):'null');
$sql.= " , fk_couverture = '".$this->couverture->id."'"; $sql.= " , fk_couverture = '".$this->couverture->id."'";
$sql.= " , fk_contrat = '".$this->contrat->id."'"; $sql.= " , fk_contrat = '".$this->contrat->id."'";
$sql.= " , fk_auteur = '".$datas["auteur"]."'"; $sql.= " , fk_auteur = '".$datas["auteur"]."'";
$sql.= " , format = '$format'"; $sql.= " , format = '$format'";
$sql.= " WHERE rowid = " . $this->id; $sql.= " WHERE rowid = " . $this->id;
dolibarr_syslog("ProductLivre::UpdateCanvas sql=".$sql, LOG_DEBUG);
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$this->errno = 0; $this->errno = 0;
@ -310,6 +311,7 @@ class ProductLivre extends Product
} }
else else
{ {
$this->error=$this->db->lasterror();
$this->_setErrNo("UpdateCanvas",1281); $this->_setErrNo("UpdateCanvas",1281);
return -1; return -1;
} }

View File

@ -283,7 +283,7 @@ class MouvementStock
if ( strftime('%Y%m%d',$entrepot_value_date) == strftime('%Y%m%d',$now) ) if ( strftime('%Y%m%d',$entrepot_value_date) == strftime('%Y%m%d',$now) )
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot_valorisation"; $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot_valorisation";
$sql.= " SET valo_pmp='".ereg_replace(",",".",$new_value)."'"; $sql.= " SET valo_pmp='".price2num($new_value)."'";
$sql.= " WHERE fk_entrepot = $entrepot_id "; $sql.= " WHERE fk_entrepot = $entrepot_id ";
$sql.= " AND ".$this->db->pdate("date_calcul")."='".$entrepot_value_date."';"; $sql.= " AND ".$this->db->pdate("date_calcul")."='".$entrepot_value_date."';";
} }
@ -292,7 +292,7 @@ class MouvementStock
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot_valorisation"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot_valorisation";
$sql.= " (date_calcul, fk_entrepot, valo_pmp)"; $sql.= " (date_calcul, fk_entrepot, valo_pmp)";
$sql.= " VALUES (".$this->db->idate(mktime()).", ".$entrepot_id; $sql.= " VALUES (".$this->db->idate(mktime()).", ".$entrepot_id;
$sql.= ",'".ereg_replace(",",".",$new_value)."');"; $sql.= ",'".price2num($new_value)."')";
} }
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -309,7 +309,7 @@ class MouvementStock
if ($error === 0) if ($error === 0)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot"; $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot";
$sql.= " SET valo_pmp='".ereg_replace(",",".",$new_value)."'"; $sql.= " SET valo_pmp='".price2num($new_value)."'";
$sql.= " WHERE rowid = $entrepot_id "; $sql.= " WHERE rowid = $entrepot_id ";
if ($this->db->query($sql)) if ($this->db->query($sql))

View File

@ -352,7 +352,7 @@ if (sizeof($factures_prev) > 0)
*/ */
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
$sql .= " SET amount = ".ereg_replace(",",".",$bonprev->total); $sql .= " SET amount = ".price2num($bonprev->total);
$sql .= " WHERE rowid = ".$prev_id; $sql .= " WHERE rowid = ".$prev_id;
if (!$db->query($sql)) if (!$db->query($sql))