Cleared up problems in checking existing reg_time entries with times from event recur...
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Oct 2017 17:16:02 +0000 (13:16 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Oct 2017 17:16:02 +0000 (13:16 -0400)
classes/data/dataRegEvent.php
views/admin/registrations/eventDashboard.html

index 23df53d..9c9c871 100644 (file)
@@ -530,6 +530,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
     {
 
         $needTimesReloaded = false;
+
         $regEventFirstTime = false;
         $regEventLastTime = false;
 
@@ -563,14 +564,15 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 $first = current($v['times']);
                 $last = end($v['times']);
 
+
                 $this->regEventData['recurrences'][$k]['first_time'] = $first;
                 $this->regEventData['recurrences'][$k]['lastTime'] = $last;
 
                 // Set event first and last times
-                if (!$regEventFirstTime || $regEventFirstTime['timestamp'] < $first ) {
+                if (!$regEventFirstTime || $regEventFirstTime['start_time']['timestamp'] > $first['start_time']['timestamp'] ) {
                     $regEventFirstTime = $first;
                 }
-                if (!$regEventLastTime || $regEventLastTime['timestamp'] > $last ) {
+                if (!$regEventLastTime || $regEventLastTime['end_time']['timestamp'] < $last['end_time']['timestamp'] ) {
                     $regEventLastTime = $last;
                 }
 
@@ -580,15 +582,21 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                     // Check all event times for matching reg event times
                     foreach ($v['times'] as $tk=>$tv) {
 
-                        // Check if time already exists in reg_times array
-                        reset($this->regEventData['reg_time']);
-                        foreach($this->regEventData['reg_time'] as $rk=>$rv) {
-                            if ($rv['event_time'] == $tk) {
-                                $id = $rk;
-                                break;
+                        $id = false;
+
+                        // If we have any times entries in this event
+                        if (is_array($this->regEventData['reg_time']) && count($this->regEventData['reg_time']) > 0) {
+
+                            // Check if this time from the event already exists in reg_times array
+                            reset($this->regEventData['reg_time']);
+                            foreach($this->regEventData['reg_time'] as $rk=>$rv) {
+                                if ($rv['event_time'] == $tk) {
+                                    $id = $rk;
+                                    break;
+                                }
                             }
-                        }
 
+                        }
                         // If it doesn't now, then add it
                         if (!$id) {
 
@@ -743,7 +751,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
             // Get all reg_time records for this event
             require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegTime.php';
             $RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config);
-            $this->regEventData['reg_time'] = $RegTime->getList('T.reg_event = '.$regEventID, 'start_datetime', true);
+            $this->regEventData['reg_time'] = $RegTime->getList('T.reg_event = '.$this->regEventData['id'], 'start_datetime', true);
 
         }
 
index 8761ad2..077016e 100644 (file)
@@ -24,7 +24,7 @@
                 <div class="glm-admin-table">
                     <div class="glm-row">
                         <div class="glm-small-12 glm-column">
-                            <h4>Earliest Event Date:</h4>
+                            <h4>First Event Time:</h4>
                         </div>
                         <div class="glm-small-12 glm-column">
                             {$regEventFirstTime.start_time.datetime}
                 <div class="glm-admin-table">
                     <div class="glm-row">
                         <div class="glm-small-12 glm-column">
-                            <h4>Latest Event Date:</h4>
+                            <h4>Last Event Time:</h4>
                         </div>
                         <div class="glm-small-12 glm-column">
-                            {$regEventLastTime.start_time.datetime}
+                            {$regEventLastTime.end_time.datetime}
                         </div>
                     </div>
                 </div>