From: Steve Sutton Date: Tue, 20 Mar 2018 13:28:52 +0000 (-0400) Subject: Update the dash board back. X-Git-Tag: v1.0.0^2~116 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=7f49cac528bd5a4785fae7b434cc9ef3f363faab;p=WP-Plugins%2Fglm-member-db-billing.git Update the dash board back. Adding the search for invoices into the dashboard. --- diff --git a/models/admin/billing/index.php b/models/admin/billing/index.php index 553ae13..3d555cc 100644 --- a/models/admin/billing/index.php +++ b/models/admin/billing/index.php @@ -234,146 +234,26 @@ class GlmMembersAdmin_billing_index extends GlmDataInvoices break; case 'list': // // Get list of pending invoices ( not overdue ) - // $pendingWhere = 'T.paid <> true AND T.due_date > now()'; - // $start = 1; - // $pending = $this->getList( $pendingWhere, 'transaction_time', true, 'id', $start, $limit ); + $pendingWhere = 'T.paid <> true AND T.due_date > now()'; + $start = 1; + $pending = $this->getList( $pendingWhere, 'transaction_time', true, 'id', $start, $limit ); // /** // * $pending = array( start, limit, returned, last, list = array...) // */ - // $numberPending = ( isset( $pending['returned'] ) ? $pending['returned'] : 0 ); + $numberPending = ( isset( $pending['returned'] ) ? $pending['returned'] : 0 ); // // // Get the number of over due invoices - // $overDueWhere = 'T.paid <> true AND T.due_date < now()'; - // $start = 1; - // $overdue = $this->getList( $overDueWhere, 'transaction_time', true, 'id', $start, $limit ); - // if ( isset( $overdue['returned'] ) ) { - // $numberOverdue = $overdue['returned']; - // } - // - // break; - default: - - $view = 'invoices'; - // Need to get the accounts + $overDueWhere = 'T.paid <> true AND T.due_date < now()'; + $start = 1; + $overdue = $this->getList( $overDueWhere, 'transaction_time', true, 'id', $start, $limit ); + if ( isset( $overdue['returned'] ) ) { + $numberOverdue = $overdue['returned']; + } $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); $accounts = $Accounts->getSimpleAccountList(); + break; + default: - $where_params = array( 'true' ); - - // Check for paging - // if ( isset( $_REQUEST['pageSelect'] ) ) { - // $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect']; - // } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['pageSelect'] ) ) { - // unset( $_SESSION['search']['pageSelect'] ); - // } - // if ( isset( $_REQUEST['nextStart'] ) ) { - // $_SESSION['search']['nextStart'] = $_REQUEST['nextStart']; - // } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['nextStart'] ) ) { - // unset( $_SESSION['search']['nextStart'] ); - // } - // if ( isset( $_REQUEST['prevStart'] ) ) { - // $_SESSION['search']['prevStart'] = $_REQUEST['prevStart']; - // } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) { - // unset( $_SESSION['search']['prevStart'] ); - // } - - // Check if we're doing paging - if (isset($_REQUEST['pageSelect'])) { - // If request is for Next - if ($_REQUEST['pageSelect'][0] == 'N') { - $newStart = $_REQUEST['nextStart'] - 0; - - // Otherwise it must be Previous - } else { - $newStart = $_REQUEST['prevStart'] - 0; - } - - if ($newStart > 0) { - $start = $newStart; - } - } - - // if( isset($_SESSION['search']['pageSelect']) ){ - // // If request is for Next - // if ($_SESSION['search']['pageSelect'][0] == 'N') { - // $newStart = $_SESSION['search']['nextStart'] - 0; - // - // // Otherwise it must be Previous - // } else { - // $newStart = $_SESSION['search']['prevStart'] - 0; - // } - // if ($newStart > 0) { - // $start = $newStart; - // } - // } - - // Get any search parameters. - $reg_options = array( - 'options' => array( - 'regexp' => '%[0-9]{2}/[0-9]{2}/[0-9]{4}%' - ) - ); - if ( isset( $_REQUEST['fromDate'] ) - && $_REQUEST['fromDate'] - && $fromDate = filter_var( $_REQUEST['fromDate'], FILTER_VALIDATE_REGEXP, $reg_options ) - ) { - $from_date = date( 'Y-m-d', strtotime( $fromDate ) ); - $where_params[] = "T.due_date >= '$from_date'"; - } - if ( isset( $_REQUEST['toDate'] ) - && $_REQUEST['toDate'] - && $toDate = filter_var( $_REQUEST['toDate'], FILTER_VALIDATE_REGEXP, $reg_options ) - ) { - $to_date = date( 'Y-m-d', strtotime( $toDate ) ); - $where_params[] = "T.due_date <= '$to_date'"; - } - if ( isset( $_REQUEST['filterAccounts'] ) - && $filterAccounts = filter_var( $_REQUEST['filterAccounts'], FILTER_VALIDATE_INT ) - ) { - $accounts[$filterAccounts]['selected'] = true; - $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 ); - - // Get the list of invoices and determine number of invoices in list - $orderBy = 'due_date ASC, transaction_time DESC'; - $this->line_items_post = true; - $invoicesResult = $this->getList($where, $orderBy, true, 'id', $start, $limit); - // echo '
$invoicesResult: ' . print_r( $invoicesResult, true ) . '
'; - $totalInvoices = $this->getStats($where); - $this->line_items_post = false; - - // Get paging results - $numbDisplayed = $invoicesResult['returned']; - $lastDisplayed = $invoicesResult['last']; - if ($start == 1) { - $prevStart = false; - } else { - $prevStart = $start - $limit; - if ($start < 1) { - $start = 1; - } - } - if ($invoicesResult['returned'] == $limit) { - $nextStart = $start + $limit; - } - - // since we're doing paging, we have to break out just the invoices data - $invoices = $invoicesResult['list']; - if (count($invoices)>0) { - $haveInvoices = true; - } - unset($invoicesResult); break; diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index 5c88006..608ef61 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -410,6 +410,14 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices ) { $accounts[$filterAccounts]['selected'] = true; $where_params[] = "T.account = $filterAccounts"; + } else if ( isset( $_REQUEST['searchName'] ) + && $searchName = filter_var( $_REQUEST['searchName'], FILTER_SANITIZE_STRING ) + ) { + // $where_params[] = "T.ref_name like '%" . esc_sql( $searchName ) . "%'"; + $where_params[] = "T.account IN ( + SELECT id + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + WHERE ref_name like '%" . esc_sql( $searchName ) . "%')"; } if ( isset( $_REQUEST['filterPending'] ) ) { diff --git a/views/admin/billing/index.html b/views/admin/billing/index.html index 7a93c2b..3050d37 100644 --- a/views/admin/billing/index.html +++ b/views/admin/billing/index.html @@ -8,78 +8,149 @@ Create Invoice Make Payment - - - - +
+
Number of Over Due Invoices Listed: {if !$numberOverdue}0{else}{$numberOverdue}{/if}
+
+ + + + + + + + +
+

+ + From Date: + To Date: + + + Member Account:  + + + +
+ + Show Pending Only + Show Overdue Only + +
+ + + + +

+

+
-
+ + + + +
Number of Over Due Invoices Listed: {if !$numberOverdue}0{else}{$numberOverdue}{/if}
+ +
+ + + + + + + + + -
IDMember NameTimeDue DateBalanceView
- - - - - - - - - - - - - {if $numberOverdue > 0} - {assign var="i" value="0"} - {foreach $overdue.list as $t} - {if $i++ is odd by 1} - - {else} - - {/if} - - - - - - - - {/foreach} - {/if} - -
IDMember NameTimeDue DateBalanceView
{$t.id} {$t.member_name} {$t.transaction_time.datetime} {$t.due_date.date} {$t.balance} View
- -
Number of Pending Invoices Listed: {if !$numberPending}0{else}{$numberPending}{/if}
- - - - - - - - - - - - - {if $numberPending > 0} - {assign var="i" value="0"} - {foreach $pending.list as $t} - {if $i++ is odd by 1} - - {else} - - {/if} - - - - - - - - {/foreach} - {/if} - -
IDMember NameTimeDue DateBalanceView
{$t.id} {$t.member_name} {$t.transaction_time.datetime} {$t.due_date.date} {$t.balance} View
+ + + {if $numberOverdue > 0} + {assign var="i" value="0"} + {foreach $overdue.list as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + {$t.id} + {$t.member_name} + {$t.transaction_time.datetime} + {$t.due_date.date} + {$t.balance} + View + + {/foreach} + {/if} + + +
+
+ + +
Number of Pending Invoices Listed: {if !$numberPending}0{else}{$numberPending}{/if}
+ + + + + + + + + + + + + {if $numberPending > 0} + {assign var="i" value="0"} + {foreach $pending.list as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + + + {/foreach} + {/if} + +
IDMember NameTimeDue DateBalanceView
{$t.id} {$t.member_name} {$t.transaction_time.datetime} {$t.due_date.date} {$t.balance} View
+ + {include file='admin/footer.html'}