From 990dd2146202a63461f459dd49a5bd2594bb7d49 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 14 Mar 2019 16:21:37 -0400 Subject: [PATCH] Fix for the account data Need to format as string not number to check against the account_number as it is a text field. --- models/admin/ajax/billingAccount.php | 25 +++++++++++++++++++++ models/front/billing/renew.php | 6 ++++- views/front/billing/renew.html | 33 +++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/models/admin/ajax/billingAccount.php b/models/admin/ajax/billingAccount.php index d620844..988021a 100644 --- a/models/admin/ajax/billingAccount.php +++ b/models/admin/ajax/billingAccount.php @@ -126,6 +126,31 @@ class GlmMembersAdmin_ajax_billingAccount extends GlmDataAccounts ); } break; + case 'verifyAccountNumber': + if ( isset( $_REQUEST['account_number'] ) && $account_number = filter_var( $_REQUEST['account_number'], FILTER_SANITIZE_STRING ) ) { + $account = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT id,ref_dest + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + WHERE account_number = %s", + $account_number + ), + ARRAY_A + ); + trigger_error( print_r( $account, E_USER_NOTICE ) ); + if ( $account ) { + $return = array( + 'status' => true, + 'member_id' => $account['id'], + 'account_id' => $account['ref_dest'], + ); + } else { + $return = array( 'status' => false ); + } + } else { + $return = array( 'status' => false ); + } + break; } header( 'Content-type:application/json;charset=utf-8', true ); diff --git a/models/front/billing/renew.php b/models/front/billing/renew.php index 49e59ed..4478fc1 100644 --- a/models/front/billing/renew.php +++ b/models/front/billing/renew.php @@ -434,7 +434,11 @@ class GlmMembersFront_billing_renew // extends GlmDataBilling } // Get the list of invoices for this member. - $statements = $BillingSupport->getStatementsByRefDest( $this->memberID ); + $statements = $BillingSupport->getStatementsByRefDest( $this->memberID ); + $transactions = false; + $account_data = false; + $balance_due = false; + $hasBillingAccount = false; // echo '
$statements: ' . print_r( $statements, true ) . '
'; if ( $statements ) { $transactions = $statements['transactions']; diff --git a/views/front/billing/renew.html b/views/front/billing/renew.html index 1b80447..3f11428 100644 --- a/views/front/billing/renew.html +++ b/views/front/billing/renew.html @@ -13,8 +13,8 @@
- - + + {if $member_invoice} @@ -44,7 +44,7 @@ Member Billing #
- +
@@ -113,6 +113,33 @@ jQuery(document).ready(function($){ minimunFractionDigits: 2 }); + // verify the account number is correct. + $('#account_number').on( 'change', function(){ + $.ajax({ + cache: false, + url: '{$ajaxUrl}', + dataType: 'json', + type: 'POST', + data: { + 'action': 'glm_members_admin_ajax', + 'glm_action': 'billingAccount', + 'option': 'verifyAccountNumber', + 'account_number': $(this).val(), + } + }).done(function(msg){ + console.log( 'msg', msg ); + if ( msg.status === false ) { + alert( 'Not a valid Account #' ); + $('#account_number').val(''); + } else { + // Set the account and member inputs + $('#account_id').val( msg.account_id ); + $('#member_id').val( msg.member_id ); + } + }); + } ); + + // Generate the total for the renewal. function getPageTotal(){ -- 2.17.1