Add reservation url for member import
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 27 Feb 2018 19:59:30 +0000 (14:59 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 27 Feb 2018 20:00:03 +0000 (15:00 -0500)
Adding the member reservation url for the member import.

models/admin/management/import/members.php

index 8c49627..502cdc2 100644 (file)
@@ -198,6 +198,29 @@ if (!$failure) {
     }
 }
 
+// Read in member/reservation url data
+// accommodation table
+if (!$failure) {
+    $sql = "
+    SELECT member_id,reservation_url
+      FROM $dbSchema.member_accommodations
+     WHERE reservation_url != ''
+       AND reservation_url IS NOT NULL";
+    $res  = pg_query($db, $sql);
+    $rows = pg_num_rows($res);
+    if ($rows > 0) {
+        $tmp = pg_fetch_all($res);
+        $membAccomm = array();
+
+        // Reproccess into array grouped by member with the main index
+        foreach ( $tmp as $x ) {
+            $membAccomm[$x['member_id']] = $x['reservation_url'];
+        }
+    }
+}
+// echo '<pre>$membAccomm: ' . print_r( $membAccomm, true ) . '</pre>';
+// exit;
+
 // Read in all credit card types
 if (!$failure) {
     $sql = "
@@ -832,36 +855,37 @@ if (!$failure) {
         $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 Member Information',
-                    'descr'          => preg_replace('%[\n\r]%', '', $val['description']),
-                    'short_descr'    => $short_descr,
-                    'addr1'          => $val['street'],
-                    'addr2'          => '',
-                    'city'           => ( (isset($city[$val['city_id']]['new_id']) && $city[$val['city_id']]['new_id']) ? $city[$val['city_id']]['new_id']: 0 ),
-                    '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),
-                    'phone'          => $val['phone'],
-                    'toll_free'      => $val['toll_free'],
-                    'url'            => ((strlen($val['url']) > 255) ?  substr($val['url'], 0, 250) : $val['url']),
-                    'email'          => $val['member_contact_email'],
-                    'logo'           => '',
-                    'cc_type'        => $ccBits,
-                    'notes'          => '',
-                    'create_time'    => $val['create_date'],
-                    'modify_time'    => $val['last_update']
+                    'member'          => $membID,
+                    'member_name'     => $val['member_name'],
+                    'status'          => $this->config['status_numb']['Active'],
+                    'reference_name'  => 'Imported Member Information',
+                    'descr'           => preg_replace('%[\n\r]%', '', $val['description']),
+                    'short_descr'     => $short_descr,
+                    'addr1'           => $val['street'],
+                    'addr2'           => '',
+                    'city'            => ( (isset($city[$val['city_id']]['new_id']) && $city[$val['city_id']]['new_id']) ? $city[$val['city_id']]['new_id']: 0 ),
+                    '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),
+                    'phone'           => $val['phone'],
+                    'toll_free'       => $val['toll_free'],
+                    'url'             => ((strlen($val['url']) > 255) ? substr($val['url'], 0, 250) : $val['url']),
+                    'reservation_url' => ((isset($membAccomm[$val['member_id']]) && $membAccomm[$val['member_id']] ) ? $membAccomm[$val['member_id']]: ''),
+                    'email'           => $val['member_contact_email'],
+                    'logo'            => '',
+                    'cc_type'         => $ccBits,
+                    'notes'           => '',
+                    'create_time'     => $val['create_date'],
+                    'modify_time'     => $val['last_update']
                 ),
                 array(
                     '%d', // member id
@@ -888,6 +912,7 @@ if (!$failure) {
                     '%s', // phone
                     '%s', // toll_free
                     '%s', // url
+                    '%s', // reservation url
                     '%s', // email
                     '%s', // logo
                     '%d', // email