new handling of events
This commit is contained in:
@@ -305,11 +305,9 @@ contactez la fipf directement",
|
||||
const DURATION_CARD_VALIDITY = '+1 year'; // string : time of validity of the card (ex: '1 month' or '1 year' or '60 days')
|
||||
const DURATION_OLD_ORDER_ID = '+3 days';
|
||||
const DURATION_ACCOUNT_DELETE_AFTER_EXPIRE = '+6 months';
|
||||
const DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_FIRST = '-30 days';
|
||||
const DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_LAST = '-7 days';
|
||||
const DURATION_REMINDER_BEFORE_ACCOUNT_DELETE_FIRST = '-30 days';
|
||||
const DURATION_REMINDER_BEFORE_ACCOUNT_DELETE_LAST = '-7 days';
|
||||
const DURATION_REMINDER_BEFORE_OFFER_EXPIRE = '-7 days';
|
||||
const DURATION_REMINDERS_BEFORE_ACCOUNT_EXPIRE = ['-30 days', '-7 days'];
|
||||
const DURATION_REMINDERS_BEFORE_ACCOUNT_DELETE = ['-30 days', '-7 days'];
|
||||
const DURATION_REMINDERS_BEFORE_OFFER_EXPIRE = ['-7 days'];
|
||||
|
||||
// OTHER
|
||||
const CARD_RENEW_PERIOD = 31; // int : number of days before expiration when renew card start to be possible
|
||||
|
||||
@@ -92,6 +92,4 @@ function send_emails_CIPF($email_name, $user_id = null) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -118,4 +118,90 @@ function handle_prof_account_deletion_CIPF($user_id) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* this function will check if users should be sent an email
|
||||
* to remind them of their card expiration date
|
||||
*
|
||||
*/
|
||||
function handle_reminders_before_card_expire_CIPF($user_id) {
|
||||
Plgntls::debug_infos();
|
||||
$card_reminders = Cipf::DURATION_REMINDERS_BEFORE_ACCOUNT_EXPIRE;
|
||||
|
||||
if (!isset_acf_card_expiration_CIPF($user_id)) {
|
||||
return;
|
||||
}
|
||||
if (is_card_date_expired_CIPF($user_id)) {
|
||||
return;
|
||||
}
|
||||
$date_limit = get_card_date_expiration_CIPF($user_id);
|
||||
if (false === $date_limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($card_reminders as $duration) {
|
||||
$date_reminder = $date_limit->modify($duration);
|
||||
$date_diff = date_diff($date_limit, $date_reminder);
|
||||
$date_diff = (int)$date_diff->format('%R%a');
|
||||
|
||||
$date_now = date_create('now');
|
||||
$current_date_diff = date_diff($date_limit, $date_now);
|
||||
$current_date_diff = (int)$current_date_diff->format('%R%a');
|
||||
|
||||
$diff = abs($current_date_diff - $date_diff);
|
||||
|
||||
if ($diff === 0)) {
|
||||
send_emails_CIPF('card_will_expire', $user_id);
|
||||
return; // don't send multiple emails
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* this function will check if users should be sent an email
|
||||
* to remind them of their account beeing soon deleted
|
||||
*
|
||||
*/
|
||||
function handle_reminders_before_account_deleted_CIPF($user_id) {
|
||||
Plgntls::debug_infos();
|
||||
$account_reminders = Cipf::DURATION_REMINDERS_BEFORE_ACCOUNT_DELETE;
|
||||
$duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
|
||||
|
||||
if (!isset_acf_card_expiration_CIPF($user_id)) {
|
||||
return;
|
||||
}
|
||||
if (!is_card_date_expired_CIPF($user_id)) {
|
||||
return;
|
||||
}
|
||||
$date_limit = get_card_date_expiration_CIPF($user_id);
|
||||
if (false === $date_limit) {
|
||||
return;
|
||||
}
|
||||
$date_deletion = $date_limit->modify($duration_deletion);
|
||||
|
||||
foreach ($account_reminders as $reminder) {
|
||||
$date_reminder = $date_deletion->modify($reminder);
|
||||
$date_diff = date_diff($date_deletion, $date_reminder);
|
||||
$date_diff = (int)$date_diff->format('%R%a');
|
||||
|
||||
$date_now = date_create('now');
|
||||
$current_date_diff = date_diff($date_deletion, $date_now);
|
||||
$current_date_diff = (int)$current_date_diff->format('%R%a');
|
||||
|
||||
// i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
|
||||
if (abs($current_date_diff) <= (abs($date_diff) + 3)) {
|
||||
send_emails_CIPF('account_will_be_deleted', $user_id);
|
||||
return; // don't send multiple emails
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user