USB Checkout History
<% If filterMachineId <> "" Then %>
Filtered by Device
<% End If %>
<% If filterSSO <> "" Then %>
Filtered by SSO: <%=Server.HTMLEncode(filterSSO)%>
<% End If %>
| USB Serial |
USB Name |
SSO |
Checkout Time |
Check-in Time |
Duration |
Wiped |
Reason |
<%
Dim strSQL, rs
' Build query with optional filters
strSQL = "SELECT uc.*, m.serialnumber, m.alias, " & _
"TIMESTAMPDIFF(MINUTE, uc.checkout_time, COALESCE(uc.checkin_time, NOW())) AS duration_minutes " & _
"FROM usbcheckouts uc " & _
"JOIN machines m ON uc.machineid = m.machineid " & _
"WHERE 1=1 "
' Apply filters
If filterMachineId <> "" And IsNumeric(filterMachineId) Then
strSQL = strSQL & "AND uc.machineid = " & CLng(filterMachineId) & " "
End If
If filterSSO <> "" Then
' Use parameterized query for SSO filter
strSQL = strSQL & "AND uc.sso = '" & Replace(filterSSO, "'", "''") & "' "
End If
strSQL = strSQL & "ORDER BY uc.checkout_time DESC"
Set rs = objConn.Execute(strSQL)
Dim rowCount
rowCount = 0
While Not rs.EOF
rowCount = rowCount + 1
Dim serialNum, usbAlias, sso, checkoutTime, checkinTime, durationMinutes, wasWiped, reason
Dim durationText, wipedText, wipedClass, statusClass
serialNum = rs("serialnumber") & ""
usbAlias = rs("alias") & ""
sso = rs("sso") & ""
reason = rs("checkout_reason") & ""
If IsNull(rs("duration_minutes")) Or rs("duration_minutes") = "" Then
durationMinutes = 0
Else
durationMinutes = CLng(rs("duration_minutes"))
End If
' Format checkout time (MM/DD/YYYY h:mm AM/PM)
If Not IsNull(rs("checkout_time")) Then
checkoutTime = Month(rs("checkout_time")) & "/" & Day(rs("checkout_time")) & "/" & Year(rs("checkout_time")) & " " & FormatDateTime(rs("checkout_time"), 3)
Else
checkoutTime = "-"
End If
' Format check-in time and determine status (MM/DD/YYYY h:mm AM/PM)
If Not IsNull(rs("checkin_time")) Then
checkinTime = Month(rs("checkin_time")) & "/" & Day(rs("checkin_time")) & "/" & Year(rs("checkin_time")) & " " & FormatDateTime(rs("checkin_time"), 3)
statusClass = ""
Else
checkinTime = "Still Out"
statusClass = ""
End If
' Format duration
If durationMinutes < 60 Then
durationText = durationMinutes & " min"
ElseIf durationMinutes < 1440 Then
durationText = Int(durationMinutes / 60) & "h " & (durationMinutes Mod 60) & "m"
Else
durationText = Int(durationMinutes / 1440) & "d " & Int((durationMinutes Mod 1440) / 60) & "h"
End If
' Format wiped status
If IsNull(rs("was_wiped")) Then
wipedText = "-"
wipedClass = ""
ElseIf rs("was_wiped") = 1 Then
wipedText = "Yes"
wipedClass = ""
Else
wipedText = "No"
wipedClass = ""
End If
%>
" title="Filter by this device">
<%=Server.HTMLEncode(serialNum)%>
|
<%=Server.HTMLEncode(usbAlias)%> |
<%=Server.HTMLEncode(sso)%>
|
<%=checkoutTime%> |
<%=checkinTime%> |
<%=durationText%> |
<%=wipedText%> |
<% If reason <> "" Then %>
<%=Server.HTMLEncode(Left(reason, 40))%><% If Len(reason) > 40 Then Response.Write("...") End If %>
<% Else %>
-
<% End If %>
|
<%
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
If rowCount = 0 Then
%>
No checkout history found.
<% If filterMachineId <> "" Or filterSSO <> "" Then %>
Show all history
<% End If %>
|
<%
End If
%>
Total: <%=rowCount%> checkout record(s)
<% If filterMachineId <> "" Or filterSSO <> "" Then %> (filtered)<% End If %>