// Month of Year - multi-pick (bitmap)
'month_of_year' => array(
- 'field' => 'month_of_year',
- 'type' => 'bitmap',
- 'bitmap' => $this->config['month'],
- 'default' => 4095, // All months selected
- 'use' => 'a'
+ 'field' => 'month_of_year',
+ 'type' => 'bitmap',
+ 'bitmap' => $this->config['month'],
+ 'default' => 4095, // All months selected
+ 'use' => 'a'
),
// Week of Month - multi-pick (bitmap)
'week_of_month' => array(
- 'field' => 'week_of_month',
- 'type' => 'bitmap',
- 'bitmap' => $this->config['week'],
- 'default' => 63, // no weeks selected
- 'use' => 'a'
+ 'field' => 'week_of_month',
+ 'type' => 'bitmap',
+ 'bitmap' => $this->config['week'],
+ 'default' => 63, // no weeks selected
+ 'use' => 'a'
),
// Day of Week - multi-pick (bitmap)
'day_of_week' => array(
- 'field' => 'day_of_week',
- 'type' => 'bitmap',
- 'bitmap' => $this->config['day'],
- 'default' => 127, // no days selected
- 'use' => 'a'
+ 'field' => 'day_of_week',
+ 'type' => 'bitmap',
+ 'bitmap' => $this->config['day'],
+ 'default' => 127, // no days selected
+ 'use' => 'a'
),
// Select by Days of the Month Flag
// Day of Month - multi-pick (bitmap)
'day_of_month' => array(
- 'field' => 'day_of_month',
- 'type' => 'bitmap',
- 'bitmap' => $this->config['day_of_month'],
- 'default' => 0, // no day selected
- 'use' => 'a'
+ 'field' => 'day_of_month',
+ 'type' => 'bitmap',
+ 'bitmap' => $this->config['day_of_month'],
+ 'default' => 0, // no day selected
+ 'use' => 'a'
),
// Last Day of Month
'use' => 'a'
),
+ // Specific Dates - serialized array of additional dates
+ 'specific_dates' => array (
+ 'field' => 'specific_dates',
+ 'type' => 'text',
+ 'use' => 'gl'
+ ),
+
+ // Specific Dates that will not be unserialized by post processing
+ 'specific_dates_unserialized' => array (
+ 'field' => 'specific_dates',
+ 'as' => 'specified_dates_unserialized',
+ 'type' => 'text',
+ 'use' => 'gl'
+ ),
+
/*
* Following included for future Holiday feature
*/
*/
public function entryPostProcessing($r, $a)
{
+ if (in_array($a, array('g','l'))) {
+ $r['specific_dates'] = unserialize($r['specific_dates']);
+ }
+
return $r;
}
// Otherwise we'll use the rest of the recurrence schedule data
} else {
-
+echo "-------------- recurring";
// For each year in recurrence range
for ($year = $fromYear ; $year <= $toYear ; $year++ ) {
} // Year
+ // Now add any specific dates entered by the pop-up calendar
+ if (is_array($recurData['specific_dates']) && count($recurData['specific_dates']) > 0) {
+ foreach ($recurData['specific_dates'] as $sd) {
+ $t = new DateTime(date('m/d/Y ', strtotime($sd)).$time);
+ $t->specified = true; // Mark as a specified date so it avoides the date limits below
+ $dates[$t->getTimestamp()] = $t;
+ }
+ }
+
}
// Create From and to timestamp for comparison - To date is already + 1 day
foreach ($dates as $k=>$v) {
// If date is within from and to range (we may not have checked this above)
- if ($v >= $from && $v < $to ) {
+ if (($v >= $from && $v < $to) || $v->specified) {
// Create text start date and time of this instance
$thisStartTime = $v->format('Y/m/d H:i:s');
* version from this plugin.
*/
define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.16');
+define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.17');
// 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');
// Check for new cities and get a table to match the submitted ID with the new city ID
$newCityID = $this->checkNewCities();
+ // Check for specific_dates submission
+
// Do selected option
switch ($option) {
}
+
}
// Update our recurrences
if ($recurID[0] == 'n') {
// Add the new recurrence
- $x = $Recurrences->insertEntry(true, $recurID.'_');
+ $r = $Recurrences->insertEntry(true, $recurID.'_');
+ $thisRecurID = $r['fieldData']['id'];
// And create time entries
- $Recurrences->createRecurrenceTimesEntries($x['fieldData']['id'], true, true);
+ $Recurrences->createRecurrenceTimesEntries($thisRecurID, true, true);
// Otherwise it's an existing recurrence
} else {
- $Recurrences->updateEntry($recurID, 'id', true, 'Recur'.$recurID.'_');
+ $r = $Recurrences->updateEntry($recurID, 'id', true, 'Recur'.$recurID.'_');
+ $thisRecurID = $recurID;
+ }
+
+ // Check for any specific dates and if so serialize the array sorted by date
+ $specDates = serialize(array());
+ if (isset($_REQUEST['Recur'.$recurID.'_specDate'])) {
+ asort($_REQUEST['Recur'.$recurID.'_specDate']);
+ $specDates = serialize($_REQUEST['Recur'.$recurID.'_specDate']);
+ }
+
+ // If there's any difference, then update the specific_dates field
+ if ($specDates != $r['fieldData']['specified_dates_unserialized']) {
+ $this->wpdb->query("
+ UPDATE ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "recurrences
+ SET specific_dates = '$specDates'
+ WHERE id = $thisRecurID;
+ ");
}
}
+++ /dev/null
--- 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 TIME NULL, -- Start time of day for event
- start_time_only BOOLEAN NULL, -- Use end of first occurrence flag
- end_time TIME NULL, -- End time of day for event - If less than start time, assume a date boundry
- 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
- recurring BOOLEAN NULL, -- Flag indicating that event recurs on a schedule rather than all dates
- 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
- file1 TINYTEXT NULL, -- File name for a single uploaded file #1
- file1_descr TINYTEXT NULL, -- Description for file uploaded in field "file" #1
- file2 TINYTEXT NULL, -- File name for a single uploaded file #2
- file2_descr TINYTEXT NULL, -- Description for file uploaded in field "file" #2
- file3 TINYTEXT NULL, -- File name for a single uploaded file #3
- file3_descr TINYTEXT NULL, -- Description for file uploaded in field "file" #3
- url TINYTEXT NULL, -- Event URL
- ticket_url TINYTEXT NULL, -- Ticket URL
- cost TINYTEXT NULL, -- Description of event cost
- admin_ref_type INT NULL, -- Type of admin contact if using a member contact
- admin_ref_dest INT NULL, -- Pointer to admin contact record if using a member contact
- admin_name TINYTEXT NULL, -- Admin Contact Name if not using a member contact
- admin_org TINYTEXT NULL, -- Admin Contact Organization if not using a member contact
- admin_email TINYTEXT NULL, -- Admin Contact E-Mail if not using a member contact
- admin_phone TINYTEXT NULL, -- Admin Contact Phone if not using a member contact
- free BOOLEAN NULL, -- Event is Free
- contact_email TINYTEXT NULL, -- Contact E-mail address
- contact_name TINYTEXT NULL, -- Contact name
- contact_phone TINYTEXT NULL, -- Event Phone
- use_member_location BOOLEAN NULL, -- Use location of the member (if provided) rather than location table data
- old_event_id INT NULL, -- ID of event from old site for reference
- notes TEXT NULL, -- Internal notes for this event
- PRIMARY KEY (id),
- INDEX(custom_time),
- INDEX(root_event),
- INDEX(ref_type),
- INDEX(ref_dest),
- INDEX(featured),
- INDEX(slideshow),
- INDEX(major)
-);
-
-----
-
--- Event Management Settings
-CREATE TABLE {prefix}management (
- id INT NOT NULL AUTO_INCREMENT,
- canonical_event_page TINYTEXT NULL, -- Canonical page slug for event detail
- pdf_logo TINYTEXT NULL, -- Image for the Top of the PDF
- footer_text TINYTEXT NULL, -- Image for the Top of the PDF
- PRIMARY KEY (id)
-);
-
-----
-
--- Set default event management entry
-INSERT INTO {prefix}management
- ( id, canonical_event_page )
- VALUES
- ( 1, 'event-detail' )
-;
-
--- /dev/null
+-- 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 TIME NULL, -- Start time of day for event
+ start_time_only BOOLEAN NULL, -- Use end of first occurrence flag
+ end_time TIME NULL, -- End time of day for event - If less than start time, assume a date boundry
+ 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
+ recurring BOOLEAN NULL, -- Flag indicating that event recurs on a schedule rather than all dates
+ 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
+ specific_dates TEXT NULL, -- Serialized array of specific dates added to the recurrence
+ 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
+ file1 TINYTEXT NULL, -- File name for a single uploaded file #1
+ file1_descr TINYTEXT NULL, -- Description for file uploaded in field "file" #1
+ file2 TINYTEXT NULL, -- File name for a single uploaded file #2
+ file2_descr TINYTEXT NULL, -- Description for file uploaded in field "file" #2
+ file3 TINYTEXT NULL, -- File name for a single uploaded file #3
+ file3_descr TINYTEXT NULL, -- Description for file uploaded in field "file" #3
+ url TINYTEXT NULL, -- Event URL
+ ticket_url TINYTEXT NULL, -- Ticket URL
+ cost TINYTEXT NULL, -- Description of event cost
+ admin_ref_type INT NULL, -- Type of admin contact if using a member contact
+ admin_ref_dest INT NULL, -- Pointer to admin contact record if using a member contact
+ admin_name TINYTEXT NULL, -- Admin Contact Name if not using a member contact
+ admin_org TINYTEXT NULL, -- Admin Contact Organization if not using a member contact
+ admin_email TINYTEXT NULL, -- Admin Contact E-Mail if not using a member contact
+ admin_phone TINYTEXT NULL, -- Admin Contact Phone if not using a member contact
+ free BOOLEAN NULL, -- Event is Free
+ contact_email TINYTEXT NULL, -- Contact E-mail address
+ contact_name TINYTEXT NULL, -- Contact name
+ contact_phone TINYTEXT NULL, -- Event Phone
+ use_member_location BOOLEAN NULL, -- Use location of the member (if provided) rather than location table data
+ old_event_id INT NULL, -- ID of event from old site for reference
+ notes TEXT NULL, -- Internal notes for this event
+ PRIMARY KEY (id),
+ INDEX(custom_time),
+ INDEX(root_event),
+ INDEX(ref_type),
+ INDEX(ref_dest),
+ INDEX(featured),
+ INDEX(slideshow),
+ INDEX(major)
+);
+
+----
+
+-- Event Management Settings
+CREATE TABLE {prefix}management (
+ id INT NOT NULL AUTO_INCREMENT,
+ canonical_event_page TINYTEXT NULL, -- Canonical page slug for event detail
+ pdf_logo TINYTEXT NULL, -- Image for the Top of the PDF
+ footer_text TINYTEXT NULL, -- Image for the Top of the PDF
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Set default event management entry
+INSERT INTO {prefix}management
+ ( id, canonical_event_page )
+ VALUES
+ ( 1, 'event-detail' )
+;
+
'0.0.11' => array('version' => '0.0.11', 'tables' => 7),
'0.0.12' => array('version' => '0.0.12', 'tables' => 7),
'0.0.15' => array('version' => '0.0.15', 'tables' => 7, 'date' => '4/11/2016'),
- '0.0.16' => array('version' => '0.0.16', 'tables' => 7, 'date' => '4/11/2016')
+ '0.0.16' => array('version' => '0.0.16', 'tables' => 7, 'date' => '4/11/2016'),
+ '0.0.17' => array('version' => '0.0.17', 'tables' => 7, 'date' => '5/5/2016')
);
--- /dev/null
+-- Gaslight Media Members Database - Events Add-On
+-- Database Version: 0.0.12
+-- 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 a specific dates field to recurrences
+ALTER TABLE {prefix}recurrences ADD COLUMN specific_dates TEXT;
<tr>
<td>
<div id="eventCalendar"></div>
+ <p>
+ <b>NOTE:</b> This calendar does not show changes you have made until you have
+ clicked on the "Update Event" button to save your changes.
</td>
</tr>
</table>
// alert('Event: ' + calEvent.title);
$("#occurrences").dialog();
$(this).css('border-color', 'red');
- },
+ }
+/* ,
dayClick: function(date, allDay, jsEvent, view) {
if (allDay) {
}
+*/
{/if}
});
$('.start-time-only-checkbox').click( function() {
startTimeOnlySetup();
});
-// startTimeOnlySetup();
}
startTimeOnlyInit();
recurID = $(this).attr('data-id');
if ($("#recurringEvent_" + recurID)[0].checked) {
$("#recurringExclude_" + recurID).removeClass('glm-hidden');
+// initCalendars();
} else {
$("#recurringExclude_" + recurID).addClass('glm-hidden');
}
$('#' + tableID + ' input:checkbox').attr('checked', false);
});
+ initCalendars();
+
+ } // Init Recurrence
+
+
+ // Initialize specific date selection calendards
+ function initCalendars() {
+
// Initialize Calendar for date selection
+ var renderedExistingEvents = 0;
$('.recur-calendar').on('click', function() {
recurID = $(this).attr('data-id');
-
+
recurName = $('#recurSchedName_' + recurID).val();
+
if (recurName == undefined || recurName == '') {
recurName = '(no schedule name)';
}
$('#recurCalendarDialog_' + recurID).attr('title', 'Select Dates for ' + recurName);
-
+
$('#recurCalendarDialog_' + recurID).dialog({
position: { my: 'top+75', of: '#recurSpecDates_' + recurID},
minWidth: 600
});
// Color to change calendar cell to (in rgb so it compares to our test below)
var calClickColor = 'rgb(173, 216, 230)';
- $('#recurCalendar_' + recurID).fullCalendar({
+ var newCalEventID = 0;
+
+ var thisCal = $('#recurCalendar_' + recurID).fullCalendar({
header : {
left: 'title',
center: '',
right: 'today prevYear,prev,next,nextYear',
},
- events: [
- // Place existing manually entered calendar dates here from template data
- ],
+ events: [],
+ editable: true,
+ eventStartEditable: false,
height : 350,
-// defaultDate : '{$firstTime.start_time.datetime}',
+ // defaultDate : '{$firstTime.start_time.datetime}',
timeFormat : 'h:mma',
fixedWeekCount : false,
+
+ eventAfterAllRender: function(view) {
+
+ // Since this will be called again when we add the events below,
+ // we have to detect if it's a second call
+ if (renderedExistingEvents != recurID) {
+ renderedExistingEvents = recurID;
+
+ // Collect specified dates for this recurrence
+ $('.recur-spec-date-' + recurID).each(function() {
+ var date = $(this).val();
+ var dateID = $(this).attr('data-id');
+
+ var e = {
+ id: dateID,
+ start: date,
+ title: 'Selected'
+ };
+ $('#recurCalendar_' + recurID).fullCalendar( 'renderEvent', e, true);
+
+ });
+ }
+ },
+
+ // Event handler for when a date is clicked
dayClick: function(date, allDay, jsEvent, view) {
- c = $(this).css('background-color');
- var e = {
- start: date,
- title: 'New Date'
- };
- if (c != calClickColor) {
- $(this).css('background-color', calClickColor);
+
+ var dateHasEvent = false;
+
+ // Check if there's an event for this date
+ thisCal.fullCalendar('clientEvents', function (event) {
+ if (moment(event.start).isSame(date, 'day')) {
+
+ // Say that we had an event already
+ dateHasEvent = true;
+
+ // Remove the event from the calendar
+ thisCal.fullCalendar( 'removeEvents', event.id);
+
+ // Remove the event from the selected dates list
+ $('#recurSpecDate_' + recurID + '_' + event.id).remove();
+
+ }
+ });
+
+ // If there wasn't an event already, add one now
+ if (!dateHasEvent) {
+
+ // Create event for this date
+ var e = {
+ id: ++newCalEventID,
+ start: date,
+ title: 'Selected'
+ };
+
+ // Add an event to this date
+ thisCal.fullCalendar( 'renderEvent', e, true);
+
+ // Add this edate to our selected dates list
$('#recurSpecDates_' + recurID).append(
- '<span id="recurSpecDate_' + recurID + '" class="button glm-button-small"><input name="recurSpecDate_' + recurID + '" type="hidden" value="' + date.format() + '">' + date.format() + '</span>'
+ '<span id="recurSpecDate_' + recurID + '_' + newCalEventID + '" class="button glm-button-small"><input name="Recur' + recurID + '_specDate[' + newCalEventID + ']" type="hidden" data-id="' + recurID + '" value="' + date.format() + '" class="recur-spec-date-' + recurID + '">' + date.format() + '</span>'
);
- } else {
- $('#recurSpecDate_' + recurID).remove();
- $(this).css('background-color', 'transparent');
+
}
- },
- viewRender:(function() {
+
+ glmPageUpdateRequired();
- var lastViewName;
- return function(view, element) {
-
- if(view.name === 'agendaDay' && lastViewName != view.name) {
-
- var newEvent = {
- start: element.date,
- title: 'My test meeting'
- };
- $('#calendar').fullCalendar( 'renderEvent', newEvent);
- }
-
- lastViewName = view.name;
- }
- })()
+ },
- });
- });
-
+ // Event handler for when an event is clicked
+ eventClick: function(calEvent, jsEvent, view) {
+
+ var id = calEvent.id;
+
+ // Remove the event from the calendar
+ thisCal.fullCalendar( 'removeEvents', id);
+
+ // Remove the event from the selected dates list
+ $('#recurSpecDate_' + recurID + '_' + id).remove();
+
+ glmPageUpdateRequired();
+
+ }
+ }); // fullCalendar
+ }); // Click on "Show Calendar"
-
- }
-
+ }
+
/*
* Category Selection
*/
</table>
</td>
</tr>
+ <tr><td colspan="2"> </td></tr>
<tr>
<th>Select with Calendar</th>
<td>
<div data-id="{$r.id}" class="button glm-button-small glm-set-none recur-calendar">Show Calendar</div>
<div id="recurCalendarDialog_{$r.id}" class="glm-dialog-box" title="">
- <p>Click on Dates to select/remove those dates for this schedule.</p>
+ <h4>Click on Dates to select/remove those dates for this schedule.</h4>
<div id="recurCalendar_{$r.id}"></div>
- <p><div data-id="closeRecurCalendar_{$r.id}" class="button button-primary glm-set-none glm-right">Save</div></p>
+ <p>
+ <b>NOTE:</b> This calendar only shows these specific dates and does not include other dates from the schedule.
+ See the Summary Calendar to view all dates for this event.
+ </p>
</div>
- Use to add specific dates to the schedule. Does not show other scheduled dates.<br>
- <p><span id="recurSpecDates_{$r.id}"></span></p>
+ Use to add/delete specific dates to the schedule.
+ <p>
+ <span id="recurSpecDates_{$r.id}">
+ {$ncei = 1000}
+ {foreach $r.specific_dates as $sd}
+ <span id="recurSpecDate_{$r.id}_{$ncei}" class="button glm-button-small"><input name="Recur{$r.id}_specDate[{$ncei}]" type="hidden" data-id="{$ncei}" value="{$sd}" class="recur-spec-date-{$r.id}">{$sd}</span>
+ {$ncei = $ncei+1}
+ {/foreach}
+ </span>
+ </p>
</td>
</tr>
</tbody>
<tr>
<th>Schedule Name:</th>
<td>
- <input data-id="{ newRecurID }" type="text" name="{ newRecurID }_name" value="" class="glm-form-text-input-small recurrence-input">
+ <input id="recurSchedName_{ newRecurID }" data-id="{ newRecurID }" type="text" name="{ newRecurID }_name" value="" class="glm-form-text-input-small recurrence-input">
</td>
</tr>
<tr>
</table>
</td>
</tr>
+ <tr><td colspan="2"> </td></tr>
<tr>
<th>Select with Calendar</th>
<td>
<div id="recurCalendarDialog_{ newRecurID }" class="glm-dialog-box" title="">
<p>Click on Dates to select/remove those dates for this schedule.</p>
<div id="recurCalendar_{ newRecurID }"></div>
- <div data-id="closeRecurCalendar_{ newRecurID }" class="button button-primary glm-set-none">Done</div>
+ <p>
+ <b>NOTE:</b> This calendar only shows these specific dates and does not include other dates from the schedule.
+ See the Summary Calendar to view all dates for this event.
+ </p>
</div>
- Use to add specific dates to the schedule. Does not show other scheduled dates.
+ Use to add/delete specific dates to the schedule.
+ <span id="recurSpecDates_{ newRecurID }">
+ </span>
</td>
</tr>
</tbody>