Hello,
I have been looking at other post for this solution by I am stuck with this:
DATEDIFF(Sa_Pdate,$today) as diffdate
// If peremption date is < than today, highlight row with red
$f = array();
$f[“column”] = “diffdate”;
$f[“op”] = “<“;
$f[“value”] = 1;
$f[“class”] = “focus-red”;
$f_conditions[] = $f;
// If peremption date is < 60, highlight row with yellow
$f = array();
$f[“column”] = “diffdate”;
$f[“op”] = “<“;
$f[“value”] = 60;
$f[“class”] = “focus-yellow”;
$f_conditions[] = $f;
The row remains highlited in yellow….
I think the order of operations is causing your issue.
The yellow highlight function is coming after the red highlight function, so it’s turning red, then getting to the yellow function, which it also matches, and turning it yellow.
Negative 20 matches both conditions: It’s less than 1 and also less than 60.
I think you need to use a different method to set the datediff column. I would handle this with SQL Queries, so you can use if/then statements. Set the color to return and just match the color with PHP Grid. Having the logic in the dataset makes reporting a lot easier. Below is pseudo code in SQL Server Format as a guideline.
CASE
When DATEDIFF(Sa_Pdate,$today) < 1 Then ‘RED’
When DATEDIFF(Sa_Pdate,$today) > 1 and < 60 Then ‘YELLOW’
When DATEDIFF(Sa_Pdate,$today) > 60 Then ‘GREEN’
END AS DATEDIFF
// Set Color
$f = array();
$f[“column”] = “diffdate”;
$f[“op”] = “-“;
$f[“value”] = “YELLOW”;
$f[“class”] = “focus-yellow”;
$f_conditions[] = $f;
Hi Mike,
Thanks for your answer. but I can\’t make this working… It\’s either one color or the other…
The class name should be dynamic like focus-$difffate right?
Hello,
Mike’s solution is correct.
It’s pretty late reply, however it would also work if you just change the array order. Set diffdate<60 format condition first in $f_conditions array and then diffdate<1.