Major cleanup with locations and schedules
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 31 Mar 2016 20:48:32 +0000 (16:48 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 31 Mar 2016 20:48:32 +0000 (16:48 -0400)
12 files changed:
classes/data/dataEvents.php
index.php
models/admin/events/list.php
setup/databaseScripts/create_database_V0.0.7.sql [deleted file]
setup/databaseScripts/create_database_V0.0.8.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.8.sql [new file with mode: 0644]
setup/validActions.php
views/admin/events/edit.html
views/admin/events/editLocation.html
views/admin/events/editSchedule.html
views/admin/events/editStatus.html

index be46841..7d0b1c6 100644 (file)
@@ -301,6 +301,13 @@ class GlmDataEvents extends GlmDataAbstract
                 'use'      => 'a'
             ),
 
+            // Event Phone
+            'phone' => array (
+                'field' => 'phone',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
             // Event URL
             'url' => array (
                 'field' => 'url',
@@ -518,14 +525,14 @@ class GlmDataEvents extends GlmDataAbstract
         $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config);
 
         // Check ID
-        $if = ($if - 0);
+        $id = ($id - 0);
         if ($id <= 0) {
             return false;
         }
 
         // Try to get the event data
         $event = $this->getEntry($id);
-        if (!event) {
+        if (!$event) {
             return false;
         }
 
index e05fa89..e9eb14e 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.7');
+define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.8');
 
 // 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');
index 784cc67..f1168de 100644 (file)
@@ -195,6 +195,9 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
         }
 
+        // Check for new cities and get a table to match the submitted ID with the new city ID
+        $newCityID = $this->checkNewCities();
+
         // Do selected option
         switch ($option) {
 
@@ -222,6 +225,80 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                     $this->updateTimestamp('created', $this->eventID);
                     $this->updateSlug($this->eventID);
 
+                    // Look for location data
+                    if (isset($_REQUEST['locID'])) {
+
+                        // For each location
+                        foreach ($_REQUEST['locID'] as $locID) {
+
+                            // Set the nLoc{id}_event value to the new event
+                            $_REQUEST[$locID.'_event'] = $this->eventID;
+
+                            // Check for new cities in this location and if so use the new city real ID
+                            if (isset($_REQEUST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
+                                $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']];
+                            }
+
+                            // Check if it's a new Location - Here it will be
+                            if ($locID[0] == 'n') {
+
+                                // Add the new location
+                                $x = $Locations->insertEntry(true, $locID.'_');
+
+                            }
+
+                        }
+
+                    }
+
+                    // Look for recurrence data
+                    if (isset($_REQUEST['recurID'])) {
+
+                        // For each recurrence
+                        foreach ($_REQUEST['recurID'] as $recurID) {
+
+                            // Set the nRecur{id}_event value to the new event
+                            $_REQUEST[$recurID.'_event'] = $this->eventID;
+
+                            // first check if the event is an all-day event
+                            if (isset($_REQUEST[$recurID.'_all_day'])) {
+
+                                // Then take the start date (date only) and stick it into the start time
+                                $red = explode(' ', $_REQUEST[$recurID.'_start_date']);
+                                $_REQUEST[$recurID.'_start_time'] = $red[0]." 00:00";
+                                $_REQUEST[$recurID.'_end_time'] = $red[0]." 00:00";
+
+                            }
+
+                            // Check if it's a new Recurrence - Here it will be
+                            if ($recurID[0] == 'n') {
+
+                                // Add the new recurrence
+                                $x = $Recurrences->insertEntry(true, $recurID.'_');
+
+                                // And create time entries
+                                $Recurrences->createRecurrenceTimesEntries($x['fieldData']['id'], true, true);
+
+                            }
+
+                        }
+
+                        // Update our recurrences
+                        $recurrences = $Recurrences->getList("T.event = ".$this->eventID);
+
+                        // Check for any updated recurrences
+                        if (isset($_REQUEST['recurUpdated']) && count($_REQUEST['recurUpdated']) > 0) {
+                            foreach ($_REQUEST['recurUpdated'] as $r) {
+
+                                // If we have a recurID as a value, then update this recurrence times
+                                if ($r) {
+                                    $Recurrences->createRecurrenceTimesEntries($r, true, true);
+                                }
+                            }
+                        }
+
+                    }
+
                     // Get this again so we have the created date
                     $event = $this->editEntry($this->eventID);
 
@@ -273,19 +350,6 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                     $eventUpdateError = true;
                 }
 
-                // Look for recurrence deletes
-                if (isset($_REQUEST['deleteRecur']) && count($_REQUEST['deleteRecur'] > 0)) {
-                    foreach ($_REQUEST['deleteRecur'] as $d) {
-
-                        // If this was not a new entry that was deleted (in which case it was never added)
-                        if ($d[0] != 'n') {
-                            $Recurrences->deleteTimeEntriesForRecurrance($d, true);
-                            $Recurrences->deleteEntry($d, true);
-                        }
-
-                    }
-                }
-
                 // Look for location deletes
                 if (isset($_REQUEST['deleteLocation']) && count($_REQUEST['deleteLocation'] > 0)) {
                     foreach ($_REQUEST['deleteLocation'] as $d) {
@@ -302,7 +366,12 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                 if (isset($_REQUEST['locID'])) {
 
                     // For each location
-                    foreach ($_REQUEST['locID'] as $locID) {
+                    while (list($id, $locID) = each($_REQUEST['locID'])) {
+
+                        // Check for new cities in this location and if so use the new city real ID
+                        if (isset($_REQEUST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
+                            $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']];
+                        }
 
                         // Check if it's a new Location
                         if ($locID[0] == 'n') {
@@ -312,14 +381,27 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
                         // Otherwise it's an existing location
                         } else {
-                           $Locations->updateEntry($locID, 'id', true, $locID.'_');
+                           $Locations->updateEntry($id, 'id', true, $locID.'_');
                         }
 
                     }
 
                 }
 
-                        // Look for recurrence data
+                // Look for recurrence deletes
+                if (isset($_REQUEST['deleteRecur']) && count($_REQUEST['deleteRecur'] > 0)) {
+                    foreach ($_REQUEST['deleteRecur'] as $d) {
+
+                        // If this was not a new entry that was deleted (in which case it was never added)
+                        if ($d[0] != 'n') {
+                            $Recurrences->deleteTimeEntriesForRecurrance($d, true);
+                            $Recurrences->deleteEntry($d, true);
+                        }
+
+                    }
+                }
+
+                // Look for recurrence data
                 if (isset($_REQUEST['recurID'])) {
 
                     // For each recurrence
@@ -346,7 +428,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
                         // Otherwise it's an existing recurrence
                         } else {
-                           $Recurrences->updateEntry($recurID, 'id', true, $recurID.'_');
+                           $Recurrences->updateEntry($recurID, 'id', true, 'Recur'.$recurID.'_');
                         }
 
                     }
@@ -577,6 +659,51 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
     }
 
+    /*
+     * Check for new Cities being added
+     *
+     * @return void
+     */
+    public function checkNewCities()
+    {
+        // Array of submitted vs new city IDs to return
+        $newCityID = array();
+
+        // If we have a new Cities submitted
+        if (isset($_REQUEST['newCity'])) {
+
+            // Try to add the city
+            require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php');
+            $Cities = new GlmDataCities($this->wpdb, $this->config);
+
+            // For each new city submitted
+            while (list($k, $v) = each($_REQUEST['newCity'])) {
+
+                $cName = trim(filter_var($_REQUEST['newCity'][$k]));
+
+                if ($cName != '') {
+
+                    // Try to add the city to cities table
+                    $cID = $Cities->addCity($cName);
+
+                    // If the city added OK
+                    if (is_int($cID) && $cID > 0) {
+
+                        // Update the Input to show the new ID
+                        // Add this to the newCityID table
+                        $newCityID[$k] = $cID;
+                    }
+
+                }
+
+            }
+
+            return $newCityID;
+        }
+
+    }
+
+
 
 
 }
diff --git a/setup/databaseScripts/create_database_V0.0.7.sql b/setup/databaseScripts/create_database_V0.0.7.sql
deleted file mode 100644 (file)
index 1196594..0000000
+++ /dev/null
@@ -1,168 +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
-  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.8.sql b/setup/databaseScripts/create_database_V0.0.8.sql
new file mode 100644 (file)
index 0000000..b22ddf4
--- /dev/null
@@ -0,0 +1,169 @@
+-- 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' )
+;
+
index ceb9573..b324373 100644 (file)
@@ -20,6 +20,7 @@ $glmMembersEventsDbVersions = array(
     '0.0.4' => array('version' => '0.0.4', 'tables' => 7),
     '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.7' => array('version' => '0.0.7', 'tables' => 7),
+    '0.0.8' => array('version' => '0.0.8', 'tables' => 7)
 );
 
diff --git a/setup/databaseScripts/update_database_V0.0.8.sql b/setup/databaseScripts/update_database_V0.0.8.sql
new file mode 100644 (file)
index 0000000..9166d69
--- /dev/null
@@ -0,0 +1,12 @@
+-- Gaslight Media Members Database  - Events Add-On
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 0.0.6
+-- 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 use end time
+ALTER TABLE {prefix}events ADD COLUMN phone TINYTEXT;
+
index 8595415..e49a8d2 100644 (file)
@@ -33,7 +33,7 @@
 $glmMembersEventsAddOnValidActions = array(
     'adminActions' => array(
         'ajax' => array(
-                'pdfOutput' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
+                'pdfOutputs' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
         ),
         'member' => array(
             'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
index a2e0f43..0f527b1 100644 (file)
 
                 if (table == 'glm-table-location' && !locationsInited) {
                     initLocations();
+                    initNewCity();
                     locationsInited = true;
                 }
 
                 if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
-                    
+
+                    // **** Should probably move all this to a function and check if it's been initialized already
                     $('#eventCalendar').fullCalendar({
         {if $haveTimes}
                         events: [
                         defaultDate : '{$firstTime.start_time.datetime}',
                         timeFormat  : 'h:mma',
                         fixedWeekCount : false,
-                        
-                        
-                        
                         eventClick: function(calEvent, jsEvent, view) {
 
                             alert('Event: ' + calEvent.title);
                         },
                         dayClick: function(date, allDay, jsEvent, view) {
 
-        if (allDay) {
-            alert('Clicked on the entire day: ' + date);
-        }else{
-            alert('Clicked on the slot: ' + date);
-        }
+                            if (allDay) {
+                                alert('Clicked on the entire day: ' + date);
+                            }else{
+                                alert('Clicked on the slot: ' + date);
+                            }
 
-        alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
+                            alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
 
-        alert('Current view: ' + view.name);
+                            alert('Current view: ' + view.name);
 
-        // change the day's background color just for fun
-        $(this).css('background-color', 'red');
+                            // change the day's background color just for fun
+                            $(this).css('background-color', 'red');
 
-    }
+                        }
         {/if}
                     });
-                    
+
                     fullCalendarLoaded = true;
                 }
 
             });
 
+            /*
+             * General Event Actions
+             */
+
             // Add Event Button Action
             $('#addEventButton').click( function() {
                 window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
             });
 
-            // 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);
-
     {if $haveEvent}
             // Delete Event dialog
             $("#deleteEventDialog").dialog({
     {/if}
 
             /*
-             * Locations
+             * Location Actions
              */
-             var numbLocations = {$numbLocations};
 
-            /*
-             * Add location using template
-             */
+            // Current number of locations
+            var numbLocations = {$numbLocations};
 
             // New location ID's start at 0 (have "n" for "new" appended to them in the template)
             var newLocID = 0;
             // Get location template and clear it from HTML so it doesn't get submitted
             locTemplate = $('#addLocationTemplate').html();
             $('#addLocationTemplate').html('');
-            
-            // When adding a new location is requested
+
+            // Request to add a new location
             $("#addLocation").click( function() {
                 addNewLocationForm();
                 $('#no-location-msg').remove();
                 }
 
                 locTemp = locTemp + locTemplate;
-                locTemp = locTemp.replace(/{ newLocID }/g, 'n' + newLocID); // Include "n" to indicate "new"
+                locTemp = locTemp.replace(/{ newLocID }/g, 'nLoc' + newLocID); // Include "n" to indicate "new"
 
                 // Append the new location form to the container
                 $('#locationTable').append(locTemp);
 
-                initLocation('n' + newLocID);
+                initLocation('nLoc' + newLocID);
 
             }
 
-            /*
-             * Things that need to be renewed each time a location is added
-             */
+            // Function to initialize actions related to a specific location
             function initLocation(locID) {
 
-                // Setup dialog box for adding a new city
-                $("#newCityDialog").dialog({
-                    autoOpen: false,
-                    minWidth: 400,
-                    dialogClass: "glm-dialog-no-close"
-                });
-                $('#newCityCancel').click( function() {
-                    $("#newCityDialog").dialog("close");
-                });
-
-                // Ad a new city button action - pop-up dialog
-                $('#newCityButton').click( function() {
-                    $("#newCityDialog").dialog("open");
-                });
-
                 // Delete a location
                 $('.delete-location').on( 'click', function() {
                     locID = $(this).attr('data-id');
                 })
 
                 initMap(locID);
+                initNewCity();
 
             }
 
             // Get recurrence template and clear it from HTML so it doesn't get submitted
             recurTemplate = $('#addRecurrenceTemplate').html();
             $('#addRecurrenceTemplate').html('');
-            
+
             function addNewRecurrenceForm() {
 
                 // Tick the new recurrence ID counter and build new HTML from the addRecurrenceTemplate
                 }
 
                 recurTemp = recurTemp + recurTemplate;
-                recurTemp = recurTemp.replace(/{ newRecurID }/g, 'n' + newRecurID); // Include "n" to indicate "new"
+                recurTemp = recurTemp.replace(/{ newRecurID }/g, 'nRecur' + newRecurID); // Include "n" to indicate "new"
 
                 // Append the new recurrence form to the container
                 $('#recurrenceTable').append(recurTemp);
             $('#addRecurrenceCancel').click( function() {
                 $("#addRecurrenceDialog").dialog("close");
             });
-            $('#addRecurrenceSubmit').click( function() {
-                // window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=list&option=delete&event={$event.fieldData.id}");
-            });
-
 
             /*
              * Category Selection
             // If submit is required and we're laving the page, alert the user
             $(window).bind('beforeunload', function() {
                 if (glmSubmitRequired) {
+
                     return true;
                 }
             });
              * New City Dialog
              */
 
-            function addNewCitySetup() {
-                     
+            var newCityLocation = false;
+            function initNewCity() {
+
                 // Setup dialog box for adding a new city
-                $(".newCityDialog").dialog({
+                $("#newCityDialog").dialog({
                     autoOpen: false,
                     minWidth: 400,
                     dialogClass: "glm-dialog-no-close"
                 });
-                $('.new-city-cancel').click( function() {
-                    locID = $(this).attr('data-id');
-                    $("#newCityDialog_" + locID).dialog("close");
+                $('#newCityCancel').click( function() {
+                    $("#newCityDialog").dialog("close");
+                    $('#newCityNameTD').removeClass('glm-form-bad-input');
+                    $('#newCityNameRequired').text('');
+                    $('#newCityName').val('');
                 });
-    
+
                 // Add a new city button action - pop-up dialog
                 $('.new-city-button').click( function() {
-                    locID = $(this).attr('data-id');
-                    $("#newCityDialog_" + locID).dialog("open");
+                    newCityLocation = $(this).attr('data-id');
+                    $("#newCityDialog").dialog("open");
                 });
+
             }
-            addNewCitySetup();
-            
+
             // Submit new city
-            var newCityAdded = false;
+            var newCityCount = 0
+            var listedCities = new Object();
+
+            // Add list of existing cities for duplicate check
+    {foreach $locations as $loc}
+        {foreach $loc.city.list as $v}
+            listedCities["{$v.name}"] = true;
+        {/foreach}
+    {/foreach}
+
             $('.newCitySubmit').click( function() {
 
-                locID = $(this).attr('data-id');
-                
                 // Get new city name
-                var newCityName = $('#newCityName_' + locID).val();
+                var newCityName = $('#newCityName').val();
 
                 // If no name is supplied, notify used it's required
                 if (newCityName == '') {
-                    $('#newCityNameTD_' + locID).addClass('glm-form-bad-input');
-                    $('#newCityNameRequired_' + locID).text('A city name is required!');
+                    $('#newCityNameTD').addClass('glm-form-bad-input');
+                    $('#newCityNameRequired').text('A city name is required!');
+                    return false;
+                } else {
+                    $('#newCityNameTD').removeClass('glm-form-bad-input');
+                    $('#newCityNameRequired').text('');
+                }
+
+                // Check list of new cities added to make sure we don't add a duplicate
+                if (typeof listedCities[newCityName] !== "undefined") {
+                    $('#newCityNameTD').addClass('glm-form-bad-input');
+                    $('#newCityNameRequired').text('This city is already listed!');
                     return false;
                 }
 
                 // Add new city name to the hidden field that will pass the new name to PHP.
-                $('#cityName_' + locID).val(newCityName);
-
-                // Add new city name to picklist and for storing - Only one permitted per submission
-                if (newCityAdded) {
+                newCityCount++;
+                $('#newCityNames').append('<input type="hidden" name="newCity[n_' + newCityCount + ']" value="' + newCityName + '">');
 
-                    // New city already added, so just update the name and select that one
-                    $('#city_' + locID).val(-1);
-                    $('#city_' + locID + ' option:selected').text(newCityName);
+                // Remember this city to check for duplicates being added
+                listedCities[newCityName] = true;
 
-                } else {
-
-                    // Add the new city name to the city picklist
-                    $('#city_' + locID).append('<option value="-1">' + newCityName + '</option>');
-                    $('#city_' + locID ).val(-1);
-                    $('#newCityNameTD_' + locID).append('<input type="hidden" name="newCity" value="' + newCityName + '">');
-                    newCityAdded = true;
-
-                }
+                $('.city-picklist').append('<option value="n_' + newCityCount + '">' + newCityName + '</option>');
+                $('#city_' + newCityLocation).val("n_" + newCityCount);
 
                 // Clear new city name from form
-                $('#newCityName_' + locID).val('');
+                $('#newCityName').val('');
 
-                $("#newCityDialog_" + locID).dialog("close");
+                $('#newCityDialog').dialog("close");
 
             });
 
                 var startLon = $('#glmLng_' + locID).val();
 
                 location[locID] = new google.maps.LatLng(startLat, startLon);
-
                 map[locID] = new google.maps.Map(document.getElementById('locationMap_' + locID), {
                     zoom: 15,
                     disableDefaultUI: false,
 
             }
 
+            /*
+             * Misc support items
+             */
+
+            // 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);
+
         });
     </script>
 
index ab951ed..0f293e6 100644 (file)
@@ -1,8 +1,26 @@
 
 <!-- Location -->
 
-    <script src="http://maps.googleapis.com/maps/api/js?{if $settings.google_maps_api_key != ''}&key={$settings.google_maps_api_key}{/if}"></script>
-    <script type="text/javascript">var enableDraggable = true;</script>
+<script src="http://maps.googleapis.com/maps/api/js?{if $settings.google_maps_api_key != ''}&key={$settings.google_maps_api_key}{/if}"></script>
+<script type="text/javascript">var enableDraggable = true;</script>
+
+<!-- Add New City Dialog Box -->
+<div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
+    <table class="glm-admin-table">
+        <tr>
+            <th class="glm-required">City Name:</th>
+            <td id="newCityNameTD">
+                <input id="newCityName" type="text" name="newCityName" class="glm-form-text-input">
+                <div id="newCityNameRequired"></div>
+            </td>
+        </tr>
+    </table>
+    <p><span class="glm-required">*</span> Required</p>
+    <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
+    <input class="newCitySubmit" type="submit" value="Add new City">
+</div>
+<!-- New city hidden input fields go here -->
+<span id="newCityNames"></span>
 
 <table id="glm-table-location" class="glm-admin-table glm-hidden glm-event-table">
     <tr>
                 <tr class="location_{$loc.id}"><td colspan="2"><hr></td></tr>
                 <tr id="location_{$loc.id}" data-id="{$loc.id}" class="location_{$loc.id} location-form">
                     <td>
-                        <input type="hidden" name="locID[{$loc.id}]" value="{$loc.id}">
-                        <input type="hidden" name="{$loc.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
+                        <input type="hidden" name="locID[{$loc.id}]" value="Loc{$loc.id}">
+                        <input type="hidden" name="loc{$loc.id}_id" value="{$loc.id}">
+                        <input type="hidden" name="Loc{$loc.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
                         <table width="100%">
                             <tr>
                                 <th>Location Name:</th>
                                 <td>
-                                    <input id="name_{$loc.id}" type="text" name="{$loc.id}_name" value="{$loc.name}" class="glm-form-text-input-medium">
+                                    <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>Address:</th>
                                 <td>
-                                    <input id="address_{$loc.id}" type="text" name="{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
+                                    <input id="address_{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
                             <tr>
                                 <td class="glm-item-container">
                                     <!--  Add new city dialog -->
                                     <div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
-                                    <div id="newCityDialog_{$loc.id}" class="glm-dialog-box" title="Enter a New City">
-                                        <table class="glm-admin-table">
-                                            <tr>
-                                                <th class="glm-required">City Name:</th>
-                                                <td id="newCityNameTD_{$loc.id}">
-                                                    <input id="newCityName_{$loc.id}" type="text" name="newCityName" class="glm-form-text-input">
-                                                    <div id="newCityNameRequired_{$loc.id}"></div>
-                                                </td>
-                                            </tr>
-                                        </table>
-                                        <p><span class="glm-required">*</span> Required</p>
-                                        <a id="newCityCancel_{$loc.id}" class="button button-primary glm-right new-city-cancel">Cancel</a>
-                                        <input data-id="{$loc.id}" class="newCitySubmit" type="submit" value="Add new City">
-                                    </div>
                                     <!-- City Selection -->
-                                    <input id="cityName_{$loc.id}" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
-                                    <select id="city_{$loc.id}" name="{$loc.id}_city">
+                                    <select id="city_{$loc.id}" class="city-picklist" name="Loc{$loc.id}_city">
                                         <option value="0"></option>
                         {foreach from=$loc.city.list item=v}
                                         <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
@@ -68,7 +72,7 @@
                             <tr>
                                 <th>State:</th>
                                 <td>
-                                    <select id="state_{$loc.id}" name="{$loc.id}_state">
+                                    <select id="state_{$loc.id}" name="Loc{$loc.id}_state">
                         {foreach from=$loc.state.list item=v}
                                         <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
                                             {$v.name}
                             <tr>
                                 <th>ZIP / Postal Code:</th>
                                 <td>
-                                    <input id="zip_{$loc.id}" type="text" name="{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium">
+                                    <input id="zip_{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
                             <tr>
                                 <th>Country:</th>
                                 <td>
-                                    <select id="country_{$loc.id}" name="{$loc.id}_country">
+                                    <select id="country_{$loc.id}" name="Loc{$loc.id}_country">
                         {foreach from=$loc.country.list item=v}
                                         <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
                                             {$v.name} {$v.value}
                             <tr>
                                 <th>Region:</th>
                                 <td>
-                                    <select name="{$loc.id}_region">
+                                    <select name="Loc{$loc.id}_region">
                                         <option value="0"></option>
                         {foreach from=$loc.region.list item=v}
                                         <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
                             <tr>
                                 <th>Phone:</th>
                                 <td>
-                                    <input type="text" name="{$loc.id}_phone" value="{$loc.phone}" class="glm-form-text-input-medium">
+                                    <input type="text" name="Loc{$loc.id}_phone" value="{$loc.phone}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
                             <tr>
                                 <th>Web Address:</th>
                                 <td>
-                                    <input type="text" name="{$loc.id}_url" value="{$loc.url}" class="glm-form-text-input-medium">
+                                    <input type="text" name="Loc{$loc.id}_url" value="{$loc.url}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
                             <tr>
                                 <th>Email Address:</th>
                                 <td>
-                                    <input type="text" name="{$loc.id}_email" value="{$loc.email}" class="glm-form-text-input-medium">
+                                    <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.id}_contact_fname" value="{$loc.contact_fname}" class="glm-form-text-input-small">
-                                    Last:  <input type="text" name="{$loc.id}_contact_lname" value="{$loc.contact_lname}" class="glm-form-text-input-small">
+                                    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.id}_contact_phone" value="{$loc.contact_phone}" class="glm-form-text-input-medium">
+                                    <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.id}_contact_email" value="{$loc.contact_email}" class="glm-form-text-input-medium">
+                                    <input type="text" name="Loc{$loc.id}_contact_email" value="{$loc.contact_email}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
 
                             <tr>
                                 <th>Location:</th>
                                 <td>
-                                    <input id="glmLat_{$loc.id}" name="{$loc.id}_lat" type="hidden" value="{$loc.lat}">
-                                    <input id="glmLng_{$loc.id}" name="{$loc.id}_lon" type="hidden" value="{$loc.lon}">
+                                    <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>
                                     <div id="glm-estimate-location_{$loc.id}" class="button button-secondary">Map Location Using Above Address</div>
                                     <p>
     <tr class="location_{ newLocID }">
         <td>
             <input type="hidden" name="locID[{ newLocID }]" value="{ newLocID }">
+    {if $haveEvent}            
             <input type="hidden" name="{ newLocID }_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
+    {/if}
             <table width="100%">
                 <tr>
                 <tr>
                     <th>City</th>
                     <td class="glm-item-container">
                         <!--  Add new city dialog -->
-                        <div class="button button-secondary glm-right new-city-button">Add a new City</div>
-                        <div id="newCityDialog_{ newLocID }" class="glm-dialog-box" title="Enter a New City">
-                            <table class="glm-admin-table">
-                                <tr>
-                                    <th class="glm-required">City Name:</th>
-                                    <td id="newCityNameTD_{ newLocID }">
-                                        <input id="newCityName_{ newLocID }" type="text" name="newCityName" class="glm-form-text-input">
-                                        <div id="newCityNameRequired_{ newLocID }"></div>
-                                    </td>
-                                </tr>
-                            </table>
-                            <p><span class="glm-required">*</span> Required</p>
-                            <a id="newCityCancel_{ newLocID }" class="button button-primary glm-right new-city-cancel">Cancel</a>
-                            <input data-id="{$loc.id}" class="newCitySubmit" type="submit" value="Add new City">
-                        </div>
+                        <div data-id="{ newLocID }" class="button button-secondary glm-right new-city-button">Add a new City</div>
                         <!-- City Selection -->
-                        <input id="cityName_{ newLocID }" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
-                        <select id="city_{ newLocID }" name="{ newLocID }_city">
+                        <select id="city_{ newLocID }" class="city-picklist" name="{ newLocID }_city">
                             <option value="0"></option>
             {foreach from=$newLocation.fieldData.city.list item=v}
                             <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
                         <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 }
                             <div id="locationMap_{ newLocID }" class="glm-map-edit">(map loads here)</div>
                             <span id="mapPosition_{ newLocID }">Lat {$newLocation.fieldData.lat}, Lon {$newLocation.fieldData.lon}</span>
                         </p>
index 15068bc..afc36c9 100644 (file)
                 <tr id="recurrence_{$r.id}" class="recurrence_{$r.id} recurrence-form">
                     <td>
                         <input type="hidden" name="recurID[{$r.id}]" value="{$r.id}">
-                        <input type="hidden" name="{$r.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
+                        <input type="hidden" name="Recur{$r.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
                         <input id="{$r.id}_recurUpdated" type="hidden" name="recurUpdated[{$r.id}]" value="0">
                         <table>
                             <tr>
                                 <th>Schedule Name:</th>
                                 <td>
-                                    <input data-id="{$r.id}" type="text" name="{$r.id}_name" value="{$r.name}" class="glm-form-text-input-small recurrence-input">
+                                    <input data-id="{$r.id}" type="text" name="Recur{$r.id}_name" value="{$r.name}" class="glm-form-text-input-small recurrence-input">
                                 </td>
                             </tr>
                             <tr><th colspan="2">First occurrence for this schedule</th></tr>
                             <tr>
                                 <th>All Day Event:</th>
                                 <td>
-                                    <input id="allDayEvent_{$r.id}" data-id="{$r.id}" type="checkbox" name="{$r.id}_all_day" class="all-day-checkbox recurrence-input" {if $r.all_day.value} checked{/if}>
+                                    <input id="allDayEvent_{$r.id}" data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_all_day" class="all-day-checkbox recurrence-input" {if $r.all_day.value} checked{/if}>
                                 </td>
                             </tr>
                             <tr class="not-all-day-{$r.id}{if $r.all_day.value} glm-hidden{/if}">
                                 <th>Start Date & Time:</th>
                                 <td>
-                                    <input data-id="{$r.id}" type="text" name="{$r.id}_start_time" value="{$r.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input recurrence-input" placeholder="Click to Select Date/Time">
+                                    <input data-id="{$r.id}" type="text" name="Recur{$r.id}_start_time" value="{$r.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input recurrence-input" placeholder="Click to Select Date/Time">
                                 </td>
                             </tr>
                             <tr class="not-all-day-{$r.id} {if $r.all_day.value} glm-hidden{/if}">
                                 <th>Start Date & Time Only</th>
                                 <td>
-                                    <input id="startTimeOnly_{$r.id}" data-id="{$r.id}" type="checkbox" name="{$r.id}_start_time_only" class="start-time-only-checkbox recurrence-input" {if $r.start_time_only.value} checked{/if}>
+                                    <input id="startTimeOnly_{$r.id}" data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_start_time_only" class="start-time-only-checkbox recurrence-input" {if $r.start_time_only.value} checked{/if}>
                                 </td>
                             </tr>
                             <tr class="start-time-only-{$r.id}{if $r.all_day.value || $r.start_time_only.value} glm-hidden{/if}">
                                 <th>End Date & Time:</th>
                                 <td>
-                                    <input data-id="{$r.id}" type="text" name="{$r.id}_end_time" value="{$r.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input recurrence-input" placeholder="Click to Select Date/Time">
+                                    <input data-id="{$r.id}" type="text" name="Recur{$r.id}_end_time" value="{$r.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input recurrence-input" placeholder="Click to Select Date/Time">
                                 </td>
                             </tr>
                             <tr class="all-day-{$r.id}{if !$r.all_day.value} glm-hidden{/if}">
                                 <th>Event Date:</th>
                                 <td>
-                                    <input data-id="{$r.id}" type="text" name="{$r.id}_start_date" value="{$r.start_date.date}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
+                                    <input data-id="{$r.id}" type="text" name="Recur{$r.id}_start_date" value="{$r.start_date.date}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
                                 </td>
                             </tr>
                             <tr><td colspan="2">&nbsp;</td></tr>
                             <tr>
                                 <th>From Date:</th>
                                 <td>
-                                    <input data-id="{$r.id}" type="text" name="{$r.id}_from_date" value="{$r.from_date.date}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
+                                    <input data-id="{$r.id}" type="text" name="Recur{$r.id}_from_date" value="{$r.from_date.date}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
                                 </td>
                             </tr>
                             <tr>
                                 <th>To Date:</th>
                                 <td>
-                                    <input data-id="{$r.id}" type="text" name="{$r.id}_to_date" value="{$r.to_date.date}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
+                                    <input data-id="{$r.id}" type="text" name="Recur{$r.id}_to_date" value="{$r.to_date.date}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
                                 </td>
                             </tr>
                 
@@ -87,7 +87,7 @@
                             <tr>
                                 <th>Ongoing Event:</th>
                                 <td width="90%">
-                                    <input id="allDatesEvent_{$r.id}" data-id="{$r.id}" type="checkbox" name="{$r.id}_all_dates" class="all-dates-checkbox recurrence-input" {if $r.all_dates.value} checked{/if}> 
+                                    <input id="allDatesEvent_{$r.id}" data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_all_dates" class="all-dates-checkbox recurrence-input" {if $r.all_dates.value} checked{/if}> 
                                     Check to have event recurr every day from the "From Date" through the "To Date".
                                 </td>
                             </tr>
                             {if $v.value==6}
                                             </tr><tr>
                             {/if}
-                                                <td style="white-space: nowrap;"><input data-id="{$r.id}" type="checkbox" name="{$r.id}_month_of_year[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
+                                                <td style="white-space: nowrap;"><input data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_month_of_year[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
                         {/foreach}
                                                 <td>&nbsp;&nbsp;<div data-id="monthOfYearTable_{$r.id}" class="button glm-button-small glm-set-all">All</div><div data-id="monthOfYearTable_{$r.id}" class="button glm-button-small glm-set-none">None</div></td>
                                             </tr>
                                 <tr>
                                     <th>Days of month:</th>
                                     <td>
-                                        <input id="specificDaysOfMonth_{$r.id}" data-id="{$r.id}" type="checkbox" name="{$r.id}_by_day_of_month" class="days-of-month-checkbox recurrence-input" {if $r.by_day_of_month.value} checked{/if}> Check to select specific days of the month.
+                                        <input id="specificDaysOfMonth_{$r.id}" data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_by_day_of_month" class="days-of-month-checkbox recurrence-input" {if $r.by_day_of_month.value} checked{/if}> Check to select specific days of the month.
                                     </td>
                                 </tr>
                                 <tr class="not-by-day-of-month-{$r.id}{if $r.by_day_of_month.value} glm-hidden{/if}">
                                         <table id="weekOfMonthTable_{$r.id}">
                                             <tr>
                         {foreach $r.week_of_month.bitmap as $v}
-                                                <td style="white-space: nowrap;"><input data-id="{$r.id}" type="checkbox" name="{$r.id}_week_of_month[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
+                                                <td style="white-space: nowrap;"><input data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_week_of_month[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
                         {/foreach}
                                                 <td>&nbsp;&nbsp;<div data-id="weekOfMonthTable_{$r.id}" class="button glm-button-small glm-set-all">All</div><div data-id="weekOfMonthTable_{$r.id}" class="button glm-button-small glm-set-none">None</div></td>
                                             </tr>
                                         <table id="dayOfWeekTable_{$r.id}">
                                             <tr>
                         {foreach $r.day_of_week.bitmap as $v}
-                                                <td style="white-space: nowrap;"><input data-id="{$r.id}" type="checkbox" name="{$r.id}_day_of_week[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}</td>
+                                                <td style="white-space: nowrap;"><input data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_day_of_week[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}</td>
                         {/foreach}
                                                 <td>&nbsp;&nbsp;<div data-id="dayOfWeekTable_{$r.id}" class="button glm-button-small glm-set-all">All</div><div data-id="dayOfWeekTable_{$r.id}" class="button glm-button-small glm-set-none">None</div></td>
                                             </tr>
                                             </tr><tr>
                             {/if}
                                                 <td>
-                                                    <input data-id="{$r.id}" type="checkbox" name="{$r.id}_day_of_month[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}
+                                                    <input data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_day_of_month[{$v.value}]" value="{$v.value}" class="recurrence-input"{if $v.default} checked{/if}> {$v.name}
                                                 </td>
                         {/foreach}
                                                 <td colspan="3" style="text-align: center;">
-                                                    <input data-id="{$r.id}" type="checkbox" name="{$r.id}_last_day_of_month" class="recurrence-input"{if $r.last_day_of_month.value} checked{/if}> Last day of the month
+                                                    <input data-id="{$r.id}" type="checkbox" name="Recur{$r.id}_last_day_of_month" class="recurrence-input"{if $r.last_day_of_month.value} checked{/if}> Last day of the month
                                                 </td>
                                                 <td><div data-id="dayOfMonthTable_{$r.id}" class="button glm-button-small glm-set-all">All</div><div data-id="dayOfMonthTable_{$r.id}" class="button glm-button-small glm-set-none">None</div></td>
                                             </tr>
     </tr>
 </table>
         
-<!-- Add/Edit Recurrence Template -->
+<!-- Add Recurrence Template -->
     
 <table id="addRecurrenceTemplate" class="glm-hidden">
     <tr class="recurrence_{ newRecurID }">
         <td>
             <input type="hidden" name="recurID[{ newRecurID }]" value="{ newRecurID }">
+    {if $haveEvent}   
             <input type="hidden" name="{ newRecurID }_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
+    {/if}            
             <table width="100%">
                 <tr>
                     <th>Schedule Name:</th>
index 76def26..5e2a568 100644 (file)
                 {if $event.fieldFail.image}<p>{$event.fieldFail.image}</p>{/if}
             </td>
         </tr>
+        <tr>
+            <th {if $event.fieldRequired.phone}class="glm-required"{/if}>Event Phone #:</th>
+            <td {if $event.fieldFail.phone}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
+                <input type="text" name="phone" value="{$event.fieldData.phone}" class="glm-form-text-input-medium" placeholder="ex: 123-123-1234">
+                {if $event.fieldFail.phone}<p>{$event.fieldFail.phone}</p>{/if}<br>
+            </td>
+        </tr>
         <tr>
             <th {if $event.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
             <td {if $event.fieldFail.url}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>