Add filter for the groups.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 23 Jun 2016 20:28:52 +0000 (16:28 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 23 Jun 2016 20:28:52 +0000 (16:28 -0400)
On the interest list view add a search filter for groups.
Using the multiselect plugin that chuck is using elsewhere.

models/admin/settings/leads.php
views/admin/settings/leads.html

index bac5237..5c2068e 100644 (file)
@@ -163,8 +163,20 @@ class GlmMembersAdmin_settings_leads extends GlmDataInterests
             $option2 = $_REQUEST['option2'];
         }
 
+        $groups = $groupData->getList();
+
         // Get a current list of interests
-        $interests = $this->getList();
+        $where = null;
+        if ( isset( $_REQUEST['filterGroups'] ) ) {
+            // For each selected category
+            foreach($_REQUEST['filterGroups'] as $c) {
+                $groups[$c]['selected'] = true;
+            }
+            $where = "group_id in (" . implode( ',', $_REQUEST['filterGroups'] ) . ")";
+        }
+        $order = "title";
+        $interests = $this->getList( $where, $order );
+
         //echo '<pre>$interests: ' . print_r($interests, true) . '</pre>';
 
         if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
@@ -184,7 +196,6 @@ class GlmMembersAdmin_settings_leads extends GlmDataInterests
             }
         }
 
-        $groups = $groupData->getList();
 
         if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
             glmMembersAdmin::addNotice( $groups, 'DataBlock', 'Interest Groups Data' );
index b84d14a..125611b 100644 (file)
@@ -5,6 +5,19 @@
     <a id="glm-groups-list" data-show-table="glm-table-groups" class="glm-settings-tab nav-tab">Groups</a>
 </h2>
 
+<form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
+    <input type="hidden" name="glm_action" value="leads">
+    <p class="right">
+        <b>Filter by Groups:</b>
+        <select id="filterGroups" name="filterGroups[]" multiple="multiple">
+            {foreach $groups as $group}
+            <option value="{$group.id}"{if $group.selected} selected{/if}>{$group.title}</option>
+            {/foreach}
+        </select>
+        <input type="submit" value="Submit" style="margin-right: 2em;">
+    </p>
+</form>
+
 <table id="glm-table-interests" class="glm-admin-table glm-settings-table{if $option2!=''} glm-hidden{/if}">
     <tr><td colspan="2">
         <!-- Add Interests Button and Dialog Box -->
             <thead>
                 <tr>
                     <th>Interest</th>
-                    <th>Used With</th>
                     <th>Groups</th>
                     <th>&nbsp;</th>
                 </tr>
                         <tr class="alternate">
                     {/if}
                             <td>
-                                <a class="editInterest" data-interestID="{$t.id}" data-refTypeID="{$t.ref_type.value}" data-interestUsesValue="{$t.uses_value.value}" data-group_id='{$t.group_id.value}'>{$t.title}</a>
-                            </td>
-                            <td id="editInterestRefType_{$t.id}">
-                                {$t.ref_type.title}
+                                <a class="editInterest" data-interestID="{$t.id}" data-group_id='{$t.group_id.value}'>{$t.title}</a>
                             </td>
                             <td id="editInterestGroups">
                                 {foreach $t.group_id.list as $group}
             
         });
 
+        /*
+         * For the multiple select
+         */
+        $('#filterGroups').multiselect();
+
     });
 </script>
 <table id="glm-table-groups" class="glm-admin-table glm-settings-table{if $option2!='group'} glm-hidden{/if}">