public function create_cron_schedules()
{
- $importFeeds = new GlmDataFeedImport( $this->wpdb, $this->config );
- $import_feeds = $importFeeds->getList();
- if ( $import_feeds ) {
- foreach ( $import_feeds as $key => &$feed ) {
- // check the next run time
- wp_schedule_event( time(), GLM_MEMBERS_EVENTS_PLUGIN_CRON_RECURRANCE, GLM_MEMBERS_EVENTS_PLUGIN_CRON_EVENT, array( (int)$feed['id'] ) );
++
+ // See if tables exists first
+ $result = $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SHOW TABLES LIKE %s",
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'feed_import'
+ )
+ );
+ if ( $result ) {
+ require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataFeedImport.php';
+ $importFeeds = new GlmDataFeedImport( $this->wpdb, $this->config );
+ $import_feeds = $importFeeds->getList();
+ if ( $import_feeds ) {
+ foreach ( $import_feeds as $key => &$feed ) {
+ // check the next run time
+ wp_schedule_event( time(), GLM_MEMBERS_EVENTS_PLUGIN_CRON_RECURRANCE, GLM_MEMBERS_EVENTS_PLUGIN_CRON_EVENT, array( (int)$feed['id'] ) );
+ }
++
}
}
}
'required' => false,
'use' => 'a'
),
++ // calendar view
++ 'calendar_view' => array(
++ 'field' => 'calendar_view',
++ 'type' => 'text',
++ 'require' => false,
++ 'use' => 'a'
++ ),
// Recipient Email
'to_email' => array(
'field' => 'to_email',
* version from this plugin.
*/
define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.3.1');
--define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.20');
++define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.21');
// 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');
$feed['next_runtime'] = wp_next_scheduled( GLM_MEMBERS_EVENTS_PLUGIN_CRON_EVENT, array( (int)$feed['id'] ) );
}
}
--
// Compile template data
$template_data = array(
'import_feeds' => $import_feeds,
if ( $event_page_id ) {
$mainEventPageUrl = get_permalink( $event_page_id );
}
-
++
++ global $wpdb;
++ $sql = "SELECT calendar_view FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "management";
++ $calendar_view = $wpdb->get_results($sql, ARRAY_A);
++ if($calendar_view[0]['calendar_view'] === "none" || empty($calendar_view[0]['calendar_view'])){
++ $calendar_view = "calendar";
++ } else {
++ $calendar_view = $calendar_view[0]['calendar_view'];
++ }
++
+ print_r($calDates);
// Compile template data
$templateData = array(
'assetsUrl' => GLM_MEMBERS_EVENTS_PLUGIN_URL . 'assets/',
'mainEventUrl' => $mainEventPageUrl,
'mainImgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/',
'imgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/',
-- 'calDates' => $calDates
++ 'calDates' => $calDates,
++ 'cal_view' => $calendar_view
);
error_reporting(E_ALL ^ E_NOTICE);
+++ /dev/null
---- Gaslight Media Members Database - Events Add-On
---- File Created: 12/02/15 15:27:15
---- Database Version: 0.0.19
---- 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
-- ical_uid TINYTEXT NULL, -- The ical UID for this event.
-- 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
-- to_email TINYTEXT NULL, -- Email address of the recipient
-- from_email TINYTEXT NULL, -- Email address of the sender
-- email_notification TEXT NULL, -- Email notification message
-- PRIMARY KEY (id)
--);
--
------
--
---- Set default event management entry
--INSERT INTO {prefix}management
-- ( id, canonical_event_page )
-- VALUES
-- ( 1, 'event-detail' )
--;
--
------
--
---- Event iCal Feed imports
--CREATE TABLE {prefix}feed_import (
-- id INT NOT NULL AUTO_INCREMENT,
-- feed_url TEXT NOT NULL, -- The ical feed url to import
-- created DATETIME NULL, -- The date this feed was created
-- updated DATETIME NULL, -- Last time this feed was updated
-- duration INT NULL, -- The time it took to fetch the feed
-- events INT NULL, -- The number of events last fetched
-- PRIMARY KEY (id)
--);
--- /dev/null
--- /dev/null
++-- Gaslight Media Members Database - Events Add-On
++-- File Created: 12/02/15 15:27:15
++-- Database Version: 0.0.19
++-- 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
++ ical_uid TINYTEXT NULL, -- The ical UID for this event.
++ 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
++ to_email TINYTEXT NULL, -- Email address of the recipient
++ from_email TINYTEXT NULL, -- Email address of the sender
++ email_notification TEXT NULL, -- Email notification message
++ calendar_view TINYTEXT NULL, -- Default calendar view
++ PRIMARY KEY (id)
++);
++
++----
++
++-- Set default event management entry
++INSERT INTO {prefix}management
++ ( id, canonical_event_page )
++ VALUES
++ ( 1, 'event-detail' )
++;
++
++----
++
++-- Event iCal Feed imports
++CREATE TABLE {prefix}feed_import (
++ id INT NOT NULL AUTO_INCREMENT,
++ feed_url TEXT NOT NULL, -- The ical feed url to import
++ created DATETIME NULL, -- The date this feed was created
++ updated DATETIME NULL, -- Last time this feed was updated
++ duration INT NULL, -- The time it took to fetch the feed
++ events INT NULL, -- The number of events last fetched
++ PRIMARY KEY (id)
++);
'0.0.18' => array('version' => '0.0.18', 'tables' => 7, 'date' => '5/26/2016'),
'0.0.19' => array('version' => '0.0.19', 'tables' => 8, 'date' => '8/05/2016'),
'0.0.20' => array('version' => '0.0.20', 'tables' => 8, 'date' => '8/12/2016'),
++ '0.0.21' => array('version' => '0.0.21', 'tables' => 8, 'date' => '8/25/2016'),
);
--- /dev/null
--- /dev/null
++-- Gaslight Media Members Database - Events Add-On
++-- File Created: 12/09/14 15:27:15
++-- Database Version: 0.0.21
++-- 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 dashes
++
++
++ALTER TABLE {prefix}management ADD COLUMN calendar_view TINYTEXT NULL; -- The time it took to fetch the feed
++
++----
++
++
{if $eventsSettings.fieldFail.footer_text}<p>{$eventsSettings.fieldFail.footer_text}</p>{/if}
</td>
</tr>
- <option value="select"> Select View </option>
+ <tr>
+ <th >Front-End Calendar View</th>
+
+ <td>
+ <select id="calendar-view" name="calendar_view">
- <option value="agenda"> Calendar</option>
++ <option value="none"> Select View </option>
+ <option value="agenda"> Agenda </option>
- <label>Current View: </label>
++ <option value="calendar"> Calendar</option>
+ </select>
+ </td>
+ <tr>
+ <th></th>
+ <td>
++ <div class="current-calendar-view">
++ <label style="font-weight: bold;font-size: 16px;"> Current View:</label><label style="font-size: 14px;"> {$eventsSettings.fieldData.calendar_view} </label>
++ </div>
+ </td>
+ </tr>
+
+
<tr>
<td>
<h1> E-Mail Notification Settings </h1>
<script type="text/javascript">
jQuery(document).ready(function($) {
--
++
var fullCalendarLoaded = false;
var recurrencesInited = false;
var locationsInited = false;
+ var table = 'glm-table-calendar';
+ var post_start, post_end, month_obj;
+ var rows = $(".glm-event-day-row");
+ var view_select = $("#glm-event-view-select");
+ var search = $("#glm-events-search-form");
+ var calendar = $("#eventCalendar");
+ var event_search = $(".glm-search-icon");
+ var main_content = $("#main-content");
++ var view = '{$cal_view}';
++
++ if(view === "calendar"){
++ calendar.show();
++ rows.hide();
++ view_select.val('calendar');
++
++ } else if ( view === "agenda"){
++ calendar.hide();
++ rows.show();
++ view_select.val('agenda');
++ }
- calendar.hide();
-/* Temporarily dissable calendar display
--
- // Get calendar month via AJAX
++
+ // AJAX FUNCTION ************************************************
+ // Get calendar month via AJAX
function eventsCalMonthAJAX(month) {
- var data = {
+ var dat = {
+
action: 'glm_members_admin_ajax',
- glm_action: 'eventsCalMonthAJAX'
- month: 'Month Stuff'
+ glm_action: 'eventsCalMonthAJAX',
+ month: month
+
};
- jQuery.post('{$ajaxUrl}', data, function(response) {
- alert(response);
+ $('.fc-event').remove();
+ jQuery.ajax({
+ type: 'POST',
+ url: '{$ajaxUrl}',
+ data: dat,
+ cache: false,
+ success: function (response){
- console.log(response);
++// console.log(response);
+ var buildingEvents = [];
+ var events_obj = jQuery.parseJSON(response);
+ var events = events_obj.events;
+// console.log(events);
+
+ buildingEvents = $.map(events, function(i, val) {
- console.log(i.title);
-
+ return {
+ title: i.title,
+ start: i.start,
+ end: i.last,
+ allDay: i.all_day,
+ url: i.url
+ };
+ });
+ $("#eventCalendar").fullCalendar('removeEvents');
+ $("#eventCalendar").fullCalendar('addEventSource', buildingEvents);
+ }
});
}
-// Fire off for testing
-var x = eventsCalMonthAJAX('123');
-
-
- if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
-
- // **** Should probably move all this to a function and check if it's been initialized already
- $('#eventCalendar').fullCalendar({
- events: [
- {$sep = ''}
- {foreach $calDates as $cDate}
- {$sep}{
- title : "{$cDate.event_name|unescape:'html'}",
- start : '{$cDate.start_time.datetime}',
- end : '{$cDate.end_time.datetime}',
- allday : {$cDate.all_day.value}
- }
- {$sep = ','}
- {/foreach}
- ],
- defaultDate : '{$firstTime.start_time.datetime}',
- timeFormat : 'h:mma',
- fixedWeekCount : false,
- eventClick: function(calEvent, jsEvent, view) {
-
- $("#occurrences").dialog();
- $(this).css('border-color', 'red');
+
+ // Calendar *****************************************************
+ $('#eventCalendar').fullCalendar({
+ viewRender: function (view, element){
+ post_start = view.start._d;
+ post_end = view.end._d;
+ {literal}month_obj = {start: view.start._d, last: view.end._d};{/literal}
+ },
+ header: {
+ left: 'prev,next today',
+ center: 'title',
+ right: 'month,agendaWeek,agendaDay'
+ },
+ dayClick: function(date, jsEvent, view) {
+ test = $('#eventCalendar').fullCalendar('getView').end;
+ console.log(test);
+ $('#eventCalendar').fullCalendar('changeView', 'agendaDay');
+ $('#eventCalendar').fullCalendar('gotoDate', date);
+ },
+ editable: true,
+ lazyFetching: true,
+ eventClick : function (event){
+ location.href = event.url;
+ },
+ eventLimit: true,
+ views: {
+ month: {
+ eventLimit: 4
+ },
+ agenda: {
+ eventLimit: 4
}
- });
-
- fullCalendarLoaded = true;
-// }
-*/
-
-
+ }
+ });
+ $("#glm-event-view-select").on("change", function (){
+ if($("#glm-event-view-select option:selected").val() === "calendar"){
+
+ main_content.removeClass("small-8").addClass("small-12");
+ rows.fadeOut('slow', function(){});
+// search.fadeOut('slow', function(){});
+ calendar.fadeIn('slow', function(){});
+ calendar.fullCalendar('render');
+ eventsCalMonthAJAX(month_obj);
+
+ } else if ( $("#glm-event-view-select option:selected").val() === "agenda"){
+
+ main_content.removeClass("small-12").addClass("small-8");
+ rows.fadeIn('slow', function(){});
+// search.fadeIn('slow', function(){});
+ calendar.fadeOut('slow', function(){});
+ }
+ });
+
+ // initialize calendar with AJAX calls *************************************
+ var x = eventsCalMonthAJAX(month_obj);
+ $(document).on("click", "button.fc-button", function () {
+ var x = eventsCalMonthAJAX(month_obj);
+ });
});
</script>