Updating the brewakers import scripts.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Apr 2017 18:11:37 +0000 (14:11 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Apr 2017 18:11:37 +0000 (14:11 -0400)
Wrapping up the import scripts for files and the images.
Fix for one of the custom field types. When the boolean field is pulled
it's t or f have to translate that to Yes and No.

models/admin/management/import.php
models/admin/management/import/brewbakersFiles.php [new file with mode: 0644]
models/admin/management/import/brewbakersImages.php [new file with mode: 0644]
models/admin/management/import/brewbakersImport.php
views/admin/management/import.html
views/admin/management/import/brewbakers.html [new file with mode: 0644]
views/admin/management/import/brewbakersFiles.html [new file with mode: 0644]
views/admin/management/import/brewbakersImages.html [new file with mode: 0644]
views/admin/member/memberInfo.html

index 473db85..e066a20 100644 (file)
@@ -146,6 +146,14 @@ class GlmMembersAdmin_management_import
                 require GLM_MEMBERS_PLUGIN_PATH.'/models/admin/management/import/memberImages.php';
                 break;
 
+            case 'brewbakersImages':
+                require GLM_MEMBERS_PLUGIN_PATH.'/models/admin/management/import/brewbakersImages.php';
+                break;
+
+            case 'brewbakersFiles':
+                require GLM_MEMBERS_PLUGIN_PATH.'/models/admin/management/import/brewbakersFiles.php';
+                break;
+
             case 'importOldMemberIds':
                 require GLM_MEMBERS_PLUGIN_PATH.'/models/admin/management/import/oldMemberIds.php';
                 break;
@@ -156,7 +164,6 @@ class GlmMembersAdmin_management_import
 
             case 'importBrewbakers':
                 require GLM_MEMBERS_PLUGIN_PATH.'/models/admin/management/import/brewbakersImport.php';
-                exit;
                 break;
 
             default:
diff --git a/models/admin/management/import/brewbakersFiles.php b/models/admin/management/import/brewbakersFiles.php
new file mode 100644 (file)
index 0000000..a6c28c6
--- /dev/null
@@ -0,0 +1,180 @@
+<?php
+/**
+ * Import Brewbakers Files
+ * Will have to do these 10 to 20 at a time.
+ */
+
+$failure = false;
+// Setup the database connection to postgres
+$dbServer    = 'localhost';
+$dbName      = 'brewbakers';
+$dbUser      = 'postgres';
+$resetdb     = true;
+$start       = ( isset( $_REQUEST['start'] ) ) ? filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT ): 0;
+$limit       = ( $start === 0 ) ? 20 : 100;
+$totalFiles = 0;
+
+$connString = "host=$dbServer dbname=$dbName user=$dbUser";
+$db = @pg_connect( $connString );
+
+require_once GLM_MEMBERS_PLUGIN_PATH.'/models/admin/ajax/fileUpload.php';
+$FileUpload = new GlmMembersAdmin_ajax_fileUpload($this->wpdb, $this->config);
+
+$refType = $this->config['ref_type_numb']['MemberInfo'];
+$refTable = $this->config['ref_type_table'][$refType];
+
+$fileBaseURL   = 'http://www.brewbakers.com/uploads/homes_files/';
+
+
+// Read in all member files for Homes and RV's
+$file = array();
+$numbFilesFound = 0;
+if (!$failure && $start === 0) {
+    // Grab the files for homes
+    $sql = "
+    SELECT *
+      FROM homes_files
+     ORDER BY homes_id";
+    $res = pg_query($db, $sql);
+    $rows = pg_num_rows($res);
+    if ($rows == 0) {
+        $templateData['genError']  = 'There does not appear to be any member files listed in this database!';
+        $failure = true;
+    } else {
+        $tmp = pg_fetch_all($res);
+        if (count($tmp) != $rows) {
+            $notice = pg_last_notice($res);
+            $templateData['genError']  = 'While reading member photo data, we did not receive the expected number of member files! ';
+            if ($notice) {
+                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+            }
+            $failure = true;
+        } else {
+
+            // Reprocess into array grouped by member with the main index the member ID
+            foreach ($tmp as $x) {
+
+                // If member entry hasn't been created yet, add it now
+                if (!isset($file['homes'][$x['homes_id']])) {
+                    $file['homes'][$x['homes_id']] = array(
+                        'homes_id' => $x['homes_id'],
+                        'files' => array()
+                    );
+                }
+
+                $file['homes'][$x['homes_id']]['files'][] = $x;
+                $numbFilesFound++;
+            }
+            //echo '<pre>$file: ' . print_r( $file, true ) . '</pre>';
+        }
+    }
+}
+if (!$failure) {
+    // Get total count
+    $sql = "
+    SELECT count(*) as total
+      FROM rvs_files";
+    $res = pg_query($db, $sql);
+    $totalFiles = pg_fetch_result( $res, 0, 'total');
+
+    // Grab the files for rvs
+    $sql = "
+    SELECT *
+      FROM rvs_files
+     ORDER BY rvs_id";
+    $sql .= " LIMIT $limit OFFSET $start";
+    $res = pg_query($db, $sql);
+    $rows = pg_num_rows($res);
+    if ($rows == 0) {
+        $templateData['genError']  = 'There does not appear to be any member files listed in this database!';
+        $failure = true;
+    } else {
+        $tmp = pg_fetch_all($res);
+        if (count($tmp) != $rows) {
+            $notice = pg_last_notice($res);
+            $templateData['genError']  = 'While reading member photo data, we did not receive the expected number of member files! ';
+            if ($notice) {
+                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+            }
+            $failure = true;
+        } else {
+
+            // Reprocess into array grouped by member with the main index the member ID
+            foreach ($tmp as $x) {
+
+                // If member entry hasn't been created yet, add it now
+                if (!isset($file['rvs'][$x['rvs_id']])) {
+                    $file['rvs'][$x['rvs_id']] = array(
+                        'rvs_id' => $x['rvs_id'],
+                        'files' => array()
+                    );
+                }
+
+                $file['rvs'][$x['rvs_id']]['files'][] = $x;
+                $numbFilesFound++;
+            }
+            //echo '<pre>$file: ' . print_r( $file, true ) . '</pre>';
+        }
+    }
+}
+//echo '<pre>$file: ' . print_r( $file, true ) . '</pre>';
+//exit;
+function getMemberInfoIdFromOldMemberId( $wpdb, $oldMemberId )
+{
+    return $wpdb->get_var(
+        $wpdb->prepare(
+            "SELECT id
+               FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info
+              WHERE member IN (
+                    SELECT id
+                      FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
+                     WHERE old_member_id = %d)",
+            $oldMemberId
+        )
+    );
+}
+//echo '<pre>$file: ' . print_r( $file, true ) . '</pre>';
+//exit;
+// Reset member files data tables if needed
+if ( !$failure && $resetdb && $start === 0 ) {
+    // Reset the data
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."files" );
+
+    // Delete Files
+    foreach( new RecursiveIteratorIterator(
+
+        new RecursiveDirectoryIterator( GLM_MEMBERS_PLUGIN_FILES_PATH, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS ),
+        RecursiveIteratorIterator::CHILD_FIRST ) as $value ) {
+            if ($value->isFile()) {
+                unlink( $value );
+            }
+        }
+}
+// If we have file URLs
+if ($file != false) {
+
+    // For each member
+    foreach ($file as $memType) {
+        foreach ($memType as $oldMemberId => $m) {
+
+            $newMemberId = getMemberInfoIdFromOldMemberId( $this->wpdb, $oldMemberId);
+
+            // For each file in this member's gallery
+            if ($m['files']) {
+                foreach ($m['files'] as $i) {
+                    $fileURL = $fileBaseURL.$i['name_on_disk'];
+                    $res = $FileUpload->storeFile ($fileURL, $refType, $refTable, $newMemberId, $i['original_name']);
+                }
+            }
+
+        }
+    }
+
+}
+
+$templateData['newStart']       = $start + $limit;
+$templateData['start']          = $start;
+$templateData['total']          = $totalFiles;
+$templateData['numbFilesFound'] = $numbFilesFound;
+
+$requestedView = 'import/brewbakersFiles.html';
diff --git a/models/admin/management/import/brewbakersImages.php b/models/admin/management/import/brewbakersImages.php
new file mode 100644 (file)
index 0000000..d42afa7
--- /dev/null
@@ -0,0 +1,200 @@
+<?php
+/**
+ * Import Brewbakers Images
+ * Will have to do these 10 to 20 at a time.
+ */
+
+$failure = false;
+// Setup the database connection to postgres
+$dbServer    = 'localhost';
+$dbName      = 'brewbakers';
+$dbUser      = 'postgres';
+$resetdb     = true;
+$start       = ( isset( $_REQUEST['start'] ) ) ? filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT ): 0;
+$limit       = ( $start === 0 ) ? 20 : 100;
+$totalImages = 0;
+
+$connString = "host=$dbServer dbname=$dbName user=$dbUser";
+$db = @pg_connect( $connString );
+
+require_once GLM_MEMBERS_PLUGIN_PATH.'/models/admin/ajax/imageUpload.php';
+$ImageUpload = new GlmMembersAdmin_ajax_imageUpload($this->wpdb, $this->config);
+
+$refType = $this->config['ref_type_numb']['MemberInfo'];
+$refTable = $this->config['ref_type_table'][$refType];
+
+// Get image array stored in a WordPress option
+$imageBaseURL = 'http://is0.gaslightmedia.com/brewbakers/CKImage/';
+
+
+// Read in all member photos for Homes and RV's
+$image = array();
+$numbImagesFound = 0;
+if (!$failure && $start === 0) {
+    // Grab the photos for homes
+    $sql = "
+    SELECT *
+      FROM homes_photos
+     ORDER BY homes_id,pos";
+    $res = pg_query($db, $sql);
+    $rows = pg_num_rows($res);
+    if ($rows == 0) {
+        $templateData['genError']  = 'There does not appear to be any member photos listed in this database!';
+        $failure = true;
+    } else {
+        $tmp = pg_fetch_all($res);
+        if (count($tmp) != $rows) {
+            $notice = pg_last_notice($res);
+            $templateData['genError']  = 'While reading member photo data, we did not receive the expected number of member photos! ';
+            if ($notice) {
+                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+            }
+            $failure = true;
+        } else {
+
+            // Reprocess into array grouped by member with the main index the member ID
+            foreach ($tmp as $x) {
+
+                // If member entry hasn't been created yet, add it now
+                if (!isset($image['homes'][$x['homes_id']])) {
+                    $image['homes'][$x['homes_id']] = array(
+                        'homes_id' => $x['homes_id'],
+                        'images' => array()
+                    );
+                }
+
+                $image['homes'][$x['homes_id']]['images'][] = $x;
+                $numbImagesFound++;
+            }
+            //echo '<pre>$image: ' . print_r( $image, true ) . '</pre>';
+        }
+    }
+}
+if (!$failure) {
+    // Get total count
+    $sql = "
+    SELECT count(*) as total
+      FROM rvs_photos";
+    $res = pg_query($db, $sql);
+    $totalImages = pg_fetch_result( $res, 0, 'total');
+
+    // Grab the photos for rvs
+    $sql = "
+    SELECT *
+      FROM rvs_photos
+     ORDER BY rvs_id,pos";
+    $sql .= " LIMIT $limit OFFSET $start";
+    $res = pg_query($db, $sql);
+    $rows = pg_num_rows($res);
+    if ($rows == 0) {
+        $templateData['genError']  = 'There does not appear to be any member photos listed in this database!';
+        $failure = true;
+    } else {
+        $tmp = pg_fetch_all($res);
+        if (count($tmp) != $rows) {
+            $notice = pg_last_notice($res);
+            $templateData['genError']  = 'While reading member photo data, we did not receive the expected number of member photos! ';
+            if ($notice) {
+                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+            }
+            $failure = true;
+        } else {
+
+            // Reprocess into array grouped by member with the main index the member ID
+            foreach ($tmp as $x) {
+
+                // If member entry hasn't been created yet, add it now
+                if (!isset($image['rvs'][$x['rvs_id']])) {
+                    $image['rvs'][$x['rvs_id']] = array(
+                        'rvs_id' => $x['rvs_id'],
+                        'images' => array()
+                    );
+                }
+
+                $image['rvs'][$x['rvs_id']]['images'][] = $x;
+                $numbImagesFound++;
+            }
+            //echo '<pre>$image: ' . print_r( $image, true ) . '</pre>';
+        }
+    }
+}
+function getMemberInfoIdFromOldMemberId( $wpdb, $oldMemberId )
+{
+    return $wpdb->get_var(
+        $wpdb->prepare(
+            "SELECT id
+               FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info
+              WHERE member IN (
+                    SELECT id
+                      FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
+                     WHERE old_member_id = %d)",
+            $oldMemberId
+        )
+    );
+}
+//echo '<pre>$image: ' . print_r( $image, true ) . '</pre>';
+//exit;
+// Reset member images data tables if needed
+if ( !$failure && $resetdb && $start === 0 ) {
+    // Reset the data
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."images" );
+
+    // Delete Images
+    foreach( new RecursiveIteratorIterator(
+
+        new RecursiveDirectoryIterator( GLM_MEMBERS_PLUGIN_IMAGES_PATH, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS ),
+        RecursiveIteratorIterator::CHILD_FIRST ) as $value ) {
+            if ($value->isFile()) {
+                unlink( $value );
+            }
+        }
+}
+// If we have image URLs
+if ($image != false) {
+
+    // For each member
+    foreach ($image as $memType) {
+        foreach ($memType as $oldMemberId => $m) {
+
+            $newMemberId = getMemberInfoIdFromOldMemberId( $this->wpdb, $oldMemberId);
+
+            // For each image in this member's gallery
+            if ($m['images']) {
+                foreach ($m['images'] as $i) {
+                    // If this is the first image (pos == 1) then add it as the logo
+                    if ( $i['pos'] == 1 ) {
+                        $imageURL = $imageBaseURL.$i['image'];
+                        $res = $ImageUpload->storeImage ($imageURL);
+
+                        // If we got a good new filename back, then it should be a good image store
+                        if ($res['newFileName']) {
+
+                            // Update the member record with the logo image name
+                            $res = $this->wpdb->update(
+                                GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info',
+                                array(
+                                    'logo' => $res['newFileName']
+                                ),
+                                array( 'id' => $newMemberId ),
+                                array( '%s' ),
+                                array( '%d' )
+                            );
+                        }
+                    }
+
+                    $imageURL = $imageBaseURL.$i['image'];
+                    $res = $ImageUpload->storeImage ($imageURL, $refType, $refTable, $newMemberId, $i['caption']);
+                }
+            }
+
+        }
+    }
+
+}
+
+$templateData['newStart']        = $start + $limit;
+$templateData['start']           = $start;
+$templateData['total']           = $totalImages;
+$templateData['numbImagesFound'] = $numbImagesFound;
+
+$requestedView = 'import/brewbakersImages.html';
index cec72b9..4f0439c 100644 (file)
@@ -1,12 +1,14 @@
 <?php
-
-echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+// Setup the brewbakers image url
+$dbImageURL = 'http://is0.gaslightmedia.com/brewbakers/CKImage/';
+//echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+$rvLimit = false; // set to false to turn off limit
 
 // Setup the database connection to postgres
-$dbServer    = 'ds4';
+$dbServer    = 'localhost';
 $dbName      = 'brewbakers';
 $dbUser      = 'postgres';
-$resetdb     = false;
+$resetdb     = true;
 $rvs         = array();
 $homes       = array();
 $amenities   = array();
@@ -33,6 +35,9 @@ if ( !$failure ) {
        AND r.class = c.id
        AND r.manufacturer = man.id
      ORDER BY r.id";
+    if ( $rvLimit ) {
+        $sql .= " LIMIT $rvLimit OFFSET 0";
+    }
     $res = pg_query( $db, $sql );
     $rows = pg_num_rows( $res );
     if ( $rows == 0 ) {
@@ -79,20 +84,18 @@ if ( !$failure ) {
             }
             $failure = true;
         }
-        echo '<pre>$homes: ' . print_r( $homes, true ) . '</pre>';
+        //echo '<pre>$homes: ' . print_r( $homes, true ) . '</pre>';
     }
 }
 // Reset member data tables if needed
 if ( !$failure && $resetdb ) {
-    // Reset the database
-    if ( !$this->deleteDataTables( GLM_MEMBERS_PLUGIN_DB_VERSION ) ) {
-        glmMembersAdmin::addNotice('<b>Unable to delete the database tables while resetting the database.</b><br>', 'AdminError');
-        break;
-    }
-    if ( !$this->createDataTables( GLM_MEMBERS_PLUGIN_DB_VERSION ) ) {
-        glmMembersAdmin::addNotice('<b>Unable to create the database tables while resetting the database.</b><br>', 'AdminError');
-        break;
-    }
+    // Reset the data
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."members" );
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info" );
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info" );
+    //$this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."amenities" );
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX."amenity_ref" );
+    $this->wpdb->query( "DELETE FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_field_data" );
 }
 // 3. Get amenities data
 if ( !$failure ) {
@@ -120,6 +123,7 @@ if ( !$failure ) {
     }
 }
 // 4. Get amenity member relation data
+$numbAmenityMembers = 0;
 if ( !$failure ) {
     // Grab the amenity data
     $sql = "
@@ -132,8 +136,8 @@ if ( !$failure ) {
         $templateData['genError']  = 'There does not appear to be any amenity relation listed in this database!';
         $failure = true;
     } else {
-        $amenityData = pg_fetch_all( $res );
-        if ( count( $amenityData ) != $rows ) {
+        $tmp = pg_fetch_all( $res );
+        if ( count( $tmp ) != $rows ) {
             $notice = pg_last_notice( $res );
             $templateData['genError']  = 'While reading base amenity relation data, we did not receive the expected number of amenityData! ';
             if ( $notice ) {
@@ -141,9 +145,21 @@ if ( !$failure ) {
             }
             $failure = true;
         }
-        //echo '<pre>$amenityData: ' . print_r( $amenityData, true ) . '</pre>';
+        $rvAmen = array();
+        foreach ( $tmp as $x ) {
+            // if rv entry hasn't been created yet, add it now
+            if ( !isset( $rvAmen[$x['rvs_id']] ) ) {
+                $rvAmen[$x['rvs_id']] = array();
+            }
+
+            $rvAmen[$x['rvs_id']][] = $x;
+            $numbAmenityMembers++;
+        }
     }
 }
+//echo '<pre>$rvAmen: ' . print_r( $rvAmen, true ) . '</pre>';
+//var_dump($rvAmen);
+//exit;
 function getCategoryId( $wpdb, $name, $parent )
 {
     // check to see if the category already exists
@@ -158,6 +174,59 @@ function getCategoryId( $wpdb, $name, $parent )
         )
     );
 }
+function getCustomFieldId( $wpdb, $name )
+{
+    return $wpdb->get_var(
+        $wpdb->prepare(
+            "SELECT id
+               FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields
+              WHERE field_name = %s",
+            $name
+        )
+    );
+}
+$customFieldIds = array(
+    'year'                  => getCustomFieldId( $this->wpdb, 'Year' ),
+    'model'                 => getCustomFieldId( $this->wpdb, 'Model' ),
+    'color'                 => getCustomFieldId( $this->wpdb, 'Color' ),
+    'length'                => getCustomFieldId( $this->wpdb, 'Length' ),
+    'weight'                => getCustomFieldId( $this->wpdb, 'UVW lbs' ),
+    'sleeping_capacity'     => getCustomFieldId( $this->wpdb, 'Sleeping Capacity' ),
+    'slide_outs'            => getCustomFieldId( $this->wpdb, 'Slide Outs' ),
+    'fresh_water_tank_size' => getCustomFieldId( $this->wpdb, 'Fresh Water (gal)' ),
+    'black_tank_size'       => getCustomFieldId( $this->wpdb, 'Black Water (gal)' ),
+    'grey_tank_size'        => getCustomFieldId( $this->wpdb, 'Gray Water (gal)' ),
+    'stock_numb'            => getCustomFieldId( $this->wpdb, 'Stock #' ),
+    'msrp'                  => getCustomFieldId( $this->wpdb, 'MSRP' ),
+    'make'                  => getCustomFieldId( $this->wpdb, 'Make' ),
+    'bedrooms'              => getCustomFieldId( $this->wpdb, 'Bedrooms' ),
+    'bathrooms'             => getCustomFieldId( $this->wpdb, 'Bathrooms' ),
+    'sqft'                  => getCustomFieldId( $this->wpdb, 'Square Footage' ),
+    'just_arrived'          => getCustomFieldId( $this->wpdb, 'Just Arrived' ),
+    'red_hot_deal'          => getCustomFieldId( $this->wpdb, 'Red Hot Deal' ),
+    'used'                  => getCustomFieldId( $this->wpdb, 'Used' ),
+);
+//echo '<pre>$customFieldIds: ' . print_r( $customFieldIds, true ) . '</pre>';
+function addCustomFieldData( $wpdb, $customFieldIds, $ref_dest, $fieldName, $fieldValue )
+{
+    // check the $fieldValue for t or f
+    if ( $fieldValue ) {
+        if ( $fieldValue == 't' ) {
+            $fieldValue = 'Yes';
+        } elseif ( $fieldValue == 'f' ) {
+            $fieldValue = 'No';
+        }
+    }
+    $wpdb->insert(
+        GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . 'custom_field_data',
+        array(
+            'field_id'   => $customFieldIds[$fieldName],
+            'ref_dest'   => $ref_dest,
+            'field_data' => ($fieldValue) ? $fieldValue: '',
+        ),
+        array( '%d', '%d', '%s' )
+    );
+}
 // 5. Get categories
 // Setup three main level categories
 // Brands, Manufactures, and Classes
@@ -189,8 +258,8 @@ function addNewCategory( $wpdb, $name, $parent )
 // Grab the Brands from Brewbakers
 if ( !$failure ) {
     // Add new main level for Brands
-    $brandId = addNewCategory( $this->wpdb, 'Brands', 0 );
-    echo '<pre>$brandId: ' . print_r( $brandId, true ) . '</pre>';
+    $rvBrandId = addNewCategory( $this->wpdb, 'Brands', 0 );
+    //echo '<pre>$rvBrandId: ' . print_r( $rvBrandId, true ) . '</pre>';
     // Get all Brands and add them as sub categories
     $sql = "
     SELECT id,name
@@ -213,16 +282,16 @@ if ( !$failure ) {
         }
         //echo '<pre>$brands: ' . print_r( $brands, true ) . '</pre>';
         foreach ( $brands as $key => $val ) {
-            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $brandId . '</pre>';
-            $newCatId = addNewCategory( $this->wpdb, $val['name'], $brandId );
+            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $rvBrandId . '</pre>';
+            $newCatId = addNewCategory( $this->wpdb, $val['name'], $rvBrandId );
         }
     }
 }
 // Grab the Housing Manufacturers
 if ( !$failure ) {
     // Add new main level for Brands
-    $manufacturerId = addNewCategory( $this->wpdb, 'Housing Manufacturers', 0 );
-    echo '<pre>$manufacturerId: ' . print_r( $manufacturerId, true ) . '</pre>';
+    $homeManufacturerId = addNewCategory( $this->wpdb, 'Housing Manufacturers', 0 );
+    //echo '<pre>$homeManufacturerId: ' . print_r( $homeManufacturerId, true ) . '</pre>';
     // Get all Manufactures from housing section and add them as sub categories
     $sql = "
     SELECT id,name
@@ -246,16 +315,16 @@ if ( !$failure ) {
         }
         //echo '<pre>$houseMan: ' . print_r( $houseMan, true ) . '</pre>';
         foreach ( $houseMan as $key => $val ) {
-            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $manufacturerId . '</pre>';
-            $newCatId = addNewCategory( $this->wpdb, $val['name'], $manufacturerId );
+            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $homeManufacturerId . '</pre>';
+            $newCatId = addNewCategory( $this->wpdb, $val['name'], $homeManufacturerId );
         }
     }
 }
 // Grab the RV Manufacturers
 if ( !$failure ) {
     // Add new main level for Brands
-    $manufacturerId = addNewCategory( $this->wpdb, 'RV Manufacturers', 0 );
-    echo '<pre>$manufacturerId: ' . print_r( $manufacturerId, true ) . '</pre>';
+    $rvManufacturerId = addNewCategory( $this->wpdb, 'RV Manufacturers', 0 );
+    //echo '<pre>$rvManufacturerId: ' . print_r( $rvManufacturerId, true ) . '</pre>';
     // Get all Manufactures from rvs section and add them as sub categories
     $sql = "
     SELECT id,name
@@ -279,16 +348,16 @@ if ( !$failure ) {
         }
         //echo '<pre>$rvMan: ' . print_r( $rvMan, true ) . '</pre>';
         foreach ( $rvMan as $key => $val ) {
-            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $manufacturerId . '</pre>';
-            $newCatId = addNewCategory( $this->wpdb, $val['name'], $manufacturerId );
+            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $rvManufacturerId . '</pre>';
+            $newCatId = addNewCategory( $this->wpdb, $val['name'], $rvManufacturerId );
         }
     }
 }
 // Grab the Housing Classes
 if ( !$failure ) {
     // Add new main level for Brands
-    $classId = addNewCategory( $this->wpdb, 'Housing Classes', 0 );
-    echo '<pre>$classId: ' . print_r( $classId, true ) . '</pre>';
+    $homeClassId = addNewCategory( $this->wpdb, 'Housing Classes', 0 );
+    //echo '<pre>$homeClassId: ' . print_r( $homeClassId, true ) . '</pre>';
     // Get all Manufactures from housing section and add them as sub categories
     $sql = "
     SELECT id,name
@@ -312,16 +381,16 @@ if ( !$failure ) {
         }
         //echo '<pre>$houseClass: ' . print_r( $houseClass, true ) . '</pre>';
         foreach ( $houseClass as $key => $val ) {
-            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $classId . '</pre>';
-            $newCatId = addNewCategory( $this->wpdb, $val['name'], $classId );
+            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $homeClassId . '</pre>';
+            $newCatId = addNewCategory( $this->wpdb, $val['name'], $homeClassId );
         }
     }
 }
 // Grab the RV Classes
 if ( !$failure ) {
     // Add new main level for Brands
-    $classId = addNewCategory( $this->wpdb, 'RV Classes', 0 );
-    echo '<pre>$classId: ' . print_r( $classId, true ) . '</pre>';
+    $rvClassId = addNewCategory( $this->wpdb, 'RV Classes', 0 );
+    //echo '<pre>$rvClassId: ' . print_r( $rvClassId, true ) . '</pre>';
     // Get all Manufactures from rvs section and add them as sub categories
     $sql = "
     SELECT id,name
@@ -345,16 +414,16 @@ if ( !$failure ) {
         }
         //echo '<pre>$rvClass: ' . print_r( $rvClass, true ) . '</pre>';
         foreach ( $rvClass as $key => $val ) {
-            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $classId . '</pre>';
-            $newCatId = addNewCategory( $this->wpdb, $val['name'], $classId );
+            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $rvClassId . '</pre>';
+            $newCatId = addNewCategory( $this->wpdb, $val['name'], $rvClassId );
         }
     }
 }
 // Grab the Homes Models
 if ( !$failure ) {
     // Add new main level for Models
-    $modelId = addNewCategory( $this->wpdb, 'Home Models', 0 );
-    echo '<pre>$modelId: ' . print_r( $modelId, true ) . '</pre>';
+    $homeModelId = addNewCategory( $this->wpdb, 'Home Models', 0 );
+    //echo '<pre>$homeModelId: ' . print_r( $homeModelId, true ) . '</pre>';
     // Get all Manufactures from rvs section and add them as sub categories
     $sql = "
     SELECT id,name
@@ -378,8 +447,8 @@ if ( !$failure ) {
         }
         //echo '<pre>$homeModel: ' . print_r( $homeModel, true ) . '</pre>';
         foreach ( $homeModel as $key => $val ) {
-            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $modelId . '</pre>';
-            $newCatId = addNewCategory( $this->wpdb, $val['name'], $modelId );
+            //echo '<pre>Adding category for ' . $val['name'] . ' parent ' . $homeModelId . '</pre>';
+            $newCatId = addNewCategory( $this->wpdb, $val['name'], $homeModelId );
         }
     }
 }
@@ -438,8 +507,20 @@ function addNewAmenity( $wpdb, $name )
         // Add the category
         $wpdb->insert(
             GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenities',
-            array( 'name' => $name ),
-            '%s'
+            array(
+                'active'      => true,
+                'name'        => $name,
+                'descr'       => '',
+                'short_descr' => '',
+                'ref_type'    => 20
+            ),
+            array(
+                '%d',
+                '%s',
+                '%s',
+                '%s',
+                '%d'
+            )
         );
         return $wpdb->insert_id;
     }
@@ -449,9 +530,9 @@ if (!$failure) {
     // Import Amenities
     while (list ($key, $val) = each ($amenity) ) {
         $amenityId = addNewAmenity( $this->wpdb, $val['name'] );
-        $amenity[$key]['new_id'] = $this->wpdb->insert_id;
+        $amenity[$key]['new_id'] = $amenityId;
     }
-    //echo '<pre>$amenity: ' . print_r( $amenity, true ) . '</pre>';
+    //echo '<pre>new $amenity: ' . print_r( $amenity, true ) . '</pre>';
 }
 function getMemberTypeId( $wpdb, $name )
 {
@@ -489,48 +570,6 @@ if (!$failure) {
     // Add member type for Homes
     $homeMemberType = addNewMemberType( $this->wpdb, 'Home' );
 }
-// Read in all member photos for Homes and RV's
-$image = array();
-$numbImagesFound = 0;
-if (!$failure) {
-    $sql = "
-    SELECT *
-      FROM homes_photos
-     ORDER BY homes_id,pos";
-    $res = pg_query($db, $sql);
-    $rows = pg_num_rows($res);
-    if ($rows == 0) {
-        $templateData['genError']  = 'There does not appear to be any member photos listed in this database!';
-        $failure = true;
-    } else {
-        $tmp = pg_fetch_all($res);
-        if (count($tmp) != $rows) {
-            $notice = pg_last_notice($res);
-            $templateData['genError']  = 'While reading member photo data, we did not receive the expected number of member photos! ';
-            if ($notice) {
-                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
-            }
-            $failure = true;
-        } else {
-
-            // Reprocess into array grouped by member with the main index the member ID
-            foreach ($tmp as $x) {
-
-                // If member entry hasn't been created yet, add it now
-                if (!isset($image[$x['homes_id']])) {
-                    $image[$x['homes_id']] = array(
-                        'homes_id' => $x['homes_id'],
-                        'images' => array()
-                    );
-                }
-
-                $image[$x['homes_id']]['images'][] = $x;
-                $numbImagesFound++;
-            }
-            //echo '<pre>$image: ' . print_r( $image, true ) . '</pre>';
-        }
-    }
-}
 if (!$failure) {
     // Import Members
     $numbMembersActive       = 0;
@@ -547,10 +586,9 @@ if (!$failure) {
         // Check for duplicate name
         // Build out the Home name from year make model class
         $membName = sprintf(
-            "%s %s %s %s",
+            "%s %s %s",
             $val['year'],
             $val['make'],
-            $val['model_name'],
             $val['class_name']
         );
         if (isset($namesInserted[$membName])) {
@@ -572,6 +610,189 @@ if (!$failure) {
                     'created'       => date('Y-m-d'),
                     'name'          => $membName,
                     'member_slug'   => sanitize_title($membName),
+                    'featured'      => ($val['featured'] == 't') ? 1: 0,
+                    'old_member_id' => $val['id']
+                ),
+                array(
+                    '%d',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%d',
+                    '%d'
+                )
+        );
+        $membID = $this->wpdb->insert_id;
+        $member[$key]['new_id'] = $membID;
+
+        // Add this member to the names inserted so we can check for duplicates
+        $namesInserted[$membName] = true;
+
+        // Insert Member Information Record
+        $res = $this->wpdb->insert(
+                GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info',
+                array(
+                    'member'         => $membID,
+                    'member_name'    => $membName,
+                    'status'         => $this->config['status_numb']['Active'],
+                    'reference_name' => 'Imported Member Information',
+                    'descr'          => preg_replace('%[\n\r]%', '', $val['description']),
+                    'short_descr'    => '',
+                    'addr1'          => '',
+                    'addr2'          => '',
+                    'city'           => 0,
+                    'state'          => 0,
+                    'country'        => '',
+                    'zip'            => '',
+                    'lat'            => 0,
+                    'lon'            => 0,
+                    'region'         => 0,
+                    'phone'          => '',
+                    'toll_free'      => '',
+                    'url'            => '',
+                    'email'          => '',
+                    'logo'           => '',
+                    'cc_type'        => 0,
+                    'notes'          => '',
+                    'create_time'    => $val['created'],
+                    'modify_time'    => ''
+                ),
+                array(
+                    '%d',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%f',
+                    '%f',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s'
+                )
+        );
+        $infoID = $this->wpdb->insert_id;
+        $member[$key]['new_info_id'] = $infoID;
+        $homeModel = $homeClass = $homeManufacturer = 0;
+        $homeCat = array();
+
+        // Add Member Categories
+        // Get category id for the model_name
+        $homeModel = getCategoryId( $this->wpdb, $val['model_name'], $homeModelId );
+        if ( $homeModel ) {
+            $homeCat[] = array(
+                'category'    => $homeModel,
+                'member_info' => $infoID
+            );
+        }
+        // Get category id for the class_name
+        $homeClass = getCategoryId( $this->wpdb, $val['class_name'], $homeClassId );
+        if ( $homeClass ) {
+            $homeCat[] = array(
+                'category'    => $homeClass,
+                'member_info' => $infoID
+            );
+        }
+        // Get category id for the manufacturer_name
+        $homeManufacturer = getCategoryId( $this->wpdb, $val['manufacturer_name'], $homeManufacturerId );
+        if ( $homeManufacturer ) {
+            $homeCat[] = array(
+                'category'    => $homeManufacturer,
+                'member_info' => $infoID
+            );
+        }
+        // Add Member Categories
+        if (isset($homeCat)) {
+            foreach ($homeCat as $catMemData) {
+
+                $res = $this->wpdb->insert(
+                    GLM_MEMBERS_PLUGIN_DB_PREFIX.'category_member_info',
+                    $catMemData,
+                    array(
+                        '%d',
+                        '%d'
+                    )
+                );
+
+            }
+        }
+
+        // Add Member Amenities (only for rvs)
+
+        // Add Custom Fields
+        // year
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'year', $val['year'] );
+        // make
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'make', $val['make'] );
+        // color
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'color', $val['color'] );
+        // Stock Number
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'stock_numb', $val['stock_numb'] );
+        // MSRP
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'msrp', $val['msrp'] );
+        // Bedrooms
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'bedrooms', $val['bedrooms'] );
+        // Bathrooms
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'bathrooms', $val['bathrooms'] );
+        // Square Footage
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'sqft', $val['sqft'] );
+        // Used
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'used', $val['used'] );
+
+    }
+    //echo '<pre>$member: ' . print_r( $member, true ) . '</pre>';
+}
+
+$haveCatImportIssues = false;
+$catImportIssues = '';
+if (!$failure) {
+    while (list ($key, $val) = each ($rvs) ) {
+        // Member is active, so set to active-moderated
+        $access = $this->config['access_numb']['Moderated'];
+        $numbMembersActive++;
+
+        // Check for duplicate name
+        // Build out the Home name from year make model class
+        $membName = sprintf(
+            "%s %s %s",
+            $val['year'],
+            $val['model_name'],
+            $val['stock_numb']
+        );
+        if (isset($namesInserted[$membName])) {
+
+            // Bump dupe count and add to name to make this one unique
+            $dupeNames++;
+            $membName .= ' DUPE-'.$dupeNames;
+
+            $membImportIssues .= '<li>Member Duplicate <b>'.$membName.'</b></li>';
+            $haveMembImportIssues = true;
+
+        }
+        // Add main member record
+        $res = $this->wpdb->insert(
+                GLM_MEMBERS_PLUGIN_DB_PREFIX.'members',
+                array(
+                    'access'        => $access,
+                    'member_type'   => $rvMemberType,
+                    'created'       => date('Y-m-d'),
+                    'name'          => $membName,
+                    'member_slug'   => sanitize_title($membName),
+                    'featured'      => ($val['featured'] == 't') ? 1: 0,
                     'old_member_id' => $val['id']
                 ),
                 array(
@@ -580,11 +801,200 @@ if (!$failure) {
                     '%s',
                     '%s',
                     '%s',
+                    '%d',
                     '%d'
                 )
         );
         $membID = $this->wpdb->insert_id;
         $member[$key]['new_id'] = $membID;
+
+        // Add this member to the names inserted so we can check for duplicates
+        $namesInserted[$membName] = true;
+
+        // Insert Member Information Record
+        $res = $this->wpdb->insert(
+                GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info',
+                array(
+                    'member'         => $membID,
+                    'member_name'    => $membName,
+                    'status'         => $this->config['status_numb']['Active'],
+                    'reference_name' => 'Imported Member Information',
+                    'descr'          => preg_replace('%[\n\r]%', '', $val['description']),
+                    'short_descr'    => '',
+                    'addr1'          => '',
+                    'addr2'          => '',
+                    'city'           => 0,
+                    'state'          => 0,
+                    'country'        => '',
+                    'zip'            => '',
+                    'lat'            => 0,
+                    'lon'            => 0,
+                    'region'         => 0,
+                    'phone'          => '',
+                    'toll_free'      => '',
+                    'url'            => '',
+                    'email'          => '',
+                    'logo'           => '',
+                    'cc_type'        => 0,
+                    'notes'          => '',
+                    'create_time'    => $val['created'],
+                    'modify_time'    => ''
+                ),
+                array(
+                    '%d',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%f',
+                    '%f',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%s',
+                    '%d',
+                    '%s',
+                    '%s',
+                    '%s'
+                )
+        );
+        $infoID = $this->wpdb->insert_id;
+        $member[$key]['new_info_id'] = $infoID;
+        $rvBrand = $rvClass = $rvManufacturer = 0;
+        $rvCat = array();
+
+        // Add Member Categories
+        // Get category id for the model_name
+        $rvBrand = getCategoryId( $this->wpdb, $val['model_name'], $rvBrandId );
+        if ( $rvBrand ) {
+            $rvCat[] = array(
+                'category'    => $rvBrand,
+                'member_info' => $infoID
+            );
+        }
+        // Get category id for the class_name
+        $rvClass = getCategoryId( $this->wpdb, $val['class_name'], $rvClassId );
+        if ( $rvClass ) {
+            $rvCat[] = array(
+                'category'    => $rvClass,
+                'member_info' => $infoID
+            );
+        }
+        // Get category id for the manufacturer_name
+        $rvManufacturer = getCategoryId( $this->wpdb, $val['manufacturer_name'], $rvManufacturerId );
+        if ( $rvManufacturer ) {
+            $rvCat[] = array(
+                'category'    => $rvManufacturer,
+                'member_info' => $infoID
+            );
+        }
+        // Add Member Categories
+        if (isset($rvCat)) {
+            foreach ($rvCat as $catMemData) {
+
+                $res = $this->wpdb->insert(
+                    GLM_MEMBERS_PLUGIN_DB_PREFIX.'category_member_info',
+                    $catMemData,
+                    array(
+                        '%d',
+                        '%d'
+                    )
+                );
+
+            }
+        }
+
+        // Add Member Amenities (only for rvs)
+        if (isset($rvAmen[$val['id']])) {
+            foreach ($rvAmen[$val['id']] as $a) {
+                // Check first if the amenity still exists
+                // Brewbakers may have extra rvs_amenity records for amenities
+                // that don't exists anymore.
+                if ( isset( $amenity[$a['amenity_id']] ) ) {
+                    $res = $this->wpdb->insert(
+                        GLM_MEMBERS_PLUGIN_DB_PREFIX.'amenity_ref',
+                        array(
+                            'amenity'  => $amenity[$a['amenity_id']]['new_id'],
+                            'ref_type' => $this->config['ref_type_numb']['MemberInfo'],
+                            'ref_dest' => $infoID
+                        ),
+                        array(
+                            '%d',
+                            '%d',
+                            '%d'
+                        )
+                    );
+                }
+            }
+        }
+
+        // Add Custom Fields
+        // year
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'year', $val['year'] );
+        // Model
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'model', $val['model_name'] );
+        // length
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'length', $val['length'] );
+        // Weight
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'weight', $val['weight'] );
+        // color
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'color', $val['color'] );
+        // Stock Number
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'stock_numb', $val['stock_numb'] );
+        // MSRP
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'msrp', $val['msrp'] );
+        // Sleeping Capacity
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'sleeping_capacity', $val['sleeping_capacity'] );
+        // Slide Outs
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'slide_outs', $val['slide_outs'] );
+        // Fresh Water
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'fresh_water_tank_size', $val['fresh_water_tank_size'] );
+        // Black Tank
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'black_tank_size', $val['black_tank_size'] );
+        // Grey Tank
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'grey_tank_size', $val['grey_tank_size'] );
+        // Just Arrived
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'just_arrived', $val['just_arrived'] );
+        // Red Hot Heal
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'red_hot_deal', $val['red_hot_deal'] );
+        // Used
+        addCustomFieldData( $this->wpdb, $customFieldIds, $infoID, 'used', $val['used'] );
+
     }
-    echo '<pre>$member: ' . print_r( $member, true ) . '</pre>';
+
+}
+// If everything is OK, make data available to the template
+if (!$failure) {
+
+    $templateData['numbMembers']          = count($member);
+    $templateData['numbMembersActive']    = $numbMembersActive;
+    $templateData['numbMembersInactive']  = $numbMembersInactive;
+    $templateData['haveMembImportIssues'] = $haveMembImportIssues;
+    $templateData['membImportIssues']     = $membImportIssues;
+    $templateData['numbCategories']       = count($rvCat) + count($homeCat);
+    $templateData['haveCatImportIssues']  = $haveCatImportIssues;
+    $templateData['catImportIssues']      = $catImportIssues;
+    $templateData['numbAmenities']        = count($amenity);
+    $templateData['numbAmenityMembers']   = $numbAmenityMembers;
+
+    // For testing only
+    $templateData['member']            = $member;
+    $templateData['amenity']           = $amenity;
+    $templateData['rvAmen']            = $rvAmen;
+}
+
+
+if ($failure) {
+    $requestedView = 'import.html';
+} else {
+    $requestedView = 'import/brewbakers.html';
 }
index 56eba1e..d47c4bf 100644 (file)
                     <input type="radio" name="option" value="importBrewbakers" class="import-type"> Import Brewbakers
                 </td>
             </tr>
+            <tr class="for-brewbakers glm-hidden">
+                <td colspan="2">
+                    <p><a href="{$thisUrl}?page={$thisPage}&glm_action=import&option=brewbakersImages">Import Images</a></p>
+                    <p><a href="{$thisUrl}?page={$thisPage}&glm_action=import&option=brewbakersFiles">Import Files</a></p>
+                </td>
+            </tr>
             <tr class="for-member-import all-import-fields">
                 <td colspan="2">
                     <p>
                 $('.for-member-import').addClass('glm-hidden');
             } else if (selected == 'importMailingAddresses') {
                 $('.for-member-import').addClass('glm-hidden');
+            } else if (selected == 'importBrewbakers') {
+                $('.for-member-import').addClass('glm-hidden');
+                $('.all-import-fields').addClass('glm-hidden');
+                $('.for-brewbakers').removeClass('glm-hidden');
             } else {
                 $('.for-member-import').addClass('glm-hidden');
                 $('.all-import-fields').addClass('glm-hidden');
diff --git a/views/admin/management/import/brewbakers.html b/views/admin/management/import/brewbakers.html
new file mode 100644 (file)
index 0000000..4427675
--- /dev/null
@@ -0,0 +1,45 @@
+{include file='admin/management/header.html'}
+
+    <h2>Data Import - Test Database</h2>
+    <ol>
+        <li>Provide legacy database information and import member data.</li>
+        <li class="glm-ol-selected">Import any images.</li>
+        <li>Review results</li>
+    </ol>
+
+    <h2>Data Import Results</h2>
+    <table class="glm-admin-table">
+        <tr>
+            <th>Members:</th>
+            <td>
+                {$numbMembers}
+                {if $haveMembImportIssues}
+                    <ul>{$membImportIssues}</ul>
+                {/if}
+            </td>
+        </tr>
+        <tr><th>Members Active:</th><td>{$numbMembersActive}</td></tr>
+        <tr><th>Members Inactive:</th><td>{$numbMembersInactive}</td></tr>
+        <tr><th>Categories:</th><td>{$numbCategories}</td></tr>
+        <tr>
+            <th>Member Category Entries:</th>
+            <td>
+                {if $haveCatImportIssues}
+                    <ul>{$catImportIssues}</ul>
+                {/if}
+            </td>
+        </tr>
+        <tr><th>Amenities:</th><td>{$numbAmenities}</td></tr>
+        <tr><th>Member Amenity Entries:</th><td>{$numbAmenityMembers}</td></tr>
+    </table>
+
+    <h3>Data Import Step 2: Import images.</h3>
+{if isset($genError)}
+    <p>
+        <h3 class="glm-error">Oops!</h3>
+        <p class="glm-error">{$genError}</p>
+    </p>
+{/if}
+
+
+{include file='admin/footer.html'}
diff --git a/views/admin/management/import/brewbakersFiles.html b/views/admin/management/import/brewbakersFiles.html
new file mode 100644 (file)
index 0000000..46b5c27
--- /dev/null
@@ -0,0 +1,37 @@
+{include file='admin/management/header.html'}
+
+    <h2>Data Import - Test Database</h2>
+    <ol>
+        <li>Provide legacy database information and import member data.</li>
+        <li>Import any images.</li>
+        <li class="glm-ol-selected">Review results</li>
+    </ol>
+
+
+    <h3>Data Import Step 3: Review Results.</h3>
+{if isset($genError)}
+    <p>
+        <h3 class="glm-error">Oops!</h3>
+        <p class="glm-error">{$genError}</p>
+    </p>
+{/if}
+
+<pre>
+Found: {$numbFilesFound} files
+Start: {$start}
+End: {$newStart}
+Total: {$total}
+</pre>
+    <a href="{$thisUrl}?page={$thisPage}&glm_action=import&option=brewbakersFiles&start={$newStart}">Next Set of Files</a>
+
+    {if $newStart > $total }
+    <h2>Process Complete</h2>
+    <p>
+        The data and image import process is complete. You should now have all member data and images imported.
+    <p>
+    <p>
+        You should now go to the "Member List" and make sure the data and images have been imported properly.
+    </p>
+    {/if}
+
+{include file='admin/footer.html'}
diff --git a/views/admin/management/import/brewbakersImages.html b/views/admin/management/import/brewbakersImages.html
new file mode 100644 (file)
index 0000000..2f4ccbf
--- /dev/null
@@ -0,0 +1,37 @@
+{include file='admin/management/header.html'}
+
+    <h2>Data Import - Test Database</h2>
+    <ol>
+        <li>Provide legacy database information and import member data.</li>
+        <li>Import any images.</li>
+        <li class="glm-ol-selected">Review results</li>
+    </ol>
+
+
+    <h3>Data Import Step 3: Review Results.</h3>
+{if isset($genError)}
+    <p>
+        <h3 class="glm-error">Oops!</h3>
+        <p class="glm-error">{$genError}</p>
+    </p>
+{/if}
+
+<pre>
+Found: {$numbImagesFound} images
+Start: {$start}
+End: {$newStart}
+Total: {$total}
+</pre>
+    <a href="{$thisUrl}?page={$thisPage}&glm_action=import&option=brewbakersImages&start={$newStart}">Next Set of Images</a>
+
+    {if $newStart > $total }
+    <h2>Process Complete</h2>
+    <p>
+        The data and image import process is complete. You should now have all member data and images imported.
+    <p>
+    <p>
+        You should now go to the "Member List" and make sure the data and images have been imported properly.
+    </p>
+    {/if}
+
+{include file='admin/footer.html'}
index ef202e6..85cad94 100644 (file)
         <a id="glm-member-info-contact" data-show-table="glm-table-contact" class="glm-member-info-tab nav-tab">Contact Info</a>
         <a id="glm-member-info-cat" data-show-table="glm-table-cat" class="glm-member-info-tab nav-tab">Categories & Amenities</a>
         <a id="glm-member-info-images" data-show-table="glm-table-images" class="glm-member-info-tab nav-tab">Images</a>
-        <!--
         <a id="glm-member-info-files" data-show-table="glm-table-files" class="glm-member-info-tab nav-tab">Files</a>
-        -->
         <a id="glm-member-info-video" data-show-table="glm-table-video" class="glm-member-info-tab nav-tab">Video</a>
         <a id="glm-member-info-live-cam" data-show-table="glm-table-live-cam" class="glm-member-info-tab nav-tab">Live Cam</a>