From: Steve Sutton Date: Fri, 16 Mar 2018 17:16:46 +0000 (-0400) Subject: Adding filters for pending and overdue X-Git-Tag: v1.0.0^2~131 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=9bccabb25ac5c425cd83f6a85836c1ecd335b806;p=WP-Plugins%2Fglm-member-db-billing.git Adding filters for pending and overdue For the main index and invoice pages. --- diff --git a/models/admin/billing/index.php b/models/admin/billing/index.php index 5fef142..998756a 100644 --- a/models/admin/billing/index.php +++ b/models/admin/billing/index.php @@ -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 '
$templateData: ' . print_r( $templateData, true ) . '
'; diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index 39e5cb6..ee5e783 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -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 diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 4824be8..326d111 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -25,9 +25,16 @@ +
+ + Show Pending Only + Show Overdue Only + +
+