Fix: Bad condition on select
This commit is contained in:
parent
064da109df
commit
ab8e9904ef
@ -62,11 +62,11 @@ if (! $user->rights->agenda->allactions->read || $_GET["filter"]=='mine')
|
|||||||
$filterd=$user->id;
|
$filterd=$user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$action=isset($_REQUEST['action'])?$_REQUEST['action']:'';
|
$action=! empty($_REQUEST['action'])?$_REQUEST['action']:'';
|
||||||
$year=isset($_REQUEST["year"])?$_REQUEST["year"]:date("Y");
|
$year=! empty($_REQUEST["year"])?$_REQUEST["year"]:date("Y");
|
||||||
$month=isset($_REQUEST["month"])?$_REQUEST["month"]:date("m");
|
$month=! empty($_REQUEST["month"])?$_REQUEST["month"]:date("m");
|
||||||
$day=isset($_REQUEST["day"])?$_REQUEST["day"]:0;
|
$day=! empty($_REQUEST["day"])?$_REQUEST["day"]:0;
|
||||||
$pid=isset($_REQUEST["projectid"])?$_REQUEST["projectid"]:0;
|
$pid=! empty($_REQUEST["projectid"])?$_REQUEST["projectid"]:0;
|
||||||
$status=isset($_GET["status"])?$_GET["status"]:$_POST["status"];
|
$status=isset($_GET["status"])?$_GET["status"]:$_POST["status"];
|
||||||
|
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
@ -203,21 +203,21 @@ else
|
|||||||
// To limit array
|
// To limit array
|
||||||
$sql.= ' AND (';
|
$sql.= ' AND (';
|
||||||
$sql.= ' (datep BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7)); // Start 7 days before
|
$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.= ' OR ';
|
||||||
$sql.= ' (datep2 BETWEEN '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7));
|
$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.= ' OR ';
|
||||||
$sql.= ' (datep < '.$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7));
|
$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.= ')';
|
$sql.= ')';
|
||||||
}
|
}
|
||||||
if ($filtera > 0 || $filtert > 0 || $filterd > 0)
|
if ($filtera > 0 || $filtert > 0 || $filterd > 0)
|
||||||
{
|
{
|
||||||
$sql.= " AND (";
|
$sql.= " AND (";
|
||||||
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
|
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
|
||||||
if ($filtert > 0) $sql.= ($filtera>0?" AND ":"")." a.fk_user_action = ".$filtert;
|
if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
|
||||||
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" AND ":"")." a.fk_user_done = ".$filterd;
|
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
}
|
}
|
||||||
if ($status == 'done') { $sql.= " AND a.percent = 100"; }
|
if ($status == 'done') { $sql.= " AND a.percent = 100"; }
|
||||||
|
|||||||
@ -55,9 +55,18 @@ $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
|
|||||||
if ($page == -1) { $page = 0 ; }
|
if ($page == -1) { $page = 0 ; }
|
||||||
$limit = $conf->liste_limit;
|
$limit = $conf->liste_limit;
|
||||||
$offset = $limit * $page ;
|
$offset = $limit * $page ;
|
||||||
if (! $sortorder) $sortorder="ASC";
|
if (! $sortorder)
|
||||||
if (! $sortfield) $sortfield="a.datec";
|
{
|
||||||
|
$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
|
// Security check
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
@ -74,26 +83,11 @@ if (! $user->rights->agenda->allactions->read || $_GET["filter"]=='mine')
|
|||||||
$filterd=$user->id;
|
$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"]))
|
if (! empty($_POST["viewcal"]))
|
||||||
{
|
{
|
||||||
$param='';
|
$param='';
|
||||||
@ -158,12 +152,12 @@ if ($filtera > 0 || $filtert > 0 || $filterd > 0)
|
|||||||
{
|
{
|
||||||
$sql.= " AND (";
|
$sql.= " AND (";
|
||||||
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
|
if ($filtera > 0) $sql.= " a.fk_user_author = ".$filtera;
|
||||||
if ($filtert > 0) $sql.= ($filtera>0?" AND ":"")." a.fk_user_action = ".$filtert;
|
if ($filtert > 0) $sql.= ($filtera>0?" OR ":"")." a.fk_user_action = ".$filtert;
|
||||||
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" AND ":"")." a.fk_user_done = ".$filterd;
|
if ($filterd > 0) $sql.= ($filtera>0||$filtert>0?" OR ":"")." a.fk_user_done = ".$filterd;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
}
|
}
|
||||||
$sql.= " ORDER BY ".$sortfield." ".$sortorder;
|
$sql.= $db->order($sortfield,$sortorder);
|
||||||
$sql.= $db->plimit( $limit + 1, $offset);
|
$sql.= $db->plimit($limit + 1, $offset);
|
||||||
//print $sql;
|
//print $sql;
|
||||||
|
|
||||||
dol_syslog("comm/action/listactions.php sql=".$sql);
|
dol_syslog("comm/action/listactions.php sql=".$sql);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user