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:
@@ -7,6 +7,7 @@
|
||||
'=============================================================================
|
||||
%>
|
||||
<!--#include file="./includes/sql.asp"-->
|
||||
<!--#include file="./includes/response.asp"-->
|
||||
<%
|
||||
' Get form data
|
||||
Dim pcid, vendorid, modelnumberid, machinenumber
|
||||
@@ -27,20 +28,20 @@
|
||||
|
||||
' Validate required ID fields
|
||||
If pcid = "" Or Not IsNumeric(pcid) Then
|
||||
Response.Write("Invalid PC ID")
|
||||
objConn.Close
|
||||
ShowError "Invalid PC ID.", "displaypcs.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
If CLng(pcid) < 1 Then
|
||||
Response.Write("Invalid PC ID")
|
||||
objConn.Close
|
||||
ShowError "Invalid PC ID.", "displaypcs.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Verify the PC exists using parameterized query - PHASE 2: Use machines table
|
||||
Dim checkSQL, rsCheck, cmdCheck
|
||||
checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machineid = ? AND pctypeid IS NOT NULL"
|
||||
checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machineid = ? AND machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
Set cmdCheck = Server.CreateObject("ADODB.Command")
|
||||
cmdCheck.ActiveConnection = objConn
|
||||
cmdCheck.CommandText = checkSQL
|
||||
@@ -65,16 +66,16 @@
|
||||
' Validate optional ID fields - allow "new" as a valid value for model and vendor
|
||||
If vendorid <> "" And vendorid <> "new" Then
|
||||
If Not IsNumeric(vendorid) Or CLng(vendorid) < 1 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_ID")
|
||||
objConn.Close
|
||||
ShowError "Invalid vendor ID.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
End If
|
||||
|
||||
If modelnumberid <> "" And modelnumberid <> "new" Then
|
||||
If Not IsNumeric(modelnumberid) Or CLng(modelnumberid) < 1 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_ID")
|
||||
objConn.Close
|
||||
ShowError "Invalid model ID.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
End If
|
||||
@@ -82,14 +83,14 @@
|
||||
' Handle new vendor creation
|
||||
If vendorid = "new" Then
|
||||
If Len(newvendorname) = 0 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=REQUIRED_FIELD")
|
||||
objConn.Close
|
||||
ShowError "Vendor name is required.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
If Len(newvendorname) > 50 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_INPUT")
|
||||
objConn.Close
|
||||
ShowError "Vendor name too long.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -106,9 +107,11 @@
|
||||
cmdNewVendor.Execute
|
||||
|
||||
If Err.Number <> 0 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Server.HTMLEncode(Err.Description)))
|
||||
Dim vendorErr
|
||||
vendorErr = Err.Description
|
||||
Set cmdNewVendor = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating vendor: " & Server.HTMLEncode(vendorErr), "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -125,20 +128,20 @@
|
||||
' Handle new model creation
|
||||
If modelnumberid = "new" Then
|
||||
If Len(newmodelnumber) = 0 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=REQUIRED_FIELD")
|
||||
objConn.Close
|
||||
ShowError "Model number is required.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
If Len(newvendorid) = 0 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=REQUIRED_FIELD")
|
||||
objConn.Close
|
||||
ShowError "Vendor is required for new model.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
If Len(newmodelnumber) > 50 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_INPUT")
|
||||
objConn.Close
|
||||
ShowError "Model number too long.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -161,9 +164,11 @@
|
||||
cmdNewModel.Execute
|
||||
|
||||
If Err.Number <> 0 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Server.HTMLEncode(Err.Description)))
|
||||
Dim modelErr
|
||||
modelErr = Err.Description
|
||||
Set cmdNewModel = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating model: " & Server.HTMLEncode(modelErr), "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -179,14 +184,14 @@
|
||||
|
||||
' Validate machine number length
|
||||
If machinenumber <> "" And Len(machinenumber) > 50 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_INPUT")
|
||||
objConn.Close
|
||||
ShowError "Machine number too long.", "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Build UPDATE statement for PC using parameterized query - PHASE 2: Use machines table
|
||||
Dim strSQL, cmdUpdate
|
||||
strSQL = "UPDATE machines SET modelnumberid = ?, machinenumber = ?, lastupdated = NOW() WHERE machineid = ? AND pctypeid IS NOT NULL"
|
||||
strSQL = "UPDATE machines SET modelnumberid = ?, machinenumber = ?, lastupdated = NOW() WHERE machineid = ? AND machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
Set cmdUpdate = Server.CreateObject("ADODB.Command")
|
||||
cmdUpdate.ActiveConnection = objConn
|
||||
cmdUpdate.CommandText = strSQL
|
||||
@@ -212,15 +217,17 @@
|
||||
cmdUpdate.Execute
|
||||
|
||||
If Err.Number <> 0 Then
|
||||
Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=db")
|
||||
Dim updateErr
|
||||
updateErr = Err.Description
|
||||
Set cmdUpdate = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error updating PC: " & Server.HTMLEncode(updateErr), "displaypc.asp?machineid=" & pcid
|
||||
Response.End
|
||||
End If
|
||||
|
||||
Set cmdUpdate = Nothing
|
||||
objConn.Close
|
||||
|
||||
' Success - redirect back to displaypc
|
||||
Response.Redirect("./displaypc.asp?pcid=" & pcid)
|
||||
' Success - show success message
|
||||
ShowSuccess "PC updated successfully.", "displaypc.asp?machineid=" & pcid, "PC details"
|
||||
%>
|
||||
|
||||
Reference in New Issue
Block a user