Added Old Member DB import
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 18 Sep 2015 19:54:28 +0000 (15:54 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 18 Sep 2015 19:54:28 +0000 (15:54 -0400)
classes/data/dataMemberInfo.php
controllers/admin.php
css/admin.css
lib/GlmDataAbstract/DataAbstract.php
misc/notes.txt
models/admin/member/memberInfo.php
models/admin/settings/import.php [new file with mode: 0644]
views/admin/member/memberInfo.html
views/admin/settings/header.html
views/admin/settings/import.html [new file with mode: 0644]
views/admin/settings/import/readDatabase.html [new file with mode: 0644]

index c1cadec..a679a53 100644 (file)
@@ -371,7 +371,7 @@ class GlmDataMemberInfo extends GlmDataAbstract
        public function entryPostProcessing($r, $a)
        {
 
-           // Only run these tests for 'l' (getList) or 'g' (getEntry)
+           // Only run these tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry)
            if ($a != 'l' && $a != 'g' && $a != 'e') {
                return $r;
            }
index 304fcb4..969c6f7 100644 (file)
@@ -58,7 +58,8 @@ $GLOBALS['glmMembersAdminValidActions'] = array(
         'settings' => array(
                 'index',            // General Options
                 'terms',            // Terms and Phrases
-                'development'
+                'development',
+                'import'            // Import data
         ),
         'shortcodes' => array(
                 'index'
@@ -720,6 +721,8 @@ class glmMembersAdmin extends GlmPluginSupport
                     // Check if there's been a model redirect request
                     if ($results['modelRedirect']) {
 
+                        $this->addNotice('<pre>'.print_r($results,1).'</pre>', 'DataBlock', 'Model Redirect');
+
                         // Set the new model action
                         $action = $results['modelRedirect'];
 
@@ -768,6 +771,7 @@ class glmMembersAdmin extends GlmPluginSupport
             }
 
             // Loop again if there's a model redirect
+
         } while ($modelRedirect);
 
         /*
index a42055e..ad75c1d 100644 (file)
@@ -94,6 +94,9 @@
 .glm-form-text-input-medium {
     width: 30em;
 }
+.glm-form-text-input-medium-long {
+    width: 50em;
+}
 .glm-form-textarea {
     width: 90%;
 }
     width: 70%;
     resize: none;
 }
+
+.glm-ol-selected
+{ 
+    font-weight: bold; 
+    color: green;
+}
\ No newline at end of file
index 69ec86f..c6fe2e0 100755 (executable)
@@ -748,7 +748,7 @@ abstract class GlmDataAbstract
         }
 
         // If this is not a "new", then do these things
-        if ($op != 'n') {
+        if ($op != 'n' && isset($_REQUEST[$as])) {
 
             // Get selected - Pointers are treated as integers except that there's no min/max
             $in = $_REQUEST[$as]-0;
index e248ef9..7ff9029 100644 (file)
@@ -1,15 +1,8 @@
 Development Notes
 -----------------
 
-
-**** NEED TO SOLVE ISSUES WITH AMENITIES NOT UPDATING CORRECTLY WHEN YOU ADD/DELETE THEM IN MEMBER INFO PAGE ****
-
 Database Updates
 
-* Added table settings_general
-* Added table settings_terms
-* ALTER TABLE wp_glm_members_images CHANGE pending status tinyint;
-* alter table wp_2_glm_members_amenities change column facility_type ref_type integer;
 
 
 
index ccfae2f..0867b34 100644 (file)
@@ -431,17 +431,19 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
 
         } // Have member info
 
-        // If we have member data
+        // If we have member info data
         if (is_array($this->memberInfo) && $this->memberInfo['status']) {
 
             // Say we do
             $this->haveMemberInfo = true;
 
-            // Also get any image gallery images
-            require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php');
-            $Images = new GlmDataImages($this->wpdb, $this->config);
-            $this->imageGallery = $Images->getGallery($this->config['ref_type_numb']['MemberInfo'], $this->memberInfoID);
-            $this->haveImageGallery = ($this->imageGallery != false);
+            // Also, if this is not a create, get any image gallery images
+            if ($this->memberInfoID) {
+                require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php');
+                $Images = new GlmDataImages($this->wpdb, $this->config);
+                $this->imageGallery = $Images->getGallery($this->config['ref_type_numb']['MemberInfo'], $this->memberInfoID);
+                $this->haveImageGallery = ($this->imageGallery != false);
+            }
 
             // Otherwise
         } else {
@@ -520,9 +522,7 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
                 $_REQUEST['city'] = $cID;
 
             }
-
         }
-
     }
 
     /*
diff --git a/models/admin/settings/import.php b/models/admin/settings/import.php
new file mode 100644 (file)
index 0000000..6cfecf5
--- /dev/null
@@ -0,0 +1,1097 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Data Import
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_import
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This method does the work for this model and returns any resulting data
+     *
+     * @return array Status and data array
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'menuItemRedirect'
+     *
+     * If not false, provides a menu item the controller should
+     * execute after this one. Normally if this is used, there would also be a
+     * modelRedirect value supplied as well.
+     *
+     * 'modelRedirect'
+     *
+     * If not false, provides an action the controller should execute after
+     * this one.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     */
+    public function modelAction ($actionData = false)
+    {
+
+        $templateData = array();
+
+        $requestedView = false;
+        $failure = false;
+
+        $option = '';
+
+        // If there has been a redirect
+        if ($actionData) {
+
+            $templateData = $actionData;
+            $option = 'importSelect';
+
+        // Otherwise check the request for desired option
+        } elseif (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
+
+            $option = $_REQUEST['option'];
+
+        // Fall back to importSelect
+        } else {
+
+            $option = 'importSelect';
+
+        }
+
+        switch($option) {
+
+            case 'importSelect':
+
+                $requestedView = 'import.html';
+
+                break;
+
+            case 'readDatabase':
+
+                /*
+                 * Check all input
+                 */
+
+                // Check hostname
+                $dbServer = preg_replace("/[^a-zA-Z0-9\._-]+/", "", trim($_REQUEST['dbServer']));
+                $templateData['dbServer'] = array('value' => $dbServer, 'problem' => false);
+                if (!$dbServer || $dbServer == '' || $dbServer != trim($_REQUEST['dbServer'])) {
+                    $templateData['dbServer']['problem'] = 'Server name or IP address was not provided or contained invalid characters.';
+                    $failure = true;
+                }
+
+                // Check database port #
+                $dbPort = preg_replace("/[^0-9]+/", "", trim($_REQUEST['dbPort']));
+                $templateData['dbPort'] = array('value' => $dbPort, 'problem' => false);
+                if (!$dbPort || $dbPort == '' || $dbPort != trim($_REQUEST['dbPort'])) {
+                    $templateData['dbPort']['problem'] = 'Server port was not provided or is not a valid nummber.';
+                    $failure = true;
+                }
+
+                // Check database name
+                $dbName = preg_replace("/[^a-zA-Z0-9_]+/", "", trim($_REQUEST['dbName']));
+                $templateData['dbName'] = array('value' => $dbName, 'problem' => false);
+                if (!$dbName || $dbName == '' || $dbName != trim($_REQUEST['dbName'])) {
+                    $templateData['dbName']['problem'] = 'Database name was not provided or is not valid for Postgres.';
+                    $failure = true;
+                }
+
+                // Check database user
+                $dbUser = preg_replace("/[^a-zA-Z0-9_]+/", "", trim($_REQUEST['dbUser']));
+                $templateData['dbUser'] = array('value' => $dbUser, 'problem' => false);
+                if (!$dbUser || $dbUser == '' || $dbUser != trim($_REQUEST['dbUser'])) {
+                    $templateData['dbUser']['problem'] = 'Database user was not provided or is not valid for Postgres.';
+                    $failure = true;
+                }
+
+                // Check Image URL
+                $dbImageURL = filter_var($_REQUEST['dbImageURL'], FILTER_SANITIZE_URL);
+                $templateData['dbImageURL'] = array('value' => $dbImageURL, 'problem' => false);
+                if (!$dbImageURL || $dbImageURL == '' || $dbImageURL != trim($_REQUEST['dbImageURL'])) {
+                    $templateData['dbImageURL']['problem'] = 'Image URL does not appear to be valid.';
+                    $failure = true;
+                }
+
+                if ($failure) {
+                    $templateData['genError'] = 'There was a problem with the database connection information you provided. See below for specific instructions.';
+                }
+
+                /*
+                 * Determine if source database is sane
+                 */
+
+                // Connect to database
+                if (!$failure) {
+                    $connString = "host=$dbServer port=$dbPort dbname=$dbName user=$dbUser";
+                    $db = @pg_connect($connString);
+                    if (!$db) {
+
+                        $err = error_get_last();
+                        $templateData['genError']  = 'There was a problem connecting to the database. The error message was...<br>'.$err['message'];
+                        $failure = true;
+
+                    }
+                }
+
+                // Determine if the members schema exists
+                if (!$failure) {
+                    $sql = "
+                        SELECT EXISTS
+                            (
+                            SELECT 1
+                              FROM information_schema.schemata AS exists
+                             WHERE schema_name = 'members'
+                            ) AS isMembers
+                    ;";
+                    $res = pg_query($db, $sql);
+                    if (pg_fetch_result($res, 0, 'isMembers') == 'f') {
+                        $templateData['genError']  = 'The "members" schema was not found! Is this the right database?';
+                        $failure = true;
+                    }
+                }
+
+                /*
+                 * Load data from source database
+                 */
+
+                // Attempt to get member base data
+                if (!$failure) {
+                    $sql = "
+                        SELECT *
+                          FROM members.member
+                         ORDER BY member_id
+                    ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any members listed in this database!';
+                        $failure = true;
+                    } else {
+                        $member = pg_fetch_all($res);
+                        if (count($member) != $rows) {
+                            $notice = pg_last_notice($res);
+                            $templateData['genError']  = 'While reading base member data, we did not receive the expected number of members! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        }
+                    }
+                }
+
+                // Read in all amenities
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.amenity
+                             ORDER BY amenity_name
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any cities 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 amenity data, we did not receive the expected number of amenities! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $amenity = array();
+
+                            // Reprocess into array indexed by amenity_id
+                            foreach ($tmp as $x) {
+                                $amenity[$x['amenity_id']] = $x;
+                            }
+                        }
+                    }
+                }
+
+                // Read in member/amenity cross-reference table
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.member_amenity
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any member/amenity cross-reference entries 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 amenity data, we did not receive the expected number of amenities! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the ameities into an array indexed by amenity_id
+                            $membAmen = array();
+
+                            // 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($membAmen[$x['member_id']])) {
+                                    $membAmen[$x['member_id']] = array();
+                                }
+
+                                $membAmen[$x['member_id']][] = $x;
+                            }
+                        }
+                    }
+                }
+
+                // Read in all credit card types
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.ccard_type
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any credit card types 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 credit card type data, we did not receive the expected number of credit card types! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $ccard = array();
+
+                            // Reprocess into array indexed by ccard_type_id
+                            foreach ($tmp as $x) {
+                                $ccard[$x['ccard_type_id']] = $x;
+                            }
+                        }
+                    }
+                }
+
+                // Read in member/credit card cross-reference table
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.member_ccard_type
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any member/credit card cross-reference entries 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/credit card cross-reference data, we did not receive the expected number of entries! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $membCcard = array();
+
+                            // 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($membCcard[$x['member_id']])) {
+                                    $membCcard[$x['member_id']] = array();
+                                }
+
+                                $membCcard[$x['member_id']][] = $x;
+                            }
+                        }
+                    }
+                }
+
+
+                // Read in all member categories
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.category
+                             ORDER BY category_id
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any categories 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 category data, we did not receive the expected number of categories! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the categories into a higherarchical array
+                            $category = array();
+
+                            // Process top level categories first
+                            foreach ($tmp as $x) {
+
+                                // If this is a top level category
+                                if ($x['parent_id'] == 0) {
+                                    $category[$x['category_id']] = $x;
+                                    $category[$x['category_id']]['subcat'] = array();
+                                }
+
+                            }
+
+                            // Now process all sub-categories
+                            reset($tmp);
+                            foreach ($tmp as $x) {
+
+                                // If this is NOT a top level category
+                                if ($x['parent_id'] > 0) {
+
+                                    // Check if we have the requested parent as a top-level category
+                                    if (isset($category[$x['parent_id']])) {
+                                        $category[$x['parent_id']]['subcat'][$x['category_id']] = $x;
+                                    } else {
+                                        $templateData['genError']  = 'There is at least one sub-category that does not have a matching top-level parent! ('.$x['name'].')<br>
+                                                This could be a third-level category. Perhaps we can handle this when we have time to work on this a bit.';
+                                        $failure = true;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+                // Read in member/Category cross-reference table
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.member_category
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any member/category cross-reference entries 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 category data, we did not receive the expected number of categories! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $membCat = array();
+
+                            // 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($membCat[$x['member_id']])) {
+                                    $membCat[$x['member_id']] = array();
+                                }
+
+                                $membCat[$x['member_id']][] = $x;
+                            }
+                        }
+                    }
+                }
+
+
+
+                // Read in all cities
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.city
+                             ORDER BY city_name
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any cities 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 city data, we did not receive the expected number of cities! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $city = array();
+
+                            // Reprocess into array indexed by city_id
+                            foreach ($tmp as $x) {
+                                $city[$x['city_id']] = $x;
+                            }
+                        }
+                    }
+                }
+
+                // Read in all states
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.state
+                             ORDER BY state_name
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any states 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 state data, we did not receive the expected number of states! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $state = array();
+
+                            // Reprocess into array indexed by state_id
+                            foreach ($tmp as $x) {
+                                $state[$x['state_id']] = $x;
+                            }
+                        }
+                    }
+                }
+
+                // Read in all regions
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.region
+                        ;";
+                    $res = pg_query($db, $sql);
+                    $rows = pg_num_rows($res);
+                    if ($rows == 0) {
+                        $templateData['genError']  = 'There does not appear to be any regions 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 region data, we did not receive the expected number of regions! ';
+                            if ($notice) {
+                                $templateData['genError'] .= 'Perhaps the following message will help.<br>'.$notice;
+                            }
+                            $failure = true;
+                        } else {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $region = array();
+
+                            // Reprocess into array indexed by state_id
+                            foreach ($tmp as $x) {
+                                $region[$x['region_id']] = $x;
+                            }
+                        }
+                    }
+                }
+
+
+
+                // Read in all member photos for member image gallery
+                if (!$failure) {
+                    $sql = "
+                            SELECT *
+                              FROM members.member_photos
+                        ;";
+                    $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 {
+
+                            // Since there was no problem, we'll post-process the cities into an array indexed by city_id
+                            $image = array();
+
+                            // 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['member_id']])) {
+                                    $image[$x['member_id']] = array();
+                                }
+
+                                $image[$x['member_id']][] = $x;
+                            }
+                        }
+                    }
+                }
+
+                /*
+                 * If requested, reset the database
+                 */
+
+                // Reset database is Option is selected
+                if (!$failure && isset($_REQUEST['dbReset']) && $_REQUEST['dbReset'] == 'on') {
+
+                    // Get current db version
+                    $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
+
+                    // Reset the database
+                    if (!$this->deleteDataTables($dbVersion)) {
+                        glmMembersAdmin::addNotice('<b>Unable to delete the database tables while resetting the database.</b><br>', 'AdminError');
+                        break;
+                    }
+                    if (!$this->createDataTables($dbVersion)) {
+                        glmMembersAdmin::addNotice('<b>Unable to create the database tables while resetting the database.</b><br>', 'AdminError');
+                        break;
+                    }
+
+                    glmMembersAdmin::addNotice('<b>Database tables have been reset in preparation importing members.</b><br>', 'AdminNotice');
+
+                    // 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 );
+                            }
+                        }
+
+                }
+
+                /*
+                 * Start importing data
+                 */
+
+                if (!$failure) {
+
+                    // Import Cities
+                    while (list ($key, $val) = each ($city) ) {
+
+                        $res = $this->wpdb->insert(
+                                GLM_MEMBERS_PLUGIN_DB_PREFIX.'cities',
+                                array(
+                                        'name' => $val['city_name'],
+                                ),
+                                array(
+                                        '%s',
+                                )
+                        );
+                        $city[$key]['new_id'] = $this->wpdb->insert_id;
+
+                    }
+
+                    // Import Regions
+                    while (list ($key, $val) = each ($region) ) {
+
+                        $res = $this->wpdb->insert(
+                                GLM_MEMBERS_PLUGIN_DB_PREFIX.'regions',
+                                array(
+                                        'name' => $val['region_name'],
+                                        'descr' => '',
+                                        'short_descr' => ''
+                                ),
+                                array(
+                                        '%s',
+                                        '%s',
+                                        '%s'
+                                )
+                        );
+                        $region[$key]['new_id'] = $this->wpdb->insert_id;
+
+                    }
+
+                    // Import Amenities
+                    while (list ($key, $val) = each ($amenity) ) {
+
+                        $res = $this->wpdb->insert(
+                            GLM_MEMBERS_PLUGIN_DB_PREFIX.'amenities',
+                            array(
+                                'active' => true,
+                                'name' => $val['amenity_name'],
+                                'descr' => '',
+                                'short_descr' => '',
+                                'ref_type' => $this->config['ref_type_numb']['MemberInfo']
+                            ),
+                            array(
+                                '%d',
+                                '%s',
+                                '%s',
+                                '%s',
+                                '%d'
+                            )
+                        );
+                        $amenity[$key]['new_id'] = $this->wpdb->insert_id;
+
+                    }
+
+                    // Import Categories
+                    $catTrans = array();
+                    while (list ($key, $val) = each ($category) ) {
+
+                        $res = $this->wpdb->insert(
+                                GLM_MEMBERS_PLUGIN_DB_PREFIX.'categories',
+                                array(
+                                        'name' => $val['name'],
+                                        'descr' => '',
+                                        'short_descr' => '',
+                                        'parent' => 0
+                                ),
+                                array(
+                                        '%s',
+                                        '%s',
+                                        '%s',
+                                        '%d'
+                                )
+                        );
+                        $newID = $this->wpdb->insert_id;
+                        $category[$key]['new_id'] = $newID;
+                        $category[$key]['new_parent'] = 0;
+
+                        $catTrans[$key]  = array(
+                            'new' => $newID,
+                            'parent' => 0
+                        );
+
+                        // Do any sub-cats for this category
+                        while (list ($key2, $val2) = each ($val['subcat']) ) {
+
+                            $res = $this->wpdb->insert(
+                                    GLM_MEMBERS_PLUGIN_DB_PREFIX.'categories',
+                                    array(
+                                            'name' => $val2['name'],
+                                            'descr' => '',
+                                            'short_descr' => '',
+                                            'parent' => $category[$key]['new_id']
+                                    ),
+                                    array(
+                                            '%s',
+                                            '%s',
+                                            '%s',
+                                            '%d'
+                                    )
+                            );
+                            $newID2 = $this->wpdb->insert_id;
+                            $category[$key]['subcat'][$key2]['new_id'] = $newID;
+                            $category[$key]['subcat'][$key2]['new_parent'] = $category[$key]['new_id'];
+
+                            $catTrans[$key2]  = array(
+                                    'new' => $newID2,
+                                    'parent' => $newID
+                            );
+
+                        }
+                    }
+
+
+
+                    // Index Credit Card types - Match to card types in configuration
+                    while (list ($key, $val) = each ($ccard) ) {
+                        reset($this->config['credit_card_numb']);
+                        while (list ($key2, $val2) = each ($this->config['credit_card_numb']) ) {
+                            if (substr($val['ccard_type_name'], 0, 3) == substr(($key2), 0, 3)) {
+                                $ccard[$key]['bitpos'] = $val2;
+                            }
+                        }
+                    }
+
+                    /*
+                     * Create Defaults Not Provided By Old Member DB
+                     */
+
+                    // Member Types
+                    $res = $this->wpdb->insert(
+                            GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_type',
+                            array(
+                                    'name' => 'Default',
+                                    'descr' => '',
+                            ),
+                            array(
+                                    '%s',
+                                    '%s',
+                            )
+                    );
+                    $defaultMemberType = $this->wpdb->insert_id;
+
+                    /*
+                     * Now Start Adding Members
+                     */
+
+                    // Import Members
+                    while (list ($key, $val) = each ($member) ) {
+
+                        $res = $this->wpdb->insert(
+                                GLM_MEMBERS_PLUGIN_DB_PREFIX.'members',
+                                array(
+                                        'access' => $this->config['memb_access_numb']['Full'],
+                                        'member_type' => $defaultMemberType,
+                                        'created' => date('Y-m-d'),
+                                        'name' => $val['member_name']
+                                ),
+                                array(
+                                        '%d',
+                                        '%d',
+                                        '%s',
+                                        '%s'
+                                )
+                        );
+                        $membID = $this->wpdb->insert_id;
+                        $member[$key]['new_id'] = $membID;
+
+                        // Create truncated short_descr from descritions - Less tags, html encoded characters, newlines, tabs, etc.
+                        $stripped = str_replace(PHP_EOL, '', preg_replace('/\t+/', '', preg_replace("/&#?[a-z0-9]{2,8};/i", "", strip_tags($val['description']))));
+                        $short_descr = implode(' ', array_slice(explode(' ', $stripped), 0, 30));
+                        if (strlen($short_descr) < strlen($stripped)) {
+                            $short_descr .= ' ...';
+                        }
+
+                        // Build Credit Card bitmap
+                        $ccBits = 0;
+                        if (isset($membCcard[$val['member_id']])) {
+                            foreach ($membCcard[$val['member_id']] as $c) {
+                                $b = $ccard[$c['ccard_type_id']]['bitpos'];
+                                $ccBits += pow(2, $b);
+                            }
+                        }
+
+                        // Insert Member Information Record
+                        $res = $this->wpdb->insert(
+                                GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info',
+                                array(
+                                        'member' => $membID,
+                                        'member_name' => $val['member_name'],
+                                        'status' => $this->config['status_numb']['Active'],
+                                        'reference_name' => 'Imported Membmer Information',
+                                        'descr' => $val['description'],
+                                        'short_descr' => $short_descr,
+                                        'addr1' => $val['street'],
+                                        'addr2' => '',
+                                        'city' => $city[$val['city_id']]['new_id'],
+                                        'state' => $state[$val['state_id']]['state_abb'],
+                                        'country' => 'US',
+                                        'zip' => $val['zip'],
+                                        'lat' => $val['lat'],
+                                        'lon' => $val['lon'],
+                                        'region' => (isset($region[$val['region']]) ? $region[$val['region']]['new_id'] : 0),
+                                        'phone' => $val['phone'],
+                                        'toll_free' => $val['toll_free'],
+                                        'url' => $val['url'],
+                                        'email' => $val['process_email'],
+                                        'logo' => '',
+                                        'cc_type' => $ccBits,
+                                        'notes' => '',
+                                        'create_time' => $val['create_date'],
+                                        'modify_time' => $val['last_update']
+                                ),
+                                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'
+                                )
+                        );
+                        $mID = $this->wpdb->insert_id;
+                        $member[$key]['new_id'] = $mID;
+
+                        // Add Member Categories
+                        if (isset($membCat[$val['member_id']])) {
+                            foreach ($membCat[$val['member_id']] as $c) {
+
+                                $res = $this->wpdb->insert(
+                                        GLM_MEMBERS_PLUGIN_DB_PREFIX.'category_member_info',
+                                        array(
+                                                'category' => $catTrans[$c['category_id']]['new'],
+                                                'member_info' => $mID
+                                        ),
+                                        array(
+                                                '%d',
+                                                '%d'
+                                        )
+                                );
+
+                            }
+                        }
+
+                        // Add Member Amenities
+                        if (isset($membAmen[$val['member_id']])) {
+                            foreach ($membAmen[$val['member_id']] as $a) {
+
+                                $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' => $mID
+                                        ),
+                                        array(
+                                                '%d',
+                                                '%d',
+                                                '%d'
+                                        )
+                                );
+
+                            }
+                        }
+
+
+                    }
+
+                    // Import
+
+                }
+
+                // If everything is OK, make data available to the template
+                if (!$failure) {
+                    $templateData['member'] = $member;
+                    $templateData['defaultMemberType'] = $defaultMemberType;
+                    $templateData['amenity'] = $amenity;
+                    $templateData['membAmen'] = $membAmen;
+                    $templateData['category'] = $category;
+                    $templateData['membCat'] = $membCat;
+                    $templateData['catTrans'] = $catTrans;
+                    $templateData['city'] = $city;
+                    $templateData['state'] = $state;
+                    $templateData['region'] = $region;
+                    $templateData['ccard'] = $ccard;
+                    $templateData['membCcard'] = $membCcard;
+                    $templateData['image'] = $image;
+                }
+
+
+                if ($failure) {
+                    return array(
+                            'status' => true,
+                            'menuItemRedirect' => 'settings',
+                            'modelRedirect' => 'import',
+                            'view' => 'admin/settings/import.html',
+                            'data' => $templateData
+                    );
+
+                }
+
+                $requestedView = 'import/readDatabase.html';
+
+                break;
+
+            default:
+
+                break;
+
+        }
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status' => true,
+            'menuItemRedirect' => false,
+            'modelRedirect' => false,
+            'view' => 'admin/settings/'.$requestedView,
+            'data' => $templateData
+        );
+
+    }
+
+    /*
+     * Delete Members Database Tables
+     *
+     * @param string $dbVersion Current version of Members Database
+     *
+     * @return boolean
+     * @access public
+     */
+    public function deleteDataTables($dbVersion)
+    {
+
+        // Read in Database deletion script - assumes the current db version.
+        $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/drop_database_V'.$dbVersion.'.sql';
+        $sql = file_get_contents($sqlFile);
+
+        // Replace {prefix} with table name prefix
+        $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+            glmMembersAdmin::addNotice('Dropping all database tables', 'Process');
+            glmMembersAdmin::addNotice($sql, 'DataBlock', 'Drop Tables SQL');
+        }
+
+        // Removing the tables using the script
+        $this->wpdb->query($sql);
+
+        // If there's been an error, display in debug Alert
+        $queryError = $this->wpdb->last_error;
+        if ($queryError) {
+            glmMembersAdmin::addNotice('<b>Error when deleting database: Database tables may not have existed.</b><br>Check following message.<br>'.$queryError, 'AdminError');
+        }
+
+        return true;
+
+    }
+
+    /*
+     * Create Members Database Tables
+     *
+     * @param string $dbVersion Current version of Members Database
+     *
+     * @return boolean
+     * @access public
+     */
+    public function createDataTables($dbVersion)
+    {
+
+        // Read in Database creation script
+        $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/create_database_V'.$dbVersion.'.sql';
+        $sql = file_get_contents($sqlFile);
+
+        // Replace {prefix} with table name prefix
+        $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
+
+        // Split script into separate queries by looking for lines with only "---"
+        $queries = preg_split('/^----$/m', $sql);
+
+        // Try executing all queries to build database
+        $qForDebug = '';
+        do {
+            $q = current($queries);
+            $this->wpdb->query($q);
+            $queryError = $this->wpdb->last_error;
+
+            if ($queryError) {
+                glmMembersAdmin::addNotice('<b>Error when creating database: Database tables may already exist.</b><br>Check following message.<br>'.$queryError, 'AdminError');
+                return false;
+            }
+            $qForDebug .= $queryError.$q;
+
+        } while ($queryError == '' && next($queries));
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+            glmMembersAdmin::addNotice('Creating database tables', 'Process');
+            glmMembersAdmin::addNotice($qForDebug, 'DataBlock', 'Create Tables SQL');
+        }
+
+        return true;
+
+    }
+
+}
+
+?>
\ No newline at end of file
index 87ce81a..da67855 100644 (file)
@@ -6,7 +6,7 @@
       <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->
     
-    {if $memberInfo}
+    {if $memberInfoID && $memberInfo}
         <!--  Delete Member Information dialog -->
         <div id="deleteMemberInfoButton" class="button-primary glm-right">Archive this Member Information</div>
         <div id="deleteMemberInfoDialog" class="glm-dialog-box" title="Delete Member Information">
@@ -29,7 +29,7 @@
     <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
         <input type="hidden" name="glm_action" value="memberInfo">
         <input type="hidden" name="member" value="{$member.id}">
-      {if $memberInfo}
+      {if $memberInfoID && $memberInfo}
         <input type="hidden" name="option" value="submit">
         <input type="hidden" name="id" value="{$memberInfo.fieldData.id}">
         <input type="hidden" name="modify_time" value="now">
@@ -47,7 +47,7 @@
                 <th>Member Type:</th>
                 <td>{$member.member_type.name}</td>
             </tr>            
-      {if $memberInfo}
+      {if $memberInfoID && $memberInfo}
             <tr>
                 <th>Access:</th>
                 <td>{$member.access.name}</td>
     {/if}
             <tr><td colspan="2">&nbsp;</td></tr>
             <tr>
-      {if $memberInfo}
+      {if $memberInfoID && $memberInfo}
             <tr>
                 <th>Created:</th>
                 <td>{$memberInfo.fieldData.create_time.datetime}</td>
             </tr>            
             <tr>
                 <th>Last Updated:</th>
-                <td>{$memberInfo.fieldData.modify_time.datetime}</td>
+                <td>{if isset($create_time)}{$memberInfo.fieldData.modify_time.datetime}{/if}</td>
             </tr>
       {/if}
             <th>Member Info Status:</th>
                     <!-- City Selection -->
                     <input id="cityName" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
                     <select name="city" id="city" class="glm-geocodeAction">
+                        <option value="0"><option>
         {foreach from=$memberInfo.fieldData.city.list item=v}
                         <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
                             {$v.name}
         {/if}
                     </select>&nbsp;&nbsp; Select a category to add to box below.<br>
                     <div id="activeCategories" class="glm-dynSelect-box">
-        {if $memberInfo.fieldData.categories}
+                    
+        {if isset($memberInfo.fieldData.categories) && $memberInfo.fieldData.categories}
             {foreach from=$memberInfo.fieldData.categories item=c}
                         <div data-id="{$c.id}" class="glm-dynSelect-item glm-members-catgegory"> 
                             {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} 
         {/if}
                     </select>&nbsp;&nbsp; Select an amenity to add to box below.<br>
                     <div id="activeAmenities" class="glm-dynSelect-box">
-        {if $memberInfo.fieldData.amenities}
+        {if isset($memberInfo.fieldData.amenities) && $memberInfo.fieldData.amenities}
             {foreach from=$memberInfo.fieldData.amenities item=c}
                         <div data-id="{$c.id}" class="glm-dynSelect-item glm-members-amenity"> 
                             {$c.name} 
             <tr>
                 <th>Image Gallery</th>
                 <td class="glm-item-container glm-imageGalleryContainer">
+                
+    {if $memberInfoID}                
                     <input type="hidden" id="galleryPositionOrder" name="galleryPositionOrder" 
                         value="{if $haveImageGallery}{foreach $imageGallery as $i name=ig}{if $i.file_name}{$i.id}{if not $smarty.foreach.ig.last},{/if}{/if}{/foreach}{/if}" />
                     <div class="glm-imageDropContainer">
             {/foreach}
         {/if}
                     </div>
+    {else}
+                    <b>Note:</b> Images may only be added to member information records that have been created.
+                    You are editing information to create a new record.
+                    <br>After you click "Add new member" below, you may come back here to add images to the gallery.
+    {/if}          
                 </td>
             </tr>
         </table>
                 $( "#largeLogoDialog" ).dialog( "option", "width", newWidth );
             });
 
-    {if $memberInfo}            
+    {if $memberInfoID && $memberInfo}            
             // Delete Member Info dialog
             $("#deleteMemberInfoDialog").dialog({
                 autoOpen: false,
             });
             $('#deleteMemberInfoCancel').click( function() {
                 $("#deleteMemberInfoDialog").dialog("close");
-            });
+            });            
             $('#deleteMemberInfoSubmit').click( function() {
                window.location.replace("{$thisURL}?page={$thisPage}&glm_action=index&member={$memberID}&deleteID={$memberInfo.fieldData.id}");
             });
index fdf136d..10ae4a5 100644 (file)
@@ -6,6 +6,7 @@
         <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index}-active{/if}">General Settings</a>
         <a href="{$thisURL}?page={$thisPage}&glm_action=terms" class="nav-tab{if $thisAction==terms}-active{/if}">Terms and Phrases</a>
         <a href="{$thisURL}?page={$thisPage}&glm_action=development" class="nav-tab{if $thisAction==development}-active{/if}">Development</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=import" class="nav-tab{if $thisAction==import}-active{/if}">Data Import</a>
     </h2>
     <div id="glm-admin-content-container">
     
\ No newline at end of file
diff --git a/views/admin/settings/import.html b/views/admin/settings/import.html
new file mode 100644 (file)
index 0000000..c05d239
--- /dev/null
@@ -0,0 +1,95 @@
+{include file='admin/settings/header.html'}
+    
+    <p>Note: Customers will not have access to this tab.</p>
+    
+    <h2>Data Import</h2>
+    <p>
+        This process export data from a legacy Gaslight Media Member DB database and imports that data into this plugin. It will only work with a Postgres database.
+        The process will include the following steps.
+    </p>
+    <ol>
+        <li class="glm-ol-selected">Provide information on the legacy database from which we'll be extracting data.</li>
+        <li>Test that database to make sure it's compatible with this process.</li>
+        <li>Read the needed data from the legacy database.</li>
+        <li>Review the extracted data to make sure it looks like the data you want to import.</li>
+        <li>Import the extracted data into is plugin</li>
+        <li>Review resulst</li>
+    </ol>
+    
+
+    <h3>Data Import Step 1</h3>
+{if isset($genError)}    
+    <p>
+        <h3 class="glm-error">Oops!</h3>
+        <p class="glm-error">{$genError}</p>
+    </p>
+{/if}    
+    <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="import">
+        <input type="hidden" name="option" value="readDatabase">
+        
+        <table class="glm-admin-table">
+        
+            <!-- Debug Settings -->
+        
+            <tr>
+                <th>Database Server: </th>
+                <td>
+                    <input class="glm-form-text-input-medium" type="text" name="dbServer" placeholder="(complete host name or IP address)" value="{if isset($dbServer)}{$dbServer.value}{/if}">
+       {if isset($dbServer)}
+                    <p class="glm-error">{$dbServer.problem}</p>
+       {/if}
+                </td>
+            </tr>
+            <tr>
+                <th>Database Port #: </th>
+                <td>
+                    <input class="glm-form-text-input-short" type="text" name="dbPort" value="{if isset($dbPort)}{$dbPort.value}{else}5432{/if}">
+       {if isset($dbPort)}
+                    <p class="glm-error">{$dbPort.problem}</p>
+       {/if}
+                </td>
+            </tr>
+            <tr>
+                <th>Database Name: </th>
+                <td>
+                    <input class="glm-form-text-input-medium" type="text" name="dbName" placeholder="(name of database}" value="{if isset($dbName)}{$dbName.value}{/if}">
+       {if isset($dbName)}
+                    <p class="glm-error">{$dbName.problem}</p>
+       {/if}
+                </td>
+            </tr>
+            <tr>
+                <th>Database User: </th>
+                <td>
+                    <input class="glm-form-text-input-medium" type="text" name="dbUser" placeholder="(user with read access to this database)" value="{if isset($dbUser)}{$dbUser.value}{/if}">
+        {if isset($dbUser)}
+                    <p class="glm-error">{$dbUser.problem}</p>
+       {/if}
+                </td>
+            </tr>
+            <tr>
+                <th>Base Original Image URL: </th>
+                <td>
+                    <input class="glm-form-text-input-medium-long" type="text" name="dbImageURL" placeholder="(i.e. http://is0.gaslightmedia.com/mountpleasantwow/original/)" value="{if isset($dbImageURL)}{$dbImageURL.value}{/if}">
+        {if isset($dbImageURL)}
+                    <p class="glm-error">{$dbImageURL.problem}</p>
+       {/if}
+                </td>
+            </tr>
+            <tr>
+                <th>Reset Database Before Import: </th>
+                <td>
+                    <input type="checkbox" name="dbReset">
+                    <br>NOTE: Selecting this option will remove all existing data from the Member database!
+                    <br>If you do not select this option, the new data will be added to the database and there will be no attempt to match up imported data with the existing data.
+                </td>
+            </tr>
+        </table>
+        
+        <input type="submit" value="Select Member" class="button-primary">
+        
+    </form>
+            
+    
+{include file='admin/footer.html'}
diff --git a/views/admin/settings/import/readDatabase.html b/views/admin/settings/import/readDatabase.html
new file mode 100644 (file)
index 0000000..7fe5168
--- /dev/null
@@ -0,0 +1,56 @@
+{include file='admin/settings/header.html'}
+    
+    <p>Note: Customers will not have access to this tab.</p>
+    
+    <h2>Data Import - Test Database</h2>
+    <ol>
+        <li>Provide information on the legacy database from which we'll be extracting data.</li>
+        <li class="glm-ol-selected">Test database to make sure it's compatible with this process.</li>
+        <li>Read the needed data from the legacy database.</li>
+        <li>Review the extracted data to make sure it looks like the data you want to import.</li>
+        <li>Import the extracted data into is plugin</li>
+        <li>Review resulst</li>
+    </ol>
+    
+
+    <h3>Data Import Step 2</h3>
+{if isset($genError)}    
+    <p>
+        <h3 class="glm-error">Oops!</h3>
+        <p class="glm-error">{$genError}</p>
+    </p>
+{/if}    
+    <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="import">
+        <input type="hidden" name="option" value="testDatabase">
+        
+        <table class="glm-admin-table">
+        
+            <!-- Debug Settings -->
+        
+            <tr>
+                <th>Database Server: </th>
+                <td>
+                    <input type="text" name="dbServer" placeholder="(complete host name or IP address)">
+                </td>
+            </tr>
+            <tr>
+                <th>Database Name: </th>
+                <td>
+                    <input type="text" name="dbName" placeholder="(name of database}">
+                </td>
+            </tr>
+            <tr>
+                <th>Database User: </th>
+                <td>
+                    <input type="text" name="dbUser" placeholder="(user with read access to this database)">
+                </td>
+            </tr>
+        </table>
+        
+        <input type="submit" value="Select Member" class="button-primary">
+        
+    </form>
+            
+    
+{include file='admin/footer.html'}