maxhugen
Posts: 272
|
| Posted: 07/06/2008, 9:33 PM |
|
I have a Grid displaying subscriber_name, and expiry_date (of their Trial subscription).
I'd like the expiry_date to display in red if earlier than today's date (ie, its expired).
Can anyone suggest a method to accomplish this pls?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
wkempees
Posts: 1679
|
| Posted: 07/07/2008, 12:34 AM |
|
Search (Top menu of forum) for "change color" or "color attributes"
Many good posts available.
One approach : use attributes, and in BeforeShowRow do your test and set attribute to override the <td class>.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
maxhugen
Posts: 272
|
| Posted: 07/07/2008, 5:01 PM |
|
Thanks Walter
I tried a search before posting, but being an Aussie, I think I typed in 'colour' instead of 'color'.
Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
maxhugen
Posts: 272
|
| Posted: 07/07/2008, 8:29 PM |
|
I'm a bit stuck on the php code 
In my Grid 'trial', I added an Attribute 'expiry', so it looks like this:
<td style="color:{trial:expiry}">{date_expiry}</td>
In the Grid's BeforeShowRow event, I tried this:
$d1 = explode("-",$Component->date_expiry->GetValue());
$d2 = explode("-",date("Y-m-d"));
$days = gregoriantojd($d1[1], $d1[2], $d1[0]) - gregoriantojd($d2[1], $d2[2], $d2[0]);
if ($days < 0) {
$Component->Attributes->SetValue("expiry", 'Red');
} else {
$Component->Attributes->SetValue("expiry", 'Black');
}
Didn't work. (Firefox just shows timer symbol, page doesn't display at all)
So, I set $d1 = $Component->date_expiry->GetValue() , just to see what it returned, and echoed $d1, which output "Array".
I can't work out what I'm doing wrong... any suggestions please?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
maxhugen
Posts: 272
|
| Posted: 07/14/2008, 5:59 PM |
|
In case anyone is interested, I finally worked out how to compare the dates.
Using "print_r ($Component->date_expiry->GetValue());" in the above example, I found the array was returning:
Array (
[0] => 1215180000
[1] => 2008
[2] => 7
[3] => 5
[4] => 0
[5] => 0
[6] => 0
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
[12] =>
[13] => 2008
)
Although I don't know what all the values in the array represent, it did show which array elements I needed. So my code finally is:
$d1 = $Component->date_expiry->GetValue();
$d2 = explode("-",date("Y-m-d"));
$days = gregoriantojd($d1[2], $d1[3], $d1[1]) - gregoriantojd($d2[1], $d2[2], $d2[0]);
if ($days < 0) {
$Component->Attributes->SetValue("expiry", 'Red');
} else {
$Component->Attributes->SetValue("expiry", 'Black');
}
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
|