if($grantStatuses[$currentStatus]=='Paid'){$approvedStatusID=array_search('Approved for Payment',$grantStatuses);if(!empty($grantStatuses[$approvedStatusID])){unset($grantStatuses[$approvedStatusID]);}}

if($isGrantPresent){$error[]=l('Grant(s)','civicrm/grant?reset=1');}if($isProgramPresent){$error[]=l('Grant Program(s)','civicrm/grant_program?reset=1');}CRM_Core_Session::setStatus(ts('You cannot delete this Grant Type because '.implode(' and ',$error).' are currently using it.'),ts("Sorry"),"error");

if(CRM_Utils_Array::value('amount_granted',$fields)&&$fields['amount_granted']>0&&!CRM_Utils_Array::value('financial_type_id',$fields)&&CRM_Utils_Array::value('money_transfer_date',$fields)){$errors['financial_type_id']=ts('Financial Type is a required field if Amount is Granted');}

if(!$grantDetails[$grantID]['amount_granted']){$errors['task']=ts('Payments are only possible when there is an amount owing.');break;}}elseif($fields['task']==DELETE_GRANTS){$params['entity_table']='civicrm_grant';$params['entity_id']=$grantID;$grantPayment=CRM_Grant_BAO_EntityPayment::retrieve($params,$defaults=CRM_Core_DAO::$_nullArray);if($grantPayment){$errors['task']=ts('You cannot delete grant because grant payment is currently using it.');break;}

/** * Hook implementation when an email is about to be sent by CiviCRM. * */functiongrantprograms_civicrm_alterMailParams(&$params){if(substr($params['valueName'],0,6)=='grant_'){CRM_Core_Smarty::singleton()->assign('messageBody',$params['html']);}