diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 83366690476..cfa936346b4 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -372,14 +372,13 @@ function activitytrim($product_type) // breakdown by quarter $sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; $sql.= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf"; - $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " WHERE f.entity = " . $conf->entity; $sql.= " AND f.rowid = fd.fk_facture"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND pf.fk_paiement= p.rowid"; $sql.= " AND fd.product_type=".$product_type; - $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate),1)."'"; $sql.= " GROUP BY annee, mois "; $sql.= " ORDER BY annee, mois ";