Ajoute la fonction ajust_stock_commande($nbpiece, $mouvement)
Permet de conserver un compteur du nombre de piece en commande non encore expediee
This commit is contained in:
parent
bd0def216b
commit
fe1c2cde5b
@ -1892,9 +1892,8 @@ class Product
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Augment ou réduit la valeur de stock pour le produit
|
* \brief Augmente ou réduit la valeur de stock pour le produit
|
||||||
* \param user utilisateur qui demande l'ajustement
|
* \param user utilisateur qui demande l'ajustement
|
||||||
* \param id_entrepot id de l'entrepot
|
* \param id_entrepot id de l'entrepot
|
||||||
* \param nbpiece nombre de pieces
|
* \param nbpiece nombre de pieces
|
||||||
@ -1906,13 +1905,6 @@ class Product
|
|||||||
$op[1] = "-" . trim($nbpiece);
|
$op[1] = "-" . trim($nbpiece);
|
||||||
|
|
||||||
if ($this->db->begin())
|
if ($this->db->begin())
|
||||||
{
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
|
||||||
$sql .= " SET stock_commande = stock_commande ".$op[$mouvement].", stock_propale = stock_propale ".$op[$mouvement];
|
|
||||||
$sql .= " WHERE rowid = $this->id ";
|
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product_stock ";
|
||||||
$sql .= " SET reel = reel ".$op[$mouvement];
|
$sql .= " SET reel = reel ".$op[$mouvement];
|
||||||
@ -1942,6 +1934,37 @@ class Product
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Augmente ou réduit le nombre de piece en commande a expedier
|
||||||
|
* \param nbpiece nombre de pieces
|
||||||
|
* \param mouvement 0 = ajout, 1 = suppression
|
||||||
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
|
*/
|
||||||
|
function ajust_stock_commande($nbpiece, $mouvement)
|
||||||
|
{
|
||||||
|
$op[0] = "+" . trim($nbpiece);
|
||||||
|
$op[1] = "-" . trim($nbpiece);
|
||||||
|
|
||||||
|
if ($this->db->begin())
|
||||||
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||||
|
$sql .= " SET stock_commande = stock_commande ".$op[$mouvement];
|
||||||
|
$sql .= " WHERE rowid = '".$this->id ."';";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
@ -1949,7 +1972,7 @@ class Product
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Charge les informations en stock du produit
|
* \brief Charge les informations en stock du produit
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user