From: Chuck Scott Date: Mon, 9 Oct 2017 17:16:02 +0000 (-0400) Subject: Cleared up problems in checking existing reg_time entries with times from event recur... X-Git-Tag: v1.0.0^2~363 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=bf38c954d955bea2cc7671e22dcf302b9e86f2c6;p=WP-Plugins%2Fglm-member-db-registrations.git Cleared up problems in checking existing reg_time entries with times from event recurences. --- diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index 23df53d..9c9c871 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -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); } diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index 8761ad2..077016e 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -24,7 +24,7 @@
-

Earliest Event Date:

+

First Event Time:

{$regEventFirstTime.start_time.datetime} @@ -34,10 +34,10 @@
-

Latest Event Date:

+

Last Event Time:

- {$regEventLastTime.start_time.datetime} + {$regEventLastTime.end_time.datetime}