From 329260275930839677991c6933de48b4d3752972 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 18 Jan 2018 11:00:32 -0500 Subject: [PATCH] WIP Adding list and separate edit page to attendee notices. Use now page for editing the attendee notices. Incorporate calendar for showing the notification date compared to the event date. Show notifications as a list view. --- models/admin/ajax/setupEventRegQueue.php | 84 +++++++ models/admin/registrations/events.php | 4 + .../registrations/events_notifications.php | 22 +- .../events_notificationsUpdate.php | 37 ++- .../create_database_V0.0.22.sql | 2 +- setup/validActions.php | 1 + views/admin/registrations/eventDashboard.html | 130 +++++----- .../registrations/eventEditNotification.html | 181 ++++++++++++++ .../registrations/eventNotifications.html | 225 ++++-------------- views/admin/registrations/eventSubTabs.html | 2 +- 10 files changed, 414 insertions(+), 274 deletions(-) create mode 100644 models/admin/ajax/setupEventRegQueue.php create mode 100644 views/admin/registrations/eventEditNotification.html diff --git a/models/admin/ajax/setupEventRegQueue.php b/models/admin/ajax/setupEventRegQueue.php new file mode 100644 index 0000000..18ce6d6 --- /dev/null +++ b/models/admin/ajax/setupEventRegQueue.php @@ -0,0 +1,84 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Members data abstract +// require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH . '/data/dataAccount.php'; + +/** + * This class performs the work of handling images passed to it via + * an AJAX call that goes through the WorPress AJAX Handler. + * + */ +class GlmMembersAdmin_ajax_setupEventRegQueue //extends GlmDataRegistrationsAccount +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for data class + // parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This model checks to see if the creditials passed in are correct. + * + * This model action does not return, it simply does it's work then calls die(); + * + * @param $actionData + * + * Echos JSON string as response and does not return + */ + public function modelAction( $actionData = false ) + { + $return = false; + + echo '

From the admin ajax setupEventRegQueue in Event Registrations.

'; + + exit(); + } +} diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index 3d2f61f..0b3d5bc 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -126,6 +126,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $registrants = false; $completed = false; $errorMsg = false; + $newEntry = false; + $when = false; // Register the masked input script that we need for input controls wp_dequeue_script('glm-members-admin-maskedinput'); @@ -232,6 +234,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'registrants' => $registrants, 'completed' => $completed, 'errorMsg' => $errorMsg, + 'newEntry' => $newEntry, + 'when' => $when, ); // echo "
".print_r($templateData,1)."
"; diff --git a/models/admin/registrations/events_notifications.php b/models/admin/registrations/events_notifications.php index 9327f86..2cf0947 100644 --- a/models/admin/registrations/events_notifications.php +++ b/models/admin/registrations/events_notifications.php @@ -16,8 +16,24 @@ require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegNotification.php'; $Notifications = new GlmDataRegistrationsRegNotification($this->wpdb, $this->config); -$regNotifications = $Notifications->getList("T.reg_event = $regEventID", 'notification_days'); - $regEvent = $this->getEntry($regEventID); -$view = 'eventNotifications'; +if ( isset( $_REQUEST['delete'] ) && filter_var( $_REQUEST['delete'], FILTER_VALIDATE_BOOLEAN ) ) { + $view = 'eventNotifications'; +} else if ( isset( $_REQUEST['id'] ) && $notice_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) { + $regNotifications = $Notifications->editEntry( $notice_id ); + $view = 'eventEditNotification'; + $days = $regNotifications['notification_days']; + echo '
$days: ' . print_r( $days, true ) . '
'; + $when = ( $days > 0 ) ? 'after' : 'before'; + echo '
$when: ' . print_r( $when, true ) . '
'; +} else if ( isset( $_REQUEST['new'] ) && filter_var( $_REQUEST['new'], FILTER_VALIDATE_BOOLEAN ) ) { + $regNotifications = $Notifications->newEntry(); + $view = 'eventEditNotification'; + $newEntry = true; +} else { + $regNotifications = $Notifications->getList("T.reg_event = $regEventID", 'notification_days'); + $view = 'eventNotifications'; +} + +// echo '
$regNotifications: ' . print_r( $regNotifications, true ) . '
'; diff --git a/models/admin/registrations/events_notificationsUpdate.php b/models/admin/registrations/events_notificationsUpdate.php index 70c7ffc..b8064c1 100644 --- a/models/admin/registrations/events_notificationsUpdate.php +++ b/models/admin/registrations/events_notificationsUpdate.php @@ -14,13 +14,13 @@ */ // New and updated notifications -if (isset($_REQUEST['name']) && is_array($_REQUEST['name'])) { +if ( isset( $_REQUEST['name'] ) && is_array( $_REQUEST['name'] ) ) { - foreach ($_REQUEST['name'] as $key=>$val) { + foreach ( $_REQUEST['name'] as $key => $val ) { // Make sure key is positive integer - $id = ($key-0); - if ($id > 0) { + $id = ( $key - 0 ); + if ( $id > 0 ) { // Update existing entry $this->wpdb->update( @@ -33,14 +33,14 @@ if (isset($_REQUEST['name']) && is_array($_REQUEST['name'])) { array( 'id' => $id ), array( '%s', '%d', '%s' ), array( '%d' ) - ); + ); // Otherwise if the id is less than 0 it must be a new one - } elseif ($id < 0) { + } elseif ( $id < 0 ) { // Insert a new entry $this->wpdb->insert( - GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_notification', + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_notification', array( 'reg_event' => $regEventID, 'name' => $_REQUEST['name'][$id], @@ -48,23 +48,22 @@ if (isset($_REQUEST['name']) && is_array($_REQUEST['name'])) { 'message' => $_REQUEST['message'][$id] ), array( '%d', '%s', '%d', '%s' ) - ); + ); } } } // Delete Notifications -if (isset($_REQUEST['delete']) && is_array($_REQUEST['delete'])) { - - $ids = ''; - foreach ($_REQUEST['delete'] as $key=>$val) { - - // Make sure key is positive integer - $id = ($key-0); - if ($id > 0) { - $this->wpdb->delete( GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_notification', array( 'ID' => $id ), array( '%d' ) ); - } +if ( isset( $_REQUEST['delete'] ) && filter_var( $_REQUEST['delete'], FILTER_VALIDATE_BOOLEAN ) ) { + // Make sure key is positive integer + $id = ( $_REQUEST['id'] - 0 ); + if ( $id > 0 ) { + $this->wpdb->delete( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_notification', + array( 'ID' => $id ), + array( '%d' ) + ); } } @@ -72,4 +71,4 @@ if (isset($_REQUEST['delete']) && is_array($_REQUEST['delete'])) { $regNotifyUpdated = true; // Fall through to get the data again -require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/admin/registrations/events_notifications.php'; +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/models/admin/registrations/events_notifications.php'; diff --git a/setup/databaseScripts/create_database_V0.0.22.sql b/setup/databaseScripts/create_database_V0.0.22.sql index 565d81b..4a6b1c9 100644 --- a/setup/databaseScripts/create_database_V0.0.22.sql +++ b/setup/databaseScripts/create_database_V0.0.22.sql @@ -323,7 +323,7 @@ CREATE TABLE {prefix}reg_rate ( CREATE TABLE {prefix}reg_notification ( id INT NOT NULL AUTO_INCREMENT, reg_event INT NULL, -- Pointer to reg_event table - name TINYTEXT NULL, -- Namme of this notification + name TINYTEXT NULL, -- Name of this notification notification_days INT NULL, -- # of days before or after event that notification takes place (- before, + after) message TEXT NULL, -- Content of message (uses template parameters to merge event/attendee data) PRIMARY KEY (id), diff --git a/setup/validActions.php b/setup/validActions.php index d1296af..6790a88 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -67,6 +67,7 @@ $glmMembersRegistrationsAddOnValidActions = array( 'summaryContent' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'updateAvailability' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'registrantsListExport' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'setupEventRegQueue' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, ), 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 17b953e..e643cd9 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -1,7 +1,7 @@ {include file='admin/registrations/eventHeader.html'} {include file='admin/registrations/eventSubTabs.html'} - -
+ +
{if $haveRegEvent}
@@ -43,7 +43,7 @@ {$regEvent.total}
- {/if} + {/if}

Registered:

@@ -77,11 +77,11 @@ {$regEvent.totalAvail}
- {/if} + {/if}
{if apply_filters('glm_members_menu_members', true)} - +
@@ -91,20 +91,20 @@
-
Add Registration Dates/Times from Event
+
Add Registration Dates/Times from Event

This action looks for dates and time specified for the associated event in the event schedules. If there are any dates and times that are not already included for registrations, this action will add them using the defaults set for this event. You may set those defaults by clicking the "Edit Registration Event" button on this page. This action will not modify or remove date and times already added to registrations for this event. -

+

- The primary purpose of this action is to assist with initial setup of registrations for an event when there are a number of + The primary purpose of this action is to assist with initial setup of registrations for an event when there are a number of dates and times specified in the schedules for the event and you wish to make most or all of those dates and times available for registration.

- NOTE: If the event covers a large number of dates, this action may add a large number of dates + NOTE: If the event covers a large number of dates, this action may add a large number of dates and times to registrations for this event. To deactivate or remove those dates you will be required to click on each date/time and either deactivate it or demove it.

@@ -113,13 +113,13 @@ - +
-

Event: {$regEvent.event_name}

+

Event: {$regEvent.event_name}

To add dates and times from the event schedules
enter exactly "ADD" in the field below.

Then click this button

- +
@@ -130,7 +130,7 @@
-
Delete Registration Event
+
Delete Registration Event

WARNING!

@@ -138,18 +138,18 @@

Continuing with this action will permanently remove this event from registrations including all configuration associated with it. - This will not remove the event listing, only the information on registrations for this event. + This will not remove the event listing, only the information on registrations for this event.

- This action is - NOT REVERSABLE! After deletion, you will be required to re-enter all registration related + This action is + NOT REVERSABLE! After deletion, you will be required to re-enter all registration related configuration information in order to have registrations for this event.

{if $regEvent.registered > 0}

ALSO NOTE!

There have been {$regEvent.registered} registrations submitted for this event.

-
+

Continuing with this action will delete all registrations for this event. This will also remove these registrations from all reports. It's important that you print all reports and other information @@ -165,13 +165,13 @@ - +

-

Event: {$regEvent.event_name}

+

Event: {$regEvent.event_name}

To delete registrations for this event, enter exactly "DELETE" in the field below.

Then click this button

- +
@@ -187,7 +187,7 @@ {/if}
- +
{/if} @@ -243,19 +243,19 @@ Active: All Day: - {if $regEvent.time_specific.value} + {if $regEvent.time_specific.value} Track Attendees: {/if} Start Time: End Time: - {if $regEvent.time_specific.value} + {if $regEvent.time_specific.value} Maximum Attendees: 0 = Unlimited Registered Attendees: Pending in Carts: Available for Registration: {else} Use form above calendar to adjust attendee availability. - {/if} + {/if}
Upate
@@ -284,13 +284,13 @@ width: 600, resizable: true }); - + // Delete Event Registrations Button $('#regEventDeleteButton').on('click', function() { $('#regEventDeleteDialog').dialog('open'); }); - + // Summary Dialog Box var timeMaskSet = false; $("#availabilityEditDialog").dialog({ @@ -301,11 +301,11 @@ // On open set the time input mask if (!timeMaskSet) { - $(".time-input").mask("X0:Y0 ZM", { + $(".time-input").mask("X0:Y0 ZM", { translation: { 'X': { // Force 1st hour digit to 0 or 1 pattern: /[01]/, optional: false - }, + }, 'Y': { // force first minute digit to 0 through 5 pattern: /[012345]/, optional: false }, @@ -313,9 +313,9 @@ pattern: /[AaPp]/, optional: false } }, - placeholder: "00:00 AM" + placeholder: "00:00 AM" }); - timeMaskSet = true; + timeMaskSet = true; } } }); @@ -326,7 +326,7 @@ /* * Initialize the Full Calendar */ - + function initFullCalendar(){ $('#eventCalendar').fullCalendar({ timezone: 'local', @@ -372,7 +372,7 @@ // Clicking on a date cell (not an existing event time) Brings up the new date dialog dayClick: function(date, allDay, jsEvent, view) { - $('#dialogAvailSubmit').off('click'); + $('#dialogAvailSubmit').off('click'); $('#availabilityTitle').html('Create New: '+date.format('MM/DD/YYYY')); $('#availabilityEditDialog').dialog('open'); $('#dialogRegActive').prop('checked', false); @@ -388,12 +388,12 @@ if ($('#dialogStartTime').val() == '' || $('#dialogEndTime').val() == '') { alert('Both start and end times are required!'); - } else { + } else { - // Submit clicked - {if $regEvent.time_specific.value} + // Submit clicked + {if $regEvent.time_specific.value} var max = $('#dialogMaxAtt').val(); - {else} + {else} var max = 0; {/if} var startDate = new Date($('#dialogStartTime').val()); @@ -405,9 +405,9 @@ if (newTimeActive) { newTimeBackgroundColor = 'light-blue'; } - - - // Initialize the event data object with submitted data + + + // Initialize the event data object with submitted data var newEvent = { {if $regEvent.time_specific.value} title: ' unlimited', @@ -419,16 +419,16 @@ active: newTimeActive, backgroundColor: newTimeBackgroundColor, allDay: $('#dialogTimeAllDay').is(':checked'), - {if $regEvent.time_specific.value} + {if $regEvent.time_specific.value} attendees: $('#dialogAttendees').is(':checked'), - {else} + {else} attendees: 0, {/if} max: max, count: 0, pending: 0, available: max, - timeId: false + timeId: false }; {if $regEvent.time_specific.value} @@ -442,7 +442,7 @@ {/if} // Try to send the data via AJAX var newTime = $.ajax({ - + url: "{$ajaxUrl}", method: "POST", data: { @@ -458,7 +458,7 @@ max: newEvent.max }, dataType: "text" - + }).done( function(newTimeId) { // If response was not a possible time ID @@ -470,10 +470,10 @@ console.log(newEvent); // Should have good time ID, so add it to the calendar $('#eventCalendar').fullCalendar('renderEvent', newEvent, true); } - - $('#availabilityEditDialog').dialog('close'); - $('#dialogAvailSubmit').off('click'); - + + $('#availabilityEditDialog').dialog('close'); + $('#dialogAvailSubmit').off('click'); + }); } @@ -490,8 +490,8 @@ console.log(newEvent); // Click on an event in the calendar eventClick: function(calEvent, jsEvent, view) { - $('#dialogAvailSubmit').off('click'); - + $('#dialogAvailSubmit').off('click'); + $("#occurrences").dialog(); $(this).css('border-color', 'red'); @@ -502,7 +502,7 @@ console.log(newEvent); $('#dialogTimeAllDay').show(); $('#dialogStartTimeLine').show(); $('#dialogEndTimeLine').show(); - + $('#availabilityTitle').html(calEvent.datetime); $('#dialogRegActive').prop('checked', calEvent.active); if(calEvent.start) { @@ -537,7 +537,7 @@ console.log(newEvent); $('#dialogAvailAtt').html(available); $('#dialogMaxAtt').off('change'); }); - + $('#dialogAvailSubmit').on('click', function() { var checked = $('#dialogRegActive').is(":checked"); @@ -552,7 +552,7 @@ console.log(newEvent); var start = calEvent.start.format('YYYY/MM/DD') + ' ' + $('#dialogStartTime').val(); var end = calEvent.start.format('YYYY/MM/DD') + ' ' + $('#dialogEndTime').val(); - + var max = $('#dialogMaxAtt').val(); var timeId = $('#dialogAvailSubmit').attr('data-timeid'); @@ -562,7 +562,7 @@ console.log(newEvent); return false; } - + $.ajax({ url: "{$ajaxUrl}", method: "POST", @@ -579,22 +579,22 @@ console.log(newEvent); }, dataType: "text" }); - $('#availabilityEditDialog').dialog('close'); - $('#dialogAvailSubmit').off('click'); + $('#availabilityEditDialog').dialog('close'); + $('#dialogAvailSubmit').off('click'); // Update times calEvent.start = start; calEvent.end = end; - + {if $regEvent.time_specific.value} calEvent.title = max + '-' + calEvent.count + '-' + calEvent.pending + '-' + calEvent.available; {else} calEvent.title = ''; {/if} - $('#eventCalendar').fullCalendar('updateEvent', calEvent); + $('#eventCalendar').fullCalendar('updateEvent', calEvent); }); - + } {/if} }); @@ -603,7 +603,7 @@ console.log(newEvent); // If not date/time specific then we need to add the data for the non-date-specific time entry. if (!{$regEvent.time_specific.value}) { - + // Not date specific so do one counts update form $('#maxAtt').on('change', function() { var max = $('#maxAtt').val(); @@ -617,26 +617,26 @@ console.log(newEvent); } $('#availAtt').html(available); }); - + $('#availSubmit').on('click', function() { var max = $('#maxAtt').val(); var time = $('#availSubmit').attr('data-timeid'); - + $.ajax({ url: "{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=updateAvailability&newTime=false&active=true&max=" + max + "®_time=" + time }); $("#submit-flash").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500); }); - + } - + // Flash certain elements for a short time after display $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500); - + }); diff --git a/views/admin/registrations/eventEditNotification.html b/views/admin/registrations/eventEditNotification.html new file mode 100644 index 0000000..a9b5098 --- /dev/null +++ b/views/admin/registrations/eventEditNotification.html @@ -0,0 +1,181 @@ +{include file='admin/registrations/eventHeader.html'} +{include file='admin/registrations/eventSubTabs.html'} + +
+ Add a Notification +

Registrant E-Mail Notifications

+
+ +

+ {if $regNotifyUpdated}Notifications Updated{/if} +

+ + +
+ +
+ + +
+
 
+
+
+
+
+

Subject

+
+
+
+
+ +
+
+
+
+

Day to Send

+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+

E-Mail Message Content

+
+
+
+
+ {php} + wp_editor( + '{if !$newEntry}{$regNotifications.fieldData.message|escape:quotes}{/if}', + 'message', + array( + 'media_buttons' => false, + 'textarea_name' => 'message[{if $newEntry}-1{else}{$regNotifications.fieldData.id}{/if}]', + 'editor_height' => 300, + ) + ); + {/php} +
+
+
+
+
 
+
+
+
+ +
+
+
+ +{literal} +
+
+
 
+
+
+

Merge Tags

+
+
+
+
+ The "merge tags" listed below may be using in the E-Mail message content to include certain information about the event and attendee. Be sure to include the "{" and "}" and "$" characters exactly as shown. +
+
+
+

{$event.name}

+
Name of the event.
+
+
+

{$event.date}

+
Date for which the attendee has registered.
+
+
+

{$event.time}

+
Time for which the attendee has registered.
+
+
+

{$registration.level}

+
Registration Level
+
+
+

{$last.name}

+
Last name of attendee.
+
+
+

{$first.name}

+
First name of attendee.
+
+
+{/literal} + + + +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/eventNotifications.html b/views/admin/registrations/eventNotifications.html index 7aa2ba3..c9ea091 100644 --- a/views/admin/registrations/eventNotifications.html +++ b/views/admin/registrations/eventNotifications.html @@ -2,7 +2,10 @@ {include file='admin/registrations/eventSubTabs.html'}
- Add a Notification + Add a Notification

Registrant E-Mail Notifications

@@ -12,195 +15,48 @@
-{literal} -
-
-
-
-
-

Name

- For reference. Not sent to attendee. -
-
-
-
- -
-
-
-
-

Day to Send

- Negative for days before event.
- Positive for days after event. -
-
-
-
- -
-
- -
-
-
-
-

E-Mail Message Content

-
-
-
-
- -
-
-
-
-
 
-
-{/literal} - -
- - -
-
-{if $regNotifications} -
 
- {foreach $regNotifications as $n} -
-
-
-
-

Name

- For reference. Not sent to attendee. -
-
-
-
- -
-
-
-
-

Day to Send

- Negative for days before event.
- Positive for days after event. -
-
-
-
- -
-
- -
-
-
-
-

E-Mail Message Content

-
-
-
-
- -
-
-
-
-
 
- {/foreach} -{else} -
-
No notifications listed
-
-{/if} -
-
-
- -
-
-
- -{literal} -
-
-
 
-
-
-

Merge Tags

-
-
-
-
- The "merge tags" listed below may be using in the E-Mail message content to include certain information about the event and attendee. Be sure to include the "{" and "}" and "$" characters exactly as shown. -
-
-
-

{$event-name}

-
Name of the event.
-
-
-

{$event-date}

-
Date for which the attendee has registered.
-
-
-

{$event-time}

-
Time for which the attendee has registered.
-
-
-

{$registration-level}

-
Registration Level
-
-
-

{$last-name}

-
Last name of attendee.
-
-
-

{$first-name}

-
First name of attendee.
-
-
-{/literal} + + + + + + + + + + + {if $regNotifications} + {foreach $regNotifications as $n} + + + + + + + {/foreach} + {else} + + + + {/if} + +
IDSubjectNotification 
{$n.id} + {$n.name} + When? + Delete +
No Notifications found.
{include file='admin/footer.html'} - diff --git a/views/admin/registrations/eventSubTabs.html b/views/admin/registrations/eventSubTabs.html index 8d4268c..44c04f6 100644 --- a/views/admin/registrations/eventSubTabs.html +++ b/views/admin/registrations/eventSubTabs.html @@ -13,7 +13,7 @@ {if apply_filters('glm-members-customfields-plugin-active', false)} Additional Fields {/if} - Attendee Notification + Attendee Notification Comp Codes {$terms.reg_term_attendee_plur_cap} -- 2.17.1