$where = ' true ';
$option = false;
$hasSearch = false;
+ $s_month = false;
// Get any provided option
if ( isset( $_REQUEST['option'] ) ) {
if ( isset( $_REQUEST['report_month'] ) && $monthYear = filter_var( $_REQUEST['report_month'] ) ) {
+ $s_month = $_REQUEST['report_month'];
if ($monthYear) {
list($month, $year) = explode("|", $monthYear);
} else {
$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'];
}
}
'hasSearch' => $hasSearch,
'list' => $list,
'months' => $months,
+ 's_month' => $s_month,
);
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" />