From 258e2addb1ce7f67eeed981fd32d572a51935909 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Fri, 18 Jul 2014 12:13:32 +0530 Subject: [PATCH] CRM-14996 fix - Reports county filter option shows all counties regardless of state or states chosen https://issues.civicrm.org/jira/browse/CRM-14996 --- CRM/Report/Form.php | 26 +++++++++++++++--------- templates/CRM/common/stateCountry.tpl | 29 ++++++++++++++++++++------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 2dbc1bd4b7..85ae9302c7 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -967,6 +967,14 @@ class CRM_Report_Form extends CRM_Core_Form { } } } + + $stateCountryMap[] = array( + 'country' => 'country_id_value', + 'state_province' => 'state_province_id_value', + 'county' => 'county_id_value' + ); + CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap); + $this->assign('filters', $filters); } @@ -2992,37 +3000,37 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND if (!is_array($value)) { $value = array($value); } - + $tmp_membership_org_sql_list = implode(', ', $value); return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} ( SELECT DISTINCT mem.contact_id - FROM civicrm_membership mem + FROM civicrm_membership mem LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id - LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id + LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id WHERE mt.member_of_contact_id IN (".$tmp_membership_org_sql_list.") AND mt.is_active = '1' AND mem_status.is_current_member = '1' AND mem_status.is_active = '1' ) "; - } + } function whereMembershipTypeClause($field, $value, $op) { $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { $value = array($value); } - + $tmp_membership_sql_list = implode(', ', $value); return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} ( SELECT DISTINCT mem.contact_id - FROM civicrm_membership mem - LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id - LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id + FROM civicrm_membership mem + LEFT JOIN civicrm_membership_status mem_status ON mem.status_id = mem_status.id + LEFT JOIN civicrm_membership_type mt ON mem.membership_type_id = mt.id WHERE mem.membership_type_id IN (".$tmp_membership_sql_list.") AND mt.is_active = '1' AND mem_status.is_current_member = '1' AND mem_status.is_active = '1' ) "; } - + /** * @param string $tableAlias */ diff --git a/templates/CRM/common/stateCountry.tpl b/templates/CRM/common/stateCountry.tpl index fbea80400e..4afb8f4b61 100644 --- a/templates/CRM/common/stateCountry.tpl +++ b/templates/CRM/common/stateCountry.tpl @@ -34,15 +34,30 @@ var placeholder = $(this).val() ? "{/literal}{ts escape='js'}Loading{/ts}{literal}..." : info.placeholder; !multiple && info.target.html(''); if ($(this).val()) { - $.getJSON(info.callback, {_value: $(this).val()}, function(data) { + if (multiple) { var options = ''; - $.each(data, function() { - if (!multiple || this.value) { - options += ''; - } + $.each($(this).val(), function(index, value) { + $.getJSON(info.callback, {_value: value}, function(data) { + $.each(data, function() { + if (this.value) { + options += ''; + } + }); + info.target.html(options).val(val).trigger('change'); + }); }); - info.target.html(options).val(val).trigger('change'); - }); + } + else { + $.getJSON(info.callback, {_value: $(this).val()}, function(data) { + var options = ''; + $.each(data, function() { + if (this.value) { + options += ''; + } + }); + info.target.html(options).val(val).trigger('change'); + }); + } } else { info.target.trigger('change'); } -- 2.25.1