Update for the add new city for business_city
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Feb 2019 21:20:51 +0000 (16:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Feb 2019 21:20:51 +0000 (16:20 -0500)
Need to add new business_city

models/admin/contacts/index.php

index d059439..01cd30d 100644 (file)
@@ -829,21 +829,16 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
      */
     public function checkNewCities($contactID)
     {
-
         // If we have a contact ID and this was a submission with a new city (id < 0)
         if ($contactID && isset($_REQUEST['city']) && $_REQUEST['city'] == -1 && isset($_REQUEST['newCityName']) && trim($_REQUEST['newCityName']) != '') {
-
             // Clean up city name
             $cName = trim(filter_var($_REQUEST['newCityName']));
-
             // Try to add the city
             require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
             $Cities = new GlmDataCities($this->wpdb, $this->config);
             $cID = $Cities->addCity($cName);
-
             // If we got a city id back
             if (is_int($cID) && $cID > 0) {
-
                 // Update the city selected for this contact record
                 $sql = "
                         UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX."contacts
@@ -851,12 +846,32 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
                             WHERE id = ".$contactID."
                             ;";
                 $this->wpdb->query($sql);
-
                 // Update submitted city value to use the new ID
                 $_REQUEST['city'] = $cID;
+            }
+        }
 
+        if ($contactID && isset($_REQUEST['business_city']) && $_REQUEST['business_city'] == -1 && isset($_REQUEST['newBusinessCityName']) && trim($_REQUEST['newBusinessCityName']) != '') {
+            // Clean up city name
+            $cName = trim(filter_var($_REQUEST['newBusinessCityName']));
+            // Try to add the city
+            require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
+            $Cities = new GlmDataCities($this->wpdb, $this->config);
+            $cID = $Cities->addCity($cName);
+            // If we got a city id back
+            if (is_int($cID) && $cID > 0) {
+                // Update the city selected for this contact record
+                $sql = "
+                        UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX."contacts
+                            SET business_city = $cID
+                            WHERE id = ".$contactID."
+                            ;";
+                $this->wpdb->query($sql);
+                // Update submitted city value to use the new ID
+                $_REQUEST['business_city'] = $cID;
             }
         }
+
     }
 
     /*