* @access public
*/
public $fields = false;
+ public $member_data = false;
/**
* Constructor
*/
public function entryPostProcessing($r, $a)
{
+ if ( $this->member_data ) {
+ $member_data = $this->wpdb->get_row(
+ $this->wpdb->prepare(
+ "SELECT A.ref_name,A.ref_dest
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "transactions I
+ LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts A ON ( I.account = A.id )
+ WHERE I.id = %d",
+ $r['id']
+ ),
+ ARRAY_A
+ );
+ if ( isset( $member_data ) && $member_data['ref_name'] ) {
+ $r['member_name'] = $member_data['ref_name'];
+ }
+ if ( isset( $member_data ) && $member_data['ref_dest'] ) {
+ $r['member_id'] = $member_data['ref_dest'];
+ }
+ }
+ if ( $this->notes ) {
+ if ( $r['type'] == $this->config['transaction_numb']['Invoice'] ) {
+ $r['notes'] = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT I.notes
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I
+ LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "transactions T ON ( I.id = T.type_id )
+ WHERE T.id = %d",
+ $r['id']
+ )
+ );
+ } else {
+ $r['notes'] = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT P.payment_method
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "payments P
+ LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "transactions T ON ( P.id = T.type_id )
+ WHERE T.id = %d",
+ $r['id']
+ )
+ );
+ }
+ }
return $r;
}
$paymentTypes = false;
$counties = false;
$accounts = false;
+ $invoices = false;
$paging = true;
$prevStart = false;
$nextStart = false;
$lastDisplayed = false;
$totalAccounts = false;
$option2 = false;
+ $transactions = false;
// Get any provided option
if ( isset( $_REQUEST['option'] ) ) {
// Do selected option
switch ($option) {
+ case 'accountsByAge':
+ $wParts[] = "T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE balance > 0.00
+ AND transaction_time + INTERVAL 60 DAY <= CURDATE()
+ )";
+ $view = 'reports';
+ break;
+
+ case 'closedAccounts':
+ $wParts[] = "T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE balance = 0.00
+ )";
+ $view = 'reports';
+ break;
+
+ case 'allAccounts':
+ $view = 'reports';
+ break;
+
+ case 'noAccounts':
+ break;
+
+ case 'reportGenerator':
+ // Check if Counties is enabled and fetch counties
+ if ( isset( $this->config['settings']['enable_counties'] ) && $this->config['settings']['enable_counties'] ) {
+ // Grab counties
+ $counties = $this->wpdb->get_results(
+ "SELECT *
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
+ ORDER BY name",
+ ARRAY_A
+ );
+ }
+
+ $paymentTypes = $BillingSupport->getAllInvoiceTypes();
+ break;
case 'openAccounts':
default:
// $where used in all places.
$where = implode( ' AND ', $wParts );
- // Check if Counties is enabled and fetch counties
- if ( isset( $this->config['settings']['enable_counties'] ) && $this->config['settings']['enable_counties'] ) {
- // Grab counties
- $counties = $this->wpdb->get_results(
- "SELECT *
- FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
- ORDER BY name",
- ARRAY_A
- );
- }
-
- $paymentTypes = $BillingSupport->getAllInvoiceTypes();
-
if (isset($_REQUEST['pageSelect'])) {
// If request is for Next
$start = $newStart;
}
}
- $orderBy = 'member_name';
- $Accounts->paymentTypes = true;
- $Accounts->balanceDue = true;
- $accountsResult = $Accounts->getList( $where, $orderBy, true, 'id', $start, $limit );
- $totalAccounts = $Accounts->getStats( $where );
- $Accounts->paymentTypes = false;
- $Accounts->balanceDue = false;
- // Get paging results
- $numbDisplayed = $accountsResult['returned'];
- $lastDisplayed = $accountsResult['last'];
- if ( $start == 1 ) {
- $prevStart = false;
+ if ( !in_array( $option, array( 'reportGenerator', 'noAccounts' ) ) ) {
+ // Getting the account listings
+ $orderBy = 'member_name';
+ $Accounts->paymentTypes = true;
+ $Accounts->balanceDue = true;
+ $accountsResult = $Accounts->getList( $where, $orderBy, true, 'id', $start, $limit );
+ $totalAccounts = $Accounts->getStats( $where );
+ $Accounts->paymentTypes = false;
+ $Accounts->balanceDue = false;
} else {
- $prevStart = $start - $limit;
- if ( $start < 1 ) {
- $start = 1;
+ switch ( $option ) {
+ case 'reportGenerator':
+ $orderBy = 'transaction_time';
+ $this->member_data = true;
+ $this->notes = true;
+ $accountsResult = $this->getList( $where, $orderBy, true, 'id', $start, $limit );
+ $totalAccounts = $this->getStats( $where );
+ $this->member_data = false;
+ $this->notes = false;
+ break;
+ case 'noAccounts':
+ break;
+ default:
+ break;
}
}
- if ( $accountsResult['returned'] == $limit ) {
- $nextStart = $start + $limit;
- }
- // since we're doing paging, we have to break out just the accounts data
- $accounts = $accountsResult['list'];
- // echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
- if ( count( $accounts ) > 0 ) {
- $haveAccounts = true;
- }
+ if ( !in_array( $option, array( 'reportGenerator', 'noAccounts' ) ) ) {
+ // Get paging results
+ $numbDisplayed = $accountsResult['returned'];
+ $lastDisplayed = $accountsResult['last'];
+ if ( $start == 1 ) {
+ $prevStart = false;
+ } else {
+ $prevStart = $start - $limit;
+ if ( $start < 1 ) {
+ $start = 1;
+ }
+ }
+ if ( $accountsResult['returned'] == $limit ) {
+ $nextStart = $start + $limit;
+ }
+ // since we're doing paging, we have to break out just the accounts data
+ $accounts = $accountsResult['list'];
+ // echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
+ if ( count( $accounts ) > 0 ) {
+ $haveAccounts = true;
+ }
+ } else {
+ switch ( $option ) {
+ case 'reportGenerator':
+ // Get paging results
+ $numbDisplayed = $accountsResult['returned'];
+ $lastDisplayed = $accountsResult['last'];
+ if ( $start == 1 ) {
+ $prevStart = false;
+ } else {
+ $prevStart = $start - $limit;
+ if ( $start < 1 ) {
+ $start = 1;
+ }
+ }
+
+ if ( $accountsResult['returned'] == $limit ) {
+ $nextStart = $start + $limit;
+ }
+
+ // since we're doing paging, we have to break out just the transactions data
+ $transactions = $accountsResult['list'];
+ // echo '<pre>$transactions: ' . print_r( $transactions, true ) . '</pre>';
+ if ( count( $transactions ) > 0 ) {
+ $haveAccounts = true;
+ }
+ break;
+ case 'noAccounts':
+ break;
+ default:
+ break;
+ }
+ }
$templateData = array(
+ 'tActionTypes' => $this->config['transaction_numb'],
'option' => $option,
'paymentTypes' => $paymentTypes,
'counties' => $counties,
'accounts' => $accounts,
+ 'transactions' => $transactions,
'paging' => $paging,
'prevStart' => $prevStart,
'nextStart' => $nextStart,
</div>
</div>
{/if}
+ {if $option == 'accountsByAge'}
+ <h3>over 60 days</h3>
+ {/if}
<br clear="all">
<br clear="all">
<p>Total found: {$totalAccounts}</p>
<input type="Submit" name="pageSelect" value="Next {$limit} Accounts" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
{/if}
<br clear="all">
- <div id="account-list">
- <table class="wp-list-table widefat fixed posts glm-admin-table">
- <thead>
- <tr>
- <th> Member Name </th>
- <th> Account Number </th>
- <th> Payment Type </th>
- <th> Balance Due </th>
- </tr>
- </thead>
- {foreach $accounts as $t}
- <tr>
- <td>
- <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.ref_dest}">
- {$t.member_name}
- </a>
- </td>
- <td> {$t.account_number} </td>
- <td> {$t.payment_type} </td>
- <td> {$t.balance_due|string_format:"%.2f"} </td>
- </tr>
- {/foreach}
- </table>
- </div>
+ {if isset( $accounts ) && !empty( $accounts )}
+ <div id="account-list">
+ <table class="wp-list-table widefat fixed posts glm-admin-table">
+ <thead>
+ <tr>
+ <th> Member Name </th>
+ <th> Account Number </th>
+ <th> Payment Type </th>
+ <th> Balance Due </th>
+ </tr>
+ </thead>
+ {foreach $accounts as $t}
+ <tr>
+ <td>
+ <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.ref_dest}">
+ {$t.member_name}
+ </a>
+ </td>
+ <td> {$t.account_number} </td>
+ <td> {$t.payment_type} </td>
+ <td> {$t.balance_due|string_format:"%.2f"} </td>
+ </tr>
+ {/foreach}
+ </table>
+ </div>
+ {/if}
+ {debug}
+ {if isset( $transactions ) && !empty( $transactions )}
+ <div id="invoice-list">
+ <table class="wp-list-table widefat fixed posts glm-admin-table">
+ <thead>
+ <tr>
+ <th> Transaction Time </th>
+ <th> Type </th>
+ <th> Member Name </th>
+ <th> Description </th>
+ <th> Amount </th>
+ </tr>
+ </thead>
+ {foreach $transactions as $t}
+ <tr>
+ <td> {$t.transaction_time.datetime} </td>
+ <td>
+ {if $t.type == $tActionTypes.Invoice}
+ Invoice
+ {else}
+ Payment
+ {/if}
+ </td>
+ <td>
+ <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.member_id}">
+ {$t.member_name}
+ </a>
+ </td>
+ <td> {$t.notes} </td>
+ <td>
+ {if $t.type == 10}
+ {$t.current_invoice_total|string_format:"%.2f"}
+ {else}
+ {$t.current_payment_total|string_format:"%.2f"}
+ {/if}
+ </td>
+ </tr>
+ {/foreach}
+ </table>
+ </div>
+ {/if}
{* Paging *}
{if $paging}
<input type="submit" name="pageSelect" value="Previous {$limit} Accounts" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>