diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index d502fd8757f..30aa156b7fb 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -147,11 +147,11 @@ $sql.= " WHERE c.id = a.fk_action"; $sql.= ' AND a.fk_user_author = u.rowid'; $sql.= ' AND a.entity = '.$conf->entity; // To limit to entity if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($_GET["type"]) $sql.= " AND c.id = ".$_GET["type"]; if ($status == 'done') { $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; } -if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND percent < 100) OR (a.percent > -1 AND a.datep2 > '".$db->idate($now)."'))"; } +if ($status == 'todo') { $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; } if ($filtera > 0 || $filtert > 0 || $filterd > 0) { $sql.= " AND ("; diff --git a/htdocs/lib/agenda.lib.php b/htdocs/lib/agenda.lib.php index 6f4638e38f8..20c7f697e97 100644 --- a/htdocs/lib/agenda.lib.php +++ b/htdocs/lib/agenda.lib.php @@ -134,14 +134,13 @@ function show_array_actions_to_do($max=5) $sql = "SELECT a.id, a.label, a.datep as dp, a.fk_user_author, a.percent,"; $sql.= " c.code, c.libelle,"; $sql.= " s.nom as sname, s.rowid, s.client"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; $sql.= ", ".MAIN_DB_PREFIX."c_actioncomm 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.= ")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid AND s.entity IN (0, ".$conf->entity.")"; $sql.= " WHERE c.id = a.fk_action"; - $sql.= " AND ((a.percent >= 0 AND percent < 100) OR (a.percent > -1 AND a.datep2 > '".$db->idate($now)."'))"; - $sql.= " AND s.rowid = a.fk_soc"; - $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '".$db->idate($now)."'))"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY a.datep DESC, a.id DESC"; @@ -155,7 +154,7 @@ function show_array_actions_to_do($max=5) { print '
| '.$langs->trans("LastActionsToDo",$max).' | '; - print ''.$langs->trans("FullList").''; + print ' | '.$langs->trans("FullList").''; print ' | ||||||
| '.$staticaction->getNomUrl(1,12).' | '; + print ''.$staticaction->getNomUrl(1,34).' | '; - print ''.dol_trunc($obj->label,22).' | '; + // print ''.dol_trunc($obj->label,22).' | '; - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; - print ''.$customerstatic->getNomUrl(1,'',16).' | '; + print ''; + if ($obj->rowid > 0) + { + $customerstatic->id=$obj->rowid; + $customerstatic->name=$obj->sname; + $customerstatic->client=$obj->client; + print $customerstatic->getNomUrl(1,'',16); + } + print ' | '; $datep=$db->jdate($obj->dp); $datep2=$db->jdate($obj->dp2); @@ -196,7 +200,7 @@ function show_array_actions_to_do($max=5) print ""; // Statut - print "".$staticaction->LibStatut($obj->percent,3)." | \n"; + print "".$staticaction->LibStatut($obj->percent,3)." | \n"; print "|
| '.$langs->trans("LastDoneTasks",$max).' | '; - print ''.$langs->trans("FullList").''; + print ' | '.$langs->trans("FullList").''; print ' | ||||||
| '.$staticaction->getNomUrl(1,12).' | '; + print ''.$staticaction->getNomUrl(1,34).' | '; - print ''.dol_trunc($obj->label,24).' | '; + //print ''.dol_trunc($obj->label,24).' | '; - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; - print ''.$customerstatic->getNomUrl(1,'',24).' | '; + print ''; + if ($obj->rowid > 0) + { + $customerstatic->id=$obj->rowid; + $customerstatic->name=$obj->sname; + $customerstatic->client=$obj->client; + print $customerstatic->getNomUrl(1,'',24); + } + print ' | '; // Date print ''.dol_print_date($db->jdate($obj->da2),'day'); print " | "; // Statut - print "".$staticaction->LibStatut($obj->percent,3)." | \n"; + print "".$staticaction->LibStatut($obj->percent,3)." | \n"; print "