diff --git a/web/zm.php b/web/zm.php index 713f14a83..d4779b7e4 100644 --- a/web/zm.php +++ b/web/zm.php @@ -607,6 +607,32 @@ top.window.focus(); } elseif ( $view == "events" ) { + switch( $sort_field ) + { + case 'Id' : + $sort_column = "E.Id"; + break; + case 'Name' : + $sort_column = "E.Name"; + break; + case 'Time' : + $sort_column = "E.StartTime"; + break; + case 'Secs' : + $sort_column = "E.Length"; + break; + case 'Frames' : + $sort_column = "E.Frames"; + break; + case 'Score' : + $sort_column = "E.AvgScore"; + break; + default: + $sort_column = "E.StartTime"; + break; + } + $sort_order = $sort_asc?"asc":"desc"; + if ( !$sort_asc ) $sort_asc = 0; if ( !$archived ) { if ( $max_events ) @@ -663,7 +689,7 @@ function checkAll(form,name){ $sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.AvgScore,E.MaxScore from Monitors as M, Events as E where M.Id = '$mid' and M.Id = E.MonitorId and E.Archived = ".($archived?"1":"0"); if ( $period ) $sql .= " and E.StartTime >= now() - interval 1 $period"; - $sql .= " order by E.Id desc"; + $sql .= " order by $sort_column $sort_order"; if ( $max_events ) $sql .= " limit 0,$max_events"; $result = mysql_query( $sql ); @@ -689,12 +715,12 @@ function checkAll(form,name){
Id | -Name | -Time | -Secs | -Frames | -Score | +Id | +Name | +Time | +Secs | +Frames | +Score | Delete |