<%
Dim showAll
showAll = Request.QueryString("showall")
If showAll = "" Then showAll = "0"
%>
Notifications
<% If showAll = "1" Then %>
Showing All
<% Else %>
Showing Active
<% End If %>
| Message |
Type |
Business Unit |
Ticket |
Start Time |
End Time |
Status |
Shopfloor |
Actions |
<%
Dim strSQL, rs
strSQL = "SELECT n.*, nt.typename, nt.typecolor, bu.businessunit, " & _
"TIMESTAMPDIFF(MINUTE, n.endtime, NOW()) as minutes_since_end, " & _
"CASE " & _
" WHEN n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _
" ELSE 0 " & _
"END as is_complete " & _
"FROM notifications n " & _
"LEFT JOIN notificationtypes nt ON n.notificationtypeid = nt.notificationtypeid " & _
"LEFT JOIN businessunits bu ON n.businessunitid = bu.businessunitid "
' Add WHERE clause based on showall parameter
If showAll <> "1" Then
' Show only truly active notifications:
' 1. isactive = 1 AND (endtime is NULL OR endtime >= NOW())
' 2. OR recently completed (within 30 min grace period for fade-out)
strSQL = strSQL & _
"WHERE (n.isactive = 1 AND (n.endtime IS NULL OR n.endtime >= NOW())) OR " & _
" (n.isactive = 0 AND n.endtime IS NOT NULL AND " & _
" DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW()) "
End If
strSQL = strSQL & "ORDER BY n.notificationid DESC"
Set rs = objconn.Execute(strSQL)
If rs.EOF Then
Response.Write("| No notifications found. |
")
Else
Do While Not rs.EOF
Dim statusText, statusClass, typeText, typeColor, rowOpacity, rowStyle
If CBool(rs("isactive")) = True Then
statusText = "Active"
statusClass = "success"
Else
statusText = "Inactive"
statusClass = "secondary"
End If
' Calculate opacity for completed notifications (fade over 30 minutes)
rowOpacity = 1.0
If rs("is_complete") = 1 And Not IsNull(rs("minutes_since_end")) Then
' Fade from 1.0 to 0.5 over 30 minutes
Dim minutesSinceEnd
minutesSinceEnd = CDbl(rs("minutes_since_end"))
If minutesSinceEnd >= 0 Then
rowOpacity = 1.0 - (minutesSinceEnd / 30) * 0.5
If rowOpacity < 0.5 Then rowOpacity = 0.5
End If
statusText = "Complete"
statusClass = "info"
End If
' Get notification type info
If IsNull(rs("typename")) Or rs("typename") = "" Then
typeText = "TBD"
typeColor = "secondary"
Else
typeText = rs("typename")
typeColor = rs("typecolor")
End If
' Get business unit info
Dim businessUnitText
If IsNull(rs("businessunit")) Or rs("businessunit") = "" Then
businessUnitText = "All"
Else
businessUnitText = Server.HTMLEncode(rs("businessunit"))
End If
' Apply opacity style
rowStyle = "opacity: " & rowOpacity & ";"
Response.Write("")
Response.Write("| " & Server.HTMLEncode(rs("notification") & "") & " | ")
Response.Write("" & typeText & " | ")
Response.Write("" & businessUnitText & " | ")
Response.Write("" & Server.HTMLEncode(rs("ticketnumber") & "") & " | ")
Response.Write("" & rs("starttime") & " | ")
Response.Write("" & rs("endtime") & " | ")
Response.Write("" & statusText & " | ")
' Shopfloor Dashboard column
Dim shopfloorText, shopfloorIcon
If CBool(rs("isshopfloor")) = True Then
shopfloorText = "Yes"
shopfloorIcon = ""
Else
shopfloorText = "No"
shopfloorIcon = ""
End If
Response.Write("" & shopfloorIcon & " | ")
Response.Write("")
Response.Write(" ")
If CBool(rs("isactive")) = True Then
Response.Write("")
Else
Response.Write("")
End If
Response.Write(" | ")
Response.Write("
")
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
objConn.Close
%>