Mets a jour les infos de stock des produits
This commit is contained in:
parent
0b9d9ed8ef
commit
2b4d773f66
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
@ -1189,7 +1189,23 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne";
|
$sql = "SELECT fk_product, qty";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
|
||||||
|
$sql.= " WHERE rowid = '$idligne';";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
while ($obj = $this->db->fetch_object($result))
|
||||||
|
{
|
||||||
|
$product = new Product($this->db);
|
||||||
|
$product->id = $obj->fk_product;
|
||||||
|
$product->ajust_stock_commande($obj->qty, 1);
|
||||||
|
}
|
||||||
|
$this->db->free($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid = '$idligne';";
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
@ -1677,6 +1693,10 @@ class Commande extends CommonObject
|
|||||||
$price = price2num($price);
|
$price = price2num($price);
|
||||||
$subprice = price2num($subprice);
|
$subprice = price2num($subprice);
|
||||||
|
|
||||||
|
|
||||||
|
$LigneOld = new CommandeLigne($this->db);
|
||||||
|
$LigneOld->fetch($rowid);
|
||||||
|
|
||||||
// Mise a jour ligne en base
|
// Mise a jour ligne en base
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
|
||||||
$sql.= " description='".addslashes($desc)."'";
|
$sql.= " description='".addslashes($desc)."'";
|
||||||
@ -1701,6 +1721,17 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
// Mise a jour info denormalisees au niveau facture
|
// Mise a jour info denormalisees au niveau facture
|
||||||
$this->update_price($this->id);
|
$this->update_price($this->id);
|
||||||
|
|
||||||
|
if ($LigneOld->qty <> $qty && $LigneOld->produit_id)
|
||||||
|
{
|
||||||
|
$delta = $qty - $LigneOld->qty;
|
||||||
|
$op = ($delta > 0) ? 0 : 1;
|
||||||
|
|
||||||
|
$product = new Product($this->db);
|
||||||
|
$product->id = $LigneOld->produit_id;
|
||||||
|
$product->ajust_stock_commande(abs($delta), $op);
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -2212,6 +2243,14 @@ class CommandeLigne
|
|||||||
|
|
||||||
dolibarr_syslog("CommandeLigne.class.php::insert sql=$sql");
|
dolibarr_syslog("CommandeLigne.class.php::insert sql=$sql");
|
||||||
|
|
||||||
|
if ($this->fk_product)
|
||||||
|
{
|
||||||
|
$product = new Product($this->db);
|
||||||
|
$product->id = $this->fk_product;
|
||||||
|
$product->ajust_stock_commande($this->qty, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -2259,7 +2298,6 @@ class CommandeLigne
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user