Merge pull request #7096 from fappels/6.0_fix_virtual_stock_read_rights_third_parties
FIX: Ignore third party read rights filter for virtual stock calculation.
This commit is contained in:
commit
aa4ff464d6
@ -2136,11 +2136,12 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Charge tableau des stats commande client pour le produit/service
|
||||
*
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param int $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @return array Array of stats (nb=nb of order, qty=qty ordered)
|
||||
* @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.
|
||||
* @return array Array of stats (nb=nb of order, qty=qty ordered)
|
||||
*/
|
||||
function load_stats_commande($socid=0,$filtrestatut='')
|
||||
function load_stats_commande($socid=0,$filtrestatut='', $forVirtualStock = 0)
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -2149,12 +2150,12 @@ class Product extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE c.rowid = cd.fk_commande";
|
||||
$sql.= " AND c.fk_soc = s.rowid";
|
||||
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||
$sql.= " AND cd.fk_product = ".$this->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
|
||||
if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")";
|
||||
|
||||
@ -2202,11 +2203,12 @@ 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
|
||||
* @return array Tableau des stats
|
||||
* @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 array Tableau des stats
|
||||
*/
|
||||
function load_stats_commande_fournisseur($socid=0,$filtrestatut='')
|
||||
function load_stats_commande_fournisseur($socid=0,$filtrestatut='', $forVirtualStock = 0)
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -2215,12 +2217,12 @@ class Product extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE c.rowid = cd.fk_commande";
|
||||
$sql.= " AND c.fk_soc = s.rowid";
|
||||
$sql.= " AND c.entity IN (".getEntity('supplier_order').")";
|
||||
$sql.= " AND cd.fk_product = ".$this->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
|
||||
if ($filtrestatut != '') $sql.= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0
|
||||
|
||||
@ -2244,11 +2246,12 @@ class Product extends CommonObject
|
||||
/**
|
||||
* Charge tableau des stats expedition client pour le produit/service
|
||||
*
|
||||
* @param int $socid Id societe pour filtrer sur une societe
|
||||
* @param int $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @return array Tableau des stats
|
||||
* @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.
|
||||
* @return array Tableau des stats
|
||||
*/
|
||||
function load_stats_sending($socid=0,$filtrestatut='')
|
||||
function load_stats_sending($socid=0,$filtrestatut='', $forVirtualStock = 0)
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -2259,14 +2262,14 @@ class Product extends CommonObject
|
||||
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."expedition as e";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE e.rowid = ed.fk_expedition";
|
||||
$sql.= " AND c.rowid = cd.fk_commande";
|
||||
$sql.= " AND e.fk_soc = s.rowid";
|
||||
$sql.= " AND e.entity IN (".getEntity('expedition').")";
|
||||
$sql.= " AND ed.fk_origin_line = cd.rowid";
|
||||
$sql.= " AND cd.fk_product = ".$this->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid > 0) $sql.= " AND e.fk_soc = ".$socid;
|
||||
if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")";
|
||||
|
||||
@ -2290,11 +2293,12 @@ 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 int $filtrestatut Id statut pour filtrer sur un statut
|
||||
* @return array Tableau des stats
|
||||
* @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.
|
||||
* @return array Tableau des stats
|
||||
*/
|
||||
function load_stats_reception($socid=0,$filtrestatut='')
|
||||
function load_stats_reception($socid=0,$filtrestatut='', $forVirtualStock = 0)
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -2303,12 +2307,12 @@ class Product extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE cf.rowid = fd.fk_commande";
|
||||
$sql.= " AND cf.fk_soc = s.rowid";
|
||||
$sql.= " AND cf.entity IN (".getEntity('supplier_order').")";
|
||||
$sql.= " AND fd.fk_product = ".$this->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid;
|
||||
if ($filtrestatut <> '') $sql.= " AND cf.fk_statut in (".$filtrestatut.")";
|
||||
|
||||
@ -3801,23 +3805,23 @@ class Product extends CommonObject
|
||||
|
||||
if (! empty($conf->commande->enabled))
|
||||
{
|
||||
$result=$this->load_stats_commande(0,'1,2');
|
||||
$result=$this->load_stats_commande(0,'1,2', 1);
|
||||
if ($result < 0) dol_print_error($this->db,$this->error);
|
||||
$stock_commande_client=$this->stats_commande['qty'];
|
||||
}
|
||||
if (! empty($conf->expedition->enabled))
|
||||
{
|
||||
$result=$this->load_stats_sending(0,'1,2');
|
||||
$result=$this->load_stats_sending(0,'1,2', 1);
|
||||
if ($result < 0) dol_print_error($this->db,$this->error);
|
||||
$stock_sending_client=$this->stats_expedition['qty'];
|
||||
}
|
||||
if (! empty($conf->fournisseur->enabled))
|
||||
{
|
||||
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4');
|
||||
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1);
|
||||
if ($result < 0) dol_print_error($this->db,$this->error);
|
||||
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
|
||||
|
||||
$result=$this->load_stats_reception(0,'4');
|
||||
$result=$this->load_stats_reception(0,'4', 1);
|
||||
if ($result < 0) dol_print_error($this->db,$this->error);
|
||||
$stock_reception_fournisseur=$this->stats_reception['qty'];
|
||||
}
|
||||
|
||||
@ -655,7 +655,7 @@ if ($id > 0 || $ref)
|
||||
{
|
||||
if ($found) $helpondiff.='<br>'; else $found=1;
|
||||
$helpondiff.=$langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty'];
|
||||
$result=$object->load_stats_commande(0,'0');
|
||||
$result=$object->load_stats_commande(0,'0', 1);
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
$helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')';
|
||||
}
|
||||
@ -664,7 +664,7 @@ if ($id > 0 || $ref)
|
||||
if (! empty($conf->expedition->enabled))
|
||||
{
|
||||
if ($found) $helpondiff.='<br>'; else $found=1;
|
||||
$result=$object->load_stats_sending(0,'2');
|
||||
$result=$object->load_stats_sending(0,'2', 1);
|
||||
$helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty'];
|
||||
}
|
||||
|
||||
@ -672,9 +672,9 @@ if ($id > 0 || $ref)
|
||||
if (! empty($conf->fournisseur->enabled))
|
||||
{
|
||||
if ($found) $helpondiff.='<br>'; else $found=1;
|
||||
$result=$object->load_stats_commande_fournisseur(0,'3,4');
|
||||
$result=$object->load_stats_commande_fournisseur(0,'3,4', 1);
|
||||
$helpondiff.=$langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty'];
|
||||
$result=$object->load_stats_commande_fournisseur(0,'0,1,2');
|
||||
$result=$object->load_stats_commande_fournisseur(0,'0,1,2', 1);
|
||||
if ($result < 0) dol_print_error($db,$object->error);
|
||||
$helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user