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 14517c6..ae6cdd6
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -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();
+  }
 }
-