Skip to content

Commit

Permalink
Merge pull request #9314 from liedekef/searchmember
Browse files Browse the repository at this point in the history
CRM-19556 : Allow to search on just being an active member
  • Loading branch information
monishdeb authored Oct 27, 2016
2 parents 8fab1e2 + ee54c71 commit bc0afc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CRM/Member/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public static function select(&$query) {
$query->_whereTables['civicrm_membership_status'] = 1;
}

if (!empty($query->_returnProperties['membership_is_current_member'])) {
$query->_select['is_current_member'] = "civicrm_membership_status.is_current_member as is_current_member";
$query->_element['is_current_member'] = 1;
$query->_tables['civicrm_membership_status'] = 1;
$query->_whereTables['civicrm_membership_status'] = 1;
}

if (!empty($query->_returnProperties['membership_status_id'])) {
$query->_select['status_id'] = "civicrm_membership_status.id as status_id";
$query->_element['status_id'] = 1;
Expand Down Expand Up @@ -251,6 +258,13 @@ public static function whereClauseSingle(&$values, &$query) {
$query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
return;

case 'membership_is_current_member':
// We don't want to include all tests for sql OR CRM-7827
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_membership_status.is_current_member", $op, $value, "Boolean");
$query->_qill[$grouping][] = ts('Is an %1 Member', array(1 => $value ? 'Active' : 'Inactive'));
$query->_tables['civicrm_membership_status'] = $query->_whereTables['civicrm_membership_status'] = 1;
return;

case 'member_test':
// We don't want to include all tests for sql OR CRM-7827
if (!$value || $query->getOperator() != 'OR') {
Expand Down Expand Up @@ -486,6 +500,7 @@ public static function buildSearchForm(&$form) {

$form->addFormRule(array('CRM_Member_BAO_Query', 'formRule'), $form);

$form->addYesNo('membership_is_current_member', ts('Active Member?'), TRUE);
$form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE);
$form->addYesNo('member_pay_later', ts('Pay Later?'), TRUE);

Expand Down
4 changes: 4 additions & 0 deletions templates/CRM/Member/Form/Search/Common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
</p>
</td>
<td>
<p>
{$form.membership_is_current_member.label}
{$form.membership_is_current_member.html}
</p>
<p>
{$form.member_is_primary.label}
{help id="id-member_is_primary" file="CRM/Member/Form/Search.hlp"}
Expand Down

0 comments on commit bc0afc0

Please sign in to comment.