From: Steve Sutton Date: Fri, 24 May 2019 13:05:27 +0000 (-0400) Subject: Updating search X-Git-Tag: v2.12.4~1^2~17^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=ce7f58e3d72a9e64f60bb314bc05b900a46ef0aa;p=WP-Plugins%2Fglm-member-db.git Updating search Combining name and city search so they can both be performed together. --- diff --git a/models/front/members/list.php b/models/front/members/list.php index 98f17d44..3fc84a11 100755 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -1016,19 +1016,21 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo // require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/memberDataByLatLon.php'; // $MapItems = new GlmMembersFront_members_memberDataByLatLon($this->wpdb, $this->config); + // echo '
$where: ' . print_r( $where, true ) . '
'; + /* * Get a current list of members - unless this is a blank start */ if (!$blankStart) { // If there's a full text search, handle separately - if ( $fullTextSearch ) { + if ( $fullTextSearch || $citySearchSelected ) { // Get stats for the current selection - $membersFound = $this->getStats(str_replace('T.', '', $where)); + // $membersFound = $this->getStats(str_replace('T.', '', $where)); // Get stats for number of members found matching current selection criteria (includes alpha selection) - $filteredMembersFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); + // $filteredMembersFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); // echo '
$fullTextSearch: ' . print_r( $fullTextSearch, true ) . '
'; if ( $appendSelect ) { @@ -1037,42 +1039,44 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $order = " member_name ASC "; } // echo '
$order: ' . print_r( $order, true ) . '
'; - ${$resultParam} = $this->getList( - $where.$alphaWhere, // where - $order, // order - true, // fieldVals - 'id', // idField - $start, // start - $limit, // limit - '', // prohibitListOptions - $appendSelect - ); - } elseif ( $citySearchSelected ) { + // ${$resultParam} = $this->getList( + // $where.$alphaWhere, // where + // $order, // order + // true, // fieldVals + // 'id', // idField + // $start, // start + // $limit, // limit + // '', // prohibitListOptions + // $appendSelect + // ); + // } elseif ( $citySearchSelected ) { // Setup city search for distance - $cityCoordinates = $this->getCityCoordinates( $citySearchSelected ); - if ( $cityCoordinates ) { - $cityName = $cityCoordinates['name']; - // Distance query - $distanceQuery = $this->getDistanceQuery( $cityCoordinates['lat'], $cityCoordinates['lon'] ); - if ( !isset( $whereSep ) || $whereSep == '' ) { + if ( $citySearchSelected ) { + $cityCoordinates = $this->getCityCoordinates( $citySearchSelected ); + if ( $cityCoordinates ) { + $cityName = $cityCoordinates['name']; + // Distance query + $distanceQuery = $this->getDistanceQuery( $cityCoordinates['lat'], $cityCoordinates['lon'] ); + if ( !isset( $whereSep ) || $whereSep == '' ) { + $whereSep = ' AND '; + } + $where .= $whereSep." ( $distanceQuery < 40 )"; $whereSep = ' AND '; + $appendSelect = " + CASE + WHEN T.city = {$citySearchSelected} THEN 0 + ELSE " . $distanceQuery . " + END AS distance"; + + $order = " distance ASC, city ASC, member_name ASC "; + // echo '
$order: ' . print_r( $order, true ) . '
'; + // echo '
$cityName: ' . print_r( $cityName, true ) . '
'; + // echo '
$distanceQuery: ' . print_r( $distanceQuery, true ) . '
'; + } else { + $appendSelect = ""; + $order = " member_name ASC "; } - $where .= $whereSep." ( $distanceQuery < 40 )"; - $whereSep = ' AND '; - $appendSelect = " - CASE - WHEN T.city = {$citySearchSelected} THEN 0 - ELSE " . $distanceQuery . " - END AS distance"; - - $order = " distance ASC, city ASC, member_name ASC "; - // echo '
$order: ' . print_r( $order, true ) . '
'; - // echo '
$cityName: ' . print_r( $cityName, true ) . '
'; - // echo '
$distanceQuery: ' . print_r( $distanceQuery, true ) . '
'; - } else { - $appendSelect = ""; - $order = " member_name ASC "; } // Get stats for the current selection @@ -1188,7 +1192,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo $ajaxRequest .= "&categorySearch=$categorySearch"; } if ( isset( $citySearch ) && $citySearch ) { - $ajaxRequest .= "&citySearch=$citySearch"; + // $ajaxRequest .= "&citySearch=$citySearch"; } if ( isset( $ajaxRequest ) && $ajaxRequest ) { $ajaxRequest .= "&ajaxRequest=$ajaxRequest"; diff --git a/views/front/members/list.html b/views/front/members/list.html index 149a958b..cae9af9e 100755 --- a/views/front/members/list.html +++ b/views/front/members/list.html @@ -420,7 +420,6 @@ {* glm-member-db-list *} {/if} - {debug}