From b78117e2c2406eee2d7690f32dc5591fc3cf11d1 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 21 Jun 2017 12:35:38 -0400 Subject: [PATCH] Updating member import scripts Adding in mailing address city state zip. --- models/admin/management/import/members.php | 73 ++++++++++++------- ..._V1.1.31.sql => drop_database_V1.1.32.sql} | 0 views/admin/management/import.html | 1 - 3 files changed, 46 insertions(+), 28 deletions(-) rename setup/databaseScripts/{drop_database_V1.1.31.sql => drop_database_V1.1.32.sql} (100%) diff --git a/models/admin/management/import/members.php b/models/admin/management/import/members.php index ab7db7dc..34c6fd0d 100644 --- a/models/admin/management/import/members.php +++ b/models/admin/management/import/members.php @@ -418,9 +418,10 @@ if (!$failure) { // 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 + // Reprocess into array indexed by city_id and by city_name foreach ($tmp as $x) { $city[$x['city_id']] = $x; + $cityNames[$x['city_name']] = $x['city_id']; } } } @@ -550,11 +551,11 @@ if (!$failure && isset($_REQUEST['dbReset']) && $_REQUEST['dbReset'] == 'on') { // Reset the database if (!$this->deleteDataTables($dbVersion)) { glmMembersAdmin::addNotice('Unable to delete the database tables while resetting the database.
', 'AdminError'); - break; + //break; } if (!$this->createDataTables($dbVersion)) { glmMembersAdmin::addNotice('Unable to create the database tables while resetting the database.
', 'AdminError'); - break; + //break; } glmMembersAdmin::addNotice('Database tables have been reset in preparation importing members.
', 'AdminNotice'); @@ -812,6 +813,12 @@ if (!$failure) { } } $this->wpdb->show_errors(); + + // Find the city id if mailing city is given + // Need the new city id inserted. + $mailingOldCityId = ( ( isset( $cityNames[$val['mailing_city']] ) && $val['mailing_city'] ) ? $cityNames[$val['mailing_city']] : 0 ); + $mailingCityId = ( (isset($city[$mailingOldCityId]['new_id'] ) && $city[$mailingOldCityId]['new_id'] ) ? $city[$mailingOldCityId]['new_id']: 0 ); + // Insert Member Information Record $res = $this->wpdb->insert( GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info', @@ -828,6 +835,12 @@ if (!$failure) { 'state' => $state[$val['state_id']]['state_abb'], 'country' => 'US', 'zip' => $val['zip'], + + 'mailing_addr1' => $val['mailing_address'], + 'mailing_city' => $mailingCityId, + 'mailing_state' => ( (isset($state[$val['mailing_state_id']]['state_abb']) && $val['mailing_state_id']) ? $state[$val['mailing_state_id']]['state_abb']: ''), + 'mailing_zip' => $val['mailing_zip'], + 'lat' => $val['lat'], 'lon' => $val['lon'], 'region' => (isset($region[$val['region']]) ? $region[$val['region']]['new_id'] : 0), @@ -842,30 +855,36 @@ if (!$failure) { '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' + '%d', // member id + '%s', // name + '%d', // status + '%s', // ref name + '%s', // descr + '%s', // short_descr + '%s', // addr1 + '%s', // addr2 + '%d', // city + '%s', // state + '%s', // country + '%s', // zip + + '%s', // mailing addr1 + '%d', // mailing city + '%s', // mailing state + '%s', // mailing zip + + '%f', // lat + '%f', // lon + '%d', // region + '%s', // phone + '%s', // toll_free + '%s', // url + '%s', // email + '%s', // logo + '%d', // email + '%s', // notes + '%s', // create_time + '%s' // modify_time ) ); $infoID = $this->wpdb->insert_id; diff --git a/setup/databaseScripts/drop_database_V1.1.31.sql b/setup/databaseScripts/drop_database_V1.1.32.sql similarity index 100% rename from setup/databaseScripts/drop_database_V1.1.31.sql rename to setup/databaseScripts/drop_database_V1.1.32.sql diff --git a/views/admin/management/import.html b/views/admin/management/import.html index 5cdffad7..115d1f63 100644 --- a/views/admin/management/import.html +++ b/views/admin/management/import.html @@ -20,7 +20,6 @@ Import member Clicks and Views
Import member Mailing Addresses
List old/new member IDs
- Import Trail Maps -- 2.17.1