From: Chuck Scott Date: Wed, 8 Jun 2016 14:53:13 +0000 (-0400) Subject: Fixed bad dates in events list when no times entries X-Git-Tag: v1.0.17^2~7 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=72ca48a4f407a8dc831e1fbed4515850c0ed4b36;p=WP-Plugins%2Fglm-member-db-events.git Fixed bad dates in events list when no times entries --- diff --git a/classes/data/dataEvents.php b/classes/data/dataEvents.php index a75e307..f21289f 100644 --- a/classes/data/dataEvents.php +++ b/classes/data/dataEvents.php @@ -774,15 +774,32 @@ class GlmDataEvents extends GlmDataAbstract public function getFirstAndLastTimes($id = false) { + $firstDate = ''; + $lastDate = ''; + // Load the data class for Event Times require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataTimes.php'); $Times = new GlmDataEventsTimes($this->wpdb, $this->config); - // Select the first and last entries by matching min and max start times + // Select the first entry by matching min start time $first = $Times->getEntry(0, 'id', "T.event = $id ORDER BY T.start_time"); - $last = $Times->getEntry(0, 'id', "T.event = $id ORDER BY T.start_time DESC"); - $r = array('first' => date('m/d/Y', $first['start_time']['timestamp']), 'last' => date('m/d/Y', $last['start_time']['timestamp'])); + // If there's a first times entry + if ($first) { + + // Convert to text date + $firstDate = date('m/d/Y', $first['start_time']['timestamp']); + + // Find last date + $last = $Times->getEntry(0, 'id', "T.event = $id ORDER BY T.start_time DESC"); + + // If last date is not the same as first + if ($last != $first) { + $lastDate = date('m/d/Y', $last['start_time']['timestamp']); + } + } + + $r = array('first' => $firstDate, 'last' => $lastDate); return $r;