Added 'Include non-constituents in this search' on Advance search

This commit is contained in:
Pradeep Nayak 2018-10-11 03:03:38 +05:30
parent af531fbd4c
commit 6a30fb4ca7
3 changed files with 37 additions and 0 deletions

View File

@ -49,6 +49,11 @@ class CRM_ConstituentsOnly_BAO_Query extends CRM_Contact_BAO_Query_Interface {
return;
}
if (!empty($query->_paramLookup['ignore_constituent_search'])) {
$query->_qill[0][] = ts("Include non-constituents in this search");
return;
}
if (CRM_Utils_Array::value('civicrm_contact', $query->_tables) && empty($query->_paramLookup['do_not_trade'])) {
$query->_where[0][] = "
IF (contact_a.do_not_trade = 1,

View File

@ -190,6 +190,25 @@ function constituentsonly_civicrm_selectWhereClause($entity, &$clauses) {
*/
function constituentsonly_civicrm_searchColumns($objectName, &$headers, &$rows, &$selector) {
if (in_array($objectName, ['contact']) && !empty($rows)) {
if (!empty($_POST['ignore_constituent_search'])) {
return;
}
$rows = CRM_ConstituentsOnly_BAO_ConstituentsOnly::updateSearchRows($rows, $headers);
}
}
/**
* Implements hook_civicrm_buildForm().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm
*/
function constituentsonly_civicrm_buildForm($formName, &$form) {
if ('CRM_Contact_Form_Search_Advanced' == $formName
&& !($form->getVar('_action') == CRM_Core_Action::DELETE)
) {
$form->addElement('checkbox', 'ignore_constituent_search', ts('Include non-constituents'));
CRM_Core_Region::instance('page-body')->add(array(
'template' => 'CRM/common.tpl',
));
}
}

13
templates/CRM/common.tpl Normal file
View File

@ -0,0 +1,13 @@
<table class="ignore_constituent_search-block">
<tr class="ignore_constituent_search">
<td>{$form.ignore_constituent_search.html} {$form.ignore_constituent_search.label}</td>
</tr>
</table>
{literal}
<script type="text/javascript">
CRM.$(function($) {
$('#search-settings td.adv-search-top-submit').before($('table.ignore_constituent_search-block tr td'));
});
</script>
{/literal}