Sort events by First Date
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 18 Apr 2017 18:23:05 +0000 (14:23 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 18 Apr 2017 18:23:05 +0000 (14:23 -0400)
If they select the show archived it will empty the From date.
From date will be set to the current date automatically.

models/admin/events/list.php
views/admin/events/list.html

index 0a9002d..7e99a1f 100644 (file)
@@ -645,6 +645,10 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                     $fromDate = date('m/d/Y', strtotime($_REQUEST['fromDate']));
                     $fromMYSQL = date('Y-m-d', strtotime($fromDate));
                     $dateWhere = " end_time >= '$fromMYSQL' ";
+                } else if ( !$filterArchived  ) {
+                    $fromDate = date('m/d/Y');
+                    $fromMYSQL = date('Y-m-d', strtotime($fromDate));
+                    $dateWhere = " end_time >= '$fromMYSQL' ";
                 }
 
                 // If we have a to Date
@@ -711,7 +715,9 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                 // Get the list of events and determine number of events in list
                 $saveFLT = $this->postFirstAndLastTimes;
                 $this->postFirstAndLastTimes = true;
-                $eventsResult = $this->getList($where, 'name', true, 'id', $start, $limit);
+                $orderBy = 'name';
+                $orderBy = "(select min(start_time) FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE T.id = event),name";
+                $eventsResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
                 $this->postFirstAndLastTimes = $saveFLT;
 
                 // Get paging results
index dc4b90c..cf0dc0a 100644 (file)
 
             $("#filterArchived").on('click', function() {
                 $("#filterPending").attr('checked', false);
+                $('input[name=fromDate]').val('');
             });
 
             $("#filterPending").on('click', function() {