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;