Returned to having only one time sent to front-end for registrations page if non...
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 14 Dec 2017 22:15:49 +0000 (17:15 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 14 Dec 2017 22:15:49 +0000 (17:15 -0500)
Time specific events still get all available times but do not get non-time-specific times entries.
Since non-time specific evnets don't get all time entries now, we may need another way to display event times for these events.

classes/data/dataRegEvent.php
classes/regCartSupport.php

index 35c6039..5f23f50 100644 (file)
@@ -828,9 +828,6 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
      *
      * Check that an event has enough data to support a registration for dates in the future.
      *
-     * getEventConfig() must have been run first to get the event configuration
-     *
-     *
      */
     public function getEventForRegistration($regEventId = false)
     {
@@ -884,60 +881,65 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 $this->regEventData['reg_class'][$regClassKey]['non_time_specific_time'] = array();
                 $this->regEventData['reg_class'][$regClassKey]['hasTimes'] = false;
 
-                // For each event time except non-time-specific entry
-                foreach ($this->regEventData['reg_time'] as $regTimeKey=>$regTime) {
-
-                    // If event time is for non-time-specific event - Calculate from the earlies and latest event times
-                    if ($regTime['non_time_specific']['value']) {
+                // If event time is time-specific event
+                if ($this->regEventData['time_specific']['value']) {
 
+                    // Scan times
+                    foreach ($this->regEventData['reg_time'] as $regTimeKey=>$regTime) {
 
                         // Try to find a current rate for this time - within the start and end days before this time
                         foreach ($regClass['reg_rate'] as $regRateKey=>$regRate) {
+                            if (!$regTime['non_time_specific']['value']) {
+
+                                // Calculate earliest and latest days for this rate calculated from the start of this event time
+                                $earliestTime   = strtotime(date('m/d/Y', $regTime['start_datetime']['timestamp']).' -'.$regRate['start_days'].' days');
+                                $latestTime     = strtotime(date('m/d/Y', $regTime['start_datetime']['timestamp']).' -'.($regRate['end_days']-1).' days');
 
-                            // Calculate earliest and latest days for this rate calculated from the start of the first date/time for this event
-                            $earliestTime   = strtotime(date('m/d/Y', $this->regEventData['first_datetime']['timestamp']).' -'.$regRate['start_days'].' days');
-                            $latestTime     = strtotime(date('m/d/Y', $this->regEventData['first_datetime']['timestamp']).' -'.($regRate['end_days']).' days');
+                                // If it's time to register with this time/rate - Add it to the class data
+                                if (time() >= $earliestTime && time() <= $latestTime) {
 
-                            // If it's time to register with this time/rate - Add it to the class data
-                            if (time() >= $earliestTime && time() <= $latestTime && false) {
+                                    // Preserve rate ID and don't let it trash the time ID
+                                    $regRate['rate_id'] = $regRate['id'];
+                                    unset($regRate['id'], $regRate['reg_event']);
 
-                                // Preserve rate ID and don't let it trash the time ID
-                                $regRate['rate_id'] = $regRate['id'];
-                                unset($regRate['id'], $regRate['reg_event']);
+                                    $this->regEventData['reg_class'][$regClassKey]['times'][$regTime['id']] = array_merge($regTime, $regRate);
+                                    $this->regEventData['reg_class'][$regClassKey]['hasTimes'] = true;
+                                }
 
-                                $this->regEventData['reg_class'][$regClassKey]['times'][$regTime['event_time']] = array_merge($regTime, $regRate);
-                                $this->regEventData['reg_class'][$regClassKey]['hasTimes'] = true;
                             }
 
                         }
-
                         unset($this->regEventData['reg_time'][$regTimeKey]);
 
-                    // If time specific event - calculate based on the time entries
-                    } else {
+                    }
 
-                        // Try to find a current rate for this time - within the start and end days before this time
-                        foreach ($regClass['reg_rate'] as $regRateKey=>$regRate) {
+                } else {
 
-                            // Calculate earliest and latest days for this rate calculated from the start of this event time
-                            $earliestTime   = strtotime(date('m/d/Y', $regTime['start_datetime']['timestamp']).' -'.$regRate['start_days'].' days');
-                            $latestTime     = strtotime(date('m/d/Y', $regTime['start_datetime']['timestamp']).' -'.($regRate['end_days']-1).' days');
 
-                            // If it's time to register with this time/rate - Add it to the class data
-                            if (time() > $earliestTime && time() < $latestTime) {
+                    // For each event time except non-time-specific entry
+                    foreach ($this->regEventData['reg_time'] as $regTimeKey=>$regTime) {
 
-                                // Preserve rate ID and don't let it trash the time ID
-                                $regRate['rate_id'] = $regRate['id'];
-                                unset($regRate['id']);
+                        if ($regTime['non_time_specific']['value']) {
 
-                                $this->regEventData['reg_class'][$regClassKey]['times'][$regTime['event_time']] = array_merge($regTime, $regRate);
-                                $this->regEventData['reg_class'][$regClassKey]['hasTimes'] = true;
-                            }
+                            // Try to find a current rate for this time - within the start and end days before this time
+                            foreach ($regClass['reg_rate'] as $regRateKey=>$regRate) {
 
-                        }
+                                // Calculate earliest and latest days for this rate calculated from the start of the first date/time for this event
+                                $earliestTime   = strtotime(date('m/d/Y', $this->regEventData['last_datetime']['timestamp']).' -'.$regRate['start_days'].' days');
+                                $latestTime     = strtotime(date('m/d/Y', $this->regEventData['last_datetime']['timestamp']).' -'.($regRate['end_days']).' days');
 
-                    }
+                                // If it's time to register with this time/rate - Add it to the class data
+                                if (time() > $earliestTime && time() < $latestTime) {
 
+                                    // Preserve rate ID and don't let it trash the time ID
+                                    $regRate['rate_id'] = $regRate['id'];
+                                    unset($regRate['id']);
+                                    $this->regEventData['reg_class'][$regClassKey]['times'][$regTime['id']] = array_merge($regTime, $regRate);
+                                    $this->regEventData['reg_class'][$regClassKey]['hasTimes'] = true;
+                                }
+                            }
+                        }
+                    }
                 }
 
             } // Have rates for this class
index be8a4f0..cef7cbd 100644 (file)
@@ -455,7 +455,7 @@ class GlmRegCartSupport
                                                 $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['removed'] = false;
 
                                                 // Check if the time selected for this registrant doesn't exist or is inactive
-                                                if (!isset($regEventTimes[$registrant['reg_time']]) || !$regEventTimes[$registrant['reg_time']]['active']) {
+                                                if (!isset($regEventTimes[$registrant['reg_time']]) || !$regEventTimes[$registrant['reg_time']]['active']['value']) {
                                                     $this->cart['messages'][] = "The event date and/or time selected for ".$registrant['fname'].' '.$registrant['fname']." has been dropped from the event. Registrant was removed.";
                                                     $removeRegistrant = true;
                                                 }