More admin enhancements to Events - First live data
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 9 Mar 2016 20:53:44 +0000 (15:53 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 9 Mar 2016 20:53:44 +0000 (15:53 -0500)
12 files changed:
activate.php
classes/data/dataRecurrences.php
classes/data/dataTimes.php
index.php
models/admin/events/list.php
setup/databaseScripts/create_database_V0.0.2.sql [deleted file]
setup/databaseScripts/create_database_V0.0.3.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.3.sql [new file with mode: 0644]
views/admin/events/calendar.html
views/admin/events/edit.html
views/admin/settings/eventCategories.html

index 97ac9a9..bd0f669 100644 (file)
@@ -84,15 +84,7 @@ class glmMembersEventsPluginActivate
 
         // Set Roles and Capabilities for this plugin
         require_once(GLM_MEMBERS_EVENTS_PLUGIN_SETUP_PATH.'/rolesAndCapabilities.php');
-        wp_enqueue_script('jquery');
-        wp_enqueue_script('jquery-style');
-        wp_enqueue_script('jquery-ui-core');
-        wp_enqueue_script('jquery-ui-dialog');
-        wp_enqueue_script('jquery-ui-autocomplete');
-
-        // Jquery DatePicker
-        wp_enqueue_script('jquery-ui-datepicker');
-        wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css');
+
     }
 
     /*
index 8fa8ff7..e3e6b22 100644 (file)
@@ -134,6 +134,7 @@ class GlmDataEventsRecurrences extends GlmDataAbstract
             'start_time' => array (
                 'field' => 'start_time',
                 'type' => 'datetime',
+                'format' => 'm/d/Y H:i',
                 'required' => true,
                 'use' => 'a'
             ),
@@ -152,6 +153,7 @@ class GlmDataEventsRecurrences extends GlmDataAbstract
             'end_time' => array (
                 'field' => 'end_time',
                 'type' => 'datetime',
+                'format' => 'm/d/Y H:i',
                 'use' => 'a'
             ),
 
@@ -206,6 +208,14 @@ class GlmDataEventsRecurrences extends GlmDataAbstract
                     'use'      => 'a'
             ),
 
+            // Select by Days of the Month Flag
+            'by_day_of_month' => array (
+                'field' => 'by_day_of_month',
+                'type' => 'checkbox',
+                'default' => false,
+                'use' => 'a'
+            ),
+
             // Day of Month - multi-pick (bitmap)
             'day_of_month' => array(
                     'field'    => 'day_of_month',
@@ -293,8 +303,8 @@ class GlmDataEventsRecurrences extends GlmDataAbstract
                 if ($recurData && $recurData['event'] > 0) {
                     $this->wpdb->query("
                         DELETE FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events
-                         WHERE root_event = $recurID
-                    ;");
+                         WHERE root_event = ".$recurData['event']."
+                    ");
                 }
 
             // Otherwise don't delete times for the custom events
@@ -352,41 +362,53 @@ class GlmDataEventsRecurrences extends GlmDataAbstract
         $fromYear = $from->format('Y');
         $toYear = $to->format('Y');
 
+        // Determine time each event starts at
+        $time = $start->format('H:i');
+
         // For each year in recurrence range
         for ($year = $fromYear ; $year <= $toYear ; $year++ ) {
 
-            // For each Month selected
+            // For each month selected
             foreach ($recurData['month_of_year']['names'] as $km=>$month) {
 
-                // For each week selected
-                foreach ($recurData['week_of_month']['names'] as $kw=>$week) {
-
-                    // For each day selected
-                    foreach ($recurData['day_of_week']['names'] as $kd=>$day) {
+                    // If selecting by days of the month
+                if ($recurData['by_day_of_month']['value']) {
 
-                        $dates[] = new DateTime("$week $day of $month $year");
+                    // For each specified days of the month ($dom is day of month)
+                    foreach ($recurData['day_of_month']['names'] as $kdom=>$dom) {
+                        $t = new DateTime("$month $dom $year $time");
+                        $dates[$t->getTimestamp()] = $t;
+                    }
 
-                    } // Day of Week
+                    // If last day of month is selected
+                    if ($recurData['last_day_of_month']['value']) {
+                        $t = new DateTime("last day of $month $year $time");
+                        $dates[$t->getTimestamp()] = $t;
+                    }
 
-                } // Week of Month
+                } else {
 
-                // For each specifi days of the month
-                foreach ($recurData['day_of_month']['names'] as $kdom=>$dom) {
+                    // For each week selected
+                    foreach ($recurData['week_of_month']['names'] as $kw=>$week) {
 
-                    $dates[] = new DateTime("$month $dom $year");
+                        // For each day selected
+                        foreach ($recurData['day_of_week']['names'] as $kd=>$day) {
+                            $t = new DateTime("$week $day of $month $year $time");
+                            $dates[$t->getTimestamp()] = $t;
+                        }
 
-                }
+                    }
 
-                // If last day of month is selected
-                if ($recurData['last_day_of_month']['value']) {
-                    $dates[] = new DateTime("last day of $month $year");
                 }
 
-
             } // Month of Year
 
         } // Year
 
+        // Check if the recurrences caught the "First Occurance"
+        if (!isset($dates[$start->getTimestamp()])) {
+            $dates[$start->getTimestamp()] = $start;
+        }
 
         // Create From and to timestamp for comparison
         $fromTime = $from->getTimestamp();
index 7298781..d8205a8 100644 (file)
@@ -130,6 +130,17 @@ class GlmDataEventsTimes extends GlmDataAbstract
                 'use' => 'glei'
             ),
 
+            // Event Name
+            'event_name' => array (
+                'field' => 'event',
+                'as' => 'event_name',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'events',
+                    'p_field' => 'name',
+                    'p_static' => true,
+                'use' => 'a'
+            ),
+
             // Custom Event ID
             'custom_event' => array(
                 'field' => 'custom_event',
index 822fd64..3ed99fa 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.2');
+define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.3');
 
 // 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 c3d3fd3..535c2e3 100644 (file)
@@ -108,8 +108,12 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
         $eventDeleted = false;
         $eventDeleteError = false;
         $recurrences = false;
+        $haveRecurrences = false;
+        $numbRecurrences = 0;
         $times = false;
         $haveTimes = false;
+        $firstTime = false;
+        $lastTime = false;
 
         // Get a list of categories
         $Categories = new GlmDataEventsCategories($this->wpdb, $this->config);
@@ -133,15 +137,9 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
             if ($this->eventID <= 0) {
                 $this->eventID = false;
-            } else {
-
-                // Get recurrences for this event
-                $recurrences = $Recurrences->getList("T.event = ".$this->eventID);
-
             }
-        }
-
 
+        }
 
         /*
          * PLACE TEMPORARY TEST DATA FOR CALENDARS HERE
@@ -251,6 +249,67 @@ 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 recurrence data
+                if (isset($_REQUEST['recurID'])) {
+
+                    // For each recurrence
+                    foreach ($_REQUEST['recurID'] as $recurID) {
+
+                        // first check if the event is an all-day event
+                        if (isset($_REQUEST[$recurID.'_all_day'])) {
+
+                            // Then take the event date (date only) and stick it into the start time
+                            $red = explode(' ', $_REQUEST[$recurID.'_event_date']);
+                            $_REQUEST[$recurID.'_start_time'] = $red[0]." 00:00";
+                            $_REQUEST[$recurID.'_end_time'] = $$red[0]." 00:00";
+
+                        }
+
+                        // Check if it's a new Recurrence
+                        if ($recurID[0] == 'n') {
+
+                            // Add the new recurrence
+                            $x = $Recurrences->insertEntry(true, $recurID.'_');
+
+                            // And create time entries
+                            $Recurrences->createRecurrenceTimesEntries($x['fieldData']['id'], true, true);
+
+                        // Otherwise it's an existing recurrence
+                        } else {
+                           $Recurrences->updateEntry($recurID, 'id', true, $recurID.'_');
+                        }
+
+                    }
+
+                    // 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);
+                            }
+                        }
+                    }
+
+                }
+
                 $haveEvent = true;
                 $view = 'edit';
 
@@ -285,6 +344,34 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
         }
 
+        // If we have an event ID
+        if ($this->eventID) {
+
+            // Get recurrences for this event
+            $recurrences = $Recurrences->getList("T.event = ".$this->eventID);
+
+            // Check if we have recurrences
+            if ($recurrences) {
+                $haveRecurrences = true;
+                $numbRecurrences = count($recurrences);
+
+                // Get list of times
+                require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataTimes.php');
+                $Times = new GlmDataEventsTimes($this->wpdb, $this->config);
+                $times = $Times->getList('T.event = '.$this->eventID, 'start_time');
+
+                if ($times && count($times) > 0) {
+                    $haveTimes = true;
+
+                    // Get the first event date/time
+                    $firstTime = current($times);
+                    $lastTime = end($times);
+
+                }
+
+            }
+        }
+
         $templateData = array(
             'option' => $option,
             'events' => $events,
@@ -302,9 +389,13 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
             'eventDeleted' => $eventDeleted,
             'eventDeleteError' => $eventDeleteError,
             'recurrences' => $recurrences,
+            'haveRecurrences' => $haveRecurrences,
+            'numbRecurrences' => $numbRecurrences,
             'newRecurrence' => $newRecurrence,
             'times' => $times,
             'haveTimes' => $haveTimes,
+            'firstTime' => $firstTime,
+            'lastTime' => $lastTime
         );
 
         // Return status, any suggested view, and any data to controller
diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql
deleted file mode 100644 (file)
index 221caf6..0000000
+++ /dev/null
@@ -1,155 +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 receint 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
-  start_time DATETIME NULL,                             -- Start of first occurance (date and time)
-  end_time DATETIME NULL,                               -- End of first occurance (date and time)
-  from_date DATE NULL,                                  -- From Date for recurrences
-  to_date DATE NULL,                                    -- To Date for recurrences
-  all_day BOOLEAN NULL,                                 -- Flag indicating if this is an all-day event (inforational only)
-  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)
-  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 recurrance entry
-  active BOOLEAN NULL,                                  -- Active flag - normally set but used to temporarily dissable 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 referernced 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 abreviation
-  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
-  cost TINYTEXT NULL,                                   -- Description of event cost
-  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.3.sql b/setup/databaseScripts/create_database_V0.0.3.sql
new file mode 100644 (file)
index 0000000..b8c6d19
--- /dev/null
@@ -0,0 +1,156 @@
+-- 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 receint 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
+  start_time DATETIME NULL,                             -- Start of first occurance (date and time)
+  end_time DATETIME NULL,                               -- End of first occurance (date and time)
+  from_date DATE NULL,                                  -- From Date for recurrences
+  to_date DATE NULL,                                    -- To Date for recurrences
+  all_day BOOLEAN NULL,                                 -- Flag indicating if this is an all-day event (inforational only)
+  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 recurrance entry
+  active BOOLEAN NULL,                                  -- Active flag - normally set but used to temporarily dissable 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 referernced 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 abreviation
+  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
+  cost TINYTEXT NULL,                                   -- Description of event cost
+  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 919ea67..beeccc5 100644 (file)
@@ -15,6 +15,7 @@
 
 $glmMembersEventsDbVersions = array(
     '0.0.1' => array('version' => '0.0.1', 'tables' => 6),
-    '0.0.2' => array('version' => '0.0.2', 'tables' => 7)
+    '0.0.2' => array('version' => '0.0.2', 'tables' => 7),
+    '0.0.3' => array('version' => '0.0.3', 'tables' => 7)
 );
 
diff --git a/setup/databaseScripts/update_database_V0.0.3.sql b/setup/databaseScripts/update_database_V0.0.3.sql
new file mode 100644 (file)
index 0000000..f20d3ac
--- /dev/null
@@ -0,0 +1,16 @@
+-- Gaslight Media Members Database  - Events Add-On
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 0.0.2
+-- 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 by_day_of_month flag field 
+ALTER TABLE {prefix}recurrences ADD COLUMN by_day_of_month BOOLEAN;
+
+
+
+
+
index 88098d4..929bae8 100644 (file)
@@ -6,25 +6,30 @@
      
 -->
 
-Place Calendar View HTML/Scripts here
+<div id="eventCalendar">calendar goes here</div>
 
-{if $haveTimes}
-    
-    {foreach $times as $v}
-    
-        Time ID: {$v.id}<br>
-        Event ID: {$v.event}<br>
-        Custom Event Data: {$v.custom_event}<br>
-        Recurrence ID: {$v.recur_id}<br>
-        Active: {$v.active}<br>
-        Start Time - timestamp: {$v.start_time.timestamp}<br>
-        Start Time - date time: {$v.start_time.datetime}<br>
-        End Time - timestamp: {$v.end_time.timestamp}<br>
-        End Time - date time: {$v.end_time.datetime}<br>
-        {$v.all_day}
+<script type="text/javascript">
+
+    $(document).ready(function() {
     
-    {/foreach}
+        /*
+         * Edit area tabs
+         */
+        $('.glm-event-tab').click( function() {
+
+            // Show selected table
+            var table = $(this).attr('data-show-table');
+
+            if (table == 'glm-table-calendar') {
+                alert(1);
+            }
+            
+        });
+
+        $('#eventCalendar').fullCalendar({
+            // put your options and callbacks here
+        })
+
+    });
     
-{else}
-    <p>(no times listed)</p>
-{/if} 
\ No newline at end of file
+</script>
\ No newline at end of file
index 007d01e..22c78c6 100644 (file)
         
         <table id="glm-table-recurrence" class="glm-admin-table glm-hidden glm-event-table">
             <tr>
-                <td colspan="2">
+                <td id="placeDeletesHere" colspan="2">
                     <a id="addRecurrence" class="button button-primary glm-button glm-right">Add an Event Schedule</a>
                 </td>
             </tr>
             <tr>
                 <td colspan="2">
-                    <table id="recurrenceTable">
-                    
+                    <table id="recurrenceTable">                    
                     <!-- Recurrence forms go here. New forms are added to the bottom of the list by the scripts at the bottom -->
         {if $recurrences}
-            {foreach $recurrences as $v}
+            {foreach $recurrences as $r}
+                        <tr><td colspan="2"><hr></td></tr>
+                        <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 id="{$r.id}_recurUpdated" type="hidden" name="recurUpdated[{$r.id}]" value="0">
+                                <table width="100%">
+                                    <tr><th></th><th>First occurrence of event</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}>
+                                        </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">
+                                        </td>
+                                    </tr>
+                                    <tr class="not-all-day-{$r.id}{if $r.all_day.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">
+                                        </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}_event_date" value="{$r.start_time.datetime}" class="glm-form-text-input-small glm-date-input recurrence-input" placeholder="Click to Select Date/Time">
+                                        </td>
+                                    </tr>
+                        
+                                    <tr><th></th><th><p>Date range over which recurring event can take place</p></th></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">
+                                        </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">
+                                        </td>
+                                    </tr>
+                        
+                                </table>
+                            </td>
+                            <td>
+                                <table width="100%">
+                        
+                                    <tr>
+                                        <th></th>
+                                        <th>                                
+                                            <a id="deleteRecurrence_{$r.id}" data-id="{$r.id}" class="button button-primary glm-button glm-right delete-new-recurrence">Delete this Event Schedule</a>
+                                            When the event recurrs
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th>Months</th>
+                                        <td>
+                                            <table>
+                                                <tr>
+                            {foreach $r.month_of_year.bitmap as $v}
+                                {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>
+                            {/foreach}
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                    <tr><td colspan="2">&nbsp;</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.
+                                        </td>
+                                    </tr>
+                                    <tr class="not-by-day-of-month-{$r.id}{if $r.by_day_of_month.value} glm-hidden{/if}">
+                                        <th>Week of the Month</th>
+                                        <td>
+                                            <table>
+                                                <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>
+                            {/foreach}
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                    <tr class="not-by-day-of-month-{$r.id}{if $r.by_day_of_month.value} glm-hidden{/if}">
+                                        <th>Day of the Week</th>
+                                        <td>
+                                            <table>
+                                                <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>
+                            {/foreach}
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                    <tr class="by-day-of-month-{$r.id}{if !$r.by_day_of_month.value} glm-hidden{/if}">
+                                        <th>Day of the Month</th>
+                                        <td>
+                                            <table width="100%" class="glm-calendar">
+                                                <tr>
+                            {foreach $r.day_of_month.bitmap as $v}
+                                {if in_array($v.value, array(7, 14, 21, 28))}
+                                                </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}
+                                                    </td>
+                            {/foreach}
+                                                    <td colspan="4" 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
+                                                    </td>
+                                                </tr>
+                                            </table>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+        
+        
         
             {/foreach}
+        {else}
+                        <tr id="no-recurrence-msg"><td colspan="2">(Add event schedules here)</td></tr>
         {/if}
-            
                     </table>
                 </td>
             </tr>
         <table id="glm-table-calendar" class="glm-admin-table glm-hidden glm-event-table">
             <tr>
                 <td>
-                    {include file='admin/events/calendar.html'}
+                    <div id="eventCalendar"></div>
                 </td>
             </tr>
         </table>
     <!-- Add/Edit Recurrence Template -->
     
     <table id="addRecurrenceTemplate" class="glm-hidden">
-        <tr><td colspan="2"><h2>New Event Schedule</h2></td></tr>
-        <tr>
+        <tr class="recurrence_{ newRecurID }">
+            <td colspan="2">
+            </td>
+        </tr>
+        <tr class="recurrence_{ newRecurID }">
             <td>
-                <input type="hidden" name="newRecurID" value="{ newRecurID }n">
+                <input type="hidden" name="recurID[{ newRecurID }]" value="{ newRecurID }">
+                <input type="hidden" name="{ newRecurID }_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
                 <table width="100%">
-                    <tr><th></th><th><p>First ocurrence of event</p></th></tr>
+                    <tr>
+                        <th class="glm-notice">New Schedule</th>
+                        <th>First ocurrence of event</th>
+                    </tr>
                     <tr>
                         <th>All Day Event:</th>
                         <td>
-                            <input id="allDayEvent_{ newRecurID }n" type="checkbox" name="all_day[{ newRecurID }n]" {if $event.fieldData.all_day.value} checked{/if}>
+                            <input id="allDayEvent_{ newRecurID }" data-id="{ newRecurID }" type="checkbox" name="{ newRecurID }_all_day" class="all-day-checkbox">
                         </td>
                     </tr>
-                    <tr class="not-all-day">
-                        <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Start Date & Time:</th>
-                        <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
-                            <input type="text" name="start_time_{ newRecurID }n" value="{$newRecurrence.fieldData.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
-                            {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
+                    <tr class="not-all-day-{ newRecurID }">
+                        <th>Start Date & Time:</th>
+                        <td>
+                            <input type="text" name="{ newRecurID }_start_time" value="{$newRecurrence.fieldData.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
                         </td>
                     </tr>
-                    <tr class="not-all-day">
-                        <th {if $newRecurrence.fieldRequired.end_time}class="glm-required"{/if}>End Date & Time:</th>
-                        <td {if $newRecurrence.fieldFail.end_time}class="glm-form-bad-input"{/if}>
-                            <input type="text" name="end_time_{ newRecurID }n" value="{$newRecurrence.fieldData.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
-                            {if $newRecurrence.fieldFail.end_time}<p>{$newRecurrence.fieldFail.end_time}</p>{/if}
+                    <tr class="not-all-day-{ newRecurID }">
+                        <th>End Date & Time:</th>
+                        <td>
+                            <input type="text" name="{ newRecurID }_end_time" value="{$newRecurrence.fieldData.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
                         </td>
                     </tr>
         
-                    <tr class="all-day glm-hidden">
-                        <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Event Date:</th>
-                        <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
-                            <input type="text" name="start_time_{ newRecurID }n" value="{$newRecurrence.fieldData.start_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
-                            {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
+                    <tr class="all-day-{ newRecurID } glm-hidden">
+                        <th>Event Date:</th>
+                        <td>
+                            <!-- Note that _event_date gets translated to _start_time in the model if _all_day is selected -->
+                            <input type="text" name="{ newRecurID }_event_date" value="{$newRecurrence.fieldData.start_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
                         </td>
                     </tr>
         
                     <tr><th></th><th><p>Date range over which recurring event can take place</p></th></tr>
                     <tr>
-                        <th {if $newRecurrence.fieldRequired.from_date}class="glm-required"{/if}>From Date:</th>
-                        <td {if $newRecurrence.fieldFail.from_date}class="glm-form-bad-input"{/if}>
-                            <input type="text" name="from_date_{ newRecurID }n" value="{$newRecurrence.fieldData.from_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
-                            {if $newRecurrence.fieldFail.from_date}<p>{$newRecurrence.fieldFail.from_date}</p>{/if}
+                        <th>From Date:</th>
+                        <td>
+                            <input type="text" name="{ newRecurID }_from_date" value="{$newRecurrence.fieldData.from_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
                         </td>
                     </tr>
                     <tr>
-                        <th {if $newRecurrence.fieldRequired.to_date}class="glm-required"{/if}>To Date:</th>
-                        <td {if $newRecurrence.fieldFail.to_date}class="glm-form-bad-input"{/if}>
-                            <input type="text" name="to_date_{ newRecurID }n" value="{$newRecurrence.fieldData.to_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
-                            {if $newRecurrence.fieldFail.to_date}<p>{$newRecurrence.fieldFail.to_date}</p>{/if}
+                        <th>To Date:</th>
+                        <td>
+                            <input type="text" name="{ newRecurID }_to_date" value="{$newRecurrence.fieldData.to_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
                         </td>
                     </tr>
         
             <td>
                 <table width="100%">
         
-                    <tr><th></th><th><p>When the event recurrs</p></th></tr>
+                    <tr>
+                        <th></th>
+                        <th>
+                            <a id="deleteRecurrence_{ newRecurID }" data-id="{ newRecurID }" class="button button-primary glm-button glm-right delete-new-recurrence">Delete this Event Schedule</a>
+                            When the event recurrs
+                        </th>
+                    </tr>
                     <tr>
                         <th>Months</th>
                         <td>
                 {if $v.value==6}
                                 </tr><tr>
                 {/if}
-                                    <td style="white-space: nowrap;"><input type="checkbox" name="month_of_year_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
+                                    <td style="white-space: nowrap;"><input type="checkbox" name="{ newRecurID }_month_of_year[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
             {/foreach}
                                 </tr>
                             </table>
                         </td>
                     </tr>
+                    <tr><td colspan="2">&nbsp;</td></tr>
                     <tr>
-                        <th>Select by:</br>Days of month:</th>
+                        <th>Days of month:</th>
                         <td>
-                            <input id="specificDaysOfMonth" type="checkbox" name="by_days_of_month_{ newRecurID }n" {if $event.fieldData.all_day.value} checked{/if}> Check to select specific days of the month.
+                            <input id="specificDaysOfMonth_{ newRecurID }" data-id="{ newRecurID }" type="checkbox" name="{ newRecurID }_by_day_of_month" class="days-of-month-checkbox"> Check to select specific days of the month.
                         </td>
                     </tr>
-                    <tr class="not-by-day-of-month">
+                    <tr class="not-by-day-of-month-{ newRecurID }">
                         <th>Week of the Month</th>
                         <td>
                             <table>
                                 <tr>
             {foreach $newRecurrence.fieldData.week_of_month.bitmap as $v}
-                                    <td style="white-space: nowrap;"><input type="checkbox" name="week_of_month_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
+                                    <td style="white-space: nowrap;"><input type="checkbox" name="{ newRecurID }_week_of_month[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
             {/foreach}
                                 </tr>
                             </table>
                         </td>
                     </tr>
-                    <tr class="not-by-day-of-month">
+                    <tr class="not-by-day-of-month-{ newRecurID }">
                         <th>Day of the Week</th>
                         <td>
                             <table>
                                 <tr>
             {foreach $newRecurrence.fieldData.day_of_week.bitmap as $v}
-                                    <td style="white-space: nowrap;"><input type="checkbox" name="date_of_week_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}</td>
+                                    <td style="white-space: nowrap;"><input type="checkbox" name="{ newRecurID }_day_of_week[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}</td>
             {/foreach}
                                 </tr>
                             </table>
                         </td>
                     </tr>
-                    <tr class="by-day-of-month glm-hidden">
+                    <tr class="by-day-of-month-{ newRecurID } glm-hidden">
                         <th>Day of the Month</th>
                         <td>
                             <table width="100%" class="glm-calendar">
                                 </tr><tr>
                 {/if}
                                     <td>
-                                        <input type="checkbox" name="date_of_week_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}
+                                        <input type="checkbox" name="{ newRecurID }_day_of_month[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}
                                     </td>
             {/foreach}
                                     <td colspan="4" style="text-align: center;">
-                                        <input type="checkbox" name="last_day_of_month_{ newRecurID }n" value="{$v.value}"{if $v.default} checked{/if}> Last day of the month
+                                        <input type="checkbox" name="{ newRecurID }_last_day_of_month"> Last day of the month
                                     </td>
                                 </tr>
                             </table>
             </td>
         </tr>
     </table>
-                                
-                                
-
 
     <script type="text/javascript">
         jQuery(document).ready(function($) {
+
+            var fullCalendarLoaded = false;
+            var recurrencesInited = false;
             
             /*
              * Edit area tabs
                 $('#' + table).removeClass('glm-hidden');
                 
                 
-                if (table == 'glm-table-recurrence') {
+                if (table == 'glm-table-recurrence' && !recurrencesInited) {
                     initRecurrence();
+                    recurrencesInited = true;
                 }
-                
-            });
-
-            /*
-             * Date/Time Pickers
-             */
-            function initRecurrence() {
-                
-                $('.glm-datetime-input').datetimepicker({
-                    format: 'm/d/Y H:i',
-                    lang: 'en',
-                    step: 15,
-                    closeOnWithoutClick: true
-                });
 
-                $('.glm-date-input').datepicker();
-                
-            }
-            
-            // All-Day selection
-            $('#allDayEvent').click( function() {
-                if ($("#allDayEvent")[0].checked) {
-                    $(".not-all-day").addClass('glm-hidden');
-                    $(".all-day").removeClass('glm-hidden');
-                } else {
-                    $(".not-all-day").removeClass('glm-hidden');
-                    $(".all-day").addClass('glm-hidden');
-                }
-            });
-            
-            // By day of month selection
-            $('#specificDaysOfMonth').click( function() {
-                if ($("#specificDaysOfMonth")[0].checked) {
-                    $(".not-by-day-of-month").addClass('glm-hidden');
-                    $(".by-day-of-month").removeClass('glm-hidden');
-                } else {
-                    $(".not-by-day-of-month").removeClass('glm-hidden');
-                    $(".by-day-of-month").addClass('glm-hidden');
+                if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
+                    $('#eventCalendar').fullCalendar({
+                        events: [
+        {if $haveTimes} 
+            {$sep = ''}
+            {foreach $times as $t}
+                            {$sep}{
+                                title : '{$t.event_name}',
+                                start : '{$t.start_time.datetime}',
+                                end   : '{$t.end_time.datetime}',
+                                allday : {$t.all_day.value}
+                            }
+                {$sep = ','}
+            {/foreach}
+        {/if}
+                        ],
+                        defaultDate : '{$lastTime.start_time.datetime}'
+                    });
+                    fullCalendarLoaded = true;
                 }
+
             });
-            
+
             // Add Event Button Action
             $('#addEventButton').click( function() {
                 window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=list&option=add";
             /*
              * Recurrences
              */
-             var haveRecurrences = false;
-        {if $recurrences}
-            haveRecurrences = true;
-        {/if}
+             var numbRecurrences = {$numbRecurrences};
 
             /*
              * Add recurrence using template
 
                 // If we already have at least one recurrence, we need to add a separator
                 var recurTemp = '';
-                if (haveRecurrences) {
-                    recurTemp = '<tbody><tr><td colspan="2"><hr></td></tr></tbody>';
+                if (numbRecurrences) {
+                    recurTemp = '<tbody class="recurrence_{ newRecurID }"><tr><td colspan="2"><hr></td></tr></tbody>';
 
                 // Otherwise, we'll say we now have our first recurrence
                 } else {
-                    haveRecurrences = true;                    
+                    numbRecurrences++;                    
                 }
 
                 recurTemp = recurTemp + $('#addRecurrenceTemplate').html();
-                recurTemp = recurTemp.replace(/{ newRecurID }/g, newRecurID);
+                recurTemp = recurTemp.replace(/{ newRecurID }/g, 'n' + newRecurID); // Include "n" to indicate "new"
                 
                 // Append the new recurrence form to the container
                 $('#recurrenceTable').append(recurTemp);
                 
+                initRecurrence();
+                                
             }
             
             // When adding a new recurrence is requested
             $("#addRecurrence").click( function() {
                 addNewRecurrenceForm();
+                $('#no-recurrence-msg').remove();
             });
             
-            // Also add a new one at the start if none exist
-            if (!haveRecurrences){
-                addNewRecurrenceForm();
+            /*
+             * Things that need to be renewed each time a recurrence is added
+             */
+            function initRecurrence() {
+               
+                // Date / Time Pickers
+                $('.glm-datetime-input').datetimepicker({
+                    format: 'm/d/Y H:i',
+                    lang: 'en',
+                    step: 15,
+                    closeOnWithoutClick: true
+                });
+
+                // Date Only Pickers
+                $('.glm-date-input').datetimepicker({
+                    format: 'm/d/Y',
+                    lang: 'en',
+                    step: 15,
+                    closeOnWithoutClick: true,
+                    timepicker: false
+                });
+                
+                
+                // Delete a recurrence
+                $('.delete-new-recurrence').on( 'click', function() {
+                    recurID = $(this).attr('data-id');
+                    $('.recurrence_' + recurID).remove();
+                    $('#placeDeletesHere').append('<input type="hidden" name="deleteRecur[' + recurID + ']" value="' + recurID + '">');
+                    numbRecurrences--;
+                })
+
+                // All-Day selection
+                $('.all-day-checkbox').click( function() {
+                    recurID = $(this).attr('data-id');
+                    if ($("#allDayEvent_" + recurID)[0].checked) {
+                        $(".not-all-day-" + recurID).addClass('glm-hidden');
+                        $(".all-day-" + recurID).removeClass('glm-hidden');
+                    } else {
+                        $(".not-all-day-" + recurID).removeClass('glm-hidden');
+                        $(".all-day-" + recurID).addClass('glm-hidden');
+                    }
+                });
+                
+                // By day of month selection
+                $('.days-of-month-checkbox').click( function() {
+                    recurID = $(this).attr('data-id');
+                    if ($("#specificDaysOfMonth_" + recurID)[0].checked) {
+                        $(".not-by-day-of-month-" + recurID).addClass('glm-hidden');
+                        $(".by-day-of-month-" + recurID).removeClass('glm-hidden');
+                    } else {
+                        $(".not-by-day-of-month-" + recurID).removeClass('glm-hidden');
+                        $(".by-day-of-month-" + recurID).addClass('glm-hidden');
+                    }
+                });
+
+                // Check for input changes to a recurrence and update recurUpdated[] submit array element for this recurID - set value to recurID 
+                $('.recurrence-input').on( 'change', function() {
+                    recurID = $(this).attr('data-id');
+                    $('#' + recurID + '_recurUpdated').val(recurID);
+                }); 
+            
             }
             
+            
             $('#addRecurrenceButton').click( function() {
                 $('#addRecurrenceDialog').dialog('open');
             });
              */
              
             // Check for any field errors and if found change related tab to error color.
-        
             $('.glm-form-bad-input').each( function(index) {
         
                 tab = $(this).attr('data-tabid');
index 5c1a8ad..7761666 100644 (file)
             $("#newCategoryDialog").dialog({
                autoOpen: false,
                minWidth: 400,
-               width:    'auto',
                 dialogClass: "glm-dialog-no-close"
             });
             $("#editCategoryDialog").dialog({
                 autoOpen: false,
                 minWidth: 400,
-                width:    'auto',
                 dialogClass: "glm-dialog-no-close"
             });
             $("#deleteCategoryDialog").dialog({
                 autoOpen: false,
                 minWidth: 400,
-                width:    'auto',
                 dialogClass: "glm-dialog-no-close"
             });