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;
|
||||
}
|
||||
|
||||
$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"; }
|
||||
|
||||
@ -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 '<br>';
|
||||
|
||||
print_actions_filter($form,$canedit,$status,$year,$month,$day,$showborthday,$action,$filtera,$filtert,$filterd,$pid,$socid);
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"acode",$param,"","",$sortfield,$sortorder);
|
||||
//print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("AffectedTo"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"acode",$param,"","",$sortfield,$sortorder);
|
||||
//print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Contact"),$_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ActionUserAsk"),$_SERVER["PHP_SELF"],"ua.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("AffectedTo"),$_SERVER["PHP_SELF"],"ut.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("DoneBy"),$_SERVER["PHP_SELF"],"ud.login",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
$contactstatic = new Contact($db);
|
||||
$contactstatic = new Contact($db);
|
||||
$now=gmmktime();
|
||||
$delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60;
|
||||
|
||||
$var=true;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var=true;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$var=!$var;
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Action (type)
|
||||
print '<td>';
|
||||
// Action (type)
|
||||
print '<td>';
|
||||
$actionstatic->id=$obj->id;
|
||||
$actionstatic->code=$obj->acode;
|
||||
$actionstatic->libelle=$obj->label;
|
||||
print $actionstatic->getNomUrl(1,12);
|
||||
print '</td>';
|
||||
print '</td>';
|
||||
|
||||
// Titre
|
||||
//print '<td>';
|
||||
//print dol_trunc($obj->label,12);
|
||||
//print '</td>';
|
||||
// Titre
|
||||
//print '<td>';
|
||||
//print dol_trunc($obj->label,12);
|
||||
//print '</td>';
|
||||
|
||||
print '<td align="center" nowrap="nowrap">';
|
||||
print '<td align="center" nowrap="nowrap">';
|
||||
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 '</td>';
|
||||
|
||||
// Third party
|
||||
print '<td>';
|
||||
if ($obj->socid)
|
||||
{
|
||||
$societestatic->id=$obj->socid;
|
||||
// Third party
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
|
||||
// Contact
|
||||
print '<td>';
|
||||
if ($obj->fk_contact > 0)
|
||||
{
|
||||
// Contact
|
||||
print '<td>';
|
||||
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 '</td>';
|
||||
print $contactstatic->getNomUrl(1,'',6);
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// User author
|
||||
print '<td align="left">';
|
||||
// User author
|
||||
print '<td align="left">';
|
||||
if ($obj->useridauthor)
|
||||
{
|
||||
$userstatic=new User($db,$obj->useridauthor);
|
||||
@ -289,8 +283,8 @@ if ($resql)
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
// User to do
|
||||
print '<td align="left">';
|
||||
// User to do
|
||||
print '<td align="left">';
|
||||
if ($obj->useridtodo)
|
||||
{
|
||||
$userstatic=new User($db,$obj->useridtodo);
|
||||
@ -301,8 +295,8 @@ if ($resql)
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
// User did
|
||||
print '<td align="left">';
|
||||
// User did
|
||||
print '<td align="left">';
|
||||
if ($obj->useriddone)
|
||||
{
|
||||
$userstatic=new User($db,$obj->useriddone);
|
||||
@ -313,19 +307,19 @@ if ($resql)
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
// Status/Percent
|
||||
print '<td align="right" nowrap="nowrap">'.$actionstatic->LibStatut($obj->percent,5).'</td>';
|
||||
// Status/Percent
|
||||
print '<td align="right" nowrap="nowrap">'.$actionstatic->LibStatut($obj->percent,5).'</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user