Add USB checkout system and SSO profile page

New Features:
- USB Device checkout/check-in system with barcode scanning
  - displayusb.asp: List all USB devices with status
  - addusb.asp: Add new USB devices via barcode scan
  - checkout_usb.asp/savecheckout_usb.asp: Check out USB to SSO
  - checkin_usb.asp/savecheckin_usb.asp: Check in with wipe confirmation
  - usb_history.asp: Full checkout history with filters
  - api_usb.asp: JSON API for AJAX lookups
- displayprofile.asp: SSO profile page showing user info and USB history
- Date/time format changed to 12-hour (MM/DD/YYYY h:mm AM/PM)
- SSO links in USB history now link to profile page via search

Database:
- New machinetypeid 44 for USB devices
- New usb_checkouts table for tracking checkouts

Cleanup:
- Removed v2 folder (duplicate/old files)
- Removed old debug/test files
- Removed completed migration documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-07 11:16:14 -05:00
parent c7834d4b99
commit 65b622c361
1061 changed files with 19034 additions and 213120 deletions

View File

@@ -7,14 +7,8 @@
' NOTE: Machines now inherit machinetypeid from their model. Each model has one machine type.
'=============================================================================
%>
<html>
<head>
<link rel="stylesheet" href="./style.css" type="text/css">
<!--#include file="./includes/sql.asp"-->
</head>
<body>
<div class="page">
<!--#include file="./includes/response.asp"-->
<%
' Get and validate all inputs
Dim machineid, modelid, businessunitid, alias, machinenotes, mapleft, maptop, fqdn
@@ -55,9 +49,8 @@
' Validate required field - machineid
If machineid = "" Or Not IsNumeric(machineid) Then
Response.Write("<div class='alert alert-danger'>Error: Machine ID is required and must be numeric.</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Machine ID is required and must be numeric.", "displaypcs.asp"
Response.End
End If
@@ -75,9 +68,8 @@
rsCheck.Close
Set rsCheck = Nothing
Set cmdCheck = Nothing
Response.Write("<div class='alert alert-danger'>Error: Machine ID " & Server.HTMLEncode(machineid) & " does not exist.</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Machine ID " & machineid & " does not exist.", "displaypcs.asp"
Response.End
End If
End If
@@ -87,40 +79,35 @@
' Validate ID fields - allow "new" as a valid value
If modelid <> "new" And Not IsNumeric(modelid) Then
Response.Write("<div class='alert alert-danger'>Error: Invalid model ID.</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Invalid model ID.", "editpc.asp?machineid=" & machineid
Response.End
End If
If businessunitid <> "new" And Not IsNumeric(businessunitid) Then
Response.Write("<div class='alert alert-danger'>Error: Invalid business unit ID.</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Invalid business unit ID.", "editpc.asp?machineid=" & machineid
Response.End
End If
' Validate field lengths
If Len(alias) > 50 Then
Response.Write("<div class='alert alert-danger'>Error: Field length exceeded.</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Field length exceeded.", "editpc.asp?machineid=" & machineid
Response.End
End If
' Handle new business unit creation
If businessunitid = "new" Then
If Len(newbusinessunit) = 0 Then
Response.Write("<div class='alert alert-danger'>New business unit name is required</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "New business unit name is required.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newbusinessunit) > 50 Then
Response.Write("<div class='alert alert-danger'>Business unit name too long</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Business unit name too long.", "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -137,10 +124,11 @@
cmdNewBU.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error creating new business unit: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim buErrMsg
buErrMsg = Err.Description
Set cmdNewBU = Nothing
objConn.Close
ShowError "Error creating new business unit: " & buErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -157,55 +145,48 @@
' Handle new model creation
If modelid = "new" Then
If Len(newmodelnumber) = 0 Then
Response.Write("<div class='alert alert-danger'>New model number is required</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "New model number is required.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newvendorid) = 0 Then
Response.Write("<div class='alert alert-danger'>Vendor is required for new model</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Vendor is required for new model.", "editpc.asp?machineid=" & machineid
Response.End
End If
' Handle new machine type creation (nested in new model)
If newmodelmachinetypeid = "new" Then
If Len(newmachinetype) = 0 Then
Response.Write("<div class='alert alert-danger'>New machine type name is required</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "New machine type name is required.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newfunctionalaccountid) = 0 Then
Response.Write("<div class='alert alert-danger'>Functional account is required for new machine type</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Functional account is required for new machine type.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newmachinetype) > 50 Or Len(newmachinedescription) > 255 Then
Response.Write("<div class='alert alert-danger'>Machine type field length exceeded</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Machine type field length exceeded.", "editpc.asp?machineid=" & machineid
Response.End
End If
' Handle new functional account creation (nested in new machine type)
If newfunctionalaccountid = "new" Then
If Len(newfunctionalaccount) = 0 Then
Response.Write("<div class='alert alert-danger'>New functional account name is required</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "New functional account name is required.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newfunctionalaccount) > 50 Or Len(newfunctionalaccountdescription) > 255 Then
Response.Write("<div class='alert alert-danger'>Functional account field length exceeded</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Functional account field length exceeded.", "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -229,10 +210,11 @@
cmdNewFA.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error creating new functional account: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim faErrMsg
faErrMsg = Err.Description
Set cmdNewFA = Nothing
objConn.Close
ShowError "Error creating new functional account: " & faErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -268,10 +250,11 @@
cmdNewMT.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error creating new machine type: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim mtErrMsg
mtErrMsg = Err.Description
Set cmdNewMT = Nothing
objConn.Close
ShowError "Error creating new machine type: " & mtErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -286,32 +269,28 @@
End If
If Len(newmodelmachinetypeid) = 0 Or Not IsNumeric(newmodelmachinetypeid) Then
Response.Write("<div class='alert alert-danger'>Machine type is required for new model</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Machine type is required for new model.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newmodelnumber) > 50 Or Len(newmodelimage) > 100 Then
Response.Write("<div class='alert alert-danger'>Model field length exceeded</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Model field length exceeded.", "editpc.asp?machineid=" & machineid
Response.End
End If
' Handle new vendor creation (nested)
If newvendorid = "new" Then
If Len(newvendorname) = 0 Then
Response.Write("<div class='alert alert-danger'>New vendor name is required</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "New vendor name is required.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newvendorname) > 50 Then
Response.Write("<div class='alert alert-danger'>Vendor name too long</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Vendor name too long.", "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -328,10 +307,11 @@
cmdNewVendor.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error creating new vendor: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim vendorErrMsg
vendorErrMsg = Err.Description
Set cmdNewVendor = Nothing
objConn.Close
ShowError "Error creating new vendor: " & vendorErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -369,10 +349,11 @@
cmdNewModel.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error creating new model: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim modelErrMsg
modelErrMsg = Err.Description
Set cmdNewModel = Nothing
objConn.Close
ShowError "Error creating new model: " & modelErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -389,14 +370,16 @@
'=============================================================================
' UPDATE MACHINES TABLE
'=============================================================================
Dim strSQL, cmdMachine, serialnumberVal, hostnameVal, aliasVal, machinenotesVal, fqdnVal
Dim strSQL, cmdMachine, serialnumberVal, hostnameVal, aliasVal, machinenotesVal, fqdnVal, machinestatusidVal
If Trim(Request.Form("serialnumber") & "") <> "" Then serialnumberVal = Trim(Request.Form("serialnumber") & "") Else serialnumberVal = Null
If Trim(Request.Form("hostname") & "") <> "" Then hostnameVal = Trim(Request.Form("hostname") & "") Else hostnameVal = Null
If alias <> "" Then aliasVal = alias Else aliasVal = Null
If machinenotes <> "" Then machinenotesVal = machinenotes Else machinenotesVal = Null
If fqdn <> "" Then fqdnVal = fqdn Else fqdnVal = Null
machinestatusidVal = Trim(Request.Form("machinestatusid"))
If machinestatusidVal = "" Or Not IsNumeric(machinestatusidVal) Then machinestatusidVal = 1
strSQL = "UPDATE machines SET serialnumber = ?, hostname = ?, fqdn = ?, modelnumberid = ?, businessunitid = ?, alias = ?, machinenotes = ?, mapleft = ?, maptop = ? WHERE machineid = ?"
strSQL = "UPDATE machines SET serialnumber = ?, hostname = ?, fqdn = ?, modelnumberid = ?, businessunitid = ?, alias = ?, machinenotes = ?, machinestatusid = ?, mapleft = ?, maptop = ? WHERE machineid = ?"
Set cmdMachine = Server.CreateObject("ADODB.Command")
cmdMachine.ActiveConnection = objConn
@@ -409,6 +392,7 @@
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@businessunitid", 3, 1, , CLng(businessunitid))
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@alias", 200, 1, 50, aliasVal)
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinenotes", 200, 1, 500, machinenotesVal)
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinestatusid", 3, 1, , CLng(machinestatusidVal))
' Handle optional map coordinates
If mapleft <> "" And maptop <> "" And IsNumeric(mapleft) And IsNumeric(maptop) Then
@@ -425,10 +409,11 @@
cmdMachine.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error updating machine: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim machineErrMsg
machineErrMsg = Err.Description
Set cmdMachine = Nothing
objConn.Close
ShowError "Error updating machine: " & machineErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
Set cmdMachine = Nothing
@@ -470,15 +455,18 @@
' Interface 1 (Primary)
If ip1 <> "" Or mac1 <> "" Then
Dim cmdComm1
Dim cmdComm1, ip1Val, mac1Val
If ip1 <> "" Then ip1Val = ip1 Else ip1Val = Null
If mac1 <> "" Then mac1Val = mac1 Else mac1Val = Null
Set cmdComm1 = Server.CreateObject("ADODB.Command")
cmdComm1.ActiveConnection = objConn
cmdComm1.CommandText = "INSERT INTO communications (machineid, comstypeid, address, macaddress, interfacename, isprimary, isactive) VALUES (?, ?, ?, ?, ?, 1, 1)"
cmdComm1.CommandType = 1
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@machineid", 3, 1, , CLng(machineid))
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@comstypeid", 3, 1, , comstypeid)
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@address", 200, 1, 50, IIf(ip1 <> "", ip1, Null))
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@macaddress", 200, 1, 50, IIf(mac1 <> "", mac1, Null))
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@address", 200, 1, 50, ip1Val)
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@macaddress", 200, 1, 50, mac1Val)
cmdComm1.Parameters.Append cmdComm1.CreateParameter("@interfacename", 200, 1, 50, "Interface 1")
On Error Resume Next
@@ -489,15 +477,18 @@
' Interface 2 (Optional)
If ip2 <> "" Or mac2 <> "" Then
Dim cmdComm2
Dim cmdComm2, ip2Val, mac2Val
If ip2 <> "" Then ip2Val = ip2 Else ip2Val = Null
If mac2 <> "" Then mac2Val = mac2 Else mac2Val = Null
Set cmdComm2 = Server.CreateObject("ADODB.Command")
cmdComm2.ActiveConnection = objConn
cmdComm2.CommandText = "INSERT INTO communications (machineid, comstypeid, address, macaddress, interfacename, isprimary, isactive) VALUES (?, ?, ?, ?, ?, 0, 1)"
cmdComm2.CommandType = 1
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@machineid", 3, 1, , CLng(machineid))
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@comstypeid", 3, 1, , comstypeid)
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@address", 200, 1, 50, IIf(ip2 <> "", ip2, Null))
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@macaddress", 200, 1, 50, IIf(mac2 <> "", mac2, Null))
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@address", 200, 1, 50, ip2Val)
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@macaddress", 200, 1, 50, mac2Val)
cmdComm2.Parameters.Append cmdComm2.CreateParameter("@interfacename", 200, 1, 50, "Interface 2")
On Error Resume Next
@@ -508,15 +499,18 @@
' Interface 3 (Optional)
If ip3 <> "" Or mac3 <> "" Then
Dim cmdComm3
Dim cmdComm3, ip3Val, mac3Val
If ip3 <> "" Then ip3Val = ip3 Else ip3Val = Null
If mac3 <> "" Then mac3Val = mac3 Else mac3Val = Null
Set cmdComm3 = Server.CreateObject("ADODB.Command")
cmdComm3.ActiveConnection = objConn
cmdComm3.CommandText = "INSERT INTO communications (machineid, comstypeid, address, macaddress, interfacename, isprimary, isactive) VALUES (?, ?, ?, ?, ?, 0, 1)"
cmdComm3.CommandType = 1
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@machineid", 3, 1, , CLng(machineid))
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@comstypeid", 3, 1, , comstypeid)
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@address", 200, 1, 50, IIf(ip3 <> "", ip3, Null))
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@macaddress", 200, 1, 50, IIf(mac3 <> "", mac3, Null))
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@address", 200, 1, 50, ip3Val)
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@macaddress", 200, 1, 50, mac3Val)
cmdComm3.Parameters.Append cmdComm3.CreateParameter("@interfacename", 200, 1, 50, "Interface 3")
On Error Resume Next
@@ -559,7 +553,21 @@
If Not rsCheck.EOF Then dualpathTypeID = rsCheck("relationshiptypeid")
rsCheck.Close
' Create Controls relationship (PC controls this equipment)
' Check if this machine is a PC (machinetypeid >= 33) to determine relationship direction
Dim isPC, currentMachineTypeID
isPC = False
Set rsCheck = objConn.Execute("SELECT machinetypeid FROM machines WHERE machineid = " & CLng(machineid))
If Not rsCheck.EOF Then
currentMachineTypeID = rsCheck("machinetypeid")
If Not IsNull(currentMachineTypeID) And currentMachineTypeID >= 33 Then
isPC = True
End If
End If
rsCheck.Close
' Create Controls relationship
' For PCs: This PC (machineid) controls the selected equipment (controllingpc form value)
' For Equipment: The selected PC (controllingpc form value) controls this equipment (machineid)
On Error Resume Next
Dim tempControllingPC
tempControllingPC = 0
@@ -576,8 +584,16 @@
cmdRelPC.ActiveConnection = objConn
cmdRelPC.CommandText = "INSERT INTO machinerelationships (machineid, related_machineid, relationshiptypeid, isactive) VALUES (?, ?, ?, 1)"
cmdRelPC.CommandType = 1
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@machineid", 3, 1, , tempControllingPC)
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@related_machineid", 3, 1, , CLng(machineid))
If isPC Then
' PC page: This PC controls the equipment (PC is machineid, equipment is related_machineid)
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@machineid", 3, 1, , CLng(machineid))
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@related_machineid", 3, 1, , tempControllingPC)
Else
' Equipment page: The PC controls this equipment (PC is machineid, equipment is related_machineid)
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@machineid", 3, 1, , tempControllingPC)
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@related_machineid", 3, 1, , CLng(machineid))
End If
cmdRelPC.Parameters.Append cmdRelPC.CreateParameter("@relationshiptypeid", 3, 1, , controlsTypeID)
On Error Resume Next
@@ -641,16 +657,14 @@
newthirdpartyvendorname = Trim(Request.Form("newthirdpartyvendorname"))
If Len(newthirdpartyvendorname) = 0 Then
Response.Write("<div class='alert alert-danger'>New third party vendor name is required</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "New third party vendor name is required.", "editpc.asp?machineid=" & machineid
Response.End
End If
If Len(newthirdpartyvendorname) > 50 Then
Response.Write("<div class='alert alert-danger'>Third party vendor name too long</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
objConn.Close
ShowError "Third party vendor name too long.", "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -667,10 +681,11 @@
cmdNewTPVendor.Execute
If Err.Number <> 0 Then
Response.Write("<div class='alert alert-danger'>Error creating new third party vendor: " & Server.HTMLEncode(Err.Description) & "</div>")
Response.Write("<a href='javascript:history.back()'>Go back</a>")
Dim tpVendorErrMsg
tpVendorErrMsg = Err.Description
Set cmdNewTPVendor = Nothing
objConn.Close
ShowError "Error creating new third party vendor: " & tpVendorErrMsg, "editpc.asp?machineid=" & machineid
Response.End
End If
@@ -757,12 +772,16 @@
On Error Goto 0
End If
objConn.Close
' Redirect to appropriate display page based on machine type
Dim redirectUrl, entityName
If isPC Then
redirectUrl = "displaypc.asp?machineid=" & machineid
entityName = "PC Details"
Else
redirectUrl = "displaymachine.asp?machineid=" & machineid
entityName = "Machine Details"
End If
' Redirect to displaymachine.asp with the machine ID
objConn.Close
ShowSuccess "Machine updated successfully.", redirectUrl, entityName
%>
<meta http-equiv="refresh" content="0; url=./displaymachine.asp?machineid=<%=Server.HTMLEncode(machineid)%>">
<p>Machine updated successfully. Redirecting...</p>
</div>
</body>
</html>