A bunch of requested changes. Not fully debugged
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 4 Apr 2016 20:28:53 +0000 (16:28 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 4 Apr 2016 20:28:53 +0000 (16:28 -0400)
17 files changed:
classes/data/dataEvents.php
index.php
setup/databaseScripts/create_database_V0.0.8.sql [deleted file]
setup/databaseScripts/create_database_V0.0.9.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.3.sql
setup/databaseScripts/update_database_V0.0.4.sql
setup/databaseScripts/update_database_V0.0.5.sql
setup/databaseScripts/update_database_V0.0.7.sql
setup/databaseScripts/update_database_V0.0.8.sql
setup/databaseScripts/update_database_V0.0.9.sql [new file with mode: 0644]
views/admin/events/edit.html
views/admin/events/editAdminContact.html [new file with mode: 0644]
views/admin/events/editLocation.html
views/admin/events/editSchedule.html
views/admin/events/editSettings.html [deleted file]
views/admin/events/editStatus.html

index 7d0b1c6..e258e8b 100644 (file)
@@ -301,9 +301,23 @@ class GlmDataEvents extends GlmDataAbstract
                 'use'      => 'a'
             ),
 
-            // Event Phone
-            'phone' => array (
-                'field' => 'phone',
+            // Contact name
+            'contact_name' => array (
+                'field' => 'contact_name',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Contact email
+            'contact_email' => array (
+                'field' => 'contact_email',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Contact Phone
+            'contact_phone' => array (
+                'field' => 'contact_phone',
                 'type' => 'text',
                 'use' => 'a'
             ),
@@ -322,6 +336,13 @@ class GlmDataEvents extends GlmDataAbstract
                 'use' => 'a'
             ),
 
+            // Free
+            'free' => array(
+                'field' => 'free',
+                'type' => 'checkbox',
+                'use' => 'a'
+            ),
+
             // Cost (description)
             'cost' => array (
                 'field' => 'cost',
@@ -329,6 +350,14 @@ class GlmDataEvents extends GlmDataAbstract
                 'use' => 'a'
             ),
 
+            // Use Member Location rather than location table
+            'use_member_location' => array (
+                'field' => 'use_member_location',
+                'type' => 'checkbox',
+                'default' => false,
+                'use' => 'a'
+            ),
+
             // Admin Reference Type
             'admin_ref_type' => array (
                 'field' => 'admin_ref_type',
@@ -452,33 +481,86 @@ class GlmDataEvents extends GlmDataAbstract
     }
 
     /**
-     * Update event slug - should be called after an event record is added or updated
+     * Update event slug - should be called after an event record is added or updated.
+     *
+     * Since slugs must be unique, if there's already a slug matching the slug directly
+     * derived from the event name, then append "-n" where n is a sequential number
+     * that makes the slug unique.
+     *
+     * This function will try numbers from 1 to $maxTries to get a unique slug.
      *
      * @param integer id ID of event that needs the slug updated
+     * @param integer maxTries Maximum number of tries to create a unique slug
+     *      default 100
      *
+     * @return string Slug stored in this event record
+     *      If this function fails, it will return false.
      * @access public
      */
-    public function updateSlug($id = false)
+    public function updateSlug($id = false, $maxTries = 100)
     {
 
         if ($id == false) {
             return false;
         }
 
+        // Get the event entry
         $e = $this->getEntry($id);
+        if (!$e) {
+            return false;
+        }
 
+        // Make a slug out of the event name
         $slug = sanitize_title($e['name']);
 
-        // Update the city selected for this memberInfo record
+        // If slug is the same as it was then do nothing
+        if ($e['name_slug'] == $slug) {
+            return $slug;
+        }
+
+        // Loop until we have a unique slug - limit loops to 50 just in case
+        $saveSlug = $slug;
+        for ($loop = 1 ; $loop <= $maxTries ; $loop++) {
+
+            // New Slug - Check if the new slug is unique
+            $matchingSlugs = $this->wpdb->get_results(
+                "
+                SELECT id, name_slug
+                  FROM ".$this->table."
+                 WHERE name_slug = '$slug'
+                   AND id != $id
+                ",
+                ARRAY_A
+            );
+
+            // If there's no matching results then we're good to use this one
+            if (!is_array($matchingSlugs) || count($matchingSlugs) == 0) {
+
+                // Write new slug and return
+                $sql = "
+                    UPDATE ".$this->table."
+                       SET name_slug = '$slug'
+                     WHERE id = $id
+                ;";
+                $this->wpdb->query($sql);
+
+                return $slug;
+
+            }
+
+            $slug = $saveSlug."-$loop";
+
+        } // for
+
+        // Unable to create unique slug
         $sql = "
             UPDATE ".$this->table."
-               SET name_slug = '$slug'
+               SET name_slug = ''
              WHERE id = $id
         ;";
         $this->wpdb->query($sql);
 
-        return $slug;
-
+        return false;
     }
 
     /**
index e9eb14e..187bdf9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -39,7 +39,7 @@
  *  version from this plugin.
  */
 define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.8');
+define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.9');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_EVENTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.58');
diff --git a/setup/databaseScripts/create_database_V0.0.8.sql b/setup/databaseScripts/create_database_V0.0.8.sql
deleted file mode 100644 (file)
index b22ddf4..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
--- Gaslight Media Members Database - Events Add-On
--- File Created: 12/02/15 15:27:15
--- Database Version: 0.0.1
--- Database Creation Script
---
--- This file is called to create a new set of tables for this
--- add-on for the most recent database version for this add-on.
---
--- There should only be one such file in this directory
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
--- Categories - Categories for events
-CREATE TABLE {prefix}categories (
-  id INT NOT NULL AUTO_INCREMENT,
-  name TINYTEXT NULL,                                   -- Name of event category
-  descr TINYTEXT NULL,                                  -- Description of this category
-  parent INT NULL,                                      -- Parent category, null or 0 if this is a top level category
-  PRIMARY KEY (id),
-  INDEX(parent)
-);
-
-----
-
--- Event-Category - Categories for specific event records
-CREATE TABLE {prefix}event_categories (
-  id INT NOT NULL AUTO_INCREMENT,
-  event INT NULL,                                       -- Pointer to the event
-  category INT NULL,                                    -- Pointer to the category
-  PRIMARY KEY (id),
-  INDEX(event),
-  INDEX(category)
-);
-
-----
-
--- Event Recurrence - Defines how an event recurs
-CREATE TABLE {prefix}recurrences (
-  id INT NOT NULL AUTO_INCREMENT,
-  event INTEGER NULL,                                   -- Pointer to event
-  name TINYTEXT NULL,                                   -- Name of this recurrence schedule - used on admin calendar
-  start_time DATETIME NULL,                             -- Start of first occurrence (date and time)
-  start_time_only BOOLEAN NULL,                         -- Use end of first occurrence flag
-  end_time DATETIME NULL,                               -- End of first occurrence (date and time)
-  all_day BOOLEAN NULL,                                 -- Flag indicating if this is an all-day event (informational only)
-  start_date DATE NULL,                                 -- Starting Date (if all_day is selected) Used instead of start_time
-  from_date DATE NULL,                                  -- From Date for recurrences
-  to_date DATE NULL,                                    -- To Date for recurrences
-  all_dates BOOLEAN NULL,                               -- Flag indicating that event recurs on all dates from from_date through to_date
-  month_of_year SMALLINT UNSIGNED NULL,                 -- Month of year (bitmap)
-  week_of_month TINYINT UNSIGNED NULL,                  -- Week of the month (bitmap)
-  day_of_week TINYINT UNSIGNED NULL,                    -- Day of the week (bitmap)
-  by_day_of_month BOOLEAN NULL,                         -- Flag indicating if selecting by days of the month
-  day_of_month INTEGER UNSIGNED NULL,                   -- Day of the month (bitmap)
-  last_day_of_month BOOLEAN NULL,                       -- Last day of the month
-  holiday INT NULL,                                     -- Pointer to holidays list (for future development)
-  holiday_offset TINYINT,                               -- Offset from holiday (from -128 to +127 days)
-  PRIMARY KEY (id),
-  INDEX(event)
-);
-
-----
-
--- Times - List of actual event times for single and recurring events
-CREATE TABLE {prefix}times (
-  id INT NOT NULL AUTO_INCREMENT,
-  event INT NULL,                                       -- Pointer to the primary record for the event
-  custom_event INT NULL,                                -- Pointer to a customized copy of the event record (if set)
-  recur_id INT NULL,                                    -- Pointer to recurrence entry
-  active BOOLEAN NULL,                                  -- Active flag - normally set but used to temporarily disable a specific date
-  start_time DATETIME NULL,                             -- Date and time event starts
-  end_time DATETIME NULL,                               -- Date and time event ends
-  all_day BOOLEAN NULL,                                 -- All Day flag
-  PRIMARY KEY (id),
-  INDEX(event),
-  INDEX(start_time),
-  INDEX(end_time)
-);
-
-----
-
--- Locations - Locations for event - If there's no location pointing to an event try to use the referenced entity in events table
-CREATE TABLE {prefix}locations (
-  id INT NOT NULL AUTO_INCREMENT,
-  event INT NULL,                                       -- Pointer to the primary or custom event record
-  name TINYTEXT NULL,                                   -- Name of location
-  address TINYTEXT NULL,                                -- Street Address
-  city INT NULL,                                        -- Pointer to city - references main plugin city table
-  state TINYTEXT NULL,                                  -- Two character state abbreviation
-  zip TINYTEXT NULL,                                    -- ZIP/Postal code
-  country TINYTEXT NULL,                                -- Country Code
-  lat FLOAT NULL,                                       -- Latitude of location
-  lon FLOAT NULL,                                       -- Longitude of location
-  region INT NULL,                                      -- Pointer to Region - references main plugin region table
-  phone TINYTEXT NULL,                                  -- Location Phone #
-  url TINYTEXT NULL,                                    -- Location URL
-  email TINYTEXT NULL,                                  -- Location E-Mail Address
-  contact_addon_id INT NULL,                            -- ID of Contact from contact add-on (optional and if available)
-  contact_fname TINYTEXT NULL,                          -- Contact first name for this location (optional)
-  contact_lname TINYTEXT NULL,                          -- Contact last name for this location (optional)
-  contact_phone TINYTEXT NULL,                          -- Contact phone for this location (optional)
-  contact_email TINYTEXT NULL,                          -- Contact E-Mail address (optional)
-  PRIMARY KEY (id)
-);
-
-----
-
--- Events - Base event information - May also be entries here referenced by the "times" table for a custom date.
-CREATE TABLE {prefix}events (
-  id INT NOT NULL AUTO_INCREMENT,
-  status INT NULL,                                      -- Status for this event, see config['status']
-  custom_time INT NULL,                                 -- If this is a custom record for a specific instance (date) this points to that times table entry
-  root_event INT NULL,                                  -- Root event pointer if this is a custom record for a specific instance (date) (if custom_time is set)
-  created DATETIME NULL,                                -- Date/Time event was created or date custom event record was created if custom record
-  updated DATETIME NULL,                                -- Date/Time this event record was last updated
-  approved DATETIME NULL,                               -- Date/Ttime this event record was approved
-  ref_type INT NULL,                                    -- Type of entity this contact is associated with - See config['ref_type']
-  ref_dest INT NULL,                                    -- Pointer to the specific entity of ref_type this contact is associated with
-  hide_address BOOLEAN NULL,                            -- Option to hide address on front-end
-  featured BOOLEAN NULL,                                -- Option to mark as featured event
-  slideshow BOOLEAN NULL,                               -- Option to mark for use in slide show
-  major BOOLEAN NULL,                                   -- Option to mark as a major event
-  name TINYTEXT NULL,                                   -- Name of this event
-  name_slug TINYTEXT NULL,                              -- Slug for this event
-  header TINYTEXT NULL,                                 -- Header text for front-end display - NOT CURRENTLY USED
-  intro TINYTEXT NULL,                                  -- Intro text for front-end display
-  descr TEXT NULL,                                      -- Full description text
-  image TINYTEXT NULL,                                  -- Image file name
-  url TINYTEXT NULL,                                    -- Event URL
-  phone TINYTEXT NULL,                                  -- Event Phone
-  ticket_url TINYTEXT NULL,                             -- Ticket URL
-  cost TINYTEXT NULL,                                   -- Description of event cost
-  admin_ref_type INT NULL,                              -- Type of admin contact if using a member contact
-  admin_ref_dest INT NULL,                              -- Pointer to admin contact record if using a member contact
-  admin_name TINYTEXT NULL,                             -- Admin Contact Name if not using a member contact
-  admin_org TINYTEXT NULL,                              -- Admin Contact Organization if not using a member contact
-  admin_email TINYTEXT NULL,                            -- Admin Contact E-Mail if not using a member contact
-  admin_phone TINYTEXT NULL,                            -- Admin Contact Phone if not using a member contact
-  old_event_id INT NULL,                                -- ID of event from old site for reference
-  notes TEXT NULL,                                      -- Internal notes for this event
-  PRIMARY KEY (id),
-  INDEX(custom_time),
-  INDEX(root_event),
-  INDEX(ref_type),
-  INDEX(ref_dest),
-  INDEX(featured),
-  INDEX(slideshow),
-  INDEX(major)
-);
-
-----
-
--- Event Management Settings
-CREATE TABLE {prefix}management (
-  id INT NOT NULL AUTO_INCREMENT,
-  canonical_event_page TINYTEXT NULL,          -- Canonical page slug for event detail
-  PRIMARY KEY (id)
-);
-
-----
-
--- Set default event management entry
-INSERT INTO {prefix}management
-    ( id, canonical_event_page )
-   VALUES
-    ( 1, 'event-detail' )
-;
-
diff --git a/setup/databaseScripts/create_database_V0.0.9.sql b/setup/databaseScripts/create_database_V0.0.9.sql
new file mode 100644 (file)
index 0000000..ca61b55
--- /dev/null
@@ -0,0 +1,173 @@
+-- Gaslight Media Members Database - Events Add-On
+-- File Created: 12/02/15 15:27:15
+-- Database Version: 0.0.1
+-- Database Creation Script
+--
+-- This file is called to create a new set of tables for this
+-- add-on for the most recent database version for this add-on.
+--
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Categories - Categories for events
+CREATE TABLE {prefix}categories (
+  id INT NOT NULL AUTO_INCREMENT,
+  name TINYTEXT NULL,                                   -- Name of event category
+  descr TINYTEXT NULL,                                  -- Description of this category
+  parent INT NULL,                                      -- Parent category, null or 0 if this is a top level category
+  PRIMARY KEY (id),
+  INDEX(parent)
+);
+
+----
+
+-- Event-Category - Categories for specific event records
+CREATE TABLE {prefix}event_categories (
+  id INT NOT NULL AUTO_INCREMENT,
+  event INT NULL,                                       -- Pointer to the event
+  category INT NULL,                                    -- Pointer to the category
+  PRIMARY KEY (id),
+  INDEX(event),
+  INDEX(category)
+);
+
+----
+
+-- Event Recurrence - Defines how an event recurs
+CREATE TABLE {prefix}recurrences (
+  id INT NOT NULL AUTO_INCREMENT,
+  event INTEGER NULL,                                   -- Pointer to event
+  name TINYTEXT NULL,                                   -- Name of this recurrence schedule - used on admin calendar
+  start_time DATETIME NULL,                             -- Start of first occurrence (date and time)
+  start_time_only BOOLEAN NULL,                         -- Use end of first occurrence flag
+  end_time DATETIME NULL,                               -- End of first occurrence (date and time)
+  all_day BOOLEAN NULL,                                 -- Flag indicating if this is an all-day event (informational only)
+  start_date DATE NULL,                                 -- Starting Date (if all_day is selected) Used instead of start_time
+  from_date DATE NULL,                                  -- From Date for recurrences
+  to_date DATE NULL,                                    -- To Date for recurrences
+  all_dates BOOLEAN NULL,                               -- Flag indicating that event recurs on all dates from from_date through to_date
+  month_of_year SMALLINT UNSIGNED NULL,                 -- Month of year (bitmap)
+  week_of_month TINYINT UNSIGNED NULL,                  -- Week of the month (bitmap)
+  day_of_week TINYINT UNSIGNED NULL,                    -- Day of the week (bitmap)
+  by_day_of_month BOOLEAN NULL,                         -- Flag indicating if selecting by days of the month
+  day_of_month INTEGER UNSIGNED NULL,                   -- Day of the month (bitmap)
+  last_day_of_month BOOLEAN NULL,                       -- Last day of the month
+  holiday INT NULL,                                     -- Pointer to holidays list (for future development)
+  holiday_offset TINYINT,                               -- Offset from holiday (from -128 to +127 days)
+  PRIMARY KEY (id),
+  INDEX(event)
+);
+
+----
+
+-- Times - List of actual event times for single and recurring events
+CREATE TABLE {prefix}times (
+  id INT NOT NULL AUTO_INCREMENT,
+  event INT NULL,                                       -- Pointer to the primary record for the event
+  custom_event INT NULL,                                -- Pointer to a customized copy of the event record (if set)
+  recur_id INT NULL,                                    -- Pointer to recurrence entry
+  active BOOLEAN NULL,                                  -- Active flag - normally set but used to temporarily disable a specific date
+  start_time DATETIME NULL,                             -- Date and time event starts
+  end_time DATETIME NULL,                               -- Date and time event ends
+  all_day BOOLEAN NULL,                                 -- All Day flag
+  PRIMARY KEY (id),
+  INDEX(event),
+  INDEX(start_time),
+  INDEX(end_time)
+);
+
+----
+
+-- Locations - Locations for event - If there's no location pointing to an event try to use the referenced entity in events table
+CREATE TABLE {prefix}locations (
+  id INT NOT NULL AUTO_INCREMENT,
+  event INT NULL,                                       -- Pointer to the primary or custom event record
+  name TINYTEXT NULL,                                   -- Name of location
+  address TINYTEXT NULL,                                -- Street Address
+  city INT NULL,                                        -- Pointer to city - references main plugin city table
+  state TINYTEXT NULL,                                  -- Two character state abbreviation
+  zip TINYTEXT NULL,                                    -- ZIP/Postal code
+  country TINYTEXT NULL,                                -- Country Code
+  lat FLOAT NULL,                                       -- Latitude of location
+  lon FLOAT NULL,                                       -- Longitude of location
+  region INT NULL,                                      -- Pointer to Region - references main plugin region table
+  phone TINYTEXT NULL,                                  -- Location Phone #
+  url TINYTEXT NULL,                                    -- Location URL
+  email TINYTEXT NULL,                                  -- Location E-Mail Address
+  contact_addon_id INT NULL,                            -- ID of Contact from contact add-on (optional and if available)
+  contact_fname TINYTEXT NULL,                          -- Contact first name for this location (optional)
+  contact_lname TINYTEXT NULL,                          -- Contact last name for this location (optional)
+  contact_phone TINYTEXT NULL,                          -- Contact phone for this location (optional)
+  contact_email TINYTEXT NULL,                          -- Contact E-Mail address (optional)
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Events - Base event information - May also be entries here referenced by the "times" table for a custom date.
+CREATE TABLE {prefix}events (
+  id INT NOT NULL AUTO_INCREMENT,
+  status INT NULL,                                      -- Status for this event, see config['status']
+  custom_time INT NULL,                                 -- If this is a custom record for a specific instance (date) this points to that times table entry
+  root_event INT NULL,                                  -- Root event pointer if this is a custom record for a specific instance (date) (if custom_time is set)
+  created DATETIME NULL,                                -- Date/Time event was created or date custom event record was created if custom record
+  updated DATETIME NULL,                                -- Date/Time this event record was last updated
+  approved DATETIME NULL,                               -- Date/Ttime this event record was approved
+  ref_type INT NULL,                                    -- Type of entity this contact is associated with - See config['ref_type']
+  ref_dest INT NULL,                                    -- Pointer to the specific entity of ref_type this contact is associated with
+  hide_address BOOLEAN NULL,                            -- Option to hide address on front-end
+  featured BOOLEAN NULL,                                -- Option to mark as featured event
+  slideshow BOOLEAN NULL,                               -- Option to mark for use in slide show
+  major BOOLEAN NULL,                                   -- Option to mark as a major event
+  name TINYTEXT NULL,                                   -- Name of this event
+  name_slug TINYTEXT NULL,                              -- Slug for this event
+  header TINYTEXT NULL,                                 -- Header text for front-end display - NOT CURRENTLY USED
+  intro TINYTEXT NULL,                                  -- Intro text for front-end display
+  descr TEXT NULL,                                      -- Full description text
+  image TINYTEXT NULL,                                  -- Image file name
+  url TINYTEXT NULL,                                    -- Event URL
+  ticket_url TINYTEXT NULL,                             -- Ticket URL
+  cost TINYTEXT NULL,                                   -- Description of event cost
+  admin_ref_type INT NULL,                              -- Type of admin contact if using a member contact
+  admin_ref_dest INT NULL,                              -- Pointer to admin contact record if using a member contact
+  admin_name TINYTEXT NULL,                             -- Admin Contact Name if not using a member contact
+  admin_org TINYTEXT NULL,                              -- Admin Contact Organization if not using a member contact
+  admin_email TINYTEXT NULL,                            -- Admin Contact E-Mail if not using a member contact
+  admin_phone TINYTEXT NULL,                            -- Admin Contact Phone if not using a member contact
+  free BOOLEAN NULL,                                    -- Event is Free
+  contact_email TINYTEXT NULL,                          -- Contact E-mail address
+  contact_name TINYTEXT NULL,                           -- Contact name
+  contact_phone TINYTEXT NULL,                          -- Event Phone
+  use_member_location BOOLEAN NULL,                     -- Use location of the member (if provided) rather than location table data
+  old_event_id INT NULL,                                -- ID of event from old site for reference
+  notes TEXT NULL,                                      -- Internal notes for this event
+  PRIMARY KEY (id),
+  INDEX(custom_time),
+  INDEX(root_event),
+  INDEX(ref_type),
+  INDEX(ref_dest),
+  INDEX(featured),
+  INDEX(slideshow),
+  INDEX(major)
+);
+
+----
+
+-- Event Management Settings
+CREATE TABLE {prefix}management (
+  id INT NOT NULL AUTO_INCREMENT,
+  canonical_event_page TINYTEXT NULL,          -- Canonical page slug for event detail
+  PRIMARY KEY (id)
+);
+
+----
+
+-- Set default event management entry
+INSERT INTO {prefix}management
+    ( id, canonical_event_page )
+   VALUES
+    ( 1, 'event-detail' )
+;
+
index b324373..3a8ef3b 100644 (file)
@@ -21,6 +21,7 @@ $glmMembersEventsDbVersions = array(
     '0.0.5' => array('version' => '0.0.5', 'tables' => 7),
     '0.0.6' => array('version' => '0.0.6', 'tables' => 7),
     '0.0.7' => array('version' => '0.0.7', 'tables' => 7),
-    '0.0.8' => array('version' => '0.0.8', 'tables' => 7)
+    '0.0.8' => array('version' => '0.0.8', 'tables' => 7),
+    '0.0.9' => array('version' => '0.0.9', 'tables' => 7),
 );
 
index f20d3ac..7a192a2 100644 (file)
@@ -1,6 +1,6 @@
 -- Gaslight Media Members Database  - Events Add-On
 -- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.2
+-- Database Version: 0.0.3
 -- Database Update From Previous Version Script
 -- 
 -- To permit each query below to be executed separately,
index 090bf25..c059470 100644 (file)
@@ -1,6 +1,6 @@
 -- Gaslight Media Members Database  - Events Add-On
 -- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.2
+-- Database Version: 0.0.4
 -- Database Update From Previous Version Script
 -- 
 -- To permit each query below to be executed separately,
index a8d1c49..cd63193 100644 (file)
@@ -1,6 +1,6 @@
 -- Gaslight Media Members Database  - Events Add-On
 -- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.2
+-- Database Version: 0.0.5
 -- Database Update From Previous Version Script
 -- 
 -- To permit each query below to be executed separately,
index ef060ef..4a4e071 100644 (file)
@@ -1,6 +1,6 @@
 -- Gaslight Media Members Database  - Events Add-On
 -- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.6
+-- Database Version: 0.0.7
 -- Database Update From Previous Version Script
 -- 
 -- To permit each query below to be executed separately,
index 9166d69..7a7ed46 100644 (file)
@@ -1,6 +1,6 @@
 -- Gaslight Media Members Database  - Events Add-On
 -- File Created: 12/09/14 15:27:15
--- Database Version: 0.0.6
+-- Database Version: 0.0.8
 -- Database Update From Previous Version Script
 -- 
 -- To permit each query below to be executed separately,
diff --git a/setup/databaseScripts/update_database_V0.0.9.sql b/setup/databaseScripts/update_database_V0.0.9.sql
new file mode 100644 (file)
index 0000000..1ba8cb2
--- /dev/null
@@ -0,0 +1,32 @@
+-- Gaslight Media Members Database  - Events Add-On
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 0.0.9
+-- 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
+
+
+-- Add Free event flag
+ALTER TABLE {prefix}events ADD COLUMN free BOOLEAN;
+
+----
+
+-- Add event E-Mail address
+ALTER TABLE {prefix}events ADD COLUMN contact_email TINYTEXT;
+
+----
+
+-- Add event Name
+ALTER TABLE {prefix}events ADD COLUMN contact_name TINYTEXT;
+
+----
+
+-- Rename event phone to contact phone
+ALTER TABLE {prefix}events CHANGE phone contact_phone TINYTEXT;
+
+----
+
+-- Use Member Location 
+ALTER TABLE {prefix}events ADD COLUMN use_member_location TINYTEXT;
+
index 0f527b1..318cb77 100644 (file)
 
        <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
             <a id="glm-event-descr" data-show-table="glm-table-descr" class="glm-event-tab nav-tab nav-tab-active">Status & Description</a>
-            <a id="glm-event-settings" data-show-table="glm-table-settings" class="glm-event-tab nav-tab">Options & Settings</a>
             <a id="glm-event-location" data-show-table="glm-table-location" class="glm-event-tab nav-tab">Location</a>
             <a id="glm-event-recurrence" data-show-table="glm-table-recurrence" class="glm-event-tab nav-tab">Event Schedule</a>
             <a id="glm-event-calendar" data-show-table="glm-table-calendar" class="glm-event-tab nav-tab">Calendar</a>
+            <a id="glm-event-settings" data-show-table="glm-table-settings" class="glm-event-tab nav-tab">Administrative Contact</a>
             {if $eventUpdated}<span class="glm-notice glm-flash-updated glm-right">Event Updated</span>{/if}
             {if $eventUpdateError}<span class="glm-error glm-flash-updated glm-right">Event Update Error</span>{/if}
             {if $eventAdded}<span class="glm-notice glm-flash-updated glm-right">Event Added</span>{/if}
 
         {include file='admin/events/editStatus.html'}
 
-        <!-- General Settings -->
-
-        {include file='admin/events/editSettings.html'}
-
         <!-- Location -->
 
         {include file='admin/events/editLocation.html'}
             </tr>
         </table>
 
+        <!-- Admin Contact -->
+
+        {include file='admin/events/editAdminContact.html'}
+
         <input id="updateEvent" type="submit" value="{if $haveEvent}Update Event{else}Add New Event{/if}">
 
     </form>
                 }
 
                 if (table == 'glm-table-location' && !locationsInited) {
+
+                    // Make sure there's at least one location
+                    {if !$locations}
+                            addNewLocationForm();
+                    {/if}
+                    
                     initLocations();
                     initNewCity();
                     locationsInited = true;
+
                 }
 
                 if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
                 initNewCity();
 
             }
+            
 
             /*
              * This is used to initialize all of the locations when the location tab is first clicked.
 
             }
 
+            // Make sure there's at least one recurrence
+    {if !$locations}
+            addNewRecurrenceForm();
+    {/if}
+
             // When adding a new recurrence is requested
             $("#addRecurrence").click( function() {
                 addNewRecurrenceForm();
 
                 // Delete a recurrence
                 $('.delete-recurrence').on( 'click', function() {
+alert(123);                    
                     recurID = $(this).attr('data-id');
                     $('#recurrence_' + recurID).remove();
                     $('#placeRecurDeletesHere').append('<input type="hidden" name="deleteRecur[' + recurID + ']" value="' + recurID + '">');
             /*
              * Misc support items
              */
-
+             
+            // Hide description of cost if Free is checked
+            $('#freeEventCheckbox').on('click', function() {
+                if ($('#freeEventCheckbox')[0].checked) {
+                    $('#descriptionOfCostField').addClass('glm-hidden');
+                } else {
+                    $('#descriptionOfCostField').removeClass('glm-hidden');
+                }
+            });
+            
+            // Hide description of cost if Free is checked
+            $('#useMemberLocationCheckbox').on('click', function() {
+                if ($(this)[0].checked) {
+                    $('#locationContainer').addClass('glm-hidden');
+                } else {
+                    $('#locationContainer').removeClass('glm-hidden');
+                }
+            });
+            
             // Flash certain elements for a short time after display
             $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
 
diff --git a/views/admin/events/editAdminContact.html b/views/admin/events/editAdminContact.html
new file mode 100644 (file)
index 0000000..f353ade
--- /dev/null
@@ -0,0 +1,39 @@
+
+<!-- Options and Settings -->
+
+    <table id="glm-table-settings" class="glm-admin-table glm-event-table glm-hidden">
+        <tr>
+            <td>
+                <table>
+                    <tr><td>&nbsp;</td><th>Administrative Contact Information</th></tr>
+                    <tr>
+                        <th>Admin Contact Name:</th>
+                        <td>
+                            <input type="text" name="admin_name" value="{$event.fieldData.admin_name}" class="glm-form-text-input-medium">
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Admin Contact Organization:</th>
+                        <td>
+                            <input type="text" name="admin_org" value="{$event.fieldData.admin_org}" class="glm-form-text-input-medium">
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Admin Contact E-Mail:</th>
+                        <td>
+                            <input type="text" name="admin_email" value="{$event.fieldData.admin_email}" class="glm-form-text-input-medium">
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Admin Contact Phone:</th>
+                        <td>
+                            <input type="text" name="admin_phone" value="{$event.fieldData.admin_phone}" class="glm-form-text-input-medium">
+                        </td>
+                    </tr>
+                </table>
+            </td>
+            <td width="50%">
+                &nbsp;
+            </td>
+        </tr>
+    </table>
index 0f293e6..84771af 100644 (file)
 <table id="glm-table-location" class="glm-admin-table glm-hidden glm-event-table">
     <tr>
         <td id="placeLocationDeletesHere" colspan="2">
-            <a id="addLocation" class="button button-primary glm-button glm-right">Add a Location</a>
+
+            <!--  Only doing one event at a time  - edit.html has JAVAscript code to create the first and only one
+                <a id="addLocation" class="button button-primary glm-button glm-right">Add a Location</a> 
+            -->
+
         </td>
     </tr>
     <tr>
+        <td>
+            <table>
+                <tr>
+                    <th>Use Member location:</th>
+                    <td>
+                        <input id="useMemberLocationCheckbox" type="checkbox" name="use_member_location" {if $event.fieldData.use_member_location.value} checked{/if}>
+                        Uses location data from the selected member rather than location data from here.
+                    </td>
+                </tr>
+            </table>
+        </td>
+    </tr>
+    
+    <tr id="locationContainer" {if $event.fieldData.use_member_location.value}class="glm-hidden"{/if}>
         <td>
             <table id="locationTable" width="100%">
                 <!-- Location forms go here. -->
                                     <input id="name_{$loc.id}" type="text" name="Loc{$loc.id}_name" value="{$loc.name}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
+                    <tr>
+                        <th>Hide Location Address:</th>
+                        <td>
+                            <input type="checkbox" name="hide_address" {if $event.fieldData.hide_address.value} checked{/if}>
+                            Don't show location address to site visitors.
+                        </td>
+                    </tr>
                             <tr>
                                 <th>Address:</th>
                                 <td>
                                     <input type="text" name="Loc{$loc.id}_email" value="{$loc.email}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
-                            <tr>
-                                <th>Contact Name:</th>
-                                <td>
-                                    First: <input type="text" name="Loc{$loc.id}_contact_fname" value="{$loc.contact_fname}" class="glm-form-text-input-small">
-                                    Last:  <input type="text" name="Loc{$loc.id}_contact_lname" value="{$loc.contact_lname}" class="glm-form-text-input-small">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Contact Phone:</th>
-                                <td>
-                                    <input type="text" name="Loc{$loc.id}_contact_phone" value="{$loc.contact_phone}" class="glm-form-text-input-medium">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Contact Email:</th>
-                                <td>
-                                    <input type="text" name="Loc{$loc.id}_contact_email" value="{$loc.contact_email}" class="glm-form-text-input-medium">
-                                </td>
-                            </tr>
 
                         </table>
                     </td>
                                 <td>
                                     <input id="glmLat_{$loc.id}" name="Loc{$loc.id}_lat" type="hidden" value="{$loc.lat}">
                                     <input id="glmLng_{$loc.id}" name="Loc{$loc.id}_lon" type="hidden" value="{$loc.lon}">
-                                    <span class="glm-right"><a id="deleteLocation_{$loc.id}" data-id="{$loc.id}" class="button button-primary glm-button glm-right delete-location">Delete Location</a></span>
+                                        <span class="glm-right">
+                                    <!-- Only doing one location per event right now
+                                            <a id="deleteLocation_{$loc.id}" data-id="{$loc.id}" class="button button-primary glm-button glm-right delete-location">Delete Location222</a>
+                                    -->
+                                        </span>
                                     <div id="glm-estimate-location_{$loc.id}" class="button button-secondary">Map Location Using Above Address</div>
                                     <p>
                                         <div id="locationMap_{$loc.id}" class="glm-map-edit">(map loads here)</div>
                     <td>
                         <input id="glmLat_{ newLocID }" name="{ newLocID }_lat" type="hidden" value="{$newLocation.fieldData.lat}">
                         <input id="glmLng_{ newLocID }" name="{ newLocID }_lon" type="hidden" value="{$newLocation.fieldData.lon}">
+                    <!-- Only doing one event per location now.
                         <span class="glm-right"><a id="deleteLocation_{ newLocID }" data-id="{ newLocID }" class="button button-primary glm-button glm-right delete-location">Delete Location</a></span>
+                    -->
                         <div id="glm-estimate-location_{ newLocID }" class="button button-secondary">Map Location Using Address</div>
                         <p>
                             locationMap_{ newLocID }
index afc36c9..12c9648 100644 (file)
 
     {/foreach}
 {else}
-                <tr id="no-recurrence-msg"><td colspan="2">(Add event schedules here)</td></tr>
+                <tr id="no-recurrence-msg"><td colspan="2"></td></tr>
 {/if}
             </table>
         </td>
diff --git a/views/admin/events/editSettings.html b/views/admin/events/editSettings.html
deleted file mode 100644 (file)
index 999baf3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-
-<!-- Options and Settings -->
-
-    <table id="glm-table-settings" class="glm-admin-table glm-event-table glm-hidden">
-        <tr>
-            <td>
-                <table>
-                    <tr><td>&nbsp;</td><th>Administrative Contact Information</th></tr>
-                    <tr>
-                        <th>Admin Contact Name:</th>
-                        <td>
-                            <input type="text" name="admin_name" value="{$event.fieldData.admin_name}" class="glm-form-text-input-medium">
-                        </td>
-                    </tr>
-                    <tr>
-                        <th>Admin Contact Organization:</th>
-                        <td>
-                            <input type="text" name="admin_org" value="{$event.fieldData.admin_org}" class="glm-form-text-input-medium">
-                        </td>
-                    </tr>
-                    <tr>
-                        <th>Admin Contact E-Mail:</th>
-                        <td>
-                            <input type="text" name="admin_email" value="{$event.fieldData.admin_email}" class="glm-form-text-input-medium">
-                        </td>
-                    </tr>
-                    <tr>
-                        <th>Admin Contact Phone:</th>
-                        <td>
-                            <input type="text" name="admin_phone" value="{$event.fieldData.admin_phone}" class="glm-form-text-input-medium">
-                        </td>
-                    </tr>
-                </table>
-            </td>
-            <td>
-                <table>
-                    <tr><td>&nbsp;</td><th>Event Options</th></tr>
-                    <tr>
-                        <th>Hide Member Address:</th>
-                        <td>
-                            <input type="checkbox" name="hide_address" {if $event.fieldData.hide_address.value} checked{/if}>
-                        </td>
-                    </tr>
-                    <tr>
-                        <th>Featured Event:</th>
-                        <td>
-                            <input type="checkbox" name="featured" {if $event.fieldData.featured.value} checked{/if}>
-                        </td>
-                    </tr>
-                    <tr>
-                        <th>Include in Slideshow:</th>
-                        <td>
-                            <input type="checkbox" name="slideshow" {if $event.fieldData.slideshow.value} checked{/if}>
-                        </td>
-                    </tr>
-                    <tr>
-                        <th>Major Event:</th>
-                        <td>
-                            <input type="checkbox" name="major" {if $event.fieldData.major.value} checked{/if}>
-                        </td>
-                    </tr>
-                </table>
-            </td>
-        </tr>
-    </table>
index 5e2a568..f69a246 100644 (file)
                 {if $event.fieldFail.status}<p>{$event.fieldFail.status}</p>{/if}
             </td>
         </tr>
+
+                    <tr>
+                        <th>Options:</th>
+                        <td>
+                            <input type="checkbox" name="featured" {if $event.fieldData.featured.value} checked{/if}>&nbsp;Featured Event&nbsp;&nbsp;
+                            <input type="checkbox" name="slideshow" {if $event.fieldData.slideshow.value} checked{/if}>&nbsp;Include in Slideshow&nbsp;&nbsp;
+                            <input type="checkbox" name="major" {if $event.fieldData.major.value} checked{/if}>&nbsp;Major Event
+                        </td>
+                    </tr>
+
+
+
         <tr>
             <th>Categories</th>
             <td class="glm-item-container">
                 {if $event.fieldFail.ticket_url}<p>{$event.fieldFail.ticket_url}</p>{/if}<br>
             </td>
         </tr>
-        <tr>
+        
+                            <tr>
+                                <th>Contact Name:</th>
+                                <td>
+                                    First: <input type="text" name="Loc{$loc.id}_contact_fname" value="{$loc.contact_fname}" class="glm-form-text-input-small">
+                                    Last:  <input type="text" name="Loc{$loc.id}_contact_lname" value="{$loc.contact_lname}" class="glm-form-text-input-small">
+                                </td>
+                            </tr>
+                            <tr>
+                                <th>Contact Phone:</th>
+                                <td>
+                                    <input type="text" name="Loc{$loc.id}_contact_phone" value="{$loc.contact_phone}" class="glm-form-text-input-medium">
+                                </td>
+                            </tr>
+                            <tr>
+                                <th>Contact Email:</th>
+                                <td>
+                                    <input type="text" name="Loc{$loc.id}_contact_email" value="{$loc.contact_email}" class="glm-form-text-input-medium">
+                                </td>
+                            </tr>
+        
+        
+        
+                    <tr>
+                        <th>Free:</th>
+                        <td>
+                            <input type="checkbox" id="freeEventCheckbox" name="free" {if $event.fieldData.free.value} checked{/if}>
+                            Mark event as Free (no cost) and don't provide "Description of Cost:".
+                        </td>
+                    </tr>
+
+        <tr id="descriptionOfCostField" {if $event.fieldData.free.value}class="glm-hidden"{/if}>
             <th {if $event.fieldRequired.cost}class="glm-required"{/if}>Description of Cost:</th>
             <td {if $event.fieldFail.cost}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
                 <input type="text" name="cost" value="{$event.fieldData.cost}" class="glm-form-text-input-medium">