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:
@@ -8,14 +8,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 machinenumber, modelid, businessunitid, alias, machinenotes, mapleft, maptop
|
||||
@@ -55,31 +49,27 @@
|
||||
|
||||
' Validate required fields
|
||||
If machinenumber = "" Then
|
||||
Response.Write("<div class='alert alert-danger'>Error: Machine number is required.</div>")
|
||||
Response.Write("<a href='addmachine.asp'>Go back</a>")
|
||||
ShowError "Machine number is required.", "addmachine.asp"
|
||||
objConn.Close
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' 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='addmachine.asp'>Go back</a>")
|
||||
ShowError "Invalid model ID.", "addmachine.asp"
|
||||
objConn.Close
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
ShowError "Invalid business unit ID.", "addmachine.asp"
|
||||
objConn.Close
|
||||
Response.End
|
||||
End If
|
||||
|
||||
' Validate field lengths
|
||||
If Len(machinenumber) > 50 Or Len(alias) > 50 Then
|
||||
Response.Write("<div class='alert alert-danger'>Error: Field length exceeded.</div>")
|
||||
Response.Write("<a href='addmachine.asp'>Go back</a>")
|
||||
ShowError "Field length exceeded.", "addmachine.asp"
|
||||
objConn.Close
|
||||
Response.End
|
||||
End If
|
||||
@@ -98,9 +88,8 @@
|
||||
rsCheck.Close
|
||||
Set rsCheck = Nothing
|
||||
Set cmdCheck = Nothing
|
||||
Response.Write("<div class='alert alert-danger'>Error: Machine number '" & Server.HTMLEncode(machinenumber) & "' already exists.</div>")
|
||||
Response.Write("<a href='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Machine number '" & machinenumber & "' already exists.", "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
End If
|
||||
@@ -111,16 +100,14 @@
|
||||
' 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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "New business unit name is required", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Business unit name too long", "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -137,10 +124,9 @@
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
Set cmdNewBU = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating new business unit: " & Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -157,55 +143,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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "New model number is required", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Vendor is required for new model", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "New machine type name is required", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Functional account is required for new machine type", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Machine type field length exceeded", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "New functional account name is required", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Functional account field length exceeded", "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -229,10 +208,9 @@
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
Set cmdNewFA = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating new functional account: " & Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -268,10 +246,9 @@
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
Set cmdNewMT = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating new machine type: " & Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -285,33 +262,29 @@
|
||||
On Error Goto 0
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
If Len(newmodelmachinetypeid) = 0 Or (newmodelmachinetypeid <> "new" And Not IsNumeric(newmodelmachinetypeid)) Then
|
||||
ShowError "Machine type is required for new model. Please select a machine type from the dropdown.", "addmachine.asp"
|
||||
objConn.Close
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Model field length exceeded", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "New vendor name is required", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Vendor name too long", "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -328,10 +301,9 @@
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
Set cmdNewVendor = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating new vendor: " & Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -369,10 +341,9 @@
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
Set cmdNewModel = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating new model: " & Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -386,11 +357,23 @@
|
||||
On Error Goto 0
|
||||
End If
|
||||
|
||||
' Get the machinetypeid from the selected model
|
||||
Dim modelMachineTypeId, rsModelType
|
||||
modelMachineTypeId = 1 ' Default fallback
|
||||
Set rsModelType = objConn.Execute("SELECT machinetypeid FROM models WHERE modelnumberid = " & CLng(modelid))
|
||||
If Not rsModelType.EOF Then
|
||||
If Not IsNull(rsModelType("machinetypeid")) Then
|
||||
modelMachineTypeId = CLng(rsModelType("machinetypeid"))
|
||||
End If
|
||||
End If
|
||||
rsModelType.Close
|
||||
Set rsModelType = Nothing
|
||||
|
||||
' Build INSERT statement with parameterized query
|
||||
' NOTE: machinetypeid is now inherited from models table and doesn't need to be specified
|
||||
' NOTE: machinetypeid is inherited from the model's machinetypeid
|
||||
Dim strSQL, cmdMachine
|
||||
strSQL = "INSERT INTO machines (machinenumber, modelnumberid, businessunitid, alias, machinenotes, mapleft, maptop, isactive, islocationonly) " & _
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, 1, 0)"
|
||||
strSQL = "INSERT INTO machines (machinenumber, modelnumberid, machinetypeid, businessunitid, alias, machinenotes, mapleft, maptop, isactive, islocationonly) " & _
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, 0)"
|
||||
|
||||
Set cmdMachine = Server.CreateObject("ADODB.Command")
|
||||
cmdMachine.ActiveConnection = objConn
|
||||
@@ -398,6 +381,7 @@
|
||||
cmdMachine.CommandType = 1
|
||||
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinenumber", 200, 1, 50, machinenumber)
|
||||
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@modelnumberid", 3, 1, , CLng(modelid))
|
||||
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinetypeid", 3, 1, , modelMachineTypeId)
|
||||
cmdMachine.Parameters.Append cmdMachine.CreateParameter("@businessunitid", 3, 1, , CLng(businessunitid))
|
||||
|
||||
' Handle optional alias
|
||||
@@ -427,10 +411,9 @@
|
||||
cmdMachine.Execute
|
||||
|
||||
If Err.Number <> 0 Then
|
||||
Response.Write("<div class='alert alert-danger'>Error: " & Server.HTMLEncode(Err.Description) & "</div>")
|
||||
Response.Write("<a href='addmachine.asp'>Go back</a>")
|
||||
Set cmdMachine = Nothing
|
||||
objConn.Close
|
||||
ShowError Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
Set cmdMachine = Nothing
|
||||
@@ -636,16 +619,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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "New third party vendor name is required", "addmachine.asp"
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
objConn.Close
|
||||
ShowError "Third party vendor name too long", "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -662,10 +643,9 @@
|
||||
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='addmachine.asp'>Go back</a>")
|
||||
Set cmdNewTPVendor = Nothing
|
||||
objConn.Close
|
||||
ShowError "Error creating new third party vendor: " & Err.Description, "addmachine.asp"
|
||||
Response.End
|
||||
End If
|
||||
|
||||
@@ -714,13 +694,8 @@
|
||||
objConn.Close
|
||||
|
||||
If CLng(newMachineId) > 0 Then
|
||||
%>
|
||||
<meta http-equiv="refresh" content="0; url=./displaymachine.asp?machineid=<%=Server.HTMLEncode(newMachineId)%>">
|
||||
<%
|
||||
ShowSuccess "Machine created successfully.", "displaymachine.asp?machineid=" & newMachineId, "machine details"
|
||||
Else
|
||||
Response.Write("Error: Machine was not added successfully.")
|
||||
ShowError "Machine was not added successfully.", "addmachine.asp"
|
||||
End If
|
||||
%>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user