Update the dataAbstract class for accounts.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 29 Mar 2018 18:25:58 +0000 (14:25 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 29 Mar 2018 18:25:58 +0000 (14:25 -0400)
Put the post processing part in if statement to check for it needing to
be used.

classes/data/dataAccounts.php

index f45f73c..15cc9ae 100644 (file)
@@ -73,6 +73,11 @@ class GlmDataAccounts extends GlmDataAbstract
      */
     public $fields = false;
 
+    /**
+     * In the Post Processing get the next_anniversary_date.
+     */
+    public $postNextAnniversaryDate = false;
+
     /**
      * Constructor
      *
@@ -257,25 +262,27 @@ class GlmDataAccounts extends GlmDataAbstract
      */
     public function entryPostProcessing($r, $a)
     {
-        // Setup the accounts anniversary date
-        $current_date = mktime( 0, 0, 0, date( 'n' ), date( 'j' ), date( 'Y' ) );
-        if ( $r['anniversary_date'] ) {
-            // Need to find the next (current) date for this account's
-            // anniversary
-            if ( $r['anniversary_date']['timestamp'] >= time() ) {
-                $r['next_anniversary_date'] = $r['anniversary_date']['date'];
-            } else {
-                // Need to get the next occurrence of the date.
-                $anniversary = strtotime( $r['anniversary_date']['mysql_date'] );
-                // Make the year current year.
-                $year = date( 'Y' );
-                // If the month and day have already occurred then add a year.
-                $test_date = mktime( 0, 0, 0, date( 'n', $anniversary ), date( 'j', $anniversary ), $year );
-                if ( $test_date <= $current_date ) {
-                    $year++;
+        if ( $this->postNextAnniversaryDate ) {
+            // Setup the accounts anniversary date
+            $current_date = mktime( 0, 0, 0, date( 'n' ), date( 'j' ), date( 'Y' ) );
+            if ( $r['anniversary_date'] ) {
+                // Need to find the next (current) date for this account's
+                // anniversary
+                if ( $r['anniversary_date']['timestamp'] >= time() ) {
+                    $r['next_anniversary_date'] = $r['anniversary_date']['date'];
+                } else {
+                    // Need to get the next occurrence of the date.
+                    $anniversary = strtotime( $r['anniversary_date']['mysql_date'] );
+                    // Make the year current year.
+                    $year = date( 'Y' );
+                    // If the month and day have already occurred then add a year.
                     $test_date = mktime( 0, 0, 0, date( 'n', $anniversary ), date( 'j', $anniversary ), $year );
+                    if ( $test_date <= $current_date ) {
+                        $year++;
+                        $test_date = mktime( 0, 0, 0, date( 'n', $anniversary ), date( 'j', $anniversary ), $year );
+                    }
+                    $r['next_anniversary_date'] = date( 'm/d/Y', $test_date );
                 }
-                $r['next_anniversary_date'] = date( 'm/d/Y', $test_date );
             }
         }
         return $r;