Filter date

genovince

Member
hi, I have a user of an association and one of the database fields is "record date". The subscription lasts one year, I need to have a notice that tells me that your subscription is about to expire or I can use a filter to find out who your subscription expiring. Among the available filters I have not been able to locate one that is right for me.
thank you
 
You may create a cron task with php code.
Set to run task every day.
In code find difference between record date and today date. If for example result is 5, then send notification mail to you that 5 days left to expire.
I hope this help you.
 
In my form I have field end_subscription with time offset 1 year from recorded date.
Create for example file expire_reminder.php in folder plugins/fabrik_cron/php/scripts with code:
PHP:
<?php
    defined('_JEXEC') or die();
    $db = FabrikWorker::getDbo();
    $db -> setQuery("SELECT * FROM table_name");
    $db -> query();
    $rows = $db->loadObjectList();

foreach ($rows as $row){
    $end_subscription = strtotime($row->end_subscription);
    $date = new DateTime();
    $datenow = $date->getTimestamp();
    $datediff = ($end_subscription - $datenow);
    $diff = round($datediff / 86400); //difference in days

    if($diff == '5'){
    $id = $row->id;
    $mailer = JFactory::getMailer();
    $mailer->addRecipient('your_mail@xxx.xxx');
    $mailer->setSubject('Subsciption Reminder');

    $body = 'Subscription for ' . $id . ' expired in ' . $diff . ' days.</b>';
    $mailer->isHTML(true);
    $mailer->Encoding = 'base64';
    $mailer->setBody($body);
    $send = $mailer->Send();
    }
}
?>
Create scheduled task "Check Subscription".
plug-in: php;
php script: file expire_reminder.php.
Set Require querystring->yes.
Query secret ->check_subs.
Create another file cron_check_subs.php in folder plugins/fabrik_cron/php/scripts with code:
PHP:
<?php
$result = file_get_contents('http://your_site.com/index.php?fabrik_cron=check_subs');
echo $result;
?>
In your cpanel create cron job run on every day.
HTML:
     /usr/local/bin/php /home/your_host_account/public_html/plugins/fabrik_cron/php/scripts/cron_check_subs.php
This settings may be vary for your host provider.

Sorry for my bad English.
 
Last edited:
Thanks for sharing that.

BTW, rather than creating the cron_ads_null.php file, you can just do ...

Code:
wget http://yoursite.com/index.php?fabrik_cron=check_subs > /dev/null 2>&1

... directly in your cron job. The 'wget' command should be available on pretty much all standard Linux releases. The "> /dev/null 2>&1" part just mutes it, makes sure that all output and messages go the /dev/null rather than winding up in your root mailbox.

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

Thank you.

Members online

Back
Top