Commiting changes for billing.
working on some issues with uptra billing.
* @access public
* @return void
*/
- public function getStatementsByRefDest( $ref_dest )
+ public function getStatementsByRefDest( $ref_dest, $all = false )
{
$balance_due = (float)0.00;
$invoice = false;
switch ( $type ){
case $this->config['transaction_numb']['Invoice']:
$invoice = $this->getInvoiceById( $transaction['type_id'] );
- $line_items = $this->getLineItemsForInvoice( $transaction['type_id'] );
- $balance_due = $balance_due + $invoice['amount_total'];
- // add to the $transaction array
- $transaction['transaction_data'] = $invoice;
- $transaction['line_items'] = $line_items;
+ // echo '<pre>$invoice: ' . print_r( $invoice, true ) . '</pre>';
+ if ( !$all && $invoice['paid'] ) {
+ unset( $transactions[$key] );
+ continue;
+ } else {
+ $line_items = $this->getLineItemsForInvoice( $transaction['type_id'] );
+ $balance_due = $balance_due + $invoice['amount_total'];
+ // add to the $transaction array
+ $transaction['transaction_data'] = $invoice;
+ $transaction['line_items'] = $line_items;
+ }
break;
case $this->config['transaction_numb']['Payment']:
- $payment = $this->getPaymentById( $transaction['type_id'] );
- $balance_due = $balance_due - $payment['amount'];
- // add to the $transaction array
- $transaction['transaction_data'] = $payment;
+ if ( !$all ) {
+ unset( $transactions[$key] );
+ continue;
+ } else {
+ $payment = $this->getPaymentById( $transaction['type_id'] );
+ $balance_due = $balance_due - $payment['amount'];
+ // add to the $transaction array
+ $transaction['transaction_data'] = $payment;
+ }
break;
case $this->config['transaction_numb']['Adjustment']:
- $payment = $this->getPaymentById( $transaction['type_id'] );
- $balance_due = $balance_due - $payment['amount'];
- // add to the $transaction array
- $transaction['transaction_data'] = $payment;
+ if ( !$all ) {
+ unset( $transactions[$key] );
+ continue;
+ } else {
+ $payment = $this->getPaymentById( $transaction['type_id'] );
+ $balance_due = $balance_due - $payment['amount'];
+ // add to the $transaction array
+ $transaction['transaction_data'] = $payment;
+ }
break;
}
}
* @access public
* @return void
*/
- public function getTransactionsByAccount( $account )
+ public function getTransactionsByAccount( $account, $unpaid = false )
{
+ $where = ( $unpaid ) ? " AND " : '';
return $this->wpdb->get_results(
$this->wpdb->prepare(
"SELECT *
}
+ $notPaid = " ( paid <> true OR paid IS NULL ) AND balance != 0.00";
+
$wParts[] = " T.id IN (
SELECT account
FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
- WHERE paid <> true ) ";
- $wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
+ WHERE $notPaid ) ";
+ $wParts[] = " ( T.usmail_invoice = true OR T.fax_invoice = true ) ";
+ $wParts[] = " $notPaid ";
// $where used in all places.
$where = implode( ' AND ', $wParts );
+ // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
// Get all invoices
$invoiceData = $this->wpdb->get_results(
ARRAY_A
);
// echo '<pre>$invoiceData: ' . print_r( $invoiceData, true ) . '</pre>';
+ // exit;
foreach ( $invoiceData as $inv ) {
$fullInvoice = $BillingSupport->getFullInvoiceData( $inv['id'] );
if ( $fullInvoice ) {
$Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
// Not paid query
- $notPaid = "( paid <> true ) AND balance != 0.00";
+ $notPaid = "( paid <> true OR paid IS NULL ) AND balance != 0.00";
if ( isset( $_REQUEST['invoice_types'] ) ) {
$invoiceTypes = $_REQUEST['invoice_types'];
// $where used in all places.
$where = implode( ' AND ', $wParts );
- // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
// Check if Counties is enabled and fetch counties
if ( isset( $this->config['settings']['enable_counties'] ) && $this->config['settings']['enable_counties'] ) {
$orderBy = 'ref_name';
$Accounts->paymentTypes = true;
$Accounts->balanceDue = true;
+ // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
$accountsResult = $Accounts->getList( $where, $orderBy, true, 'id', $start, $limit );
$totalAccounts = $Accounts->getStats( $where );
$Accounts->paymentTypes = false;
$wParts[] = "T.id IN (
SELECT account
FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
- WHERE balance > 0 AND balance IS NOT NULL
+ WHERE balance > 0
+ AND balance IS NOT NULL
+ AND ( paid <> true OR paid IS NULL )
)";
$view = 'reports';
break;
}
}
if ( !in_array( $option, array( 'reportGenerator', 'noAccounts' ) ) ) {
+ echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
// Getting the account listings
$orderBy = 'member_name';
$Accounts->paymentTypes = true;
$errors = false;
$invoiceTypes = false;
$renewalFormSession = false;
+ $allStatements = false;
// For lockedToMember.
$lockedToMember = false;
case 'list':
$view = 'statements';
+ if ( isset( $_REQUEST['all'] ) && $all = filter_var( $_REQUEST['all'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $allStatements = true;
+ }
// echo '<pre>$test: ' . print_r( $test, true ) . '</pre>';
break;
}
// Get the list of invoices for this member.
- $statements = $BillingSupport->getStatementsByRefDest( $this->memberID );
+ $statements = $BillingSupport->getStatementsByRefDest( $this->memberID, $allStatements );
// echo '<pre>$statements: ' . print_r( $statements, true ) . '</pre>';
if ( $statements ) {
$transactions = $statements['transactions'];
<a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=account" class="">Billing Info</a>
</li>
<li>
- <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}" class="">All Statements</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&all=1" class="">All Statements</a>
</li>
{if ($account_status == 'Pending' || $account_status == 'Expired') && !apply_filters('glm-billing-account-has-renewal', true, $accountID )}
<li>