Adding counties and payment types to export filters.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 27 Aug 2019 14:37:39 +0000 (10:37 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 27 Aug 2019 14:37:39 +0000 (10:37 -0400)
So Uptra can export billing accounts per payment type.

models/admin/ajax/accountsListExport.php
models/admin/billing/accounts.php
models/admin/billing/index.php
views/admin/billing/exportBillingModal.html

index 7feaa44..ea8f84d 100644 (file)
@@ -132,6 +132,9 @@ class GlmMembersAdmin_ajax_accountsListExport extends GlmDataAccounts
             )
         );
 
+        if ( isset( $_REQUEST['invoice_types'] ) && $invoiceTypes = filter_var( $_REQUEST['invoice_types'], FILTER_VALIDATE_INT,array( 'flags' => FILTER_FORCE_ARRAY ) ) ) {
+            $where_params[] = "T.invoice_type IN (" . implode(',', $invoiceTypes) . ")";
+        }
         if ( isset( $_REQUEST['fromDate'] ) && $_REQUEST['fromDate']
             && $fromDate = filter_var( $_REQUEST['fromDate'], FILTER_VALIDATE_REGEXP, $reg_options )
         ) {
index 97d2808..49073b7 100644 (file)
@@ -128,6 +128,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
         $filterExpired      = false;
         $filterActive       = false;
         $searchName         = false;
+        $paymentTypes       = false;
+        $counties           = false;
 
         // Get any provided option
         if ( isset( $_REQUEST['option'] ) ) {
@@ -460,6 +462,14 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
 
         }
 
+        $counties = $this->wpdb->get_results(
+            "SELECT *
+               FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
+            ORDER BY name",
+            ARRAY_A
+        );
+        $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+        $paymentTypes = $BillingSupport->getAllInvoiceTypes();
 
         $templateData = array(
             'option'              => $option,
@@ -498,6 +508,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts
             'filterExpired'       => $filterExpired,
             'filterActive'        => $filterActive,
             'filterArchived'      => $filterArchived,
+            'paymentTypes'        => $paymentTypes,
+            'counties'            => $counties,
         );
 
         // Return status, any suggested view, and any data to controller
index 2ba6026..5d6a6ce 100644 (file)
@@ -132,6 +132,8 @@ class GlmMembersAdmin_billing_index extends GlmDataAccounts
         $filterActive       = false;
         $invoices           = false;
         $searchName         = false;
+        $paymentTypes       = false;
+        $counties           = false;
 
         // For lockedToMember
         $lockedToMember = false;
@@ -269,6 +271,15 @@ class GlmMembersAdmin_billing_index extends GlmDataAccounts
 
         }
 
+        $counties = $this->wpdb->get_results(
+            "SELECT *
+               FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
+            ORDER BY name",
+            ARRAY_A
+        );
+        $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+        $paymentTypes = $BillingSupport->getAllInvoiceTypes();
+
         // Compile template data
         $templateData = array(
             'accountID'          => $accountID,
@@ -305,7 +316,9 @@ class GlmMembersAdmin_billing_index extends GlmDataAccounts
             'filterActive'       => $filterActive,
             'filterArchived'     => $filterArchived,
             'searchName'         => $searchName,
-            'pluginAssetsUrl'    => GLM_MEMBERS_BILLING_PLUGIN_BASE_URL . '/assets/'
+            'pluginAssetsUrl'    => GLM_MEMBERS_BILLING_PLUGIN_BASE_URL . '/assets/',
+            'paymentTypes'        => $paymentTypes,
+            'counties'            => $counties,
         );
 
         // Return status, any suggested view, and any data to controller
index 19f4d35..e5f1f21 100644 (file)
@@ -3,6 +3,31 @@
         <input type="hidden" name="action" value="glm_members_admin_ajax">
         <input type="hidden" name="glm_action" value="accountsListExport">
         <table class="glm-admin-table unstriped">
+            <tr>
+                <th>Payment Types</th>
+                <td>
+                    <select multiple size="5" id="invoice_types" name="invoice_types[]">
+                        {foreach $paymentTypes as $paymentType}
+                            <option value="{$paymentType.id}"
+                                {if isset($smarty.request.invoice_types) && is_array( $smarty.request.invoice_types ) && in_array( $paymentType.id, $smarty.request.invoice_types )}
+                                    selected
+                                {/if}>{$paymentType.name}</option>
+                        {/foreach}
+                    </select>
+                </td>
+            </tr>
+            {if $counties}
+                <tr>
+                    <th>Counties</th>
+                    <td>
+                        <select multiple size="5" id="counties" name="counties[]">
+                            {foreach $counties as $county}
+                                <option value="{$county.id}"{if isset($smarty.request.counties) && in_array( $county.id, $smarty.request.counties )} selected{/if}>{$county.name}</option>
+                            {/foreach}
+                        </select>
+                    </td>
+                </tr>
+            {/if}
             <tr><th>Show Active: </th><td><input type="checkbox" name="filterActive" {if $filterActive}checked{/if}></td></tr>
             <tr><th>Show Pending: </th><td><input type="checkbox" name="filterPending" {if $filterPending}checked{/if}></td></tr>
             <tr><th>Show Overdue: </th><td><input type="checkbox" name="filterOverdue" {if $filterOverdue}checked{/if}></td></tr>