diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 2c0a81763da..429add9d630 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -62,11 +62,11 @@ if (! $user->rights->agenda->allactions->read || $_GET["filter"]=='mine')
$filterd=$user->id;
}
-$action=isset($_REQUEST['action'])?$_REQUEST['action']:'';
-$year=isset($_REQUEST["year"])?$_REQUEST["year"]:date("Y");
-$month=isset($_REQUEST["month"])?$_REQUEST["month"]:date("m");
-$day=isset($_REQUEST["day"])?$_REQUEST["day"]:0;
-$pid=isset($_REQUEST["projectid"])?$_REQUEST["projectid"]:0;
+$action=! empty($_REQUEST['action'])?$_REQUEST['action']:'';
+$year=! empty($_REQUEST["year"])?$_REQUEST["year"]:date("Y");
+$month=! empty($_REQUEST["month"])?$_REQUEST["month"]:date("m");
+$day=! empty($_REQUEST["day"])?$_REQUEST["day"]:0;
+$pid=! empty($_REQUEST["projectid"])?$_REQUEST["projectid"]:0;
$status=isset($_GET["status"])?$_GET["status"]:$_POST["status"];
$langs->load("other");
@@ -203,21 +203,21 @@ else
// To limit array
$sql.= ' AND (';
$sql.= ' (datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7)); // Start 7 days before
- $sql.= ' AND '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)).')'; // End 7 days after + 3 to go from 28 to 31
+ $sql.= ' AND '.$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10)).')'; // End 7 days after + 3 to go from 28 to 31
$sql.= ' OR ';
$sql.= ' (datep2 BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7));
- $sql.= ' AND '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)).')';
+ $sql.= ' AND '.$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10)).')';
$sql.= ' OR ';
$sql.= ' (datep < '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7));
- $sql.= ' AND datep2 > '.$db->idate(dol_mktime(0,0,0,$month,28,$year)+(60*60*24*10)).')';
+ $sql.= ' AND datep2 > '.$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10)).')';
$sql.= ')';
}
if ($filtera > 0 || $filtert > 0 || $filterd > 0)
{
$sql.= " AND (";
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
- if ($filtert > 0) $sql.= ($filtera>0?" AND ":"")." a.fk_user_action = ".$filtert;
- if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" AND ":"")." a.fk_user_done = ".$filterd;
+ if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
+ if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
$sql.= ")";
}
if ($status == 'done') { $sql.= " AND a.percent = 100"; }
diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php
index 6e6b91e2a94..7cefcda7cef 100644
--- a/htdocs/comm/action/listactions.php
+++ b/htdocs/comm/action/listactions.php
@@ -55,9 +55,18 @@ $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
-if (! $sortorder) $sortorder="ASC";
-if (! $sortfield) $sortfield="a.datec";
-
+if (! $sortorder)
+{
+ $sortorder="ASC";
+ if ($status == 'todo') $sortorder="DESC";
+ if ($status == 'done') $sortorder="DESC";
+}
+if (! $sortfield)
+{
+ $sortfield="a.percent";
+ if ($status == 'todo') $sortfield="a.datep";
+ if ($status == 'done') $sortfield="a.datep2";
+}
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@@ -74,26 +83,11 @@ if (! $user->rights->agenda->allactions->read || $_GET["filter"]=='mine')
$filterd=$user->id;
}
-if ($page == -1) { $page = 0 ; }
-$limit = $conf->liste_limit;
-$offset = $limit * $page ;
-if (! $sortorder)
-{
- $sortorder="ASC";
- if ($status == 'todo') $sortorder="DESC";
- if ($status == 'done') $sortorder="DESC";
-}
-if (! $sortfield)
-{
- $sortfield="a.percent";
- if ($status == 'todo') $sortfield="a.datep";
- if ($status == 'done') $sortfield="a.datep2";
-}
/*
-* Actions
-*/
+ * Actions
+ */
if (! empty($_POST["viewcal"]))
{
$param='';
@@ -158,85 +152,85 @@ if ($filtera > 0 || $filtert > 0 || $filterd > 0)
{
$sql.= " AND (";
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
- if ($filtert > 0) $sql.= ($filtera>0?" AND ":"")." a.fk_user_action = ".$filtert;
- if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" AND ":"")." a.fk_user_done = ".$filterd;
+ if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
+ if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
$sql.= ")";
}
-$sql.= " ORDER BY ".$sortfield." ".$sortorder;
-$sql.= $db->plimit( $limit + 1, $offset);
+$sql.= $db->order($sortfield,$sortorder);
+$sql.= $db->plimit($limit + 1, $offset);
//print $sql;
dol_syslog("comm/action/listactions.php sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
- $actionstatic=new ActionComm($db);
- $societestatic=new Societe($db);
+ $actionstatic=new ActionComm($db);
+ $societestatic=new Societe($db);
- $num = $db->num_rows($resql);
+ $num = $db->num_rows($resql);
$title=$langs->trans("DoneAndToDoActions");
if ($status == 'done') $title=$langs->trans("DoneActions");
if ($status == 'todo') $title=$langs->trans("ToDoActions");
- if ($socid)
- {
- $societe = new Societe($db);
- $societe->fetch($socid);
+ if ($socid)
+ {
+ $societe = new Societe($db);
+ $societe->fetch($socid);
- print_barre_liste($langs->trans($title).' '.$langs->trans("For").' '.$societe->nom, $page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,'',$num);
- }
- else
- {
- print_barre_liste($langs->trans($title), $page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,'',$num);
- }
+ print_barre_liste($langs->trans($title).' '.$langs->trans("For").' '.$societe->nom, $page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,'',$num);
+ }
+ else
+ {
+ print_barre_liste($langs->trans($title), $page, $_SERVER["PHP_SELF"], $param,$sortfield,$sortorder,'',$num);
+ }
//print '
';
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showborthday,$action,$filtera,$filtert,$filterd,$pid,$socid);
$i = 0;
- print "
| '; + // Action (type) + print ' | '; $actionstatic->id=$obj->id; $actionstatic->code=$obj->acode; $actionstatic->libelle=$obj->label; print $actionstatic->getNomUrl(1,12); - print ' | '; + print ''; - // Titre - //print ''; - //print dol_trunc($obj->label,12); - //print ' | '; + // Titre + //print ''; + //print dol_trunc($obj->label,12); + //print ' | '; - print ''; + print ' | '; print dol_print_date($db->jdate($obj->dp),"day"); $late=0; if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; @@ -250,35 +244,35 @@ if ($resql) print dol_print_date($db->jdate($obj->dp2),"day"); print ' | '; - // Third party - print ''; - if ($obj->socid) - { - $societestatic->id=$obj->socid; + // Third party + print ' | '; + if ($obj->socid) + { + $societestatic->id=$obj->socid; $societestatic->client=$obj->client; $societestatic->nom=$obj->societe; - print $societestatic->getNomUrl(1,'',6); - } - else print ' '; + print $societestatic->getNomUrl(1,'',6); + } + else print ' '; print ' | '; - // Contact - print ''; - if ($obj->fk_contact > 0) - { + // Contact + print ' | '; + if ($obj->fk_contact > 0) + { $contactstatic->name=$obj->name; $contactstatic->firstname=$obj->firstname; $contactstatic->id=$obj->fk_contact; - print $contactstatic->getNomUrl(1,'',6); - } - else - { - print " "; - } - print ' | '; + print $contactstatic->getNomUrl(1,'',6); + } + else + { + print " "; + } + print ''; - // User author - print ''; + // User author + print ' | '; if ($obj->useridauthor) { $userstatic=new User($db,$obj->useridauthor); @@ -289,8 +283,8 @@ if ($resql) else print ' '; print ' | '; - // User to do - print ''; + // User to do + print ' | '; if ($obj->useridtodo) { $userstatic=new User($db,$obj->useridtodo); @@ -301,8 +295,8 @@ if ($resql) else print ' '; print ' | '; - // User did - print ''; + // User did + print ' | '; if ($obj->useriddone) { $userstatic=new User($db,$obj->useriddone); @@ -313,19 +307,19 @@ if ($resql) else print ' '; print ' | '; - // Status/Percent - print ''.$actionstatic->LibStatut($obj->percent,5).' | '; + // Status/Percent + print ''.$actionstatic->LibStatut($obj->percent,5).' | '; - print "