Test with more data
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 13 Aug 2018 18:01:02 +0000 (14:01 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 13 Aug 2018 18:01:02 +0000 (14:01 -0400)
Select month searched if given.

models/admin/travel/reports.php
views/admin/travel/reports.html

index 9352551..bdfa353 100644 (file)
@@ -87,6 +87,7 @@ class GlmMembersAdmin_travel_reports //extends GlmDataTravelLeads
         $where     = ' true ';
         $option    = false;
         $hasSearch = false;
+        $s_month   = false;
 
         // Get any provided option
         if ( isset( $_REQUEST['option'] ) ) {
@@ -103,6 +104,7 @@ class GlmMembersAdmin_travel_reports //extends GlmDataTravelLeads
 
             if ( isset( $_REQUEST['report_month'] ) && $monthYear = filter_var( $_REQUEST['report_month'] ) ) {
 
+                $s_month = $_REQUEST['report_month'];
                 if ($monthYear) {
                     list($month, $year) = explode("|", $monthYear);
                 } else {
@@ -137,14 +139,16 @@ class GlmMembersAdmin_travel_reports //extends GlmDataTravelLeads
         $months = $this->wpdb->get_results(
             "SELECT MONTH(search_date) as month, YEAR(search_date) as year
                FROM " . GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . "search_reports
-            GROUP BY month, year",
+            GROUP BY month, year
+            ORDER BY year DESC, month DESC",
             ARRAY_A
         );
 
         // Add Month name to $months
         if ( isset( $months ) && !empty( $months ) ) {
             foreach ( $months as $key => $row ) {
-                $months[$key]['full_month'] = date( 'F', mktime( 0, 0, 0, $row['month'], $row['year']) );
+                $months[$key]['full_month']   = date( 'F', mktime( 0, 0, 0, $row['month'], $row['year']) );
+                $months[$key]['option_value'] = $row['month'] . '|' .$row['year'];
             }
         }
 
@@ -153,6 +157,7 @@ class GlmMembersAdmin_travel_reports //extends GlmDataTravelLeads
             'hasSearch' => $hasSearch,
             'list'      => $list,
             'months'    => $months,
+            's_month'   => $s_month,
         );
 
 
index 3389b0e..a92c0a2 100644 (file)
@@ -49,7 +49,7 @@
             Show Summary for Month
             <select name="report_month">
                 {foreach $months as $m}
-                <option value="{$m.month}|{$m.year}">{$m.full_month} {$m.year}</option>
+                    <option value="{$m.option_value}"{if $s_month == $m.option_value} selected{/if}>{$m.full_month} {$m.year}</option>
                 {/foreach}
             </select>
             <input type="submit" value="Go" />