diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 7c6308e29e6..a05fcf761b6 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -95,8 +95,6 @@ class box_activity extends ModeleBoxes // compute the year limit to show $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); - $cumuldata = array(); - // list the summary of the propals if (! empty($conf->propal->enabled) && $user->rights->propale->lire) @@ -146,11 +144,10 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) + while ($line < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -231,10 +228,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($line < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, @@ -290,11 +286,11 @@ class box_activity extends ModeleBoxes $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -317,10 +313,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($line < count($data)) { $billurl="search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -371,12 +366,13 @@ class box_activity extends ModeleBoxes $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=0"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -399,13 +395,12 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; $alreadypaid=-1; - while ($line < count($cumuldata)) { + while ($line < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"',