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

@@ -1,12 +1,13 @@
<%
'=============================================================================
' FILE: savedevice_direct.asp
' PURPOSE: Create new PC/device with minimal required fields
' PURPOSE: Create new PC with minimal required fields (PC-only scanner)
' SECURITY: Parameterized queries, HTML encoding, input validation
' UPDATED: 2025-10-27 - Migrated to secure patterns
' UPDATED: 2025-12-04 - Changed to PC-only (machinetypeid 36 = PC - Standard)
'=============================================================================
%>
<!--#include file="./includes/sql.asp"-->
<!--#include file="./includes/response.asp"-->
<%
' Get the serial number from the form
Dim serialnumber
@@ -15,13 +16,14 @@
' Basic validation - serial number should not be empty and should be alphanumeric-ish
If serialnumber = "" Or Len(serialnumber) < 3 Or Len(serialnumber) > 100 Then
objConn.Close
Response.Redirect("./adddevice.asp?error=INVALID_SERIAL")
ShowError "Invalid serial number. Must be 3-100 characters.", "adddevice.asp"
Response.End
End If
' Check if serial number already exists - PHASE 2: Use machines table
Dim checkSQL, rsCheck, cmdCheck, existingMachineID
checkSQL = "SELECT machineid FROM machines WHERE serialnumber = ? AND pctypeid IS NOT NULL"
' Check ALL machines regardless of type to prevent duplicates
Dim checkSQL, rsCheck, cmdCheck, existingMachineID, existingPCTypeID
checkSQL = "SELECT machineid, pctypeid FROM machines WHERE serialnumber = ? AND isactive = 1"
Set cmdCheck = Server.CreateObject("ADODB.Command")
cmdCheck.ActiveConnection = objConn
cmdCheck.CommandText = checkSQL
@@ -31,13 +33,20 @@
Set rsCheck = cmdCheck.Execute
If Not rsCheck.EOF Then
' Serial number already exists - redirect to edit page
' Serial number already exists - redirect to appropriate edit page
existingMachineID = rsCheck("machineid")
existingPCTypeID = rsCheck("pctypeid")
rsCheck.Close
Set rsCheck = Nothing
Set cmdCheck = Nothing
objConn.Close
Response.Redirect("./editdevice.asp?pcid=" & existingMachineID & "&scanned=1")
' Redirect to PC edit page if it's a PC (pctypeid IS NOT NULL), otherwise to machine edit page
If Not IsNull(existingPCTypeID) Then
Response.Redirect("./editpc.asp?machineid=" & existingMachineID & "&scanned=1")
Else
Response.Redirect("./editmachine.asp?machineid=" & existingMachineID & "&scanned=1")
End If
Response.End
End If
@@ -45,23 +54,22 @@
Set rsCheck = Nothing
Set cmdCheck = Nothing
' Insert new device with minimal required fields - PHASE 2: Use machines table
' Insert new PC with minimal required fields - PHASE 2: Use machines table
' machinetypeid = 36 (PC - Standard)
' machinestatusid = 2 (Inventory)
' isactive = 1
' modelnumberid = 1 (default model)
' requires_manual_machine_config = 0 (no manual config needed)
' osid = 1 (default OS)
' machinetypeid = 33 (Standard PC)
' pctypeid = 1 (Standard PC type)
' machinenumber = 'IT Closet' (default location for new devices)
' maptop = 1519, mapleft = 1896 (default map location)
' hostname = serialnumber (default)
' isactive = 1
Dim insertSQL, cmdInsert
insertSQL = "INSERT INTO machines (serialnumber, machinestatusid, isactive, modelnumberid, requires_manual_machine_config, osid, machinetypeid, pctypeid, machinenumber, lastupdated) " & _
"VALUES (?, 2, 1, 1, 0, 1, 33, 1, 'IT Closet', NOW())"
insertSQL = "INSERT INTO machines (serialnumber, hostname, machinetypeid, machinestatusid, modelnumberid, maptop, mapleft, isactive, lastupdated) " & _
"VALUES (?, ?, 36, 2, 1, 1519, 1896, 1, NOW())"
Set cmdInsert = Server.CreateObject("ADODB.Command")
cmdInsert.ActiveConnection = objConn
cmdInsert.CommandText = insertSQL
cmdInsert.CommandType = 1
cmdInsert.Parameters.Append cmdInsert.CreateParameter("@serialnumber", 200, 1, 100, serialnumber)
cmdInsert.Parameters.Append cmdInsert.CreateParameter("@hostname", 200, 1, 255, serialnumber)
On Error Resume Next
cmdInsert.Execute
@@ -69,11 +77,13 @@
If Err.Number = 0 Then
Set cmdInsert = Nothing
objConn.Close
' Success - redirect back with success message
Response.Redirect("./adddevice.asp?added=" & Server.URLEncode(Request.Form("serialnumber")))
' Success - show success message
ShowSuccess "PC with serial '" & Server.HTMLEncode(serialnumber) & "' added successfully.", "adddevice.asp", "scanner"
Else
Dim insertErr
insertErr = Err.Description
Set cmdInsert = Nothing
objConn.Close
Response.Redirect("./adddevice.asp?error=db")
ShowError "Error adding PC: " & Server.HTMLEncode(insertErr), "adddevice.asp"
End If
%>