Added ability to search contribution using contribution soft custom fields

This commit is contained in:
CiviWare Solutions 2018-12-26 00:52:21 +00:00
parent 54ab2b53bb
commit 7d15dd1c4d
2 changed files with 32 additions and 0 deletions

View File

@ -149,12 +149,30 @@ function softcreditcustomfields_civicrm_entityTypes(&$entityTypes) {
_softcreditcustomfields_civix_civicrm_entityTypes($entityTypes); _softcreditcustomfields_civix_civicrm_entityTypes($entityTypes);
} }
/**
* Implements hook_civicrm_preProcess().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_preProcess
*/
function softcreditcustomfields_civicrm_preProcess($formName, &$form) {
if (in_array($formName, ['CRM_Contribute_Form_Search', 'CRM_Contact_Form_Search_Advanced'])) {
$extendsMap = &CRM_Core_BAO_CustomQuery::$extendsMap;
$extendsMap['ContributionSoft'] = 'civicrm_contribution_soft';
}
}
/** /**
* Implements hook_civicrm_buildForm(). * Implements hook_civicrm_buildForm().
* *
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm
*/ */
function softcreditcustomfields_civicrm_buildForm($formName, &$form) { function softcreditcustomfields_civicrm_buildForm($formName, &$form) {
if ('CRM_Contribute_Form_Search' == $formName) {
CRM_Contribute_BAO_Query::addCustomFormFields($form, ['ContributionSoft']);
CRM_Core_Region::instance('page-footer')->add(array(
'template' => "CRM/Contribute/Form/Search/SoftCredit-Search.tpl",
));
}
if ('CRM_Contribute_Form_ContributionView' == $formName) { if ('CRM_Contribute_Form_ContributionView' == $formName) {
$softCredits = $form->get_template_vars('softContributions'); $softCredits = $form->get_template_vars('softContributions');
if (!empty($softCredits)) { if (!empty($softCredits)) {

View File

@ -0,0 +1,14 @@
{if $contributionSoftGroupTree}
<div class="softcredit_custom_groups">
<br>
{include file="CRM/Custom/Form/Search.tpl" groupTree=$contributionSoftGroupTree showHideLinks=false}
</div>
<script type="text/javascript">
{literal}
CRM.$(function($) {
$('div#contribution_soft_credit_type_wrapper').append($('div.softcredit_custom_groups'));
});
{/literal}
</script>
{/if}