This topic is locked
[SOLVED]

 Turning Row Red after expire date

2/4/2019 5:29:33 AM
PHPRunner General questions
Tandy author

I have been trying to figure out the code to turn a row red if the expire date has been met.

I have a table called: truck_expiration_datesThen in that table I have:truck_number int 11description varchar 50date date

The date field is the date the permit expires.I have been trying to use stuff from this post The code I came up with and put in before display on the list event is:

global $record;

if ($data["date"]>"CURDATE()");

else

$row["rowstyle"]='style="background:red"';

Is that code work for PHPrunner 10? it was all back in 5 and 6 days.

I have tried just:$row["rowstyle"]='style="background:red"';

to see if the row would change but nothing.Any help would be great on this..

Thank AllJames Tandy

admin 2/4/2019

That article is old and advise may not apply anymore. But here is the article from the current manual that should work:

https://xlinesoft.com/phprunner/docs/conditional_formatting.htm

Tandy author 2/4/2019



That article is old and advise may not apply anymore. But here is the article from the current manual that should work:

https://xlinesoft.co..._formatting.htm



Thank You very much. That worked out great. Here is my main code for expired permits:

if ($data["date"] < now())

$record["date_css"]="background:red;";


Now how could I set it up to turn yellow 60 days before it expires? I tried:

if ($data["date"] < DateTime.Now.Add(-60))

$record["date_css"].='background:yellow';



But got bad errors..

Thank You for your help as always.. Great software..

admin 2/4/2019

DateTime.Now.Add is C# code. You need to search for PHP counterpart.
Comparing dates in PHP:

https://stackoverflow.com/questions/40547752/how-to-compare-dates-and-strings-in-php
Subtract days from date in PHP:

https://stackoverflow.com/questions/20901760/subtracting-days-months-or-years-from-date-using-php

Tandy author 2/4/2019



DateTime.Now.Add is C# code. You need to search for PHP counterpart.
Comparing dates in PHP:

https://stackoverflo...-strings-in-php
Subtract days from date in PHP:

https://stackoverflo...-date-using-php


Thank You very much.. I will try to figure it out..

Tandy author 2/13/2019

Ok, I don't know if it is right but this code works for me:

if ($data["date"] <= date("Y-m-d", strtotime('30 days'))){

$record["date_css"]="background:yellow";}
if ($data["date"] < now()){

$record["date_css"]="background:red;";}



If the date is 30 days before it expires the record turns yellow. If that date is reached then the record turns red..

Hope it is right and can help others..

James Tandy