From: Chuck Scott Date: Fri, 26 Jan 2018 21:02:25 +0000 (-0500) Subject: Fixed Getting times from event not working and other issues in Reg Event Dashboard X-Git-Tag: v1.0.0^2~46 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=b0137e924ac30c354572282ee9b64fff7fdb26b8;p=WP-Plugins%2Fglm-member-db-registrations.git Fixed Getting times from event not working and other issues in Reg Event Dashboard Fixed checkEventTimes() in dataRegEvent.php to fix copying times from event. Cleaned up various debug messages that included redundant message text. Fixed sub-tabs that weren't clickable when selected. Fixed getEventConfig() First and Last times not showing correctly after just adding a date/time. Fixed event dashboard Calendar not showing proper month when first loading. --- diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index 198eb65..914843b 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -206,6 +206,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract 'field' => 'attendee_max', 'type' => 'integer', 'required' => false, + 'default' => 0, 'use' => 'a' ), @@ -752,28 +753,25 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract $firstTime = false; $lastTime = false; - // Check for reg_time data (are we still using this?) + // Check for reg_time data if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) { foreach ($this->regEventData['reg_time'] as $time) { // If the time is not for non-time-specific inventory if (!$time['non_time_specific']['value']) { - if (!$firstTime || $time['start_datetime']['timestamp'] < $firstTime) { $firstTime = $time['start_datetime']['timestamp']; } if (!$lastTime || $time['start_datetime']['timestamp'] > $lastTime) { $lastTime = $time['start_datetime']['timestamp']; } - } - } } // Generate date as used in results - $firstDateTime = date('Y-m-d H:i:s', $firstTime); - $lastDateTime = date('Y-m-d H:i:s', $lastTime); + $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)); // 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 || @@ -781,15 +779,15 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract ) { // Update the regEventData first and last times - $this->regEventData['first_dateTime'] = array('datetime' => $firstDateTime, 'timestamp' => $firstTime); - $this->regEventData['last_dateTime'] = array('datetime' => $lastDateTime, 'timestamp' => $lastTime); + $this->regEventData['first_datetime'] = $firstDateTime; + $this->regEventData['last_datetime'] = $lastDateTime; // Update the database $this->wpdb->update( GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_event', array( - 'first_datetime' => date('Y-m-d H:i:s', $firstTime), - 'last_datetime' => date('Y-m-d H:i:s', $lastTime), + 'first_datetime' => $firstDateTime['mysql_datetime'], + 'last_datetime' => $lastDateTime['mysql_datetime'], ), array( 'id' => $this->regEventData['id'] ), array( @@ -814,8 +812,8 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract ) { // Update this reg_time entry - NOTE: for non-time-specific entries the end_datetime is the start of the last occurance of the event - $this->regEventData['reg_time'][$regTimeKey]['start_datetime'] = array('datetime' => $firstDateTime, 'timestamp' => $firstTime); - $this->regEventData['reg_time'][$regTimeKey]['end_datetime'] = array('datetime' => $lastDateTime, 'timestamp' => $lastTime); + $this->regEventData['reg_time'][$regTimeKey]['start_datetime'] = $firstDateTime; + $this->regEventData['reg_time'][$regTimeKey]['end_datetime'] = $lastDateTime; // Update the database $this->wpdb->update( @@ -832,14 +830,10 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract ); } // If times changed - } // is non_time_specific - } // each reg_time - } // non_time_specific - // Add Recurrence summary to event data // $this->regEventData['recurrenceSummary'] = $recurrenceSummary; @@ -995,20 +989,20 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract * * @param integer $regEventId Optional ID of a reg event record. If provided, load all registration data using getEventConfig() above * This is not required if the event data has already been loaded using getEVentConfig() by the calling code - * @param boolean $deleteRemovedTimes Optional flag to ask that times removed from the event are removed from registration - * @param boolean $nonDateSpecificOnly Optional flag to check only for the default non-date-specific time entry. * * @return array updated reg_times data or false if not regEventData has been provided or no recurrence data */ - public function checkEventTimes($regEventId = false, $deleteTimes = false, $nonDateSpecificOnly = false) + public function checkEventTimes($regEventId = false ) { +echo "

checkEventTimes()

"; + $needTimesReloaded = false; $message = ''; // If we've been passed a reg event id, get the configuration (with recurrence data) if ($regEventId && $regEventId > 0) { - $this->getEventConfig($regEventId, false, false, true); + $this->getEventConfig($regEventId, true, false, true, false, true); } // If we don't have event data @@ -1016,140 +1010,83 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract return false; } - // Only do this if we haven't requested only non-date-specific time entry check - if (!$nonDateSpecificOnly) { - - // If we don't have recurrences for the event - if (!is_array($this->regEventData['recurrences']) || count($this->regEventData['recurrences']) == 0) { - return false; - } - - // For each recurrence - foreach ($this->regEventData['recurrences'] as $recurKey=>$recurVal) { - - // If we have times for this recurrence - if ($recurVal['times'] && count($recurVal['times']) > 0) { - - // If this is a time specific event - if ($this->regEventData['time_specific']['value']) { - - // Check all event times for matching reg event times - foreach ($recurVal['times'] as $eventTimeKey=>$eventTimeVal) { - - $id = false; - - // If we have any times entries in this event - if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) { + /* + * For each time entry from the event, check to see if it needs to be added to registrations + */ - // Check if this time from the event already exists in reg_times array - reset($this->regEventData['reg_time']); - foreach($this->regEventData['reg_time'] as $regTimeKey=>$regTimeVal) { - if ($regTimeVal['event_time'] == $eventTimeKey) { + foreach ($this->regEventData['times'] as $eventTimeKey=>$eventTimeVal) { - // Set ID to say we found this one. - $id = $regTimeKey; + $id = false; - // Also add OK to the reg_time to say that it matches a recur time - see below - $this->regEventData['reg_time'][$regTimeKey]['OK'] = true; - } - } + // If we have any times entries in this event + if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) { - } - // If it wasn't found, then add it - if (!$id) { - - $needTimesReloaded = true; - $message .= "
    New dates and/or times have been added"; - - $sTime = date('Y-m-d H:i:s',strtotime($eventTimeVal['start_time']['datetime'])); - $eTime = date('Y-m-d H:i:s',strtotime($eventTimeVal['end_time']['datetime'])); - - // Add reg event time - $this->wpdb->insert( - GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time", - array( - 'reg_event' => $this->regEventData['id'], - 'active' => false, - 'event_time' => $eventTimeKey, - 'start_datetime' => $sTime, - 'end_datetime' => $eTime, - 'all_day' => $eventTimeVal['all_day']['value'], - 'non_time_specific' => false, - 'attendees' => $this->regEventData['attendees']['value'], - 'attendee_max' => $this->regEventData['attendee_max'], - 'attendee_count' => 0, - 'attendees_pending' => 0, - 'attendees_available' => $this->regEventData['attendee_max'], - 'total_base_charge' => 0, - - 'total_per_attendee' => 0, - 'total_other' => 0, - 'total_taxes' => 0, - 'total_charges' => 0, - 'total_discounts' => 0, - 'total_payments' => 0 - ), - array( - '%d', // reg_event - '%d', // event_time record ID - '%s', // start_datetime - '%s', // end_datetime - '%d', // all_day flag - '%d', // attendees flag - '%d', // attendee_max - '%d', // attendee_count - '%d', // attendees_pending - '%d', // attendees_available - '%f', // total_base__charge - '%f', // total_per_attendee - '%f', // total_other - '%f', // total_taxes - '%f', // total_charges - '%f', // total_discounts - '%f' // total_payments - ) - ); - - } // If time isn't in reg_times - } // each recurrence times - } // time specific - } // have times for recurrence - - } // each recurrence - - // If this is a time specific event - $deleteList = ''; - $deleteSep = ''; - if ($this->regEventData['time_specific']['value']) { - - // Check all reg_times we had from before to make sure they were matched with a recur time + // Check if this time from the event already exists in reg_times array + reset($this->regEventData['reg_time']); foreach($this->regEventData['reg_time'] as $regTimeKey=>$regTimeVal) { - if (!isset($regTimeVal['OK'])) { + if ($regTimeVal['start_datetime']['timestamp'] == $eventTimeVal['start_time']['timestamp']) { - // If this time didn't match a recur time, then it must have been removed in the event so add to list - $deleteList .= $deleteSep.$regTimeKey; - $deleteSep = ','; + // Set ID to say we found this one. + $id = $regTimeKey; + // Also add OK to the reg_time to say that it matches a recur time - see below + $this->regEventData['reg_time'][$regTimeKey]['OK'] = true; } } - } - // If requested and there's anything in the delete list, purge them now and say we need a reload - if ($deleteTimes && $deleteList != '') { - $this->wpdb->query(" - DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time - WHERE id IN ($deleteList) - "); - $needTimesReloaded = true; - $message .= '
    Old dates and/or times have been removed'; - } - - // Get rid of all of the recurrence data - No longer needed - unset($this->regEventData['recurrences']); + // If it wasn't found, then add it + if (!$id) { + $needTimesReloaded = true; +echo "

**** TIME ADDED ****

"; + // Add reg event time + $this->wpdb->insert( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time", + array( + 'reg_event' => $this->regEventData['id'], + 'active' => false, + 'event_time' => $eventTimeKey, + 'start_datetime' => $eventTimeVal['start_time']['mysql_datetime'], + 'end_datetime' => $eventTimeVal['end_time']['mysql_datetime'], + 'all_day' => $eventTimeVal['all_day']['value'], + 'non_time_specific' => false, + 'attendees' => $this->regEventData['attendees']['value'], + 'attendee_max' => $this->regEventData['attendee_max'], + 'attendee_count' => 0, + 'attendees_pending' => 0, + 'attendees_available' => $this->regEventData['attendee_max'], + 'total_base_charge' => 0, - } // if time specific check + 'total_per_attendee' => 0, + 'total_other' => 0, + 'total_taxes' => 0, + 'total_charges' => 0, + 'total_discounts' => 0, + 'total_payments' => 0 + ), + array( + '%d', // reg_event + '%d', // event_time record ID + '%s', // start_datetime + '%s', // end_datetime + '%d', // all_day flag + '%d', // attendees flag + '%d', // attendee_max + '%d', // attendee_count + '%d', // attendees_pending + '%d', // attendees_available + '%f', // total_base__charge + '%f', // total_per_attendee + '%f', // total_other + '%f', // total_taxes + '%f', // total_charges + '%f', // total_discounts + '%f' // total_payments + ) + ); + } // If time isn't in reg_times + } // each recurrence times // If this event is not time specific if (!$this->regEventData['time_specific']['value']) { @@ -1167,8 +1104,6 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract break; } } - - } // If no default time, create one now. @@ -1216,11 +1151,9 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract '%f', // total_discounts '%f' // total_payments ) - ); - + ); } // no default time - } // not times specific // Check if we need the times entries reloaded @@ -1232,9 +1165,6 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract $RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config); $this->regEventData['reg_time'] = $RegTime->getList('T.reg_event = '.$this->regEventData['id'], 'start_datetime', true); - $this->regEventData['message'] = 'Dates and Times have been updated due to changes in the "Dates Schedules" for this event.'.$message; - - } // echo "
".print_r($this->regEventData,1)."
"; diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index ff7cf91..c6e381f 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -177,7 +177,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $subModel = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/admin/registrations/events_'.$modelFile.'.php'; if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - trigger_error("Registration Events: Sub-Controller calling: $subModel", E_USER_NOTICE); + trigger_error("Sub-Controller Model: $subModel", E_USER_NOTICE); } require_once $subModel; diff --git a/models/admin/registrations/events_addEdit.php b/models/admin/registrations/events_addEdit.php index 67f9cf9..51a6854 100644 --- a/models/admin/registrations/events_addEdit.php +++ b/models/admin/registrations/events_addEdit.php @@ -82,9 +82,6 @@ if ($option == 'add') { $regEventUpdated = true; - // Create all needed reg_time entries - $this->checkEventTimes($regEventID); - } } diff --git a/models/admin/registrations/events_delete.php b/models/admin/registrations/events_delete.php index 28dd639..d8ac88b 100644 --- a/models/admin/registrations/events_delete.php +++ b/models/admin/registrations/events_delete.php @@ -17,7 +17,7 @@ $regEventDeleted = false; // If we don't have a registration Event ID if (!$regEventID) { - $messages[] = 'Request to delete registrations for an event but ID for this was not supplied.'; + $messages[] = 'Request to delete '.$this->config['terms']['reg_term_registration_plur'].' for an '.$this->config['terms']['reg_term_event'].' but ID for this was not supplied.'; } else { // Check if we received a confirmation override to delete a reg event that has completed registrations @@ -27,14 +27,14 @@ if (!$regEventID) { $regEvent = $this->getEntry($regEventID); if (!$regEvent) { - $messages[] = 'Request to delete registrations for an event but unable to find registration setup for this event.'; + $messages[] = 'Request to delete '.$this->config['terms']['reg_term_registration_plur'].' for an '.$this->config['terms']['reg_term_event'].' but unable to find it.'; } else { // Delete registrations for this event $regEventDeleted = $this->deleteRegEvent($regEventID); if (!$regEventDeleted) { - $messages[] = 'Attempt to delete registrations for this event failed. Nothing has been deleted'; + $messages[] = 'Attempt to delete '.$this->config['terms']['reg_term_registration_plur'].' for this '.$this->config['terms']['reg_term_event'].' failed. Nothing has been deleted'; } } @@ -45,7 +45,8 @@ if (!$regEventID) { } if ($regEventDeleted) { - + $view = 'registrationEventDeleted'; +/* // Return status, any suggested view, and any data to controller return array( 'status' => true, @@ -53,10 +54,10 @@ if ($regEventDeleted) { 'view' => 'admin/registrations/registrationEventDeleted.html', 'data' => array() ); - break; - -} +*/ +} else { // Registration event was not deleted so falling through to eventDashboard to display reasons or ask for confirmation require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/admin/registrations/events_dashboard.php'; +} diff --git a/models/admin/registrations/events_eventDashboard.php b/models/admin/registrations/events_eventDashboard.php index ec9a7c1..e7a5ce1 100644 --- a/models/admin/registrations/events_eventDashboard.php +++ b/models/admin/registrations/events_eventDashboard.php @@ -13,16 +13,15 @@ * @link http://dev.gaslightmedia.com/ */ -$regEvent = $this->getEventConfig($regEventID, true, false, true, false, true); - // Check if there's a request to add event times from the event +$getTimesFromEvent = false; if (isset($_REQUEST) && isset($_REQUEST['getTimesFromEvent']) && $_REQUEST['getTimesFromEvent'] == 'yes') { // Check that the user entered the correct confirmation string if (isset($_REQUEST['addConfirmation']) && $_REQUEST['addConfirmation'] == 'ADD') { // Get the event data again along with any new times - $regEvent = $this->getEventConfig($regEventID, true, false, true); + $getTimesFromEvent = true; $messages[] = 'Per your request, any dates and times specified in the event schedules that were not already added here, have now been added.'; @@ -32,11 +31,13 @@ if (isset($_REQUEST) && isset($_REQUEST['getTimesFromEvent']) && $_REQUEST['getT } -// If this isn't a time specific event - check for new event non-date-specific only time entry -if (!$regEvent['time_specific']['value']) { - $regEvent = $this->checkEventTimes(false, false, true); +// If requested, get any new times from the event and add them to the reg_times +if ($getTimesFromEvent) { + $regEvent = $this->checkEventTimes($regEventID); } +$regEvent = $this->getEventConfig($regEventID, true, false, true, false, true); + if ($regEvent !== false) { $haveRegEvent = true; @@ -51,16 +52,10 @@ if ($regEvent !== false) { } // Check if we have any times for this reg_event -if (is_array($regEvent['reg_time']) || count($regEvent['reg_time']) > 0) { +if (is_array($regEvent['reg_time']) && count($regEvent['reg_time']) > 0) { $haveRegEventTimes = true; } else { - $messages[] = 'There are no dates for registrations for this event.'; -} - -// calculate default calendar date for event dashboard -$defaultCalTime = time(); -if (isset($regEventFirstTime) && $regEventFirstTime['timestamp']+0 > 0) { - $defaultCalTime = $regEventFirstTime['timestamp']; + $messages[] = 'There are no dates on the calendar for this '.$this->config['terms']['reg_term_event'].'.'; } $view = 'eventDashboard'; diff --git a/models/front/registrations/index.php b/models/front/registrations/index.php index df15033..5277ae3 100644 --- a/models/front/registrations/index.php +++ b/models/front/registrations/index.php @@ -113,7 +113,7 @@ class GlmMembersFront_registrations_index } if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - trigger_error("Registration Front-End Sub-Controller: Page = $page ", E_USER_NOTICE); + trigger_error("Sub-controller Page: $page ", E_USER_NOTICE); } // Load the specified model @@ -121,7 +121,7 @@ class GlmMembersFront_registrations_index require_once $pageFile; if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - trigger_error("Sub-Controller Calling: $pageFile", E_USER_NOTICE); + trigger_error("Sub-Controller Model: $pageFile", E_USER_NOTICE); } // load and run the model diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 01679ba..f76f3c7 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} + {$regEvent.first_datetime.datetime}
@@ -27,7 +27,7 @@

Last {$terms.reg_term_event_cap} Time:

- {$regEventLastTime.datetime} + {$regEvent.last_datetime.datetime}
@@ -326,11 +326,14 @@ /* * Initialize the Full Calendar */ - function initFullCalendar(){ $('#eventCalendar').fullCalendar({ timezone: 'local', + {if $regEvent.first_datetime.datetime != ''} + defaultDate : '{$regEvent.first_datetime.datetime}', + {/if} {if $regEvent} + // Add existing registration dates/times events: [ {$sep = ''} @@ -601,7 +604,11 @@ {/if} }); } + initFullCalendar(); + {if $regEvent.first_datetime.datetime == ''} + alert('No dates have been added yet. Click on a date to add a date and time for this {$terms.reg_term_event} or click the "Add {$terms.reg_term_registration_plur_cap} Dates/Times from {$terms.reg_term_event_cap}" button to copy from the {$terms.reg_term_event}.'); + {/if} // If not date/time specific then we need to add the data for the non-date-specific time entry. if (!{$regEvent.time_specific.value}) { diff --git a/views/admin/registrations/eventEdit.html b/views/admin/registrations/eventEdit.html index 654dd63..fb36c88 100644 --- a/views/admin/registrations/eventEdit.html +++ b/views/admin/registrations/eventEdit.html @@ -13,7 +13,6 @@ - @@ -62,8 +61,14 @@ {if $regEvent.fieldFail.time_specific}

{$regEvent.fieldFail.time_specific}

{/if}
- - + + + +
Default Max {$terms.reg_term_attendee_plur_cap}: + This number of attendees will be used as a default for non-Date/Time specific {$terms.reg_term_event_plur} and when adding time entries to date/Time specific {$terms.reg_term_event_plur}.
+ + {if $regEvent.fieldFail.attendee_max}

{$regEvent.fieldFail.attendee_max}

{/if}
+
{$terms.reg_term_attendee_plur_cap} Hold Time (minutes): diff --git a/views/admin/registrations/eventSubTabs.html b/views/admin/registrations/eventSubTabs.html index 326f699..3dabb1c 100644 --- a/views/admin/registrations/eventSubTabs.html +++ b/views/admin/registrations/eventSubTabs.html @@ -7,15 +7,14 @@