Fix activity box

This commit is contained in:
Laurent Destailleur 2017-09-17 20:36:45 +02:00
parent 9dbd88f0ba
commit fb15b2aab0

View File

@ -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&amp;leftmenu=orders&amp;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&amp;paye=1&amp;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."&amp;paye=0";
$this->info_box_contents[$line][0] = array(
'td' => 'align="left" width="16"',