adding filter for front end list and search for cities
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 16 Jan 2018 20:18:59 +0000 (15:18 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 16 Jan 2018 20:18:59 +0000 (15:18 -0500)
getting cities by contact, returning list of cities associated with contacts for search

models/front/contacts/list.php

index 9ef2cd5..7390f3c 100644 (file)
@@ -188,7 +188,34 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
             )";
             $haveFilter = true;
         }
-
+        // Filter by selected city
+        if (isset($_REQUEST['citySearch']) && $_REQUEST['citySearch'] !== "") {
+            $citySearch = esc_sql($_REQUEST['citySearch']);
+            $where .= " AND (
+                city = $citySearch
+            )";
+            $haveFilter = true;
+        }
+        
+        // Filter by name string supplied
+        if (isset($_REQUEST['filterName']) && $_REQUEST['filterName'] !== "") {
+            $filterName = esc_sql($_REQUEST['filterName']);
+            $where .= " AND (
+                lname LIKE '%$filterName%' OR
+                fname LIKE '%$filterName%'
+            )";
+            $haveFilter = true;
+        }
+        // Filter by company string supplied
+        if (isset($_REQUEST['filterOrganization']) && $_REQUEST['filterOrganization'] !== "") {
+            $filterOrganization = esc_sql($_REQUEST['filterOrganization']);
+            $where .= " AND (
+                org LIKE '%$filterOrganization%'
+            )";
+            $haveFilter = true;
+        }
+        
+        
         // Filter by text string supplied
         if (isset($_REQUEST['filterText'])) {
             $filterText = esc_sql($_REQUEST['filterText']);
@@ -285,8 +312,6 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
 
         }
 
-
-
             if ($paging) {
                 //Get paging results
                $numbDisplayed = $listResult['returned'];
@@ -333,6 +358,7 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
             $haveCounties = true;
         }
 
+
         // Compile template data
         $templateData = array(
             'option' => $option,
@@ -351,6 +377,7 @@ class GlmMembersFront_contacts_list extends GlmDataContacts
             'countyList' => $countyList,
             'haveCounties' => $haveCounties,
             'countySearch' => $countySearch,
+            'citySearch' => $citySearch,
             'haveFilter' => $haveFilter,
             'contactMembers' => $contactMembers,
             'alphaList' => $alphaList,