From dc11df03690ce4ba55762b7fe370a893fe94b13b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 26 Apr 2018 15:49:32 -0400 Subject: [PATCH] Continuing work on requested changes and fixes. Added date submitted to reg event registrant list and changed headder titles. Fixed positioning of cancel button for edit event notification in reg admin. Fixed confusion with first and last dates for event on reg event dashboard. Now displaying current month on reg event dashboard calendar when not date have been added. Fixed submission of new reg event dates on reg event dashboard when "All Day" selected. Fixed confusion with first and last dates attending for attendee. More work on notifications cron processing. Now have working queries. --- classes/data/dataRegEvent.php | 17 +++- classes/data/dataRegRequestRegistrant.php | 14 ++- models/admin/ajax/updateAvailability.php | 5 +- models/admin/registrations/events.php | 5 +- .../registrations/events_eventDashboard.php | 23 +++-- .../admin/registrations/sendNotifications.php | 94 +++++++++++++++++++ setup/adminHooks.php | 5 +- .../create_database_V0.0.28.sql | 2 +- views/admin/registrations/eventDashboard.html | 33 ++++--- .../registrations/eventEditNotification.html | 4 +- .../registrations/eventNotifications.html | 8 +- .../admin/registrations/eventRegistrants.html | 4 +- views/front/registrations/cart.html | 2 +- views/front/registrations/cartSummary.html | 8 +- 14 files changed, 179 insertions(+), 45 deletions(-) diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index e7d7655..0469982 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -762,6 +762,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract // Get the first and last times in the reg_times entries $firstTime = false; $lastTime = false; + $haveTimeEntry = false; // Check for reg_time data if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) { @@ -775,13 +776,25 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract if (!$lastTime || $time['start_datetime']['timestamp'] > $lastTime) { $lastTime = $time['start_datetime']['timestamp']; } + $haveTimeEntry = true; } } } + // Fix empty first/last datetimes when there's no times entries + if (!$haveTimeEntry) { + $firstTime = time(); + $lastTime = time(); + } + // Generate date as used in results - $firstDateTime = array('datetime' => date('m/d/Y h:i A', $firstTime), 'timestamp' => $firstTime, 'mysql_datetime' => date('Y-m-d H:i:s', $firstTime)); - $lastDateTime = array('datetime' => date('m/d/Y h:i A', $lastTime), 'timestamp' => $lastTime, 'mysql_datetime' => date('Y-m-d H:i:s', $lastTime)); + if ($haveTimeEntry) { + $firstDateTime = array('datetime' => date('m/d/Y h:i A', $firstTime), 'timestamp' => $firstTime, 'mysql_datetime' => date('Y-m-d H:i:s', $firstTime)); + $lastDateTime = array('datetime' => date('m/d/Y h:i A', $lastTime), 'timestamp' => $lastTime, 'mysql_datetime' => date('Y-m-d H:i:s', $lastTime)); + } else { + $firstDateTime = 'NULL'; + $lastDateTime = 'NULL'; + } // Check if we need to update first and/or last event times in database - if so, do that if ($this->regEventData['first_datetime']['timestamp'] != $firstTime || diff --git a/classes/data/dataRegRequestRegistrant.php b/classes/data/dataRegRequestRegistrant.php index 040c2fb..faf296d 100644 --- a/classes/data/dataRegRequestRegistrant.php +++ b/classes/data/dataRegRequestRegistrant.php @@ -250,11 +250,23 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract 'field' => 'reg_request', 'as' => 'request_status', 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request R', + 'p_table' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request', 'p_field' => 'status', 'p_static' => true, 'required' => true, 'use' => 'lg' + ), + + // Date Request Submitted + 'date_submitted' => array ( + 'field' => 'reg_request', + 'as' => 'date_submitted', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request', + 'p_field' => 'date_submitted', + 'p_static' => true, + 'required' => true, + 'use' => 'lg' ) ); diff --git a/models/admin/ajax/updateAvailability.php b/models/admin/ajax/updateAvailability.php index 2f1c672..d00d55d 100644 --- a/models/admin/ajax/updateAvailability.php +++ b/models/admin/ajax/updateAvailability.php @@ -107,9 +107,10 @@ // Get start and end times if available. If start and no end, use start for end $startTime = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING); - $startTime = date('Y-m-d H:i:s', strtotime($startTime)); $endTime = filter_input(INPUT_POST, 'end', FILTER_SANITIZE_STRING); - $endTime = date('Y-m-d H:i:s', strtotime($endTime)); + + $startTime = date('Y-m-d H:i:s', strtotime($startTime)); + $endTime = date('Y-m-d H:i:s', strtotime($endTime)); // Get the reg_time entry id if ($newTime) { diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index 8af4e26..32caa79 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -105,6 +105,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $haveRegEvent = false; $haveRegEventRecurrences = false; $haveRegEventTimes = false; + $defaultCalendarDate = false; $regEventFirstTime = false; $regEventLastTime = false; $regEventUpdated = false; @@ -129,6 +130,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $newEntry = false; $when = false; + // Register the masked input script that we need for input controls wp_dequeue_script('glm-members-admin-maskedinput'); wp_register_script( @@ -211,6 +213,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'haveRegEvent' => $haveRegEvent, 'haveRegEventRecurrences' => $haveRegEventRecurrences, 'haveRegEventTimes' => $haveRegEventTimes, + 'defaultCalendarDate' => $defaultCalendarDate, 'regEventFirstTime' => $regEventFirstTime, 'regEventLastTime' => $regEventLastTime, 'regEventUpdated' => $regEventUpdated, @@ -234,7 +237,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'completed' => $completed, 'errorMsg' => $errorMsg, 'newEntry' => $newEntry, - 'when' => $when, + 'when' => $when ); // echo "
".print_r($templateData,1)."
"; diff --git a/models/admin/registrations/events_eventDashboard.php b/models/admin/registrations/events_eventDashboard.php index e7a5ce1..737d7ba 100644 --- a/models/admin/registrations/events_eventDashboard.php +++ b/models/admin/registrations/events_eventDashboard.php @@ -41,8 +41,20 @@ $regEvent = $this->getEventConfig($regEventID, true, false, true, false, true); if ($regEvent !== false) { $haveRegEvent = true; - $regEventFirstTime = $regEvent['first_datetime']; - $regEventLastTime = $regEvent['last_datetime']; + $haveRegEventTimes = false; + $defaultCalendarDate = false; + + // Check that we have reg event times + if ($regEvent['first_datetime'] != 'NULL') { + $haveRegEventTimes = true; + $regEventFirstTime = $regEvent['first_datetime']; + $regEventLastTime = $regEvent['last_datetime']; + } else { + // We don't so set to current time so at least the current month is displayed in the calendar + $defaultCalendarDate = date('m/d/Y h:i A'); + $messages[] = 'There are no dates on the calendar for this '.$this->config['terms']['reg_term_event'].'.'; + } + // if there's a user notice, add it to messages if (isset($regEvent['message']) && $regEvent['message']) { @@ -51,11 +63,4 @@ if ($regEvent !== false) { } -// Check if we have any times for this reg_event -if (is_array($regEvent['reg_time']) && count($regEvent['reg_time']) > 0) { - $haveRegEventTimes = true; -} else { - $messages[] = 'There are no dates on the calendar for this '.$this->config['terms']['reg_term_event'].'.'; -} - $view = 'eventDashboard'; diff --git a/models/admin/registrations/sendNotifications.php b/models/admin/registrations/sendNotifications.php index 00c2544..8c90131 100644 --- a/models/admin/registrations/sendNotifications.php +++ b/models/admin/registrations/sendNotifications.php @@ -92,6 +92,100 @@ class GlmMembersAdmin_registrations_sendNotifications extends GlmDataRegistratio trigger_error('Registrations Notifications Called', E_USER_NOTICE); } + // Get list of notifications for all active events + $notifications = $this->wpdb->get_results( + " + SELECT N.*, E.time_specific, E.first_datetime, E.last_datetime + FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_notification N, + ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_event E + WHERE E.id = N.reg_event + AND E.active + ORDER BY N.reg_event + ", + ARRAY_A + ); + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + trigger_error('Notifications: Found '.count($notifications).' notifications for active events', E_USER_NOTICE); + } + + // If there's notifications + if ($notifications and is_array($notifications) && count($notifications) > 0) { + + $event = false; + + // For each notification + foreach ($notifications as $notification) { + + // If event is time-specific + if ($notification['time_specific']) { + + } else { + + } + + // Build date range we're going to notify (one day) + $days = abs($notification['notification_days']); + $oper = $notification['notification_days'] < 0 ? '+' : '-'; + $attendStartTime = strtotime(date('r')." $oper $days days"); + $attendEndTime = strtotime(date('r', $attendStartTime).' + 1 day'); + $start = date('Y-m-d 00:00:00', $attendStartTime); + $end = date('Y-m-d 00:00:00', $attendEndTime); + + // Build clause to select which event dates to report for + if ($oper == '+') { + $timeClause = " + (NOT T.non_time_specific AND (T.start_datetime >= '$start' AND T.start_datetime < '$end')) + OR + (T.non_time_specific AND (E.first_datetime >= '$start' AND E.first_datetime < '$end')) + "; + } else { + $timeClause = " + (NOT T.non_time_specific AND (T.end_datetime >= '$start' AND T.end_datetime < '$end')) + OR + (T.non_time_specific AND (E.last_datetime >= '$start' AND E.last_datetime < '$end')) + "; + } + + $sql = " + SELECT A.fname, A.lname, A.email, E.event_name, E.first_Datetime, E.last_datetime, E.descr, + T.non_time_specific, T.start_datetime, T.end_datetime + FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_registrant R, + ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request Q, + ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."account A, + ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time T, + ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_event E + WHERE A.id = R.account + AND Q.id = R.reg_request + AND Q.status = ".$this->config['submission_status_numb']['COMPLETE']." + AND T.id = R.reg_time + AND E.id = R.reg_event + AND E.active + AND E.id = ".$notification['reg_event']." + AND ( + $timeClause + ) + "; + $attendees = $this->wpdb->get_results($sql, ARRAY_A); + +echo "
".print_r($attendees, 1)."
"; + + // If there's any attendess to contact, process each + if (is_array($attendees) && count($attendees) > 0) { + foreach ($attendees as $attendee) { + + echo "E-Mail for ".$attendee['fname']."
"; + + + } + } + + + + } + + + } // This model does not return any data return array( diff --git a/setup/adminHooks.php b/setup/adminHooks.php index c5df1ff..170a2e4 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -105,11 +105,12 @@ add_filter('glm_associate_cron_request', function($request) { // Sanity check - Must be passed an array if (is_array($request)) { + // Send Registration Notifications $request[] = array( 'menu' => 'registrations', // Menu where action exists 'action' => 'sendNotifications', // Name of action to run - 'daysOfWeek'=> array(1, 2, 3, 7), // All Days - 'times' => array(0, 13, 21), // All Hours + 'daysOfWeek'=> false, // All Days + 'times' => false, //array(3), // 3 AM ********************************************************************* FIX WHEN DONE TESTING 'params' => false // Any parameters needed by the triggered action ); diff --git a/setup/databaseScripts/create_database_V0.0.28.sql b/setup/databaseScripts/create_database_V0.0.28.sql index 49f498e..182d710 100644 --- a/setup/databaseScripts/create_database_V0.0.28.sql +++ b/setup/databaseScripts/create_database_V0.0.28.sql @@ -219,7 +219,7 @@ CREATE TABLE {prefix}reg_event ( event_code TINYTEXT NULL, -- A short code used to reference this event - can be used to directly select an event to register for notify_email TINYTEXT NULL, -- E-Mail addresses to receive notification of a registration other than org_internal_email in management, comma separated admin_active BOOLEAN NULL, -- Active flag for admin from Events - If logged in Admin user for this event and this is true then admin user may enter registrations even if active is off. - active BOOLEAN NULL, -- Active flag to indicate that this event is available for registrations + active BOOLEAN NULL, -- Active flag to indicate that this event is available for registrations and notifications time_specific BOOLEAN NULL, -- Registration for this event is not date/time specific. Can attend any date/time of event. attendees BOOLEAN NULL, -- Registration requires attendees - Otherwise the person submitting the registration is the registrant attendee_max MEDIUMINT NULL, -- Attendee limit - 0 = unlimited diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 65f8948..dc83cfa 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -19,7 +19,7 @@

First {$terms.reg_term_event_cap} Time:

- {$regEventFirstTime.datetime} + {$regEventFirstTime.datetime} 
@@ -27,7 +27,7 @@

Last {$terms.reg_term_event_cap} Time:

- {$regEventLastTime.datetime} + {$regEventLastTime.datetime} 
@@ -327,16 +327,20 @@ * Initialize the Full Calendar */ function initFullCalendar(){ + $('#eventCalendar').fullCalendar({ timezone: 'local', - {if $regEvent.first_datetime.datetime != ''} + {if $haveRegEventTimes} defaultDate : '{$regEvent.first_datetime.datetime}', + {else} + defaultDate : '{$defaultCalendarDate}', {/if} {if $regEvent} + {if $haveRegEventTimes} // Add existing registration dates/times events: [ - {$sep = ''} + {$sep = ''} {if $haveRegEventTimes} {foreach $regEvent.reg_time as $t} {if $t.non_time_specific.value == false} @@ -372,6 +376,8 @@ {/foreach} {/if} ], + {/if} + // Clicking on a date cell (not an existing event time) Brings up the new date dialog dayClick: function(date, allDay, jsEvent, view) { @@ -389,6 +395,11 @@ $('#dialogAvailLine').hide(); $('#dialogAvailSubmit').on('click', function() { + if ($('#dialogTimeAllDay').prop('checked')) { + $('#dialogStartTime').val('00:00:00'); + $('#dialogEndTime').val('23:59:59'); + } + if ($('#dialogStartTime').val() == '' || $('#dialogEndTime').val() == '') { alert('Both start and end times are required!'); } else { @@ -399,16 +410,14 @@ {else} var max = 0; {/if} - var startDate = new Date($('#dialogStartTime').val()); - var startTime = $('#dialogStartTime').val(); var newTimeActive = $('#dialogRegActive').is(":checked"); var newTimeBackgroundColor = '#aaa'; - if (newTimeActive) { newTimeBackgroundColor = 'light-blue'; } + var startTime = date.format() + ' ' + $('#dialogStartTime').val(); // Initialize the event data object with submitted data var newEvent = { @@ -417,7 +426,7 @@ {else} title: '', {/if} - start: date.format() + ' ' + startTime, + start: startTime, end: date.format() + ' ' + $('#dialogEndTime').val(), active: newTimeActive, backgroundColor: newTimeBackgroundColor, @@ -431,18 +440,17 @@ count: 0, pending: 0, available: max, + datetime: startTime, timeId: false }; - + {if $regEvent.time_specific.value} // If max or active is set, override the defaults if (newEvent.max > 0 ) { newEvent.title = ' ' + newEvent.max + '-0-0-' + newEvent.max } - if (newEvent.active) { - newEvent.backgroundColor = 'light-blue'; - } {/if} + // Try to send the data via AJAX var newTime = $.ajax({ @@ -466,6 +474,7 @@ // If response was not a possible time ID newEvent.timeId = parseInt(newTimeId); + newEvent.allDay = false; if (newEvent.timeId == '0') { alert('New {$terms.reg_term_event} date/time may not have been stored properly. Reload page to check.'); diff --git a/views/admin/registrations/eventEditNotification.html b/views/admin/registrations/eventEditNotification.html index 632e67e..a7b65d6 100644 --- a/views/admin/registrations/eventEditNotification.html +++ b/views/admin/registrations/eventEditNotification.html @@ -88,10 +88,8 @@
 
-
+
-
-
diff --git a/views/admin/registrations/eventNotifications.html b/views/admin/registrations/eventNotifications.html index 90d81f8..e30c320 100644 --- a/views/admin/registrations/eventNotifications.html +++ b/views/admin/registrations/eventNotifications.html @@ -28,12 +28,8 @@ {if $regNotifications} {foreach $regNotifications as $n} - {$n.id} - - {$n.name} - + {$n.id} + {$n.name} {$n.notification_days|regex_replace:"/[-]/":""} days {if $n.notification_days > 0 }After{else}Before{/if} Name Level - Date/Time + Event Date/Time Rate Status + Submitted @@ -80,6 +81,7 @@ {$r.event_time_reformatted} {$r.rate_name} {$r.request_status_name} + {$r.date_submitted} You have not yet submitted your {$terms.reg_term_registration}. See above notes!
diff --git a/views/front/registrations/cartSummary.html b/views/front/registrations/cartSummary.html index 6a1f2bd..4d6b360 100644 --- a/views/front/registrations/cartSummary.html +++ b/views/front/registrations/cartSummary.html @@ -163,7 +163,7 @@ {if $cart.globalPayCodes} -
+
{foreach $cart.globalPayCodes as $payCode}
@@ -174,14 +174,14 @@
{/foreach} -
+
{/if} -- 2.17.1