<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
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']) {
- $name = CRM_Utils_Type::escape($_GET['name'], 'String');
- $name = str_replace('*', '%', $name);
+ $name = CRM_Utils_Type::escape($_GET['name'], 'String');
+ $name = str_replace('*', '%', $name);
$whereClause = "p.creator_pledge_desc LIKE '%$name%' ";
- $getRecords = TRUE;
+ $getRecords = TRUE;
}
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
- $pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
+ $pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
$whereClause = "p.id = {$pledgeId} ";
- $getRecords = TRUE;
+ $getRecords = TRUE;
}
if ($getRecords) {
if (!$name && isset($_GET['id'])) {
$name = $_GET['id'];
}
- $elements[] = array('name' => trim($name, '*'),
+ $elements[] = array(
+ 'name' => trim($name, '*'),
'value' => trim($name, '*'),
);
}
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();
+ }
+
+}