Updates on uptravel account import
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 4 Jun 2019 12:51:18 +0000 (08:51 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 4 Jun 2019 12:51:18 +0000 (08:51 -0400)
Need all accounts.

models/admin/management/billing.php
models/admin/management/importAccounts.php
views/admin/management/importAccounts.html

index 7066bd4..ffe12c1 100644 (file)
@@ -117,6 +117,7 @@ class GlmMembersAdmin_management_billing extends GlmDataBillingManagement
         $importResults       = false;
         $totalImports        = false;
         $numberProcessed     = false;
+        $totalMembers        = false;
 
         // echo '<pre>Config: ' . print_r( $this->config, true ) . '</pre>';
         // General settings are always stored in a record with ID=1.
@@ -273,6 +274,7 @@ class GlmMembersAdmin_management_billing extends GlmDataBillingManagement
             'totalImports'        => $totalImports,
             'numberProcessed'     => $numberProcessed,
             'start'               => ( isset( $start ) ? $start : false ),
+            'totalMembers'        => $totalMembers,
         );
 
         // Return status, suggested view, and data to controller
index 862eaeb..b9709d7 100644 (file)
@@ -134,7 +134,7 @@ LEFT OUTER JOIN members.member_account MA ON ( MA.member_id = M.member_id )
 LEFT OUTER JOIN members.payment_types PT ON ( MA.payment_type = PT.id )
  WHERE PT.name != ''
    AND PT.name IS NOT NULL
-   AND M.member_id IN ( SELECT DISTINCT member_id FROM members.billing where transaction_date >= '01/01/2018' )
+   -- AND M.member_id IN ( SELECT DISTINCT member_id FROM members.billing where transaction_date >= '01/01/2017' )
 ";
 
 // Get total number of members.
@@ -144,7 +144,6 @@ SELECT count(M.member_id) as total
 ";
 $totalStmt      = $dbh->query( $sql );
 $totalMembers   = $totalStmt->fetchColumn();
-$importResults .= 'Total Members: ' . $totalMembers . "<br>";
 
 // return false;
 
@@ -155,10 +154,9 @@ SELECT M.member_id,M.billing_contact,M.account_number,
        M.mailing_address,M.mailing_city_id,M.mailing_state_id,M.mailing_zip,
        M.street,M.city_id,M.state_id,M.zip,M.region
  $fromWhere
-ORDER BY M.member_id";
-
-//LIMIT 10
-//OFFSET $start";
+ORDER BY M.member_id
+LIMIT 10
+OFFSET $start";
 $stmt = $dbh->query( $sql );
 $members = $stmt->fetchAll();
 $numberMembers = count( $members );
@@ -169,9 +167,12 @@ $importResults .= 'Total Members this round: ' . count( $members ) . "<br>";
 
 if ( $start === 0 ) {
     // Clear the invoices,line_items and transactions
+    // $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts" );
     // $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices" );
     // $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "line_items" );
     // $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "transactions" );
+    // $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "payments" );
+    // $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_payments" );
 }
 
 $getState = $dbh->prepare(
@@ -205,7 +206,7 @@ function getCountyId( $wpdb, $county_name )
 
 foreach ( $members as $member ) {
 
-    $importResults .= '<pre>$member: ' . print_r( $member, true ) . '</pre>';
+    // $importResults .= '<pre>$member: ' . print_r( $member, true ) . '</pre>';
 
     // Get the new id of member (old_member_id).
     $newMemberId = $this->wpdb->get_var(
@@ -216,7 +217,7 @@ foreach ( $members as $member ) {
             $member['member_id']
         )
     );
-    $importResults .= '<pre>$newMemberId: ' . print_r( $newMemberId, true ) . '</pre>';
+    // $importResults .= '<pre>$newMemberId: ' . print_r( $newMemberId, true ) . '</pre>';
 
     if ( $newMemberId ) {
 
@@ -300,7 +301,7 @@ foreach ( $members as $member ) {
             '%s', // billing_county
         );
 
-        $importResults .= '<pre>$accountData: ' . print_r( $accountData, true ) . '</pre>';
+        // $importResults .= '<pre>$accountData: ' . print_r( $accountData, true ) . '</pre>';
 
         // Check if member has an account.
         $accountId = $this->wpdb->get_var(
@@ -311,7 +312,7 @@ foreach ( $members as $member ) {
                 $newMemberId
             )
         );
-        $importResults .= '<pre>$accountId: ' . print_r( $accountId, true ) . '</pre>';
+        // $importResults .= '<pre>$accountId: ' . print_r( $accountId, true ) . '</pre>';
 
         // If not create one.
         if ( !$accountId ) {
@@ -325,13 +326,13 @@ foreach ( $members as $member ) {
         } else {
 
             // Else update account.
-            $this->wpdb->update(
-                GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
-                $accountData,
-                array( 'id' => $accountId ),
-                $accountDataFormat,
-                array( '%d' )
-            );
+            // $this->wpdb->update(
+            //     GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
+            //     $accountData,
+            //     array( 'id' => $accountId ),
+            //     $accountDataFormat,
+            //     array( '%d' )
+            // );
 
         }
 
index 2f584b1..e0475c1 100644 (file)
     </form>
 {/if}
 
+Total Accounts: {$totalMembers} <br>
 Number processed: {$numberProcessed}
 
-{*
+{* auto load next *}
 {if $numberProcessed < $totalMembers}
 
 <script>
 jQuery(document).ready(function($){
 
-    //window.location.href = '{$thisUrl}?page={$thisPage}&glm_action=billing&option=createInvoices&option2=create&start={$numberProcessed}';
+    window.location.href = '{$thisUrl}?page={$thisPage}&glm_action=billing&option=importAccounts&option2=import&start={$numberProcessed}';
 
 });
 
 </script>
 {/if}
-*}
 
 {include file='admin/management/footer.html'}