rewrite budget screen to be multifund-aware
This commit is contained in:
parent
75cee740f7
commit
e00085d701
@ -50,7 +50,7 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
|||||||
}
|
}
|
||||||
$grantBudgetTableName = CRM_Grant_DAO_GrantBudget::getTableName();
|
$grantBudgetTableName = CRM_Grant_DAO_GrantBudget::getTableName();
|
||||||
$sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
|
$sql = "SELECT cgb.id, cft.name, IFNULL(cgb.budget, 0) AS budget,
|
||||||
SUM(IFNULL(cg." . GRANT_AMOUNT_CHECK_FIELD . ", 0)) as total_amount_granted,
|
SUM(IFNULL(trxn." . GRANT_AMOUNT_CHECK_FIELD . ", 0)) as total_amount_granted,
|
||||||
cft.id AS financial_type_id
|
cft.id AS financial_type_id
|
||||||
FROM civicrm_financial_type cft
|
FROM civicrm_financial_type cft
|
||||||
INNER JOIN " . GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME . " gs
|
INNER JOIN " . GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME . " gs
|
||||||
@ -62,6 +62,9 @@ class CRM_Grant_BAO_GrantBudget extends CRM_Grant_DAO_GrantBudget {
|
|||||||
ON cg.financial_type_id = cft.id AND cg.status_id IN (%4)
|
ON cg.financial_type_id = cft.id AND cg.status_id IN (%4)
|
||||||
AND cg." . GRANT_DATE_CHECK_FIELD . " >= %2
|
AND cg." . GRANT_DATE_CHECK_FIELD . " >= %2
|
||||||
AND cg." . GRANT_DATE_CHECK_FIELD . " < %3
|
AND cg." . GRANT_DATE_CHECK_FIELD . " < %3
|
||||||
|
LEFT JOIN civicrm_entity_financial_account cefa
|
||||||
|
ON cefa.entity_table = 'civicrm_financial_type' AND cft.id = cefa.entity_id AND account_relationship = 14
|
||||||
|
LEFT JOIN civicrm_financial_trxn trxn ON trxn.from_financial_account_id = cefa.financial_account_id
|
||||||
{$where}
|
{$where}
|
||||||
GROUP BY cft.id
|
GROUP BY cft.id
|
||||||
ORDER BY cft.name";
|
ORDER BY cft.name";
|
||||||
|
@ -7,8 +7,9 @@ define('GRANT_SCHOLARSHIP_CUSTOM_GROUP', 'grant_scholarship');
|
|||||||
define('GRANT_SCHOLARSHIP_CUSTOM_FIELD', 'is_grant_scholarship');
|
define('GRANT_SCHOLARSHIP_CUSTOM_FIELD', 'is_grant_scholarship');
|
||||||
define('GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME', 'civicrm_value_grant_scholarship');
|
define('GRANT_SCHOLARSHIP_CUSTOM_TABLE_NAME', 'civicrm_value_grant_scholarship');
|
||||||
define('GRANT_SCHOLARSHIP_YEAR_DIFF', 10);
|
define('GRANT_SCHOLARSHIP_YEAR_DIFF', 10);
|
||||||
define('GRANT_DATE_CHECK_FIELD', 'money_transfer_date');
|
define('GRANT_DATE_CHECK_FIELD', 'decision_date');
|
||||||
define('GRANT_AMOUNT_CHECK_FIELD', 'amount_granted');
|
define('GRANT_AMOUNT_CHECK_FIELD', 'total_amount');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_civicrm_config().
|
* Implements hook_civicrm_config().
|
||||||
*
|
*
|
||||||
@ -221,26 +222,28 @@ function annualgrantbudgets_civicrm_apiWrappers(&$wrappers, $apiRequest) {
|
|||||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm
|
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function annualgrantbudgets_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
|
// //This whole validation needs rewriting.
|
||||||
if ($formName == 'CRM_Grant_Form_Grant' && !($form->_action & CRM_Core_Action::DELETE)) {
|
//function annualgrantbudgets_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
|
||||||
if (empty($fields['financial_type_id'])
|
// if ($formName == 'CRM_Grant_Form_Grant' && !($form->_action & CRM_Core_Action::DELETE)) {
|
||||||
|| empty($fields['status_id'])
|
// if (empty($fields['financial_type_id'])
|
||||||
|| empty($fields[GRANT_DATE_CHECK_FIELD])
|
// || empty($fields['status_id'])
|
||||||
|| empty($fields[GRANT_AMOUNT_CHECK_FIELD])
|
// || empty($fields[GRANT_DATE_CHECK_FIELD])
|
||||||
) {
|
// || empty($fields[GRANT_AMOUNT_CHECK_FIELD])
|
||||||
return;
|
// ) {
|
||||||
}
|
// return;
|
||||||
$paidStatusID = CRM_Core_PseudoConstant::getKey(
|
// }
|
||||||
'CRM_Grant_DAO_Grant',
|
// $paidStatusID = CRM_Core_PseudoConstant::getKey(
|
||||||
'status_id',
|
// 'CRM_Grant_DAO_Grant',
|
||||||
'Paid'
|
// 'status_id',
|
||||||
);
|
// 'Paid'
|
||||||
if ($paidStatusID != $fields['status_id']) {
|
// );
|
||||||
return;
|
// if ($paidStatusID != $fields['status_id']) {
|
||||||
}
|
// return;
|
||||||
list($isError, $grantBudget) = CRM_Grant_BAO_GrantBudget::checkBudget($fields, $form->getVar('_id'));
|
// }
|
||||||
if ($isError) {
|
//
|
||||||
$errors[GRANT_AMOUNT_CHECK_FIELD] = ts("The annual budget for this grant is {$grantBudget['budget']}. Grants totaling {$grantBudget['total_amount_granted']} have been made. {$grantBudget['balance_amount']} remains.");
|
// list($isError, $grantBudget) = CRM_Grant_BAO_GrantBudget::checkBudget($fields, $form->getVar('_id'));
|
||||||
}
|
// if ($isError) {
|
||||||
}
|
// $errors[GRANT_AMOUNT_CHECK_FIELD] = ts("The annual budget for this grant is {$grantBudget['budget']}. Grants totaling {$grantBudget['total_amount_granted']} have been made. {$grantBudget['balance_amount']} remains.");
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
Loading…
Reference in New Issue
Block a user