diff --git a/CRM/Grant/DAO/Grant.php b/CRM/Grant/DAO/Grant.php index 080ea1d0ea88e1221163564b0a15ceaebee7152b..5b80f12ca75e0f6e1f47fbbbb08ae8de5c452575 100644 --- a/CRM/Grant/DAO/Grant.php +++ b/CRM/Grant/DAO/Grant.php @@ -176,6 +176,12 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO * @var int unsigned */ public $grant_rejected_reason_id; + /** + * Id of Grant Incomplete Reason. + * + * @var int unsigned + */ + public $grant_incomplete_reason_id; /** * * @var string @@ -383,6 +389,16 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO 'dataPattern' => '', 'export' => false, ) , + 'grant_incomplete_reason_id' => array( + 'name' => 'grant_incomplete_reason_id', + 'type' => CRM_Utils_Type::T_INT, + 'required' => true, + 'import' => true, + 'where' => 'civicrm_grant.grant_incomplete_reason_id', + 'headerPattern' => '', + 'dataPattern' => '', + 'export' => false, + ) , 'assessment' => array( 'name' => 'assessment', 'type' => CRM_Utils_Type::T_STRING, diff --git a/grantprograms.php b/grantprograms.php index 0ca5727a0fc7ca5dcb02bd45415d7ba4359b0378..7869fd9baac5022b0819a91797bd8a0f7fd720b5 100644 --- a/grantprograms.php +++ b/grantprograms.php @@ -267,6 +267,14 @@ function grantprograms_civicrm_buildForm($formName, &$form) { FALSE ); + $form->_reasonGrantIncomplete = CRM_Core_OptionGroup::values('reason_grant_incomplete'); + $form->add('select', + 'grant_incomplete_reason_id', + ts('Reason Grant Incomplete'), + array('' => ts('- select -')) + $form->_reasonGrantIncomplete, + FALSE + ); + $form->_grantPrograms = CRM_Grant_BAO_GrantProgram::getGrantPrograms(); $form->add('select', 'grant_program_id', @@ -701,6 +709,7 @@ function grantprograms_civicrm_post($op, $objectName, $objectId, &$objectRef) { $grantType = $grantTypes[$params['grant_type_id']]; $grantStatus = $grantStatus[$params['status_id']]; $grantIneligibleReasons = CRM_Core_OptionGroup::values('reason_grant_ineligible'); + $grantIncompleteReasons = CRM_Core_OptionGroup::values('reason_grant_incomplete'); $page->assign('grant_type', $grantType); $page->assign('grant_programs', $grantProgram); @@ -708,10 +717,17 @@ function grantprograms_civicrm_post($op, $objectName, $objectId, &$objectRef) { if (CRM_Utils_Array::value('grant_rejected_reason_id', $params)) { $params['grant_rejected_reason'] = $grantIneligibleReasons[$params['grant_rejected_reason_id']]; } + + if (CRM_Utils_Array::value('grant_rejected_reason_id', $params)) { + $params['grant_rejected_reason'] = $grantIneligibleReasons[$params['grant_rejected_reason_id']]; + } + if (CRM_Utils_Array::value('grant_incomplete_reason_id', $params)) { + $params['grant_incomplete_reason'] = $grantIncompleteReasons[$params['grant_incomplete_reason_id']]; + } $page->assign('grant', $params); CRM_Grant_BAO_GrantProgram::sendMail($params['contact_id'], $params, $grantStatus); } - + $grantStatus = CRM_Core_OptionGroup::values('grant_status', TRUE); if (isset($endDate)) { $infoTooLate = key(CRM_Core_PseudoConstant::accountOptionValues('grant_info_too_late')); diff --git a/sql/grantprograms_install.sql b/sql/grantprograms_install.sql index 1c65c89df6cd7bb3950a7d85cb53a20dd33b0545..cf2ff8661f8c4874ca37773dfb4d452ca2229dc2 100755 --- a/sql/grantprograms_install.sql +++ b/sql/grantprograms_install.sql @@ -102,7 +102,8 @@ ALTER TABLE `civicrm_grant_program` ALTER TABLE `civicrm_grant` ADD `grant_program_id` INT( 10 ) UNSIGNED NOT NULL COMMENT 'Grant Program ID of grant program record given grant belongs to.' AFTER `contact_id`, ADD `grant_rejected_reason_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'Id of Grant Rejected Reason.' AFTER `status_id` , - ADD `assessment` VARCHAR( 655 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `grant_rejected_reason_id`; + ADD `grant_incomplete_reason_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'Id of Grant Incomplete Reason.' AFTER `grant_rejected_reason_id` , + ADD `assessment` VARCHAR( 655 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `grant_incomplete_reason_id`; -- -- Constraints for table `civicrm_grant` diff --git a/sql/message_templates/grant_awaiting_info_html.tpl b/sql/message_templates/grant_awaiting_info_html.tpl index 2d8b756bbf62de152291f92eea0a1f414d88deef..66176a93ba0c3a5b95d459f23fa87948365bcc79 100644 --- a/sql/message_templates/grant_awaiting_info_html.tpl +++ b/sql/message_templates/grant_awaiting_info_html.tpl @@ -14,6 +14,10 @@ Grant Program Name: {$grant_programs} <br> Grant Type : {$grant_type}<br> Total Amount : {$grant.amount_total}<br> +{if $grant.grant_incomplete_reason} +Grant Incomplete Reason: +{$grant.grant_incomplete_reason}<br> +{/if} {if customField} {foreach from=$customField key=key item=data} <b>{$customGroup.$key}</b><br> diff --git a/sql/message_templates/grant_awaiting_info_text.tpl b/sql/message_templates/grant_awaiting_info_text.tpl index 93b230a4c901d2eea94bed510d7d5f0c22848830..813a70d07b3a1bba831630ee12aeca203d528b62 100644 --- a/sql/message_templates/grant_awaiting_info_text.tpl +++ b/sql/message_templates/grant_awaiting_info_text.tpl @@ -1,8 +1,12 @@ Dear {contact.display_name}, This is being sent to you as a receipt of {$grant_status} grant. Grant Program Name: {$grant_programs} <br> -Grant Type {$grant_type} -Total Amount: {$grant.amount_total} +Grant Type {$grant_type}<br> +Total Amount: {$grant.amount_total}<br> +{if $grant.grant_incomplete_reason} +Grant Incomplete Reason: +{$grant.grant_incomplete_reason}<br> +{/if} {if customField} {foreach from=$customField key=key item=data} {$customGroup.$key} diff --git a/templates/CRM/Grant/Form/GrantExtra.tpl b/templates/CRM/Grant/Form/GrantExtra.tpl index d96f34eca9c76357644f825f06fd4024c35d27b2..54f48b35399c06b8f9105d36fe5c48006e5f1c39 100755 --- a/templates/CRM/Grant/Form/GrantExtra.tpl +++ b/templates/CRM/Grant/Form/GrantExtra.tpl @@ -28,6 +28,10 @@ <tr class="crm-grant-form-block-grant_rejected_reason_id grant_rejected_reason_id"> <td class="label">{$form.grant_rejected_reason_id.label}</td> <td>{$form.grant_rejected_reason_id.html}</td> + </tr> + <tr class="crm-grant-form-block-grant_incomplete_reason_id grant_incomplete_reason_id"> + <td class="label">{$form.grant_incomplete_reason_id.label}</td> + <td>{$form.grant_incomplete_reason_id.html}</td> </tr> <tr class="crm-grant-form-block-grant_program_id"> <td class="label">{$form.grant_program_id.label}</td> @@ -67,6 +71,7 @@ {literal} cj(document).ready(function(){ cj('.crm-grant-form-block-grant_rejected_reason_id').insertAfter('.crm-grant-form-block-status_id'); + cj('.crm-grant-form-block-grant_incomplete_reason_id').insertAfter('.crm-grant-form-block-status_id'); cj('.crm-grant-form-block-grant_program_id').insertAfter('.crm-grant-form-block-grant_type_id'); cj('.crm-grant-form-block-assessment').insertAfter('.crm-grant-form-block-amount_requested'); cj('.crm-grant-form-block-prev_assessment').insertAfter('.crm-grant-form-block-assessment'); @@ -83,12 +88,24 @@ if ( cj("#status_id option:selected").text() == 'Ineligible') { } else { cj('.grant_rejected_reason_id').hide(); } + +if (cj("#status_id option:selected").text() == 'Awaiting Information') { + cj('.grant_incomplete_reason_id').show(); +} else { + cj('.grant_incomplete_reason_id').hide(); +} + cj('#status_id').change(function(){ -if ( this.options[this.selectedIndex].text == 'Ineligible' ) { +if (this.options[this.selectedIndex].text == 'Ineligible') { cj('.grant_rejected_reason_id').show(); } else { cj('.grant_rejected_reason_id').hide(); } +if (this.options[this.selectedIndex].text == 'Awaiting Information') { + cj('.grant_incomplete_reason_id').show(); +} else { + cj('.grant_incomplete_reason_id').hide(); +} }); var grantId = {/literal}{if $grant_id}{$grant_id}{else}{literal}0{/literal}{/if}{literal}; var dataUrl = {/literal}"{crmURL p='civicrm/grant/search' h=0 q="snippet=1&force=1"}"{literal};