New: Store and show estimated value of stock
This commit is contained in:
parent
39b72a5fbe
commit
27c363530d
@ -280,8 +280,7 @@ class Commande extends CommonObject
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We decrement stock of product (and sub-products)
|
||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
@ -350,7 +349,7 @@ class Commande extends CommonObject
|
||||
function set_draft($user)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
|
||||
$error=0;
|
||||
|
||||
// Protection
|
||||
@ -386,7 +385,7 @@ class Commande extends CommonObject
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
@ -474,7 +473,7 @@ class Commande extends CommonObject
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increment stock of product (and sub-products)
|
||||
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
@ -1157,12 +1156,12 @@ class Commande extends CommonObject
|
||||
$ligne->date_start = $this->db->jdate($objp->date_start);
|
||||
$ligne->date_end = $this->db->jdate($objp->date_end);
|
||||
|
||||
$this->lignes[$i] = $ligne;
|
||||
$this->lignes[$i] = $ligne; // For backward compatibility
|
||||
$this->lines[$i] = $line;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($result);
|
||||
|
||||
$this->lines = $this->lignes; // For backward compatibility
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -1244,10 +1243,10 @@ class Commande extends CommonObject
|
||||
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'expedition as e';
|
||||
$sql .=" WHERE e.fk_commande = ".$this->id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $this->db->fetch_row(0);
|
||||
$row = $this->db->fetch_row($resql);
|
||||
return $row[0];
|
||||
}
|
||||
}
|
||||
@ -1266,14 +1265,14 @@ class Commande extends CommonObject
|
||||
$sql.=' AND cd.fk_commande =' .$this->id;
|
||||
if ($filtre_statut >= 0) $sql.=' AND l.fk_statut = '.$filtre_statut;
|
||||
$sql .= ' GROUP BY cd.fk_product ';
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row( $i);
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$this->livraisons[$row[0]] = $row[1];
|
||||
$i++;
|
||||
}
|
||||
@ -1719,9 +1718,9 @@ class Commande extends CommonObject
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $txtva, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
{
|
||||
global $conf;
|
||||
|
||||
dol_syslog("Commande::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $date_start, $date_end, $type");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
@ -2263,10 +2262,10 @@ class CommandeLigne
|
||||
var $fk_product; // Id produit predefini
|
||||
var $product_type = 0; // Type 0 = product, 1 = Service
|
||||
|
||||
var $qty; // Quantite (exemple 2)
|
||||
var $tva_tx; // Taux tva produit/service (exemple 19.6)
|
||||
var $subprice; // P.U. HT (exemple 100)
|
||||
var $remise_percent; // % de la remise ligne (exemple 20%)
|
||||
var $qty; // Quantity (example 2)
|
||||
var $tva_tx; // VAT Rate for product/service (example 19.6)
|
||||
var $subprice; // U.P. HT (example 100)
|
||||
var $remise_percent; // % for line discount (example 20%)
|
||||
var $rang = 0;
|
||||
var $marge_tx;
|
||||
var $marque_tx;
|
||||
|
||||
@ -549,7 +549,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
||||
if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$commande->fetch($_GET['id']); // Load order and lines
|
||||
|
||||
$result=$commande->valid($user);
|
||||
if ($result >= 0)
|
||||
@ -567,14 +567,16 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' &
|
||||
if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$commande->fetch($_GET['id']); // Load order and lines
|
||||
|
||||
$result = $commande->cloture($user);
|
||||
}
|
||||
|
||||
if ($_REQUEST['action'] == 'confirm_cancel' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$commande->fetch($_GET['id']); // Load order and lines
|
||||
|
||||
$result = $commande->cancel($user);
|
||||
}
|
||||
|
||||
@ -584,8 +586,7 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
||||
* Repasse la commande en mode brouillon
|
||||
*/
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
$commande->set_draft($user);
|
||||
$commande->fetch($_GET['id']); // Load order and lines
|
||||
|
||||
$result = $commande->set_draft($user);
|
||||
if ($result >= 0)
|
||||
|
||||
@ -398,7 +398,7 @@ class Expedition extends CommonObject
|
||||
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||
|
||||
// Loop on each product line to add a stock movement
|
||||
$sql = "SELECT cd.fk_product, ed.qty, ed.fk_entrepot";
|
||||
$sql = "SELECT cd.fk_product, cd.subprice, ed.qty, ed.fk_entrepot";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed";
|
||||
$sql.= " WHERE ed.fk_expedition = ".$this->id;
|
||||
@ -419,8 +419,7 @@ class Expedition extends CommonObject
|
||||
$mouvS = new MouvementStock($this->db);
|
||||
// We decrement stock of product (and sub-products)
|
||||
$entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty);
|
||||
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $obj->qty, $obj->subprice);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
|
||||
|
||||
@ -1359,8 +1359,7 @@ class Facture extends CommonObject
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We decrease stock for product
|
||||
$entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
@ -1455,8 +1454,7 @@ class Facture extends CommonObject
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We decrease stock for product
|
||||
$entrepot_id = "1"; // TODO ajouter possibilité de choisir l'entrepot
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3045,7 +3043,7 @@ class FactureLigne
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
global $conf;
|
||||
global $conf;
|
||||
|
||||
// Clean parameters
|
||||
$this->desc=trim($this->desc);
|
||||
|
||||
@ -546,8 +546,7 @@ class CommandeFournisseur extends Commande
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We decrement stock of product (and sub-products)
|
||||
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
@ -958,34 +957,33 @@ class CommandeFournisseur extends Commande
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$error = -1;
|
||||
}
|
||||
// Si module stock gere et que expedition faite depuis un entrepot
|
||||
if (!$error && $conf->stock->enabled && $entrepot)
|
||||
{
|
||||
$mouv = new MouvementStock($this->db);
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouv->reception($user, $product, $entrepot, $qty, $price);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$this->db->error()." - sql=$sql";
|
||||
dol_syslog("CommandeFournisseur::DispatchProduct".$this->error, LOG_ERR);
|
||||
$error = -2;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
{
|
||||
$error = -1;
|
||||
}
|
||||
// Si module stock gere et que expedition faite depuis un entrepot
|
||||
if (!$error && $conf->stock->enabled && $entrepot)
|
||||
{
|
||||
$mouv = new MouvementStock($this->db);
|
||||
$result=$mouv->reception($user, $product, $entrepot, $qty, $price);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$this->db->error()." - sql=$sql";
|
||||
dol_syslog("CommandeFournisseur::DispatchProduct".$this->error, LOG_ERR);
|
||||
$error = -2;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
if ($error == 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -458,8 +458,7 @@ class FactureFournisseur extends Facture
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
// We increase stock for product
|
||||
$entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
|
||||
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->pu_ht);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,7 +392,7 @@ class Livraison extends CommonObject
|
||||
|
||||
dol_syslog("livraison.class.php::valid enregistrement des mouvements");
|
||||
|
||||
$sql = "SELECT cd.fk_product, ld.qty ";
|
||||
$sql = "SELECT cd.fk_product, cd.subprice, ld.qty ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."livraisondet as ld";
|
||||
$sql.= " WHERE ld.fk_livraison = ".$this->id;
|
||||
@ -410,8 +410,7 @@ class Livraison extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$mouvS = new MouvementStock($this->db);
|
||||
// TODO Add price of product in method or '' to update PMP
|
||||
$result=$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty);
|
||||
$result=$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty, $obj->subprice);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user