Merge pull request #4820 from kurund/CRM-15705
[civicrm-core.git] / CRM / Pledge / Page / AJAX.php
old mode 100644 (file)
new mode 100755 (executable)
index f242f79..ae6cdd6
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -39,9 +39,9 @@
 class CRM_Pledge_Page_AJAX {
 
   /**
-   * Function for building Pledge Name combo box
+   * Building Pledge Name combo box
    */
-  static function pledgeName() {
+  public static function pledgeName() {
 
     $getRecords = FALSE;
     if (isset($_GET['name']) && $_GET['name']) {
@@ -86,5 +86,17 @@ WHERE {$whereClause}
     echo CRM_Utils_JSON::encode($elements, 'value');
     CRM_Utils_System::civiExit();
   }
+    /**
+    * Function to setDefaults according to Pledge Id
+    * for batch entry pledges
+    */
+  public function getPledgeDefaults() {
+    $details = array();
+    if (!empty($_POST['pid'])) {
+      $pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer');
+      $details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID);
+    }
+    echo json_encode($details);
+    CRM_Utils_System::civiExit();
+  }
 }
-