'."\n"; } for ( $i = 1; $i <= $trms; $i++ ) { $conjunction_name = "cnj$i"; $obracket_name = "obr$i"; $cbracket_name = "cbr$i"; $attr_name = "attr$i"; $op_name = "op$i"; $value_name = "val$i"; if ( isset($$conjunction_name) ) { $filter_query .= "&$conjunction_name=".$$conjunction_name; $filter_sql .= " ".$$conjunction_name." "; $filter_fields .= ''."\n"; } if ( isset($$obracket_name) ) { $filter_query .= "&$obracket_name=".$$obracket_name; $filter_sql .= str_repeat( "(", $$obracket_name ); $filter_fields .= ''."\n"; } if ( isset($$attr_name) ) { $filter_query .= "&$attr_name=".$$attr_name; $filter_fields .= ''."\n"; switch ( $$attr_name ) { case 'DateTime': $dt_val = strftime( "%Y-%m-%d %H:%M:%S", strtotime( $$value_name ) ); $filter_sql .= "E.StartTime ".$$op_name." '$dt_val'"; $filter_query .= "&$op_name=".urlencode($$op_name); $filter_fields .= ''."\n"; break; case 'Date': $dt_val = strftime( "%Y-%m-%d %H:%M:%S", strtotime( $$value_name ) ); $filter_sql .= "to_days( E.StartTime ) ".$$op_name." to_days( '$dt_val' )"; $filter_query .= "&$op_name=".urlencode($$op_name); $filter_fields .= ''."\n"; break; case 'Time': $dt_val = strftime( "%Y-%m-%d %H:%M:%S", strtotime( $$value_name ) ); $filter_sql .= "extract( hour_second from E.StartTime ) ".$$op_name." extract( hour_second from '$dt_val' )"; $filter_query .= "&$op_name=".urlencode($$op_name); $filter_fields .= ''."\n"; break; case 'Weekday': $dt_val = strftime( "%Y-%m-%d %H:%M:%S", strtotime( $$value_name ) ); $filter_sql .= "weekday( E.StartTime ) ".$$op_name." weekday( '$dt_val' )"; $filter_query .= "&$op_name=".urlencode($$op_name); $filter_fields .= ''."\n"; break; case 'Length': case 'Frames': case 'AlarmFrames': case 'TotScore': case 'AvgScore': case 'MaxScore': $filter_sql .= "E.".$$attr_name." ".$$op_name." ".$$value_name; $filter_query .= "&$op_name=".urlencode($$op_name); $filter_fields .= ''."\n"; break; case 'Archived': $filter_sql .= "E.Archived = ".$$value_name; break; } $filter_query .= "&$value_name=".urlencode($$value_name); $filter_fields .= ''."\n"; } if ( isset($$cbracket_name) ) { $filter_query .= "&$cbracket_name=".$$cbracket_name; $filter_sql .= str_repeat( ")", $$cbracket_name ); $filter_fields .= ''."\n"; } } if ( $filter_sql ) { $count_sql .= " and ( $filter_sql )"; $events_sql .= " and ( $filter_sql )"; } $events_sql .= " order by $sort_column $sort_order"; if ( $page ) { $events_sql .= " limit ".(($page-1)*EVENT_HEADER_LINES).", ".EVENT_HEADER_LINES; } ?>