Entry an expiration date.

meridion

Member
Hi, I need to do the following:
Entry an expiration date. When approaching that date say (To conquer), when conquer say (defeated).
 
I need, enter a due date ... and that day arrived, I appear in a field ... "expired"

view the attachment
 

Attachments

  • Sin-título-1.jpg
    Sin-título-1.jpg
    146.5 KB · Views: 93
Ok, hola como estas?

yo necesito, ingresar una fecha de vencimiento. Supongamos
Juan Perez, fecha de vencimiento de carnet de conducir 2/12/2016.
Al llegar ese d?a aparezca 2/12/2016. o que diga vencido.
Y FALTANDO UN MES ME APAREZCA UN CAMPO QUE DIGA "POR VENCER"

se entiende?
 
I think I understand.

Couple of ways to do this. One way would be to use a 'calc' element which tests your expiration date and returns 'expired' or 'unexpired'. Or you could use the PHP scheduled task, and write a few lines of code to set a field by hand once a day (or whatever).

You can then use the 'use as row class' and a little custom CSS to style the element(s) / row as you want when your field is 'expired'.

First question ... do you need to compare against time of day, or just the date part?

-- hugh
 
OK. The easiest way would be .to create a 'calc' element (you may need to install the calc element, as it's not part of the core) ..

Code:
$expirationDate = '{yourtable___yourdate}';
if (!empty($expirationDate)) {
   $expirationDate = new DateTime($expirationDate);
   $expirationDate->setTime(0, 0, 0);
   $today = new DateTime();
   $today->setTime(0, 0, 0);
   if ($expirationDate >= $today) {
      return "expired";
   }
}
return "notexpired";

Replace yourtable___yourdate with the full element name of your expiration date element.

Set "Calc on save only" to No.

You should then have an element which contains either 'expired' or 'notexpired' in your list. You can then set "Use as row class" on that, and in your template folder (usually ./components/com_fabrik/views/list/tmpl/bootstrap) copy custom_css_example.php to custom_css.php, and where the comments show where to add stuff, put ...

Code:
tr.expired {
   background-color: red;
}

... or whatever.

You can use any value you want for the expired/unexpired, just don't use a number as the first letter.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top