forked from Wavyzz/dolibarr
Add: gestion du volume d'un produit
This commit is contained in:
@@ -2206,24 +2206,35 @@ class Form
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Selection des unites de poids
|
* \brief Selection des unites de mesure
|
||||||
* \param name Nom champ html
|
* \param name Nom champ html
|
||||||
|
* \param measuring_style Le style de mesure : weight, volume,...
|
||||||
* \param default For<6F>age de l'unite
|
* \param default For<6F>age de l'unite
|
||||||
* \remarks pour l'instant on ne definit pas les unites dans la base
|
* \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;
|
global $langs,$conf,$mysoc;
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
$units[3] = $langs->trans("WeightUnitmg");
|
if ($measuring_style == 'weight')
|
||||||
$units[0] = $langs->trans("WeightUnitkg");
|
{
|
||||||
$units[-3] = $langs->trans("WeightUnitg");
|
$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 '<select class="flat" name="'.$name.'">';
|
print '<select class="flat" name="'.$name.'">';
|
||||||
if ($adddefault) print '<option value="0">'.$langs->trans("Default").'</option>';
|
if ($adddefault) print '<option value="0">'.$langs->trans("Default").'</option>';
|
||||||
|
|
||||||
foreach ($units as $key => $value)
|
foreach ($measuring_units as $key => $value)
|
||||||
{
|
{
|
||||||
print '<option value="'.$key.'"';
|
print '<option value="'.$key.'"';
|
||||||
if ($key == $default)
|
if ($key == $default)
|
||||||
@@ -2235,6 +2246,12 @@ class Form
|
|||||||
print '</select>';
|
print '</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
|
function load_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
|
||||||
{
|
{
|
||||||
global $langs,$conf,$mysoc;
|
global $langs,$conf,$mysoc;
|
||||||
|
|||||||
@@ -59,9 +59,14 @@ FeaturesSupported=Features supported
|
|||||||
Width=Width
|
Width=Width
|
||||||
Height=Height
|
Height=Height
|
||||||
Weight=Weight
|
Weight=Weight
|
||||||
WeightUnitmg=tonnes
|
WeightUnitton=tonnes
|
||||||
WeightUnitkg=kg
|
WeightUnitkg=kg
|
||||||
WeightUnitg=g
|
WeightUnitg=g
|
||||||
|
WeightUnitmg=mg
|
||||||
|
Volume=Volume
|
||||||
|
VolumeUnitm3=m3
|
||||||
|
VolumeUnitcm3=cm3
|
||||||
|
VolumeUnitmm3=mm3
|
||||||
BugTracker=Bug tracker
|
BugTracker=Bug tracker
|
||||||
##### Webcal #####
|
##### Webcal #####
|
||||||
LoginWebcal=Login for Webcalendar
|
LoginWebcal=Login for Webcalendar
|
||||||
|
|||||||
@@ -59,9 +59,14 @@ FeaturesSupported=Fonctionnalit
|
|||||||
Width=Largeur
|
Width=Largeur
|
||||||
Height=Hauteur
|
Height=Hauteur
|
||||||
Weight=Poids
|
Weight=Poids
|
||||||
WeightUnitmg=tonnes
|
WeightUnitton=tonnes
|
||||||
WeightUnitkg=kg
|
WeightUnitkg=kg
|
||||||
WeightUnitg=g
|
WeightUnitg=g
|
||||||
|
WeightUnitmg=mg
|
||||||
|
Volume=Volume
|
||||||
|
VolumeUnitm3=m3
|
||||||
|
VolumeUnitcm3=cm3
|
||||||
|
VolumeUnitmm3=mm3
|
||||||
BugTracker=Bug tracker
|
BugTracker=Bug tracker
|
||||||
##### Webcal #####
|
##### Webcal #####
|
||||||
LoginWebcal=Login Webcalendar
|
LoginWebcal=Login Webcalendar
|
||||||
|
|||||||
@@ -2299,25 +2299,39 @@ function weight_convert($weight,&$from_unit,$to_unit)
|
|||||||
|
|
||||||
return $weight;
|
return $weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Renvoi le texte d'une unite
|
\brief Renvoi le texte d'une unite
|
||||||
\param int Unit
|
\param int Unit
|
||||||
\return string Unite
|
\param measuring_style Le style de mesure : weight, volume,...
|
||||||
|
\return string Unite
|
||||||
\todo gerer les autres unit<69>s de mesure comme la livre, le gallon, le litre, ...
|
\todo gerer les autres unit<69>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 :)
|
/* Note Rodo aux dev :)
|
||||||
* Ne pas ins<6E>rer dans la base de donn<6E>es ces valeurs
|
* Ne pas ins<6E>rer dans la base de donn<6E>es ces valeurs
|
||||||
* cela surchagerait inutilement d'une requete suppl<70>mentaire
|
* cela surchagerait inutilement d'une requete suppl<70>mentaire
|
||||||
* pour quelque chose qui est somme toute peu variable
|
* 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';
|
|
||||||
|
|
||||||
return $weight_string[$unit];
|
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 $measuring_units[$unit];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,6 +65,14 @@ class Product
|
|||||||
// Statut indique si le produit est en vente '1' ou non '0'
|
// Statut indique si le produit est en vente '1' ou non '0'
|
||||||
var $status;
|
var $status;
|
||||||
|
|
||||||
|
//! Unit<69>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_propale=array();
|
||||||
var $stats_commande=array();
|
var $stats_commande=array();
|
||||||
var $stats_contrat=array();
|
var $stats_contrat=array();
|
||||||
@@ -299,6 +307,8 @@ class Product
|
|||||||
$this->stock_loc = trim($this->stock_loc);
|
$this->stock_loc = trim($this->stock_loc);
|
||||||
$this->new_weight = price2num($this->new_weight);
|
$this->new_weight = price2num($this->new_weight);
|
||||||
$this->new_weight_units = trim($this->new_weight_units);
|
$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 = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||||
$sql .= " SET label = '" . addslashes($this->libelle) ."'";
|
$sql .= " SET label = '" . addslashes($this->libelle) ."'";
|
||||||
@@ -307,6 +317,8 @@ class Product
|
|||||||
$sql .= ",envente = " . $this->status;
|
$sql .= ",envente = " . $this->status;
|
||||||
$sql .= ",weight = " . ($this->new_weight!='' ? "'".$this->new_weight."'" : 'null');
|
$sql .= ",weight = " . ($this->new_weight!='' ? "'".$this->new_weight."'" : 'null');
|
||||||
$sql .= ",weight_units = '" . $this->new_weight_units."'";
|
$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 .= ",seuil_stock_alerte = '" . $this->seuil_stock_alerte."'";
|
||||||
$sql .= ",description = '" . addslashes($this->description) ."'";
|
$sql .= ",description = '" . addslashes($this->description) ."'";
|
||||||
$sql .= ",stock_loc = '" . addslashes($this->stock_loc) ."'";
|
$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 = "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.= " 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";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
||||||
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
||||||
@@ -963,6 +975,8 @@ class Product
|
|||||||
$this->stock_loc = $result["stock_loc"];
|
$this->stock_loc = $result["stock_loc"];
|
||||||
$this->weight = $result["weight"];
|
$this->weight = $result["weight"];
|
||||||
$this->weight_units = $result["weight_units"];
|
$this->weight_units = $result["weight_units"];
|
||||||
|
$this->volume = $result["volume"];
|
||||||
|
$this->volume_units = $result["volume_units"];
|
||||||
|
|
||||||
$this->stock_in_command = $result["stock_commande"];
|
$this->stock_in_command = $result["stock_commande"];
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
|||||||
$product->canvas = $_POST["canvas"];
|
$product->canvas = $_POST["canvas"];
|
||||||
$product->new_weight = $_POST["weight"];
|
$product->new_weight = $_POST["weight"];
|
||||||
$product->new_weight_units = $_POST["weight_units"];
|
$product->new_weight_units = $_POST["weight_units"];
|
||||||
|
$product->new_volume = $_POST["volume"];
|
||||||
|
$product->new_volume_units = $_POST["volume_units"];
|
||||||
// MultiPrix
|
// MultiPrix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
{
|
{
|
||||||
@@ -149,6 +151,8 @@ if ($_POST["action"] == 'update' &&
|
|||||||
$product->canvas = $_POST["canvas"];
|
$product->canvas = $_POST["canvas"];
|
||||||
$product->new_weight = $_POST["weight"];
|
$product->new_weight = $_POST["weight"];
|
||||||
$product->new_weight_units = $_POST["weight_units"];
|
$product->new_weight_units = $_POST["weight_units"];
|
||||||
|
$product->new_volume = $_POST["volume"];
|
||||||
|
$product->new_volume_units = $_POST["volume_units"];
|
||||||
|
|
||||||
if ($product->check())
|
if ($product->check())
|
||||||
{
|
{
|
||||||
@@ -520,10 +524,14 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
|||||||
}
|
}
|
||||||
else
|
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 '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
||||||
print '<input name="weight" size="4" value="">';
|
print '<input name="weight" size="4" value="">';
|
||||||
print $html->select_weight_units("weight_units");
|
print $html->select_measuring_units("weight_units","weight");
|
||||||
|
print '</td></tr>';
|
||||||
|
print '<tr><td>'.$langs->trans("volume").'</td><td>';
|
||||||
|
print '<input name="volume" size="4" value="">';
|
||||||
|
print $html->select_measuring_units("volume_units","volume");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,32 +765,43 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
// Dur<75>e
|
// Dur<75>e
|
||||||
if ($product->isservice())
|
if ($product->isservice())
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
|
||||||
|
if ($product->duration_value > 1)
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
|
$dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||||
if ($product->duration_value > 1)
|
}
|
||||||
{
|
else
|
||||||
$dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
{
|
||||||
}
|
$dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||||
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 $langs->trans($dur[$product->duration_unit])." ";
|
|
||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
||||||
if ($product->weight != '')
|
if ($product->weight != '')
|
||||||
{
|
{
|
||||||
print $product->weight." ".weight_units_string($product->weight_units);
|
print $product->weight." ".measuring_units_string($product->weight_units,"weight");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print ' ';
|
print ' ';
|
||||||
}
|
}
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
|
||||||
|
if ($product->volume != '')
|
||||||
|
{
|
||||||
|
print $product->volume." ".measuring_units_string($product->volume_units,"volume");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print ' ';
|
||||||
|
}
|
||||||
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
// Note
|
// Note
|
||||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'.nl2br($product->note).'</td></tr>';
|
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'.nl2br($product->note).'</td></tr>';
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
@@ -877,10 +896,14 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
}
|
}
|
||||||
else
|
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 '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
||||||
print '<input name="weight" size="5" value="'.$product->weight.'">';
|
print '<input name="weight" size="5" value="'.$product->weight.'">';
|
||||||
print $html->select_weight_units("weight_units",$product->weight_units);
|
print $html->select_measuring_units("weight_units", "weight", $product->weight_units);
|
||||||
|
print '</td></tr>';
|
||||||
|
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
|
||||||
|
print '<input name="volume" size="5" value="'.$product->volume.'">';
|
||||||
|
print $html->select_measuring_units("volume_units", "volume", $product->volume_units);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 (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 (108, 5000, 26, 2);
|
||||||
insert into `llx_menu_const` (`rowid`, `fk_menu`, `fk_constraint`, `user`) values (109, 5001, 6, 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;
|
||||||
@@ -45,5 +45,7 @@ create table llx_product
|
|||||||
gencode varchar(255) DEFAULT NULL,
|
gencode varchar(255) DEFAULT NULL,
|
||||||
weight float DEFAULT NULL,
|
weight float DEFAULT NULL,
|
||||||
weight_units tinyint DEFAULT NULL,
|
weight_units tinyint DEFAULT NULL,
|
||||||
|
volume float DEFAULT NULL,
|
||||||
|
volume_units tinyint DEFAULT NULL,
|
||||||
canvas varchar(15) DEFAULT ''
|
canvas varchar(15) DEFAULT ''
|
||||||
)type=innodb;
|
)type=innodb;
|
||||||
|
|||||||
Reference in New Issue
Block a user