From fca964075590f233b741d64a4f253d5dfde68564 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Jun 2011 17:55:19 +0000 Subject: [PATCH] Fix: Actions can has no status. --- htdocs/comm/action/listactions.php | 4 +- htdocs/lib/agenda.lib.php | 66 +++++++++++++++++------------- 2 files changed, 39 insertions(+), 31 deletions(-) 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 ''; print ''; - print ''; $var = true; $i = 0; @@ -171,16 +170,21 @@ function show_array_actions_to_do($max=5) print ""; $staticaction->type_code=$obj->code; - $staticaction->libelle=$obj->libelle; + $staticaction->libelle=$obj->label; $staticaction->id=$obj->id; - print ''; + print ''; - print ''; + // print ''; - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; - print ''; + 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 "\n"; + print "\n"; print "\n"; @@ -226,16 +230,15 @@ function show_array_last_actions_done($max=5) $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label,"; $sql.= " c.code, c.libelle,"; $sql.= " s.rowid, s.nom as sname, 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 >= 100 OR (a.percent = -1 AND a.datep2 <= '".$db->idate($now)."'))"; - $sql.= " AND s.rowid = a.fk_soc"; - $sql.= " AND s.entity = ".$conf->entity; - if ($socid) $sql.= " AND s.rowid = ".$socid; 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.datep2 DESC"; $sql .= $db->plimit($max, 0); @@ -246,7 +249,7 @@ function show_array_last_actions_done($max=5) print '
'.$langs->trans("LastActionsToDo",$max).''.$langs->trans("FullList").''; + print ''.$langs->trans("FullList").''; print '
'.$staticaction->getNomUrl(1,12).''.$staticaction->getNomUrl(1,34).''.dol_trunc($obj->label,22).''.dol_trunc($obj->label,22).''.$customerstatic->getNomUrl(1,'',16).''; + if ($obj->rowid > 0) + { + $customerstatic->id=$obj->rowid; + $customerstatic->name=$obj->sname; + $customerstatic->client=$obj->client; + print $customerstatic->getNomUrl(1,'',16); + } + print '".$staticaction->LibStatut($obj->percent,3)."".$staticaction->LibStatut($obj->percent,3)."
'; print ''; - print ''; $var = true; $i = 0; @@ -261,24 +264,29 @@ function show_array_last_actions_done($max=5) print ""; - $staticaction->code=$obj->code; - $staticaction->libelle=$obj->libelle; + $staticaction->type_code=$obj->code; + $staticaction->libelle=$obj->label; $staticaction->id=$obj->id; - print ''; + print ''; - print ''; + //print ''; - $customerstatic->id=$obj->rowid; - $customerstatic->name=$obj->sname; - $customerstatic->client=$obj->client; - print ''; + print ''; // Date print '"; // Statut - print "\n"; + print "\n"; print "\n"; $i++;
'.$langs->trans("LastDoneTasks",$max).''.$langs->trans("FullList").''; + print ''.$langs->trans("FullList").''; print '
'.$staticaction->getNomUrl(1,12).''.$staticaction->getNomUrl(1,34).''.dol_trunc($obj->label,24).''.dol_trunc($obj->label,24).''.$customerstatic->getNomUrl(1,'',24).''; + if ($obj->rowid > 0) + { + $customerstatic->id=$obj->rowid; + $customerstatic->name=$obj->sname; + $customerstatic->client=$obj->client; + print $customerstatic->getNomUrl(1,'',24); + } + print ''.dol_print_date($db->jdate($obj->da2),'day'); print "".$staticaction->LibStatut($obj->percent,3)."".$staticaction->LibStatut($obj->percent,3)."