From cb23c5152b8a769f1e54dfa91aa82814d3f29cda Mon Sep 17 00:00:00 2001 From: Civiware Solutions Date: Sun, 12 Aug 2018 01:29:39 +0530 Subject: [PATCH] added a way to store new budget for financial type --- CRM/AnnualGrantBudgets/APIWrapper.php | 36 +++++++++++++++++++++++++++ annualgrantbudgets.php | 12 +++++++++ 2 files changed, 48 insertions(+) create mode 100644 CRM/AnnualGrantBudgets/APIWrapper.php diff --git a/CRM/AnnualGrantBudgets/APIWrapper.php b/CRM/AnnualGrantBudgets/APIWrapper.php new file mode 100644 index 0000000..1e6f606 --- /dev/null +++ b/CRM/AnnualGrantBudgets/APIWrapper.php @@ -0,0 +1,36 @@ + $ids[0], + 'fiscal_year' => $ids[1], + ]; + try { + $gBId = civicrm_api3('GrantBudget', 'getvalue', $gBParams + ['return' => 'id']); + $params['id'] = $gBId; + } + catch (CiviCRM_API3_Exception $e) { + $params += $gBParams; + } + $apiRequest['params'] = $params; + } + } + return $apiRequest; + } + + /** + * alter the result before returning it to the caller. + */ + public function toApiOutput($apiRequest, $result) { + return $result; + } + +} diff --git a/annualgrantbudgets.php b/annualgrantbudgets.php index 3fa11d1..7d7c1a1 100644 --- a/annualgrantbudgets.php +++ b/annualgrantbudgets.php @@ -201,3 +201,15 @@ function annualgrantbudgets_civicrm_navigationMenu(&$menu) { ]); _annualgrantbudgets_civix_navigationMenu($menu); } + +/** + * Implements hook_civicrm_apiWrappers(). + * + * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_apiWrappers + * + */ +function annualgrantbudgets_civicrm_apiWrappers(&$wrappers, $apiRequest) { + if (strtolower($apiRequest['entity']) == 'grantbudget' && $apiRequest['action'] == 'create') { + $wrappers[] = new CRM_AnnualGrantBudgets_APIWrapper(); + } +}