CRM-16838: Sort task contacts again after merging households.
authorAllen Shaw <allen@JoineryHQ.com>
Mon, 10 Oct 2016 23:43:33 +0000 (18:43 -0500)
committerAllen Shaw <allen@JoineryHQ.com>
Mon, 10 Oct 2016 23:43:33 +0000 (18:43 -0500)
CRM/Contact/Form/Task.php

index e3b94b6b2d61a97f2b90b295d9e871158969d46b..e0fd60b50578c9ed23b4402a99b5020caf4dafcf 100644 (file)
@@ -443,6 +443,21 @@ class CRM_Contact_Form_Task extends CRM_Core_Form {
       }
       $householdsDAO->free();
     }
+
+    // If contact list has changed, households will probably be at the end of
+    // the list. Sort it again by sort_name.
+    if (implode(',', $this->_contactIds) != $relID) {
+      $contact_sort = array();
+      $result = civicrm_api3('Contact', 'get', array(
+        'return' => array('id'),
+        'id' => array('IN' => $this->_contactIds),
+        'options' => array(
+          'limit' => 0,
+          'sort' => "sort_name"
+        ),
+      ));
+      $this->_contactIds = array_keys($result['values']);
+    }
   }
 
   /**