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 '<pre>$invoicesResult: ' . print_r( $invoicesResult, true ) . '</pre>';
- $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;
<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>
- <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>
+<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>
+</form>
- </td>
+<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>Member Name</th>
+ <th>Time</th>
+ <th>Due Date</th>
+ <th>Balance</th>
+ <th>View</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>Time</th>
- <th>Due Date</th>
- <th>Balance</th>
- <th>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> {$t.member_name} </td>
- <td> {$t.transaction_time.datetime} </td>
- <td> {$t.due_date.date} </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 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>Member Name</th>
- <th>Time</th>
- <th>Due Date</th>
- <th>Balance</th>
- <th>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> {$t.member_name} </td>
- <td> {$t.transaction_time.datetime} </td>
- <td> {$t.due_date.date} </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>
+ </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> {$t.member_name} </td>
+ <td> {$t.transaction_time.datetime} </td>
+ <td> {$t.due_date.date} </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>Member Name</th>
+ <th>Time</th>
+ <th>Due Date</th>
+ <th>Balance</th>
+ <th>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> {$t.member_name} </td>
+ <td> {$t.transaction_time.datetime} </td>
+ <td> {$t.due_date.date} </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>
+
+<script>
+ jQuery(document).ready(function($) {
+
+ // Date Input
+ $('.glm-date-input').datepicker({
+ dateFormat: 'mm/dd/yy'
+ });
+
+ var availableAccounts = [
+ {foreach $accounts as $m}
+ { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' },
+ {/foreach}
+ ]
+
+ $('#account_name').autocomplete({
+ source: availableAccounts,
+ select: function( event, ui ){
+ $('#member-account').val( ui.item.id );
+ },
+ });
+
+ {if $filterAccounts}
+ {$selected = 0}
+ {foreach $accounts as $m}
+ {if $m.id == $filterAccounts}
+ {$selected = $m.ref_name|unescape:'html'|replace:'"':''}
+ {/if}
+ {/foreach}
+ $('#account_name').autocomplete().val('{$selected}');
+ {/if}
+ });
+</script>
{include file='admin/footer.html'}