diff --git a/CRM/Grant/BAO/GrantProgram.php b/CRM/Grant/BAO/GrantProgram.php index 6e0ff0b447009bef11879be3375a45d72634068d..eb8ee8a63f8cc1b594cc39f9152c65bb698af425 100755 --- a/CRM/Grant/BAO/GrantProgram.php +++ b/CRM/Grant/BAO/GrantProgram.php @@ -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); + } } } } diff --git a/CRM/Grant/Form/Task/GrantPayment.php b/CRM/Grant/Form/Task/GrantPayment.php index 9ce6199fceb6060279cbdf7bc88c44e3ed2d3e92..fb665d59619ed1d2d0ef6673089fd165d207f3f4 100755 --- a/CRM/Grant/Form/Task/GrantPayment.php +++ b/CRM/Grant/Form/Task/GrantPayment.php @@ -321,18 +321,20 @@ class CRM_Grant_Form_Task_GrantPayment extends CRM_Core_Form $entityFileDAO->entity_id = $_SESSION[ 'CiviCRM' ][ 'userID' ]; $entityFileDAO->file_id = $grantPaymentCheckFile; $entityFileDAO->save(); - + + $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); + $activityType = CRM_Core_PseudoConstant::activityType(); $params = array( - 'source_contact_id' => $_SESSION[ 'CiviCRM' ][ 'userID' ], - 'activity_type_id' => key(CRM_Core_OptionGroup::values( 'activity_type', false, false, false, 'AND v.label = "Grant Payment"' , 'value' )), - 'assignee_contact_id' => $_SESSION[ 'CiviCRM' ][ 'userID' ], - 'subject' => "Grant Payment", - 'activity_date_time' => date('Ymdhis'), - 'status_id' => CRM_Core_OptionGroup::getValue( 'activity_status', 'Completed', 'name' ), - 'priority_id' => 2, - 'details' => "<a href=".CRM_Utils_System::url( 'civicrm/file', 'reset=1&id='.$grantPaymentFile.'&eid='.$_SESSION[ 'CiviCRM' ][ 'userID' ].'').">".$downloadName."</a></br><a href=".CRM_Utils_System::url( 'civicrm/file', 'reset=1&id='.$grantPaymentCheckFile.'&eid='.$_SESSION[ 'CiviCRM' ][ 'userID' ].'').">".$checkRegisterFile."</a>", - ); - CRM_Activity_BAO_Activity::create( $params ); + 'source_contact_id' => $_SESSION['CiviCRM']['userID'], + 'activity_type_id' => array_search('Grant Payment', $activityType), + 'assignee_contact_id' => $_SESSION['CiviCRM']['userID'], + 'subject' => "Grant Payment", + 'activity_date_time' => date('Ymdhis'), + 'status_id' => array_search('Completed', $activityStatus), + 'priority_id' => 2, + 'details' => "<a href=" . CRM_Utils_System::url('civicrm/file', 'reset=1&id=' . $grantPaymentFile . '&eid=' . $_SESSION['CiviCRM']['userID'] . '') . ">" . $downloadName . "</a></br><a href=" . CRM_Utils_System::url('civicrm/file', 'reset=1&id=' . $grantPaymentCheckFile . '&eid=' . $_SESSION['CiviCRM']['userID'] . '') . ">" . $checkRegisterFile . "</a>", + ); + CRM_Activity_BAO_Activity::create($params); require_once 'CRM/Grant/DAO/EntityPayment.php'; if ( $this->_prid ) { @@ -362,7 +364,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." ); } diff --git a/CRM/Grant/Form/Task/Reprint.php b/CRM/Grant/Form/Task/Reprint.php index bc5f6086f6cacd9d24e5f192ec0944b37ce2b766..f349ac8d775de6366c72705d543b3b0601017d39 100755 --- a/CRM/Grant/Form/Task/Reprint.php +++ b/CRM/Grant/Form/Task/Reprint.php @@ -299,18 +299,19 @@ class CRM_Grant_Form_Task_Reprint extends CRM_Grant_Form_PaymentTask $entityFileDAO->entity_id = $_SESSION[ 'CiviCRM' ][ 'userID' ]; $entityFileDAO->file_id = $grantPaymentCheckFile; $entityFileDAO->save(); - + $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); + $activityType = CRM_Core_PseudoConstant::activityType(); $params = array( - 'source_contact_id' => $_SESSION[ 'CiviCRM' ][ 'userID' ], - 'activity_type_id' => key(CRM_Core_OptionGroup::values( 'activity_type', false, false, false, 'AND v.label = "Grant Payment"' , 'value' )), - 'assignee_contact_id' => $_SESSION[ 'CiviCRM' ][ 'userID' ], - 'subject' => "Grant Payment", - 'activity_date_time' => date('Ymdhis'), - 'status_id' => CRM_Core_OptionGroup::getValue( 'activity_status','Completed','name' ), - 'priority_id' => 2, - 'details' => "<a href=".CRM_Utils_System::url( 'civicrm/file', 'reset=1&id='.$grantPaymentFile.'&eid='.$_SESSION[ 'CiviCRM' ][ 'userID' ].'').">".$downloadName."</a></br><a href=".CRM_Utils_System::url( 'civicrm/file', 'reset=1&id='.$grantPaymentCheckFile.'&eid='.$_SESSION[ 'CiviCRM' ][ 'userID' ].'').">".$checkRegisterFile."</a>", - ); - CRM_Activity_BAO_Activity::create( $params ); + 'source_contact_id' => $_SESSION['CiviCRM']['userID'], + 'activity_type_id' => array_search('Grant Payment', $activityType), + 'assignee_contact_id' => array($_SESSION['CiviCRM']['userID']), + 'subject' => "Grant Payment", + 'activity_date_time' => date('Ymdhis'), + 'status_id' => array_search('Completed', $activityStatus), + 'priority_id' => 2, + 'details' => "<a href=" . CRM_Utils_System::url('civicrm/file', 'reset=1&id=' . $grantPaymentFile . '&eid=' . $_SESSION['CiviCRM']['userID'] . '') . ">" . $downloadName . "</a></br><a href=" . CRM_Utils_System::url('civicrm/file', 'reset=1&id=' . $grantPaymentCheckFile . '&eid=' . $_SESSION['CiviCRM']['userID'] . '') . ">" . $checkRegisterFile . "</a>", + ); + CRM_Activity_BAO_Activity::create($params); CRM_Core_Session::setStatus( "Selected payment stopped and reprinted successfully."); CRM_Utils_System::redirect(CRM_Utils_System::url( 'civicrm/grant/payment/search', 'reset=1&bid='.$values['payment_batch_number'].'&download='.$fileName.'&force=1')); } diff --git a/grantprograms.php b/grantprograms.php index 124c7381a740af07fb0826e2ad7c5334c2023c12..da50ee07de27d098e9026e4f372ce289733574bb 100644 --- a/grantprograms.php +++ b/grantprograms.php @@ -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); } } diff --git a/sql/grantprograms_disable.sql b/sql/grantprograms_disable.sql index d2f0d3e29e2303835352bdcbc10b3deac03b70f9..a60b88350f2d7259d00e20ab244323195d3a1e6e 100644 --- a/sql/grantprograms_disable.sql +++ b/sql/grantprograms_disable.sql @@ -40,3 +40,8 @@ UPDATE civicrm_option_value SET is_active = 0 WHERE name = 'NEI Grant' AND optio UPDATE civicrm_financial_account SET is_active = 0 WHERE name = 'NEI Grant'; UPDATE civicrm_financial_type SET is_active = 0 WHERE name = 'NEI Grant'; + +-- RG-212 +UPDATE civicrm_option_group cog INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id +SET cov.is_active = 0 +WHERE cog.name = 'activity_type' AND cov.name IN ('grant_status_change', 'grant_payment'); diff --git a/sql/grantprograms_enable.sql b/sql/grantprograms_enable.sql index 8ddfb960bb9d6828ec5e7e9322630c4aeb9880fb..d59387fbd8a615e76078215ce01c294c446df036 100644 --- a/sql/grantprograms_enable.sql +++ b/sql/grantprograms_enable.sql @@ -41,3 +41,7 @@ UPDATE civicrm_option_value SET is_active = 1 WHERE name = 'NEI Grant' AND optio UPDATE civicrm_financial_account SET is_active = 1 WHERE name = 'NEI Grant'; UPDATE civicrm_financial_type SET is_active = 1 WHERE name = 'NEI Grant'; +-- RG-212 +UPDATE civicrm_option_group cog INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id +SET cov.is_active = 1 +WHERE cog.name = 'activity_type' AND cov.name IN ('grant_status_change', 'grant_payment'); \ No newline at end of file diff --git a/sql/grantprograms_install.sql b/sql/grantprograms_install.sql index 06ab49a46ecf53c28ec704975e7036324aa96637..e838c352e087822251d155f6acdf63c88f71408f 100755 --- a/sql/grantprograms_install.sql +++ b/sql/grantprograms_install.sql @@ -345,3 +345,11 @@ INSERT INTO `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES (@ogId, 'Number of Days after Course till Ineligible', 120, 'number_of_days_after_course_till_ineligible', NULL, 0, 0, 1, 'Number of Days after Course till Ineligible', 0, 1, 1, 2, NULL); + +-- RG-212 +SELECT @activityType := cog.id, @value := max(cast(value as unsigned)) + 1 FROM civicrm_option_group cog INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id WHERE cog.name = 'activity_type'; + +INSERT INTO civicrm_option_value(option_group_id, label, value, name, grouping, filter, is_default, weight, description, is_optgroup, is_reserved, is_active, component_id, visibility_id) +VALUES (@activityType, 'Grant Status Change', @value, 'grant_status_change', NULL, 0, 0, @value, 'Grant status change', 0, 1, 1, 5, NULL), + (@activityType, 'Grant Payment', @value + 1, 'grant_payment', NULL, 0, 0, @value + 1, 'Grant payment', 0, 1, 1, 5, NULL); + diff --git a/sql/grantprograms_uninstall.sql b/sql/grantprograms_uninstall.sql index 3d9dcfbd060af0cdd0716bff80a36e9599d78408..b042c39baf9c8a6f68710bce19581754ec06199f 100755 --- a/sql/grantprograms_uninstall.sql +++ b/sql/grantprograms_uninstall.sql @@ -134,3 +134,6 @@ DELETE FROM civicrm_financial_type WHERE name = 'NEI Grant'; ALTER table civicrm_grant DROP column grant_incomplete_reason_id; DELETE FROM civicrm_extension WHERE full_name = 'biz.jmaconsulting.grantprograms'; + +-- RG-212 +DELETE cov FROM civicrm_option_group cog INNER JOIN civicrm_option_value cov ON cov.option_group_id = cog.id WHERE cog.name = 'activity_type' AND cov.name IN ('grant_status_change', 'grant_payment');