Ajuste les stocks de commande des sous-produits
This commit is contained in:
parent
445c6239e1
commit
9df9702d11
@ -1412,6 +1412,35 @@ class Product
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Remplit le tableau des sous-produits
|
||||||
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
|
*/
|
||||||
|
function load_subproduct()
|
||||||
|
{
|
||||||
|
$this->subproducts_id = array();
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
$sql = "SELECT fk_product_subproduct FROM ".MAIN_DB_PREFIX."product_subproduct";
|
||||||
|
$sql .= " WHERE fk_product=$this->id;";
|
||||||
|
|
||||||
|
if ($result = $this->db->query($sql))
|
||||||
|
{
|
||||||
|
while ($row = $this->db->fetch_row($result) )
|
||||||
|
{
|
||||||
|
$this->subproducts_id[$i] = $row[0];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$this->db->free($result);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Lie un sous produit au produit/service
|
* \brief Lie un sous produit au produit/service
|
||||||
* \param id_sub Id du produit à lier
|
* \param id_sub Id du produit à lier
|
||||||
@ -1990,6 +2019,16 @@ class Product
|
|||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$this->load_subproduct();
|
||||||
|
|
||||||
|
for ($i = 0 ; $i < sizeof($this->subproducts_id) ; $i++)
|
||||||
|
{
|
||||||
|
$product = new Product($this->db);
|
||||||
|
$product->id = $this->subproducts_id[$i];
|
||||||
|
$product->ajust_stock_commande($nbpiece, $mouvement);
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user