Database updates
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 26 Jul 2018 14:25:22 +0000 (10:25 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 26 Jul 2018 14:39:57 +0000 (10:39 -0400)
Adding new fields for Organization / Company
Adding flags for publish and use as billing for Org and contact info

classes/data/dataContacts.php
index.php
setup/databaseScripts/create_database_V0.0.3.sql [deleted file]
setup/databaseScripts/create_database_V0.0.4.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.4.sql [new file with mode: 0644]

index be75079..51de016 100644 (file)
@@ -448,7 +448,103 @@ class GlmDataContacts extends GlmDataAbstract
                     'p_blank' => true,
                 'required' => true,
                 'use' => 'lged'
-            )
+            ),
+
+            // Address line 1
+            'business_addr1' => array (
+                'field' => 'business_addr1',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Address line 2
+            'business_addr2' => array (
+                'field' => 'business_addr2',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // City
+            'business_city' => array (
+                'field' => 'business_city',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                    'p_blank' => true,
+                'use' => 'a'
+            ),
+
+            // State
+            'business_state' => array (
+                'field' => 'business_state',
+                'type' => 'list',
+                'list' => $this->config['states'],
+                'default' => 'MI',
+                'use' => 'a'
+            ),
+
+            // ZIP / Postal Code
+            'business_zip' => array (
+                'field' => 'business_zip',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Country
+            'business_country' => array (
+                'field' => 'business_country',
+                'type' => 'list',
+                'list' => $this->config['countries'],
+                'default' => 'US',
+                'use' => 'a'
+            ),
+
+            // E-Mail Address
+            'business_email' => array(
+                'field'    => 'business_email',
+                'type'     => 'email',
+                'use'      => 'a'
+            ),
+
+            // E-Mail Address
+            'business_mobile' => array(
+                'field'    => 'business_mobile',
+                'type'     => 'phone',
+                'use'      => 'a'
+            ),
+
+            // Contact Publish Flag
+            'contact_publish' => array (
+                'field' => 'contact_publish',
+                'type' => 'checkbox',
+                'default' => false,
+                'use' => 'a'
+            ),
+
+            // Contact Use As Billing Flag
+            'contact_use_billing' => array (
+                'field' => 'contact_use_billing',
+                'type' => 'checkbox',
+                'default' => false,
+                'use' => 'a'
+            ),
+
+            // Org Publish Flag
+            'business_publish' => array (
+                'field' => 'business_publish',
+                'type' => 'checkbox',
+                'default' => false,
+                'use' => 'a'
+            ),
+
+            // Org Use As Billing Flag
+            'business_use_billing' => array (
+                'field' => 'business_use_billing',
+                'type' => 'checkbox',
+                'default' => false,
+                'use' => 'a'
+            ),
 
         );
 
index 7eac47b..df2da4c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -40,7 +40,7 @@ if (!defined('ABSPATH')) {
  *  version nunmber of that release for the DB version.
  */
 define('GLM_MEMBERS_CONTACTS_PLUGIN_VERSION', '1.1.10');
-define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_VERSION', '0.0.3');
+define('GLM_MEMBERS_CONTACTS_PLUGIN_DB_VERSION', '0.0.4');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.58');
diff --git a/setup/databaseScripts/create_database_V0.0.3.sql b/setup/databaseScripts/create_database_V0.0.3.sql
deleted file mode 100644 (file)
index b74ad14..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
--- Gaslight Media Members Database 
--- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.3
--- Database Creation Script - Contacts Add-On
--- 
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
--- 
--- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
--- 
-
--- Contacts - used by various entities
-CREATE TABLE {prefix}contacts (
-  id INT NOT NULL AUTO_INCREMENT,
-  active BOOLEAN NULL,                      -- Contact is active flag
-  access INT NULL,                          -- Access type - See access table in plugin.ini
-  primary_contact BOOLEAN NULL,             -- Contact is the "Primary Contact" for mailings to entity (ref_type/ref_dest)
-  fname TINYTEXT NULL,                      -- First name of contact
-  lname TINYTEXT NULL,                      -- Last name of contact
-  contact_type INT NULL,                    -- Contact type - see contact_type table (individual, role, ...)
-  contact_role INT NULL,                    -- Contact WordPress user Role
-  org TINYTEXT NULL,                        -- Organization name
-  title TINYTEXT NULL,                      -- Title/Position
-  descr TEXT NULL,                          -- Description of position/responsibilities - Displayed
-  image TINYTEXT NULL,                      -- Image
-  addr1 TINYTEXT NULL,                      -- Address line 1 - Address is for contact, not necessarily for organization
-  addr2 TINYTEXT NULL,                      -- Address line 2 
-  county TINYTEXT NULL,                     -- County
-  city INT NULL,                            -- Pointer to city in cities table
-  state TINYTEXT NULL,                      -- Two character state code - matches states.ini entries
-  country TINYTEXT NULL,                    -- Two character country code - matches countries.ini entries 
-  zip TINYTEXT NULL,                        -- ZIP/Postal Code     
-  lat FLOAT NULL,                           -- Latitude of contact location
-  lon FLOAT NULL,                           -- Longitude of contact location
-  url TINYTEXT NULL,                        -- URL to information regarding this contact
-  office_phone TINYTEXT NULL,               -- Office phone number
-  home_phone TINYTEXT NULL,                 -- Home phone number - or after-hours phone number
-  mobile_phone TINYTEXT NULL,               -- Mobile phone number
-  alt_phone TINYTEXT NULL,                  -- An alternate phone number
-  fax TINYTEXT NULL,                        -- FAX number (do people still use these?) 
-  email TINYTEXT NULL,                      -- E-Mail address
-  alt_email TINYTEXT NULL,                  -- Alternate E-Mail address - Also used to log-in 
-  username TINYTEXT NULL,                   -- Optional username to use for login
-  password TINYTEXT NULL,                   -- Encrypted password
-  notes TEXT NULL,                          -- Notes - Not displayed on front-end
-  create_time TIMESTAMP NULL,               -- Create date/time
-  modify_time TIMESTAMP NULL,               -- Last modified date/time
-  ref_type INT NULL,                        -- Type of entity this contact is associated with                        
-  ref_dest INT NULL,                        -- Pointer to the specific entity of ref_type this contact is associated with
-  PRIMARY KEY (id),
-  INDEX(fname(20)),
-  INDEX(lname(20)),
-  INDEX(city),
-  INDEX(zip(10)),
-  INDEX(lat),
-  INDEX(lon),
-  INDEX(email(20))
-);
diff --git a/setup/databaseScripts/create_database_V0.0.4.sql b/setup/databaseScripts/create_database_V0.0.4.sql
new file mode 100644 (file)
index 0000000..bebb7c2
--- /dev/null
@@ -0,0 +1,70 @@
+-- Gaslight Media Members Database
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 0.0.4
+-- Database Creation Script - Contacts Add-On
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+--
+-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
+--
+
+-- Contacts - used by various entities
+CREATE TABLE {prefix}contacts (
+  id INT NOT NULL AUTO_INCREMENT,
+  active BOOLEAN NULL,                      -- Contact is active flag
+  access INT NULL,                          -- Access type - See access table in plugin.ini
+  primary_contact BOOLEAN NULL,             -- Contact is the "Primary Contact" for mailings to entity (ref_type/ref_dest)
+  fname TINYTEXT NULL,                      -- First name of contact
+  lname TINYTEXT NULL,                      -- Last name of contact
+  contact_type INT NULL,                    -- Contact type - see contact_type table (individual, role, ...)
+  contact_role INT NULL,                    -- Contact WordPress user Role
+  org TINYTEXT NULL,                        -- Organization name
+  title TINYTEXT NULL,                      -- Title/Position
+  descr TEXT NULL,                          -- Description of position/responsibilities - Displayed
+  image TINYTEXT NULL,                      -- Image
+  addr1 TINYTEXT NULL,                      -- Address line 1 - Address is for contact, not necessarily for organization
+  addr2 TINYTEXT NULL,                      -- Address line 2
+  county TINYTEXT NULL,                     -- County
+  city INT NULL,                            -- Pointer to city in cities table
+  state TINYTEXT NULL,                      -- Two character state code - matches states.ini entries
+  country TINYTEXT NULL,                    -- Two character country code - matches countries.ini entries
+  zip TINYTEXT NULL,                        -- ZIP/Postal Code
+  lat FLOAT NULL,                           -- Latitude of contact location
+  lon FLOAT NULL,                           -- Longitude of contact location
+  url TINYTEXT NULL,                        -- URL to information regarding this contact
+  home_phone TINYTEXT NULL,                 -- Home phone number - or after-hours phone number
+  mobile_phone TINYTEXT NULL,               -- Mobile phone number
+  alt_phone TINYTEXT NULL,                  -- An alternate phone number
+  email TINYTEXT NULL,                      -- E-Mail address
+  alt_email TINYTEXT NULL,                  -- Alternate E-Mail address - Also used to log-in
+  username TINYTEXT NULL,                   -- Optional username to use for login
+  password TINYTEXT NULL,                   -- Encrypted password
+  notes TEXT NULL,                          -- Notes - Not displayed on front-end
+  create_time TIMESTAMP NULL,               -- Create date/time
+  modify_time TIMESTAMP NULL,               -- Last modified date/time
+  ref_type INT NULL,                        -- Type of entity this contact is associated with
+  ref_dest INT NULL,                        -- Pointer to the specific entity of ref_type this contact is associated with
+  business_addr1 TINYTEXT NULL,             -- Org Address 1
+  business_addr2 TINYTEXT NULL,             -- Org Address 2
+  business_city INT NULL,                   -- Org City
+  business_state TINYTEXT NULL,             -- Org State
+  business_zip TINYTEXT NULL,               -- Org Zip
+  business_country TINYTEXT NULL,           -- Org Country
+  business_email TINYTEXT NULL,             -- Org Email
+  office_phone TINYTEXT NULL,               -- Org Office phone number
+  business_mobile TINYTEXT NULL,            -- Org Mobile
+  fax TINYTEXT NULL,                        -- Org FAX number (do people still use these?)
+  contact_publish BOOLEAN NULL,             -- Flag to publish Contact Info to Directory
+  contact_use_billing BOOLEAN NULL,         -- Flag to use Contact Info as Billing
+  business_publish BOOLEAN NULL,            -- Flag to publish Business to Directory
+  business_use_billing BOOLEAN NULL,        -- Flag to use Business as Billing
+  PRIMARY KEY (id),
+  INDEX(fname(20)),
+  INDEX(lname(20)),
+  INDEX(city),
+  INDEX(zip(10)),
+  INDEX(lat),
+  INDEX(lon),
+  INDEX(email(20))
+);
index 8eff965..c584960 100644 (file)
@@ -29,7 +29,8 @@
 $glmMembersContactsDbVersions = array(
     '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '4/15/2016'),
     '0.0.2' => array('version' => '0.0.2', 'tables' => 1, 'date' => '7/25/2016'),
-    '0.0.3' => array('version' => '0.0.3', 'tables' => 1, 'date' => '1/11/2017')
+    '0.0.3' => array('version' => '0.0.3', 'tables' => 1, 'date' => '1/11/2017'),
+    '0.0.4' => array('version' => '0.0.4', 'tables' => 1, 'date' => '07/26/2018'),
 );
 
 
diff --git a/setup/databaseScripts/update_database_V0.0.4.sql b/setup/databaseScripts/update_database_V0.0.4.sql
new file mode 100644 (file)
index 0000000..e1c2ed9
--- /dev/null
@@ -0,0 +1,53 @@
+-- Gaslight Media Members Database  - Contacts Add-On
+-- File Created: 2018-07-26
+-- Database Version: 0.0.4
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_addr1 TINYTEXT NULL;             -- Org Address 1
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_addr2 TINYTEXT NULL;             -- Org Address 2
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_city INT NULL;                   -- Org City
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_state TINYTEXT NULL;             -- Org State
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_zip TINYTEXT NULL;               -- Org Zip
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_country TINYTEXT NULL;           -- Org Country
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_email TINYTEXT NULL;             -- Org Email
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_mobile TINYTEXT NULL;            -- Org Mobile
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN contact_publish BOOLEAN NULL;             -- Flag to publish Contact Info to Directory
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN contact_use_billing BOOLEAN NULL;         -- Flag to use Contact Info as Billing
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_publish BOOLEAN NULL;            -- Flag to publish Business to Directory
+
+----
+
+ALTER TABLE {prefix}contacts ADD COLUMN business_use_billing BOOLEAN NULL;        -- Flag to use Business as Billing