Bonjour,
Ce bug me causait quelques soucis. J'ai donc fait une petite modification au niveau du fichier "product.class.php", au niveau de la fonction "load_stats_commande" :
function load_stats_commande($socid=0,$filtrestatut='')
{
global $conf,$user;
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
$sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON cd.rowid = ed.fk_origin_line"; // modification
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition as e ON ed.fk_expedition = e.rowid"; // modification
$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";
$sql.= " WHERE c.rowid = cd.fk_commande";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND (e.fk_statut IS NULL OR e.fk_statut = 0)"; // modification
$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 ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")";
$result = $this->db->query($sql) ;
if ( $result )
{
$obj=$this->db->fetch_object($result);
$this->stats_commande['customers']=$obj->nb_customers;
$this->stats_commande['nb']=$obj->nb;
$this->stats_commande['rows']=$obj->nb_rows;
$this->stats_commande['qty']=$obj->qty?$obj->qty:0;
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
J'ai modifié la requête (3 lignes à rajouter). Je pense que c'est correct.
Quels sont les avis des experts ?