Updating search
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 24 May 2019 13:05:27 +0000 (09:05 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 24 May 2019 13:05:27 +0000 (09:05 -0400)
Combining name and city search so they can both be performed together.

models/front/members/list.php
views/front/members/list.html

index 98f17d4..3fc84a1 100755 (executable)
@@ -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 '<pre>$where: ' . print_r( $where, true ) . '</pre>';
+
             /*
              *  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 '<pre>$fullTextSearch: ' . print_r( $fullTextSearch, true ) . '</pre>';
                     if ( $appendSelect ) {
@@ -1037,42 +1039,44 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                         $order = " member_name ASC ";
                     }
                     // echo '<pre>$order: ' . print_r( $order, true ) . '</pre>';
-                    ${$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 '<pre>$order: ' . print_r( $order, true ) . '</pre>';
+                            // echo '<pre>$cityName: ' . print_r( $cityName, true ) . '</pre>';
+                            // echo '<pre>$distanceQuery: ' . print_r( $distanceQuery, true ) . '</pre>';
+                        } 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 '<pre>$order: ' . print_r( $order, true ) . '</pre>';
-                        // echo '<pre>$cityName: ' . print_r( $cityName, true ) . '</pre>';
-                        // echo '<pre>$distanceQuery: ' . print_r( $distanceQuery, true ) . '</pre>';
-                    } 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";
index 149a958..cae9af9 100755 (executable)
         </div> {* glm-member-db-list *}
     {/if}
 
-    {debug}
     <script>
 
         jQuery(document).ready(function($) {