From: Steve Sutton Date: Fri, 22 Mar 2019 19:40:41 +0000 (-0400) Subject: Updating the billing import scripts for uptra X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=35da47c23f585faa264af8d2a92540b9e5515575;p=WP-Plugins%2Fglm-member-db-billing.git Updating the billing import scripts for uptra Also this includes the script for verifying the billing data. --- diff --git a/models/admin/management/billing.php b/models/admin/management/billing.php index 1bd76c3..12164f7 100644 --- a/models/admin/management/billing.php +++ b/models/admin/management/billing.php @@ -153,10 +153,10 @@ class GlmMembersAdmin_management_billing extends GlmDataBillingManagement $regSettings = $this->updateEntry( $id ); // Check if we were successful - if ($regSettings['status']) { + if ( $regSettings['status'] ) { $settingsUpdated = true; - $regSettings = $this->editEntry( $id ); + $regSettings = $this->editEntry( $id ); } else { $settingsUpdateError = true; @@ -191,7 +191,7 @@ class GlmMembersAdmin_management_billing extends GlmDataBillingManagement $option2 = ''; } switch ( $option2 ) { - case 'verify': + case 'import': require_once GLM_MEMBERS_BILLING_PLUGIN_PATH.'/models/admin/management/importBillingData.php'; // die('here'); break; diff --git a/models/admin/management/importBillingData.php b/models/admin/management/importBillingData.php index c433674..63f329b 100644 --- a/models/admin/management/importBillingData.php +++ b/models/admin/management/importBillingData.php @@ -5,6 +5,8 @@ // For billing support functions require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php'; $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); + +$limit = 10; // Connect to their live database. $dbh = new PDO( 'pgsql: host=ds5 dbname=uptravel user=postgres', @@ -15,10 +17,7 @@ $dbh = new PDO( ) ); -$dbh->setAttribute( - PDO::ATTR_ERRMODE, - PDO::ERRMODE_EXCEPTION -); +$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); if ( isset( $_REQUEST['start'] ) && $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT ) ) { } else { @@ -43,7 +42,7 @@ SELECT * FROM members.billing $sqlWhere ORDER BY transaction_date,transaction_time - LIMIT 10 + LIMIT $limit OFFSET $start"; $statsSql = "SELECT count(*) @@ -240,4 +239,4 @@ if ( $billingRecords ) { } } -$numberProcessed = $start + 10; +$numberProcessed = $start + $limit; diff --git a/models/admin/management/verifyBillingData.php b/models/admin/management/verifyBillingData.php index 75b180d..0a37d9e 100644 --- a/models/admin/management/verifyBillingData.php +++ b/models/admin/management/verifyBillingData.php @@ -15,10 +15,7 @@ $dbh = new PDO( ) ); -$dbh->setAttribute( - PDO::ATTR_ERRMODE, - PDO::ERRMODE_EXCEPTION -); +$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); if ( isset( $_REQUEST['start'] ) && $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT ) ) { } else { @@ -31,16 +28,26 @@ $importResults = ''; $query = " SELECT id,name FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE id in ( SELECT DISTINCT ref_dest - FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts ) + WHERE id in ( + SELECT DISTINCT ref_dest + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts ) + AND old_member_id IN ( 17484, 4799, 17035, 6040, 5442, 5434, 18660 ) LIMIT 20 OFFSET 0"; $results = $this->wpdb->get_results( $query, ARRAY_A ); -$importResults .= '
$results: ' . print_r( $results, true ) . '
'; +// $importResults .= '
$results: ' . print_r( $results, true ) . '
'; foreach ( $results as $row ) { - $account_id = $BillingSupport->getAccountByRefDest( $row['id'] ); - echo '
$account_id: ' . print_r( $account_id, true ) . '
'; + // Get balance due + $account = $BillingSupport->getAccountByRefDest( $row['id'] ); + if ( !$account ) { + $importResults .= '

No account

'; + } else { + $importResults .= '

Account: ' . $account['id'] . '

'; + } + $balanceDue = $BillingSupport->getBalanceDueByAccount( $account['id'] ); + $importResults .= '
$balanceDue: ' . print_r( $balanceDue, true ) . '
'; + // $importResults .= '
$account_id: ' . print_r( $account_id, true ) . '
'; }