CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Pledge with 'Send additional reminders' 0 days after the last one sent
Pages: [1]

Author Topic: Pledge with 'Send additional reminders' 0 days after the last one sent  (Read 788 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Pledge with 'Send additional reminders' 0 days after the last one sent
February 02, 2011, 01:46:17 pm
(UPDATE - see my analysis and proposed patch in my reply, below)

Last night my UpdatePledgeRecord.php sent 12 pledge reminders to the same person!

That's one for each pledge payment from Feb 2011 to Jan 2012 when the pledge finishes.

CiviPledge shouldn't sent reminders for future pledges.

The only notable difference between this pledge and others is that 'Send additional reminders' is set to '0' (zero) days after the last one sent.

Ken
« Last Edit: February 02, 2011, 07:17:50 pm by ken »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Pledge with 'Send additional reminders' 0 days after the last one sent
February 02, 2011, 07:16:30 pm
I've found the problem.

When a Pledge Payment is created, the 'reminder_date' is set to NULL. The code in bin/UpdatePledgeRecord.php does not cater for NULLs in this field.

The code on lines 188-199 of the 3.3.3 code is ...

Code: [Select]
                $firstReminderDate = new DateTime($details['scheduled_date']);
                $nextReminderDate  = new DateTime($details['reminder_date']);
               
                $firstReminderDate->modify("-". $details['initial_reminder_day'] ."day");
                $nextReminderDate->modify("+". $details['additional_reminder_day']."day");
               
                $firstReminderDate = $firstReminderDate->format("Ymd");
                $nextReminderDate  = $nextReminderDate->format("Ymd");
               
                if ( ( $details['reminder_count'] < $details['max_reminders'] )
                     && ( ( empty( $details['reminder_date'] ) && $firstReminderDate <= $now )
                          || $nextReminderDate <= $now  ) ) {

$details['reminder_date'] is NULL.
$details['additional_reminder_day'] is zero.
$nextReminderDate is set to "now" and then modified by adding zero days
$nextReminderDate <= $now, so the email reminder is sent

Note that this logic is in a loop which iterates over all 'Pending' pledge payments, including all future payments of the pledge with 'additional_reminder_day' set to zero.

A patch which I believe will fix this problem is ...

Code: [Select]
@@ -185,18 +185,18 @@
                     continue;
                 }
                 
-                $firstReminderDate = new DateTime($details['scheduled_date']);
-                $nextReminderDate  = new DateTime($details['reminder_date']);
-               
-                $firstReminderDate->modify("-". $details['initial_reminder_day'] ."day");
-                $nextReminderDate->modify("+". $details['additional_reminder_day']."day");
-               
-                $firstReminderDate = $firstReminderDate->format("Ymd");
-                $nextReminderDate  = $nextReminderDate->format("Ymd");
+                if ( empty( $details['reminder_date'] ) ) {
+                    $nextReminderDate = new DateTime($details['scheduled_date']);
+                    $nextReminderDate->modify("-". $details['initial_reminder_day'] ."day");
+                    $nextReminderDate = $nextReminderDate->format("Ymd");
+                } else {
+                    $nextReminderDate  = new DateTime($details['reminder_date']);
+                    $nextReminderDate->modify("+". $details['additional_reminder_day']."day");
+                    $nextReminderDate  = $nextReminderDate->format("Ymd");
+                }
                 
                 if ( ( $details['reminder_count'] < $details['max_reminders'] )
-                     && ( ( empty( $details['reminder_date'] ) && $firstReminderDate <= $now )
-                          || $nextReminderDate <= $now  ) ) {
+                     && ( $nextReminderDate <= $now ) ) {
                     
                     $toEmail = $doNotEmail = $onHold = null;
                     
« Last Edit: February 03, 2011, 02:53:22 am by ken »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Pledge with 'Send additional reminders' 0 days after the last one sent
February 03, 2011, 12:29:09 pm
Ken - Thx for the detailed analysis and patch. I've posted an issue for this:
http://issues.civicrm.org/jira/browse/CRM-7492

... and committed your changes as well as a fix for another issue where script was displaying message that a pledge status had been updated regardless of whether the status was changed or not.

Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • Pledge with 'Send additional reminders' 0 days after the last one sent

This forum was archived on 2017-11-26.