forked from CiviWare/org.agbu.annualgrantbudgets
rewrite validation to support multifund
This commit is contained in:
@ -222,28 +222,19 @@ function annualgrantbudgets_civicrm_apiWrappers(&$wrappers, $apiRequest) {
|
||||
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm
|
||||
*
|
||||
*/
|
||||
// //This whole validation needs rewriting.
|
||||
//function annualgrantbudgets_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
|
||||
// if ($formName == 'CRM_Grant_Form_Grant' && !($form->_action & CRM_Core_Action::DELETE)) {
|
||||
// if (empty($fields['financial_type_id'])
|
||||
// || empty($fields['status_id'])
|
||||
// || empty($fields[GRANT_DATE_CHECK_FIELD])
|
||||
// || empty($fields[GRANT_AMOUNT_CHECK_FIELD])
|
||||
// ) {
|
||||
// return;
|
||||
// }
|
||||
// $paidStatusID = CRM_Core_PseudoConstant::getKey(
|
||||
// 'CRM_Grant_DAO_Grant',
|
||||
// 'status_id',
|
||||
// 'Paid'
|
||||
// );
|
||||
// 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.");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
function annualgrantbudgets_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
|
||||
if ($formName == 'CRM_Grant_Form_Grant' && !($form->_action & CRM_Core_Action::DELETE)) {
|
||||
if (empty($fields['financial_type_id']) || empty($fields['status_id']) || empty($fields[GRANT_DATE_CHECK_FIELD])
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$paidStatusID = CRM_Core_PseudoConstant::getKey(
|
||||
'CRM_Grant_DAO_Grant', 'status_id', 'Paid'
|
||||
);
|
||||
if ($paidStatusID != $fields['status_id']) {
|
||||
return;
|
||||
}
|
||||
$budgetErrors = CRM_Grant_BAO_GrantBudget::checkBudget($fields, $form->getVar('_id'));
|
||||
$errors = array_merge($errors, $budgetErrors);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user