diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 1ceb7ff4b4b..86cdb908273 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2206,24 +2206,35 @@ class Form /** - * \brief Selection des unites de poids + * \brief Selection des unites de mesure * \param name Nom champ html + * \param measuring_style Le style de mesure : weight, volume,... * \param default Forçage de l'unite * \remarks pour l'instant on ne definit pas les unites dans la base */ - function select_weight_units($name='weight_units', $default='0', $adddefault=0) + function select_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0) { global $langs,$conf,$mysoc; $langs->load("other"); - $units[3] = $langs->trans("WeightUnitmg"); - $units[0] = $langs->trans("WeightUnitkg"); - $units[-3] = $langs->trans("WeightUnitg"); + if ($measuring_style == 'weight') + { + $measuring_units[3] = $langs->trans("WeightUnitton"); + $measuring_units[0] = $langs->trans("WeightUnitkg"); + $measuring_units[-3] = $langs->trans("WeightUnitg"); + $measuring_units[-6] = $langs->trans("WeightUnitmg"); + } + else if ($measuring_style == 'volume') + { + $measuring_units[0] = $langs->trans("VolumeUnitm3"); + $measuring_units[-3] = $langs->trans("VolumeUnitcm3"); + $measuring_units[-6] = $langs->trans("VolumeUnitmm3"); + } print ''; - } - + } + + /** + * + * + * + * + */ function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='') { global $langs,$conf,$mysoc; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 002fc6d0796..2e768cd1cc6 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -59,9 +59,14 @@ FeaturesSupported=Features supported Width=Width Height=Height Weight=Weight -WeightUnitmg=tonnes +WeightUnitton=tonnes WeightUnitkg=kg WeightUnitg=g +WeightUnitmg=mg +Volume=Volume +VolumeUnitm3=m3 +VolumeUnitcm3=cm3 +VolumeUnitmm3=mm3 BugTracker=Bug tracker ##### Webcal ##### LoginWebcal=Login for Webcalendar diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 6252269e37b..e9043fc9690 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -59,9 +59,14 @@ FeaturesSupported=Fonctionnalit Width=Largeur Height=Hauteur Weight=Poids -WeightUnitmg=tonnes +WeightUnitton=tonnes WeightUnitkg=kg WeightUnitg=g +WeightUnitmg=mg +Volume=Volume +VolumeUnitm3=m3 +VolumeUnitcm3=cm3 +VolumeUnitmm3=mm3 BugTracker=Bug tracker ##### Webcal ##### LoginWebcal=Login Webcalendar diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 4d291cb9b1d..711020681c9 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -2299,25 +2299,39 @@ function weight_convert($weight,&$from_unit,$to_unit) return $weight; } + /** \brief Renvoi le texte d'une unite - \param int Unit - \return string Unite + \param int Unit + \param measuring_style Le style de mesure : weight, volume,... + \return string Unite \todo gerer les autres unités de mesure comme la livre, le gallon, le litre, ... */ -function weight_units_string($unit) +function measuring_units_string($unit,$measuring_style='') { /* Note Rodo aux dev :) * Ne pas insérer dans la base de données ces valeurs * cela surchagerait inutilement d'une requete supplémentaire * pour quelque chose qui est somme toute peu variable */ - $weight_string[3] = 'Tonnes'; - $weight_string[0] = 'kg'; - $weight_string[-3] = 'g'; - $weight_string[-6] = 'mg'; + + global $langs; + + if ($measuring_style == 'weight') + { + $measuring_units[3] = $langs->trans("WeightUnitton"); + $measuring_units[0] = $langs->trans("WeightUnitkg"); + $measuring_units[-3] = $langs->trans("WeightUnitg"); + $measuring_units[-6] = $langs->trans("WeightUnitmg"); + } + else if ($measuring_style == 'volume') + { + $measuring_units[0] = $langs->trans("VolumeUnitm3"); + $measuring_units[-3] = $langs->trans("VolumeUnitcm3"); + $measuring_units[-6] = $langs->trans("VolumeUnitmm3"); + } - return $weight_string[$unit]; + return $measuring_units[$unit]; } /** diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 46ff4bde1e4..2f5f2ac369e 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -65,6 +65,14 @@ class Product // Statut indique si le produit est en vente '1' ou non '0' var $status; + //! Unités de mesure + var $new_weight; + var $weight; + var $weight_units; + var $new_volume; + var $volume; + var $volume_units; + var $stats_propale=array(); var $stats_commande=array(); var $stats_contrat=array(); @@ -299,6 +307,8 @@ class Product $this->stock_loc = trim($this->stock_loc); $this->new_weight = price2num($this->new_weight); $this->new_weight_units = trim($this->new_weight_units); + $this->new_volume = price2num($this->new_volume); + $this->new_volume_units = trim($this->new_volume_units); $sql = "UPDATE ".MAIN_DB_PREFIX."product "; $sql .= " SET label = '" . addslashes($this->libelle) ."'"; @@ -307,6 +317,8 @@ class Product $sql .= ",envente = " . $this->status; $sql .= ",weight = " . ($this->new_weight!='' ? "'".$this->new_weight."'" : 'null'); $sql .= ",weight_units = '" . $this->new_weight_units."'"; + $sql .= ",volume = " . ($this->new_volume!='' ? "'".$this->new_volume."'" : 'null'); + $sql .= ",volume_units = '" . $this->new_volume_units."'"; $sql .= ",seuil_stock_alerte = '" . $this->seuil_stock_alerte."'"; $sql .= ",description = '" . addslashes($this->description) ."'"; $sql .= ",stock_loc = '" . addslashes($this->stock_loc) ."'"; @@ -933,7 +945,7 @@ class Product $sql = "SELECT rowid, ref, label, description, note, price, price_ttc, price_base_type, tva_tx, envente,"; $sql.= " nbvente, fk_product_type, duration, seuil_stock_alerte,canvas,"; - $sql.= " stock_commande, stock_loc, weight, weight_units"; + $sql.= " stock_commande, stock_loc, weight, weight_units, volume, volume_units"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; if ($id) $sql.= " WHERE rowid = '".$id."'"; if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'"; @@ -963,6 +975,8 @@ class Product $this->stock_loc = $result["stock_loc"]; $this->weight = $result["weight"]; $this->weight_units = $result["weight_units"]; + $this->volume = $result["volume"]; + $this->volume_units = $result["volume_units"]; $this->stock_in_command = $result["stock_commande"]; diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 4cf01e62a65..c526ed95584 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -86,6 +86,8 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) $product->canvas = $_POST["canvas"]; $product->new_weight = $_POST["weight"]; $product->new_weight_units = $_POST["weight_units"]; + $product->new_volume = $_POST["volume"]; + $product->new_volume_units = $_POST["volume_units"]; // MultiPrix if($conf->global->PRODUIT_MULTIPRICES == 1) { @@ -149,6 +151,8 @@ if ($_POST["action"] == 'update' && $product->canvas = $_POST["canvas"]; $product->new_weight = $_POST["weight"]; $product->new_weight_units = $_POST["weight_units"]; + $product->new_volume = $_POST["volume"]; + $product->new_volume_units = $_POST["volume_units"]; if ($product->check()) { @@ -520,10 +524,14 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) } else { - // Le poids ne concerne que les produits et pas les services + // Le poids et le volume ne concerne que les produits et pas les services print '