Update filter to one for active
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 7 Aug 2018 17:05:25 +0000 (13:05 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 7 Aug 2018 17:05:25 +0000 (13:05 -0400)
Active will get all active memberships. Based on the setting for when to
expire past renewal date

models/admin/ajax/contactsListExport.php
views/admin/contacts/index.html

index fe1f90c..d87e15f 100644 (file)
@@ -141,14 +141,19 @@ class GlmMembersAdmin_ajax_contactsListExport extends GlmDataContacts
                 ) ";
             }
 
-        }
-
-
-        // echo '<pre>$BFSelect: ' . print_r( $BFSelect, true ) . '</pre>';
-        // echo '<pre>$BFHeaders: ' . print_r( $BFHeaders, true ) . '</pre>';
-        // exit;
+            // Check if there is an active only filter
+            if ( isset( $_REQUEST['active_only'] ) && $active_only = filter_var( $_REQUEST['active_only'], FILTER_VALIDATE_BOOLEAN ) ) {
+                $days_after_expired = $this->config['settings']['days_after_expired'];
+                $current_date       = date( 'Y-m-d' );
+                $where .= " AND T.ref_dest IN (
+                    SELECT DISTINCT(ref_dest)
+                      FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+                     WHERE renewal_date IS NOT NULL
+                       AND renewal_date + INTERVAL 1 YEAR + INTERVAL $days_after_expired DAY > '$current_date'
+                ) ";
+            }
 
-        // Only return information records that are active
+        }
 
         // Check if there is a member_type filter
         if ( isset( $_REQUEST['filterMemberTypes'] ) && $memberTypeFilter = filter_var( $_REQUEST['filterMemberTypes'], FILTER_VALIDATE_INT ) ) {
index f4b0940..589b6a2 100644 (file)
                 </tr>
                 {if apply_filters( 'glm-members-billing-enabled', false )}
                 <tr>
-                    <th>Only Billing Accounts: </th>
+                    <th>Billing Accounts: </th>
                     <td>
-                        <input type="checkbox" name="billing_only"><br>
+                        <input type="checkbox" name="active_only">Active Only ( Not Expired ) <br>
                     </td>
                 </tr>
                 {/if}