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 ''.$langs->trans("Weight").''; print ''; - print $html->select_weight_units("weight_units"); + print $html->select_measuring_units("weight_units","weight"); + print ''; + print ''.$langs->trans("volume").''; + print ''; + print $html->select_measuring_units("volume_units","volume"); print ''; } @@ -757,32 +765,43 @@ if ($_GET["id"] || $_GET["ref"]) // Durée if ($product->isservice()) + { + print ''.$langs->trans("Duration").''.$product->duration_value.' '; + if ($product->duration_value > 1) { - print ''.$langs->trans("Duration").''.$product->duration_value.' '; - if ($product->duration_value > 1) - { - $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); - } - else { - $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); - } - print $langs->trans($dur[$product->duration_unit])." "; + $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + } + else + { + $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$product->duration_unit])." "; - print ''; - } + print ''; + } else - { - print ''.$langs->trans("Weight").''; - if ($product->weight != '') - { - print $product->weight." ".weight_units_string($product->weight_units); - } - else - { - print ' '; - } - print "\n"; - } + { + print ''.$langs->trans("Weight").''; + if ($product->weight != '') + { + print $product->weight." ".measuring_units_string($product->weight_units,"weight"); + } + else + { + print ' '; + } + print "\n"; + print ''.$langs->trans("Volume").''; + if ($product->volume != '') + { + print $product->volume." ".measuring_units_string($product->volume_units,"volume"); + } + else + { + print ' '; + } + print "\n"; + } // Note print ''.$langs->trans("Note").''.nl2br($product->note).''; print "\n"; @@ -877,10 +896,14 @@ if ($_GET["id"] || $_GET["ref"]) } 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 ''.$langs->trans("Weight").''; print ''; - print $html->select_weight_units("weight_units",$product->weight_units); + print $html->select_measuring_units("weight_units", "weight", $product->weight_units); + print ''; + print ''.$langs->trans("Volume").''; + print ''; + print $html->select_measuring_units("volume_units", "volume", $product->volume_units); print ''; } diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index cb5544edd95..ef500ae0fee 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -516,3 +516,6 @@ insert into `llx_menu_const` (`rowid`, `fk_menu`, `fk_constraint`, `user`) value insert into `llx_menu_const` (`rowid`, `fk_menu`, `fk_constraint`, `user`) values (107, 4901, 6, 2); insert into `llx_menu_const` (`rowid`, `fk_menu`, `fk_constraint`, `user`) values (108, 5000, 26, 2); insert into `llx_menu_const` (`rowid`, `fk_menu`, `fk_constraint`, `user`) values (109, 5001, 6, 2); + +ALTER TABLE llx_product ADD COLUMN volume float DEFAULT NULL after weight_units; +ALTER TABLE llx_product ADD COLUMN volume_units tinyint DEFAULT NULL after volume; \ No newline at end of file diff --git a/mysql/tables/llx_product.sql b/mysql/tables/llx_product.sql index 192c656979c..7a0c1b49811 100644 --- a/mysql/tables/llx_product.sql +++ b/mysql/tables/llx_product.sql @@ -45,5 +45,7 @@ create table llx_product gencode varchar(255) DEFAULT NULL, weight float DEFAULT NULL, weight_units tinyint DEFAULT NULL, + volume float DEFAULT NULL, + volume_units tinyint DEFAULT NULL, canvas varchar(15) DEFAULT '' )type=innodb;