Now the dash board shows member accounts pending and overdue.
The search for the dashboard and billing are now in it's own template.
I added filter search for expired accounts.
public function modelAction($actionData = false)
{
- $option = 'list';
- $this->account_id = false;
- $haveAccounts = false;
- $invoiceUpdated = false;
- $invoiceUpdateError = false;
- $invoiceAdded = false;
- $invoiceAddError = false;
- $view = 'accounts';
- $fromDate = false;
- $toDate = false;
- $filterArchived = false;
- $filterPending = false;
- $filterFeatured = false;
- $invoiceDeleted = false;
- $invoiceDeleteError = false;
- $invoiceInsertError = false;
- $numbDisplayed = false;
- $lastDisplayed = false;
- $paging = true;
- $prevStart = false;
- $nextStart = false;
- $start = 1;
- $limit = 20; // Set to the number of listings per page
- $invTypes = array();
- $invoiceTypes = false;
- $invoiceTypeJSON = '';
- $accounts = false;
- $nonAccountMembers = false;
- $invoiceHtml = '';
- $fromDate = '';
- $toDate = '';
- $annFromDate = '';
- $annToDate = '';
- $totalAccounts = false;
- $allAccounts = false;
- $filterAccounts = false;
- $searchName = false;
+ $option = 'list';
+ $this->account_id = false;
+ $haveAccounts = false;
+ $invoiceUpdated = false;
+ $invoiceUpdateError = false;
+ $invoiceAdded = false;
+ $invoiceAddError = false;
+ $view = 'accounts';
+ $fromDate = false;
+ $toDate = false;
+ $filterArchived = false;
+ $filterFeatured = false;
+ $invoiceDeleted = false;
+ $invoiceDeleteError = false;
+ $invoiceInsertError = false;
+ $numbDisplayed = false;
+ $lastDisplayed = false;
+ $paging = true;
+ $prevStart = false;
+ $nextStart = false;
+ $start = 1;
+ $limit = 20; // Set to the number of listings per page
+ $invTypes = array();
+ $invoiceTypes = false;
+ $invoiceTypeJSON = '';
+ $accounts = false;
+ $nonAccountMembers = false;
+ $invoiceHtml = '';
+ $fromDate = '';
+ $toDate = '';
+ $annFromDate = '';
+ $annToDate = '';
+ $totalAccounts = false;
+ $allAccounts = false;
+ $filterAccounts = false;
+ $filterPending = false;
+ $filterOverdue = false;
+ $filterExpired = false;
+ $searchName = false;
// Get any provided option
if ( isset( $_REQUEST['option'] ) ) {
$to_date = date( 'Y-m-d', strtotime( $toDate ) );
$where_params[] = "T.renewal_date <= '$to_date'";
}
- if ( isset( $_REQUEST['annFromDate'] ) && $_REQUEST['annFromDate']
- && $annFromDate = filter_var( $_REQUEST['annFromDate'], FILTER_VALIDATE_REGEXP, $reg_options )
- ) {
- $annFrom_date = date( 'Y-m-d', strtotime( $annFromDate ) );
- $where_params[] = "T.anniversary_date >= '$annFrom_date'";
- }
- if ( isset( $_REQUEST['annToDate'] ) && $_REQUEST['annToDate']
- && $annToDate = filter_var( $_REQUEST['annToDate'], FILTER_VALIDATE_REGEXP, $reg_options )
- ) {
- $annTo_date = date( 'Y-m-d', strtotime( $annToDate ) );
- $where_params[] = "T.anniversary_date <= '$annTo_date'";
- }
if ( isset( $_REQUEST['filterAccounts'] )
&& $filterAccounts = filter_var( $_REQUEST['filterAccounts'], FILTER_VALIDATE_INT )
) {
$where_params[] = "T.ref_name like '%" . esc_sql( $searchName ) . "%'";
}
+ if ( isset( $_REQUEST['filterPending'] ) ) {
+ $filterPending = filter_var( $_REQUEST['filterPending'], FILTER_VALIDATE_BOOLEAN );
+ $where_params[] = "renewal_date >= now()";
+ }
+ if ( isset( $_REQUEST['filterOverdue'] ) ) {
+ $filterOverdue = filter_var( $_REQUEST['filterOverdue'], FILTER_VALIDATE_BOOLEAN );
+ $expiredDate = date( 'Y-m-d', mktime( 0, 0, 0, date( 'n' ), date( 'j' ) - 30, date( 'Y' )) );
+ $where_params[] = "renewal_date < now()";
+ $where_params[] = "renewal_date >= '$expiredDate'";
+ }
+ if ( isset( $_REQUEST['filterExpired'] ) ) {
+ $filterExpired = filter_var( $_REQUEST['filterExpired'], FILTER_VALIDATE_BOOLEAN );
+ $expiredDate = date( 'Y-m-d', mktime( 0, 0, 0, date( 'n' ), date( 'j' ) - 30, date( 'Y' )) );
+ $where_params[] = "renewal_date < '$expiredDate'";
+ }
+
// Build the $where string from the $where_parts array.
// By implode with AND.
$where = implode( ' AND ', $where_params );
// Get the list of accounts and determine number of accounts in list
- $orderBy = 'ref_name';
+ $orderBy = 'renewal_date ASC';
$accountsResult = $this->getList( $where, $orderBy, true, 'id', $start, $limit );
$totalAccounts = $this->getStats( $where );
'totalAccounts' => $totalAccounts,
'allAccounts' => $allAccounts,
'filterAccounts' => $filterAccounts,
+ 'filterPending' => $filterPending,
+ 'filterOverdue' => $filterOverdue,
'searchName' => $searchName,
+ 'filterExpired' => $filterExpired,
);
// Return status, any suggested view, and any data to controller
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataInvoices.php';
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php';
-class GlmMembersAdmin_billing_index extends GlmDataInvoices
+class GlmMembersAdmin_billing_index extends GlmDataAccounts
{
/**
$totalInvoices = false;
$filterPending = false;
$filterOverdue = false;
+ $filterExpired = false;
$invoices = false;
// For lockedToMember
}
switch ( $option ) {
- case 'account':
- require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php';
- $Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
-
- // Check to see if we're adding an account or editing one.
- if ( isset( $_REQUEST['ref_name'] ) ) {
- $_REQUEST['anniversary_date'] = date('Y-m-d', strtotime($_REQUEST['anniversary_date']));
- // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
- // if there's no id then add account
- if ( !isset( $_REQUEST['id'] ) ) {
- $account = $Accounts->insertEntry();
- if ( !$account['status'] ) {
- $accountInsertError = true;
- } else {
- $accountAdded = true;
- }
- } else {
- $account = $Accounts->updateEntry( $_REQUEST['id'] );
- if ( !$account['status'] ) {
- $accountUpdateError = true;
- } else {
- $accountUpdated = true;
- }
- }
- }
-
- // Need to see if there's an account for this member.
- $accountID = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT id
- FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
- WHERE ref_dest = %d",
- $this->memberID
- )
- );
- if ( !$account ) {
- if ( $accountID ) {
- $account = $Accounts->editEntry( $accountID );
- $haveAccount = true;
- } else {
- $accountID = 0;
- $account = $Accounts->newEntry();
- // Set the ref_name from memberData
- $account['fieldData']['ref_name'] = $memberData['name'];
- $haveAccount = false;
- }
- } else {
- $haveAccount = true;
- // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
- }
-
- // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
- $view = 'editAccount';
- break;
+ // case 'account':
+ // require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php';
+ // $Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
+ //
+ // // Check to see if we're adding an account or editing one.
+ // if ( isset( $_REQUEST['ref_name'] ) ) {
+ // $_REQUEST['anniversary_date'] = date('Y-m-d', strtotime($_REQUEST['anniversary_date']));
+ // // if there's no id then add account
+ // if ( !isset( $_REQUEST['id'] ) ) {
+ // $account = $Accounts->insertEntry();
+ // if ( !$account['status'] ) {
+ // $accountInsertError = true;
+ // } else {
+ // $accountAdded = true;
+ // }
+ // } else {
+ // $account = $Accounts->updateEntry( $_REQUEST['id'] );
+ // if ( !$account['status'] ) {
+ // $accountUpdateError = true;
+ // } else {
+ // $accountUpdated = true;
+ // }
+ // }
+ // }
+ //
+ // // Need to see if there's an account for this member.
+ // $accountID = $this->wpdb->get_var(
+ // $this->wpdb->prepare(
+ // "SELECT id
+ // FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+ // WHERE ref_dest = %d",
+ // $this->memberID
+ // )
+ // );
+ // if ( !$account ) {
+ // if ( $accountID ) {
+ // $account = $Accounts->editEntry( $accountID );
+ // $haveAccount = true;
+ // } else {
+ // $accountID = 0;
+ // $account = $Accounts->newEntry();
+ // // Set the ref_name from memberData
+ // $account['fieldData']['ref_name'] = $memberData['name'];
+ // $haveAccount = false;
+ // }
+ // } else {
+ // $haveAccount = true;
+ // // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+ // }
+ //
+ // // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+ // $view = 'editAccount';
+ // break;
case 'list':
- $orderBy = 'due_date ASC, transaction_time DESC';
- // // Get list of pending invoices ( not overdue )
- $pendingWhere = 'T.paid <> true AND T.due_date > now()';
+ // Dash board list should be getting list of members Accounts. (based on renewal_date)
+ // Expired
+ // Pass Due
+ // Pending
+ // Active
+ // Get list of pending invoices ( not overdue )
+ $orderBy = 'renewal_date ASC';
+ $pendingWhere = "renewal_date >= now()";
$start = 1;
- $this->line_items_post = true;
$pending = $this->getList( $pendingWhere, $orderBy, true, 'id', $start, $limit );
- $this->line_items_post = false;
- // /**
- // * $pending = array( start, limit, returned, last, list = array...)
- // */
+ // echo '<pre>$pending: ' . print_r( $pending, true ) . '</pre>';
$numberPending = ( isset( $pending['returned'] ) ? $pending['returned'] : 0 );
- //
- // // Get the number of over due invoices
- $overDueWhere = 'T.paid <> true AND T.due_date < now()';
+
+ // Get the number of over due invoices
+ $overDueWhere = "renewal_date < now()";
$start = 1;
- $this->line_items_post = true;
$overdue = $this->getList( $overDueWhere, $orderBy, true, 'id', $start, $limit );
- $this->line_items_post = false;
if ( isset( $overdue['returned'] ) ) {
$numberOverdue = $overdue['returned'];
}
+
+ // Get list of accounts for autocomplete
$Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
$accounts = $Accounts->getSimpleAccountList();
- break;
- default:
+ $dashboards = array(
+ 'Pending Accounts' => array(
+ 'number' => $numberPending,
+ 'data' => $pending,
+ ),
+ 'Overdue Accounts' => array(
+ 'number' => $numberOverdue,
+ 'data' => $overdue,
+ )
+ );
break;
+ default:
+ break;
}
$templateData = array(
'accountID' => $accountID,
'option' => $option,
- 'fromMemberMenu' => ( defined('GLM_MEMBERS_BILLING_MEMBER_MENU' ) ? true: false ),
+ 'fromMemberMenu' => ( defined( 'GLM_MEMBERS_BILLING_MEMBER_MENU' ) ? true: false ),
'lockedToMember' => $lockedToMember,
- 'numberPending' => $numberPending,
- 'pending' => $pending,
- 'numberOverdue' => $numberOverdue,
- 'overdue' => $overdue,
+ 'dashboards' => $dashboards,
'memberID' => $this->memberID,
'haveMember' => $haveMember,
'haveAccount' => $haveAccount,
'totalInvoices' => $totalInvoices,
'filterPending' => $filterPending,
'filterOverdue' => $filterOverdue,
+ 'filterExpired' => $filterExpired,
);
// echo '<pre>$templateData: ' . print_r( $templateData, true ) . '</pre>';
--- /dev/null
+<form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
+ <input type="hidden" name="glm_action" value="accounts">
+ <input type="hidden" name="option" value="list">
+
+ <input type="hidden" name="searched" value="1">
+ <input type="hidden" name="prevStart" value="{$prevStart}">
+ <input type="hidden" name="nextStart" value="{$nextStart}">
+ <input type="hidden" name="limit" value="{$limit}">
+
+ <div class="">
+ <span class="glm-nowrap">
+ <b>From Date: </b><input type="text" name="fromDate" value="{$fromDate}" class="glm-form-text-input-short glm-date-input">
+ <b>To Date: </b><input type="text" name="toDate" value="{$toDate}" class="glm-form-text-input-short glm-date-input">
+ </span>
+ <span class="glm-nowrap">
+ <b>Member Account: </b>
+ <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts}">
+ <input id="account_name" name="searchName" value="{if $searchName}{$searchName}{/if}" />
+ </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
+ <input id="filterExpired" name="filterExpired" value="1" {if $filterExpired}checked{/if} type="checkbox" /> Show Expired Only
+ </span>
+ <br>
+ <span class="glm-nowrap">
+ <input type="submit" value="Submit">
+ </span>
+ </div>
<h2>Accounts</h2>
-<form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
- <input type="hidden" name="glm_action" value="accounts">
- <input type="hidden" name="option" value="list">
-
- <input type="hidden" name="searched" value="1">
- <input type="hidden" name="prevStart" value="{$prevStart}">
- <input type="hidden" name="nextStart" value="{$nextStart}">
- <input type="hidden" name="limit" value="{$limit}">
-
- <div class="">
- <h3>Search Renewal date</h3>
- <span class="glm-nowrap">
- <b>From Date: </b><input type="text" name="fromDate" value="{$fromDate}" class="glm-form-text-input-short glm-date-input">
- <b>To Date: </b><input type="text" name="toDate" value="{$toDate}" class="glm-form-text-input-short glm-date-input">
- </span>
- <br>
- <h3>Search Anniversary date</h3>
- <span class="glm-nowrap">
- <b>From Date: </b><input type="text" name="annFromDate" value="{$annFromDate}" class="glm-form-text-input-short glm-date-input">
- <b>To Date: </b><input type="text" name="annToDate" value="{$annToDate}" class="glm-form-text-input-short glm-date-input">
- </span>
- <br>
- <span class="glm-nowrap">
- <b>Member Account: </b>
- <input id="member-account" type="hidden" name="filterAccounts" value="{$filterAccounts}">
- <input id="account_name" name="searchName" value="{if $searchName}{$searchName}{/if}" />
- </span>
- <br>
- <span class="glm-nowrap">
- <input type="submit" value="Submit">
- </span>
- </div>
+ {include file='admin/billing/accountSearchForm.html'}
<br clear="all">
<p>Total found: {$totalAccounts}</p>
<a class="button glm-right button-primary" href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices&option=add">Create Invoice</a>
<a class="button glm-right button-primary" href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=payments&option=add">Make Payment</a>
-<form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
- <input type="hidden" name="glm_action" value="invoices">
- <input type="hidden" name="option" value="list">
-
- <input type="hidden" name="searched" value="1">
- <input type="hidden" name="prevStart" value="{$prevStart}">
- <input type="hidden" name="nextStart" value="{$nextStart}">
- <input type="hidden" name="limit" value="{$limit}">
-
- <div class="">
- <p>
- <span class="glm-nowrap">
- <b>From Date: </b><input type="text" name="fromDate" value="{$fromDate}" class="glm-form-text-input-short glm-date-input">
- <b>To Date: </b><input type="text" name="toDate" value="{$toDate}" class="glm-form-text-input-short glm-date-input">
- </span>
- <span class="glm-nowrap">
- <b>Member Account: </b>
- <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>
+ {include file='admin/billing/accountSearchForm.html'}
</form>
-<br clear="all">
-<table class="glm-admin-table">
- <tr><th>Number of Over Due Invoices Listed: </th><td align="left"> {if !$numberOverdue}0{else}{$numberOverdue}{/if} </td></tr>
- <tr>
- <td>
-
- </td>
- </tr>
-</table>
-<table class="wp-list-table widefat fixed posts glm-admin-table">
- <thead>
- <tr>
- <th style="width: 50px;">ID</th>
- <th style="width: 150px;">Member Name</th>
- <th>Invoice For</th>
- <th style="width: 150px;">Time</th>
- <th style="width: 70px;">Due Date</th>
- <th style="width: 100px;">Amount Total</th>
- <th style="width: 70px;">Balance</th>
- <th style="width: 50px;">View</th>
- </tr>
- </thead>
- <tbody>
- {if $numberOverdue > 0}
- {assign var="i" value="0"}
- {foreach $overdue.list as $t}
- {if $i++ is odd by 1}
- <tr>
- {else}
- <tr class="alternate">
- {/if}
- <td> {$t.id} </td>
- <td> <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.member_id}">{$t.member_name}</a> </td>
- <td>
- {foreach $t.line_items as $item}
- {$item.name} {if $item.recurring && $item.recurrence_string}( {$item.recurrence_string} ){/if}
- {/foreach}
- </td>
- <td> {$t.transaction_time.datetime} </td>
- <td> {$t.due_date.date} </td>
- <td> {$t.amount_total} </td>
- <td> {$t.balance} </td>
- <td> <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices&option=view&id={$t.id}">View</a> </td>
- </tr>
- {/foreach}
- {/if}
- </tbody>
-</table>
-<br clear="all">
-<br clear="all">
-<table class="glm-admin-table">
- <tr><th>Number of Pending Invoices Listed: </th><td align="left"> {if !$numberPending}0{else}{$numberPending}{/if} </td></tr>
-</table>
-<table class="wp-list-table widefat fixed posts glm-admin-table">
- <thead>
- <tr>
- <th style="width: 50px;">ID</th>
- <th style="width: 150px;">Member Name</th>
- <th>Invoice For</th>
- <th style="width: 150px;">Time</th>
- <th style="width: 70px;">Due Date</th>
- <th style="width: 100px;">Amount Total</th>
- <th style="width: 70px;">Balance</th>
- <th style="width: 50px;">View</th>
- </tr>
- </thead>
- <tbody>
- {if $numberPending > 0}
- {assign var="i" value="0"}
- {foreach $pending.list as $t}
- {if $i++ is odd by 1}
- <tr>
- {else}
- <tr class="alternate">
- {/if}
- <td> {$t.id} </td>
- <td> <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.member_id}">{$t.member_name}</a> </td>
- <td>
- {foreach $t.line_items as $item}
- {$item.name} {if $item.recurring && $item.recurrence_string}( {$item.recurrence_string} ){/if}
- {/foreach}
- </td>
- <td> {$t.transaction_time.datetime} </td>
- <td> {$t.due_date.date} </td>
- <td> {$t.amount_total} </td>
- <td> {$t.balance} </td>
- <td> <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoices&option=view&id={$t.id}">View</a> </td>
- </tr>
- {/foreach}
- {/if}
- </tbody>
-</table>
+{foreach $dashboards as $dashboard_title => $list}
+ <br clear="all">
+ <table class="glm-admin-table">
+ <tr><th colspan="2">{$dashboard_title}</th></tr>
+ </table>
+ <table class="wp-list-table widefat fixed posts glm-admin-table">
+ <thead>
+ <tr>
+ <th style="width: 50px;">ID</th>
+ <th>Member Name</th>
+ <th>Billing Email</th>
+ <th>Anniversary Date</th>
+ <th>Renewal Date</th>
+ </tr>
+ </thead>
+ <tbody>
+ {if $list.number > 0}
+ {assign var="i" value="0"}
+ {foreach $list.data.list as $t}
+ {if $i++ is odd by 1}
+ <tr>
+ {else}
+ <tr class="alternate">
+ {/if}
+ <td> {$t.id} </td>
+ <td> <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.ref_dest.value}">{$t.ref_name}</a> </td>
+ <td> {$t.email} </td>
+ <td> {$t.anniversary_date.date} </td>
+ <td> {$t.renewal_date.date} </td>
+ </tr>
+ {/foreach}
+ {/if}
+ </tbody>
+ </table>
+ <br clear="all">
+{/foreach}
<script>
jQuery(document).ready(function($) {