Update product.class.php
This commit is contained in:
parent
07f6ae34dc
commit
fcff96d43f
@ -3038,12 +3038,13 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Charge tableau des stats commande fournisseur pour le produit/service
|
||||
*
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id des statuts pour filtrer sur des statuts
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @return int Array of stats in $this->stats_commande_fournisseur, <0 if ko or >0 if ok
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id des statuts pour filtrer sur des statuts
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @param int $dateofvirtualstock Date of virtual stock
|
||||
* @return int Array of stats in $this->stats_commande_fournisseur, <0 if ko or >0 if ok
|
||||
*/
|
||||
public function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
|
||||
public function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $dateofvirtualstock = null)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $user, $hookmanager, $action;
|
||||
@ -3069,6 +3070,9 @@ class Product extends CommonObject
|
||||
if ($filtrestatut != '') {
|
||||
$sql .= " AND c.fk_statut in (".$this->db->sanitize($filtrestatut).")"; // Peut valoir 0
|
||||
}
|
||||
if (!empty($dateofvirtualstock)) {
|
||||
$sql .= " AND c.date_livraison <= '".$this->db->idate($dateofvirtualstock)."'";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
@ -3181,12 +3185,13 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Charge tableau des stats réception fournisseur pour le produit/service
|
||||
*
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @param int $dateofvirtualstock Date of virtual stock
|
||||
* @return int Array of stats in $this->stats_reception, <0 if ko or >0 if ok
|
||||
*/
|
||||
public function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
|
||||
public function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $dateofvirtualstock = null)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $user, $hookmanager, $action;
|
||||
@ -3212,6 +3217,9 @@ class Product extends CommonObject
|
||||
if ($filtrestatut <> '') {
|
||||
$sql .= " AND cf.fk_statut IN (".$this->db->sanitize($filtrestatut).")";
|
||||
}
|
||||
if (!empty($dateofvirtualstock)) {
|
||||
$sql .= " AND fd.datec <= '".$this->db->idate($dateofvirtualstock)."'";
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
@ -3238,12 +3246,13 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Charge tableau des stats production pour le produit/service
|
||||
*
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param string $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
|
||||
* @param int $dateofvirtualstock Date of virtual stock
|
||||
* @return integer Array of stats in $this->stats_mrptoproduce (nb=nb of order, qty=qty ordered), <0 if ko or >0 if ok
|
||||
*/
|
||||
public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
|
||||
public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $dateofvirtualstock = null)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $user, $hookmanager, $action;
|
||||
@ -3268,6 +3277,9 @@ class Product extends CommonObject
|
||||
if ($filtrestatut <> '') {
|
||||
$sql .= " AND m.status IN (".$this->db->sanitize($filtrestatut).")";
|
||||
}
|
||||
if (!empty($dateofvirtualstock)) {
|
||||
$sql .= " AND m.date_valid <= '".$this->db->idate($dateofvirtualstock)."'"; // better date to code ? end of production ?
|
||||
}
|
||||
$sql .= " GROUP BY role";
|
||||
|
||||
$this->stats_mrptoconsume['customers'] = 0;
|
||||
@ -5346,10 +5358,11 @@ class Product extends CommonObject
|
||||
* @param string $option '' = Load all stock info, also from closed and internal warehouses, 'nobatch', 'novirtual'
|
||||
* You can also filter on 'warehouseclosed', 'warehouseopen', 'warehouseinternal'
|
||||
* @param int $includedraftpoforvirtual Include draft status of PO for virtual stock calculation
|
||||
* @param int $dateofvirtualstock Date of virtual stock
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
* @see load_virtual_stock(), loadBatchInfo()
|
||||
*/
|
||||
public function load_stock($option = '', $includedraftpoforvirtual = null)
|
||||
public function load_stock($option = '', $includedraftpoforvirtual = null, $dateofvirtualstock = null)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
@ -5407,7 +5420,7 @@ class Product extends CommonObject
|
||||
$this->db->free($result);
|
||||
|
||||
if (!preg_match('/novirtual/', $option)) {
|
||||
$this->load_virtual_stock($includedraftpoforvirtual); // This also load all arrays stats_xxx...
|
||||
$this->load_virtual_stock($includedraftpoforvirtual, $dateofvirtualstock); // This also load all arrays stats_xxx...
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -5424,10 +5437,11 @@ class Product extends CommonObject
|
||||
* This function need a lot of load. If you use it on list, use a cache to execute it one for each product id.
|
||||
*
|
||||
* @param int $includedraftpoforvirtual Include draft status and not yet approved Purchase Orders for virtual stock calculation
|
||||
* @param int $dateofvirtualstock Date of virtual stock
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
* @see load_stock(), loadBatchInfo()
|
||||
*/
|
||||
public function load_virtual_stock($includedraftpoforvirtual = null)
|
||||
public function load_virtual_stock($includedraftpoforvirtual = null, $dateofvirtualstock = null)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $hookmanager, $action;
|
||||
@ -5466,7 +5480,7 @@ class Product extends CommonObject
|
||||
if (isset($includedraftpoforvirtual)) {
|
||||
$filterStatus = '0,1,2,'.$filterStatus; // 1,2 may have already been inside $filterStatus but it is better to have twice than missing $filterStatus does not include them
|
||||
}
|
||||
$result = $this->load_stats_commande_fournisseur(0, $filterStatus, 1);
|
||||
$result = $this->load_stats_commande_fournisseur(0, $filterStatus, 1, $dateofvirtualstock);
|
||||
if ($result < 0) {
|
||||
dol_print_error($this->db, $this->error);
|
||||
}
|
||||
@ -5478,7 +5492,7 @@ class Product extends CommonObject
|
||||
if (isset($includedraftpoforvirtual)) {
|
||||
$filterStatus = '0,'.$filterStatus;
|
||||
}
|
||||
$result = $this->load_stats_reception(0, $filterStatus, 1);
|
||||
$result = $this->load_stats_reception(0, $filterStatus, 1, $dateofvirtualstock);
|
||||
if ($result < 0) {
|
||||
dol_print_error($this->db, $this->error);
|
||||
}
|
||||
@ -5490,14 +5504,14 @@ class Product extends CommonObject
|
||||
if (isset($includedraftpoforvirtual)) {
|
||||
$filterStatus = '0,'.$filterStatus;
|
||||
}
|
||||
$result = $this->load_stats_reception(0, $filterStatus, 1); // Use same tables than when module reception is not used.
|
||||
$result = $this->load_stats_reception(0, $filterStatus, 1, $dateofvirtualstock); // Use same tables than when module reception is not used.
|
||||
if ($result < 0) {
|
||||
dol_print_error($this->db, $this->error);
|
||||
}
|
||||
$stock_reception_fournisseur = $this->stats_reception['qty'];
|
||||
}
|
||||
if (!empty($conf->mrp->enabled)) {
|
||||
$result = $this->load_stats_inproduction(0, '1,2', 1);
|
||||
$result = $this->load_stats_inproduction(0, '1,2', 1, $dateofvirtualstock);
|
||||
if ($result < 0) {
|
||||
dol_print_error($this->db, $this->error);
|
||||
}
|
||||
@ -6196,8 +6210,6 @@ class Product extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage products or services.
|
||||
* Do not use 'Service' as class name since it is already used by APIs.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user