User dash: show most recent contributions, not earliest
authorAndrew Hunt <andrew@aghstrategies.com>
Wed, 27 Mar 2019 15:43:34 +0000 (11:43 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Wed, 27 Mar 2019 17:08:52 +0000 (13:08 -0400)
CRM/Contribute/Page/UserDashboard.php

index 9b4e614c389f901c3613ce800bf178ad9efbe8dd..1efad9f3862c60f0cdd2ae268579b797630b33ef 100644 (file)
@@ -37,7 +37,10 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
    */
   public function listContribution() {
     $rows = civicrm_api3('Contribution', 'get', [
-      'options' => ['limit' => 12],
+      'options' => [
+        'limit' => 12,
+        'sort' => 'receive_date DESC',
+      ],
       'sequential' => 1,
       'contact_id' => $this->_contactId,
       'return' => [
@@ -54,6 +57,9 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
       ],
     ])['values'];
 
+    // We want oldest first, just among the most recent contributions
+    $rows = array_reverse($rows);
+
     foreach ($rows as $index => $row) {
       // This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
       // which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons