diff --git a/api_shopfloor.asp b/api_shopfloor.asp index 6d508a9..82fded6 100644 --- a/api_shopfloor.asp +++ b/api_shopfloor.asp @@ -17,11 +17,11 @@ strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, " & _ "nt.typename, nt.typecolor, bu.businessunit, " & _ "CASE " & _ " WHEN n.starttime <= NOW() AND (n.endtime IS NULL OR n.endtime >= NOW()) THEN 1 " & _ - " WHEN nt.typecolor = 'danger' AND n.endtime IS NOT NULL AND n.endtime < NOW() AND DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW() THEN 1 " & _ + " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() AND DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW() THEN 1 " & _ " ELSE 0 " & _ "END as is_current, " & _ "CASE " & _ - " WHEN nt.typecolor = 'danger' AND n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _ + " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _ " ELSE 0 " & _ "END as is_resolved, " & _ "CASE " & _ @@ -34,7 +34,7 @@ strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, " & _ "LEFT JOIN businessunits bu ON n.businessunitid = bu.businessunitid " & _ "WHERE n.isshopfloor = 1 AND (" & _ " n.isactive = 1 OR " & _ - " (n.isactive = 0 AND nt.typecolor = 'danger' AND n.endtime IS NOT NULL AND " & _ + " (n.isactive = 0 AND n.endtime IS NOT NULL AND " & _ " DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW())" & _ ")" diff --git a/displaynotifications.asp b/displaynotifications.asp index ac7e888..7ef8af9 100644 --- a/displaynotifications.asp +++ b/displaynotifications.asp @@ -65,10 +65,18 @@ <% Dim strSQL, rs - strSQL = "SELECT n.*, nt.typename, nt.typecolor, bu.businessunit " & _ + 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 " & _ + "WHERE n.isactive = 1 OR " & _ + " (n.isactive = 0 AND n.endtime IS NOT NULL AND " & _ + " DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW()) " & _ "ORDER BY n.notificationid DESC" Set rs = objconn.Execute(strSQL) @@ -76,7 +84,7 @@ Response.Write("No notifications found.") Else Do While Not rs.EOF - Dim statusText, statusClass, typeText, typeColor + Dim statusText, statusClass, typeText, typeColor, rowOpacity, rowStyle If CBool(rs("isactive")) = True Then statusText = "Active" statusClass = "success" @@ -85,6 +93,20 @@ 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" @@ -102,7 +124,9 @@ businessUnitText = Server.HTMLEncode(rs("businessunit")) End If - Response.Write("") + ' Apply opacity style + rowStyle = "opacity: " & rowOpacity & ";" + Response.Write("") Response.Write("" & Server.HTMLEncode(rs("notification") & "") & "") Response.Write("" & typeText & "") Response.Write("" & businessUnitText & "")