org.agbu.annualgrantbudgets/api/v3/GrantBudget.php

74 lines
1.6 KiB
PHP

<?php
/**
* This api exposes CiviCRM GrantBudget.
*
* @package CiviCRM_APIv3
*/
/**
* Save a GrantBudget.
*
* @param array $params
*
* @return array
*/
function civicrm_api3_grant_budget_create($params) {
if (!empty($params['budget'])) {
$params['budget'] = CRM_Utils_Rule::cleanMoney($params['budget']);
if (!is_numeric($params['budget'] )) {
throw new Exception(ts('Annual Budget is not in money format.'));
}
}
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'GrantBudget');
}
/**
* Get a GrantBudget.
*
* @param array $params
*
* @return array
* Array of retrieved GrantBudget property values.
*/
function civicrm_api3_grant_budget_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
* Delete a GrantBudget.
*
* @param array $params
*
* @return array
* Array of deleted values.
*/
function civicrm_api3_grant_budget_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
/**
* Delete a GrantBudget.
*
* @param array $params
*
* @return array
* Array of deleted values.
*/
function civicrm_api3_grant_budget_getbudget($params) {
$result = CRM_Grant_BAO_GrantBudget::getGrantBudget($params);
return civicrm_api3_create_success($result, $params, 'GrantBudget', 'get');
}
/**
* Adjust metadata for Grant budget action.
*
* @param $spec
*/
function _civicrm_api3_grant_budget_getbudget_spec(&$spec) {
$spec['fiscal_year'] = [
'api.required' => 1,
'title' => ts('Fiscal Year'),
'type' => CRM_Utils_Type::T_INT,
];
}