Adding filters for pending and overdue
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 16 Mar 2018 17:16:46 +0000 (13:16 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 16 Mar 2018 17:16:46 +0000 (13:16 -0400)
For the main index and invoice pages.

models/admin/billing/index.php
models/admin/billing/invoices.php
views/admin/billing/invoices.html

index 5fef142..998756a 100644 (file)
@@ -125,6 +125,8 @@ class GlmMembersAdmin_billing_index extends GlmDataInvoices
         $haveInvoices       = false;
         $filterAccounts     = '';
         $totalInvoices      = false;
+        $filterPending      = false;
+        $filterOverdue      = false;
 
         // For lockedToMember
         $lockedToMember = false;
@@ -332,6 +334,13 @@ class GlmMembersAdmin_billing_index extends GlmDataInvoices
                 $where_params[] = "T.account =  $filterAccounts";
             }
 
+            if ( isset( $_REQUEST['filterPending'] ) ) {
+                $filterPending = filter_var( $_REQUEST['filterPending'], FILTER_VALIDATE_BOOLEAN );
+            }
+            if ( isset( $_REQUEST['filterOverdue'] ) ) {
+                $filterOverdue = filter_var( $_REQUEST['filterOverdue'], FILTER_VALIDATE_BOOLEAN );
+            }
+
             // Build the $where from $where_params array.
             // By imploding them with AND between each array element.
             $where = implode( ' AND ', $where_params );
@@ -402,6 +411,8 @@ class GlmMembersAdmin_billing_index extends GlmDataInvoices
             'accounts'           => $accounts,
             'filterAccounts'     => $filterAccounts,
             'totalInvoices'      => $totalInvoices,
+            'filterPending'      => $filterPending,
+            'filterOverdue'      => $filterOverdue,
         );
         // echo '<pre>$templateData: ' . print_r( $templateData, true ) . '</pre>';
 
index 39e5cb6..ee5e783 100644 (file)
@@ -127,6 +127,8 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
         $fromMemberMenu     = false;
         $filterAccounts     = '';
         $totalInvoices      = false;
+        $filterPending      = false;
+        $filterOverdue      = false;
 
         // Get any provided option
         if (isset($_REQUEST['option'])) {
@@ -410,6 +412,18 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
                 $where_params[] = "T.account =  $filterAccounts";
             }
 
+            if ( isset( $_REQUEST['filterPending'] ) ) {
+                $filterPending = filter_var( $_REQUEST['filterPending'], FILTER_VALIDATE_BOOLEAN );
+                $where_params[] = "T.paid <> true";
+                $where_params[] = "T.due_date > now()";
+            }
+            if ( isset( $_REQUEST['filterOverdue'] ) ) {
+                $filterOverdue = filter_var( $_REQUEST['filterOverdue'], FILTER_VALIDATE_BOOLEAN );
+                // $where_params[] = "T.due_date <= '" . date( 'Y-m-d' ) . "'";
+                $where_params[] = "T.paid <> true";
+                $where_params[] = "T.due_date < now()";
+            }
+
             // Build the $where from $where_params array.
             // By imploding them with AND between each array element.
             $where = implode( ' AND ', $where_params );
@@ -480,6 +494,8 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
             'fromMemberMenu'      => $fromMemberMenu,
             'filterAccounts'      => $filterAccounts,
             'totalInvoices'       => $totalInvoices,
+            'filterPending'       => $filterPending,
+            'filterOverdue'       => $filterOverdue,
         );
 
         // Return status, any suggested view, and any data to controller
index 4824be8..326d111 100644 (file)
                     <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts}">
                     <input id="account_name" name="searchName" value="" />
                 </span>
+            <br>
+                <span class="glm-nowrap">
+                    <input id="filterPending" name="filterPending" value="1" {if $filterPending}checked{/if} type="checkbox" /> Show Pending Only
+                    <input id="filterOverdue" name="filterOverdue" value="1" {if $filterOverdue}checked{/if} type="checkbox" /> Show Overdue Only
+                </span>
+            <br>
                 <span class="glm-nowrap">
                     <input type="submit" value="Submit">
                 </span>
+
             <p>
         </div>
         <br clear="all">