Commit 9f5383e1 authored by Pradeep Nayak's avatar Pradeep Nayak

-- worked on RG-212, added create activity code when grant status is changed.

parent 6716f5e1
......@@ -304,7 +304,7 @@ WHERE civicrm_contact.id = $id ";
return $grants;
}
static function sendMail($contactID, &$values, $grantStatus) {
static function sendMail($contactID, &$values, $grantStatus, $grantId = FALSE) {
$value = array();
if (CRM_Utils_Array::value('is_auto_email', $values)) {
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
......@@ -331,6 +331,23 @@ WHERE civicrm_contact.id = $id ";
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['autoSubmitted'] = TRUE;
CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
if ($grantId) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$activityType = CRM_Core_PseudoConstant::activityType();
$session = CRM_Core_Session::singleton();
$params = array(
'source_contact_id'=> $session->get('userID'),
'source_record_id' => $grantId,
'activity_type_id'=> array_search('Grant Status Change', $activityType),
'assignee_contact_id'=> array($contactID),
'subject'=> "Grant Status Change",
'activity_date_time'=> date('Ymdhis'),
'status_id'=> array_search('Completed', $activityStatus),
'priority_id'=> 2,
'details'=> '',
);
CRM_Activity_BAO_Activity::create($params);
}
}
}
}
......
......@@ -362,7 +362,7 @@ class CRM_Grant_Form_Task_GrantPayment extends CRM_Core_Form
$this->assign( 'grant_programs', $grantPrograms[$mailParams[$grantId]['grant_program_id']] );
$this->assign( 'grant_status', 'Paid' );
$this->assign( 'params', $mailParams[$grantId] );
CRM_Grant_BAO_GrantProgram::sendMail( $grantContctId[$grantId], $mailParams[$grantId], 'Paid' );
CRM_Grant_BAO_GrantProgram::sendMail($grantContctId[$grantId], $mailParams[$grantId], 'Paid', $grantId);
}
CRM_Core_Session::setStatus( "Created ".count($details)." payments to pay for ".count($this->_approvedGrants)." grants to ".count($details)." applicants." );
}
......
......@@ -746,7 +746,7 @@ function grantprograms_civicrm_post($op, $objectName, $objectId, &$objectRef) {
$smarty = CRM_Core_Smarty::singleton();
$sendMail = $smarty->get_template_vars('sendMail');
if ($sendMail) {
CRM_Grant_BAO_GrantProgram::sendMail($params['contact_id'], $params, $grantStatus);
CRM_Grant_BAO_GrantProgram::sendMail($params['contact_id'], $params, $grantStatus, $objectId);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment