$sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
- $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE YEAR(start_time) = $year AND MONTH(start_time) = $month AND active = 1 ORDER BY start_time) LIMIT 3; ";
+ $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE YEAR(start_time) = $year AND MONTH(start_time) = $month AND active = 1 AND end_time >= CURDATE() ORDER BY start_time) LIMIT 3; ";
$events = $wpdb->get_results($sql);
// $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
// $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ORDER BY start_time) LIMIT 3";
- $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times GROUP BY event ORDER BY start_time LIMIT 3;";
+ $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE end_time >= CURDATE() GROUP BY event ORDER BY start_time LIMIT 3;";
+// $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ORDER BY start_time LIMIT 3;";
$events_times = $wpdb->get_results($sql);
foreach($events_times as $times){
}
}
foreach($events as $event){
- $sql = "SELECT start_time, end_time FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE event = " . $event->id;
+ $sql = "SELECT start_time, end_time, event FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE event = " . $event->id;
if($event->image !== ''){
$image = $image_url . $event->image;
}
$date = $wpdb->get_results($sql);
- $dates[] = $date[0];
+
+ if(count($date) > 1){
+ $end_date = date('M d', strtotime($date[1]->end_time));
+ } else {
+ $end_date = '';
+ }
+
$start_date = date('M d', strtotime($date[0]->start_time));
- $end_date = date('M d', strtotime($date[0]->end_time));
$start_timestamp = strtotime($start_date);
$end_timestamp = strtotime($end_date);
-
+
+ if($start_timestamp < $end_timestamp){
+ $start_date = $start_date . " - " . $end_date;
+ }
$sidebar_events[$event->id] =
array(
- "start_date" => $start_date,
+ "start_date" => $start_date,
"end_date" => $end_date,
"name" => $event->name,
"content" => $event->descr,
'message' => $info,
'sidebar_events' => $sidebar_events,
'array_dates' => $arrayDates,
- 'event' => $events
);
header('Content-type:application/json;charset=utf-8', true);
<h1>Upcoming Events </h1>
<div id="sidebar-date-select" class="sidebar-datepicker"></div>
<div class="sidebar-events"></div>
-
+
<script>
jQuery(document).ready(function($) {
$('.sidebar-event').fadeIn("slow");
},
success: function(data){
-
if(data.array_dates !== null){
var num = 0;
$.each(data.array_dates, function(index, value){