Add inline machine type creation and employee search results

- Add "+ New" button for machine types when adding models on network device pages
  (firewall, switch, server, access point, camera)
- Machine type dropdown now grouped by category (Equipment, Network, PC)
- Add firewall device type to savenetworkdevice.asp
- Remove employee autocomplete dropdown from global search bar
- Add employee search results to search.asp results page
- Update data_cache.asp with null-safe CLng handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-01-22 16:18:10 -05:00
parent 6d1cbc01c6
commit 12a35ed7e0
12 changed files with 1248 additions and 36 deletions

View File

@@ -19,7 +19,7 @@ deviceId = Trim(Request.Form("id"))
isDelete = Trim(Request.Form("delete"))
' Validate device type
If deviceType <> "idf" And deviceType <> "server" And deviceType <> "switch" And deviceType <> "camera" And deviceType <> "accesspoint" Then
If deviceType <> "idf" And deviceType <> "server" And deviceType <> "switch" And deviceType <> "camera" And deviceType <> "accesspoint" And deviceType <> "firewall" Then
objConn.Close
ShowError "Invalid device type.", "networkdevices.asp"
Response.End
@@ -51,6 +51,11 @@ Select Case deviceType
nameField = "switchname"
redirectUrl = "networkdevices.asp?filter=Switch"
deviceDisplayName = "Switch"
Case "firewall"
machineTypeId = 46
nameField = "firewallname"
redirectUrl = "networkdevices.asp?filter=Firewall"
deviceDisplayName = "Firewall"
Case "camera"
machineTypeId = 18
nameField = "cameraname"
@@ -192,6 +197,53 @@ If modelid = "new" Then
On Error Goto 0
End If
' Handle new machine type creation (nested)
If newmodelmachinetypeid = "new" Then
Dim newmachinetypename, newmachinetypecategory
newmachinetypename = Trim(Request.Form("newmachinetypename"))
newmachinetypecategory = Trim(Request.Form("newmachinetypecategory"))
If newmachinetypename = "" Then
objConn.Close
ShowError "Machine type name is required.", "networkdevices.asp"
Response.End
End If
If newmachinetypecategory = "" Then
newmachinetypecategory = "Equipment"
End If
' Insert new machine type using parameterized query
Dim sqlNewMT, cmdNewMT
sqlNewMT = "INSERT INTO machinetypes (machinetype, category, isactive) VALUES (?, ?, 1)"
Set cmdNewMT = Server.CreateObject("ADODB.Command")
cmdNewMT.ActiveConnection = objConn
cmdNewMT.CommandText = sqlNewMT
cmdNewMT.CommandType = 1
cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@machinetype", 200, 1, 50, newmachinetypename)
cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@category", 200, 1, 50, newmachinetypecategory)
On Error Resume Next
cmdNewMT.Execute
If Err.Number <> 0 Then
Dim mtErr
mtErr = Err.Description
Set cmdNewMT = Nothing
objConn.Close
ShowError "Error creating machine type: " & mtErr, "networkdevices.asp"
Response.End
End If
' Get newly created machine type ID
Dim rsNewMT
Set rsNewMT = objConn.Execute("SELECT LAST_INSERT_ID() AS newid")
newmodelmachinetypeid = CLng(rsNewMT("newid"))
rsNewMT.Close
Set rsNewMT = Nothing
Set cmdNewMT = Nothing
On Error Goto 0
End If
' Insert new model using parameterized query
Dim sqlNewModel, cmdNewModel
sqlNewModel = "INSERT INTO models (modelnumber, vendorid, machinetypeid, notes, documentationpath, isactive) VALUES (?, ?, ?, ?, ?, 1)"
@@ -201,7 +253,7 @@ If modelid = "new" Then
cmdNewModel.CommandType = 1
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@modelnumber", 200, 1, 50, newmodelnumber)
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@vendorid", 3, 1, , CLng(newvendorid))
If newmodelmachinetypeid <> "" Then
If newmodelmachinetypeid <> "" And IsNumeric(newmodelmachinetypeid) Then
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@machinetypeid", 3, 1, , CLng(newmodelmachinetypeid))
Else
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@machinetypeid", 3, 1, , Null)
@@ -313,6 +365,8 @@ Select Case deviceType
machinenumber = "SVR-" & Replace(deviceName, " ", "-")
Case "switch"
machinenumber = "SW-" & Replace(deviceName, " ", "-")
Case "firewall"
machinenumber = "FW-" & Replace(deviceName, " ", "-")
Case "camera"
machinenumber = "CAM-" & Replace(deviceName, " ", "-")
Case "accesspoint"
@@ -413,9 +467,9 @@ If ipaddress <> "" Then
Set rsComm = Nothing
If commExists Then
' Update existing communication
' Update existing communication (ensure isprimary=1 so display query finds it)
Dim sqlUpdateComm, cmdUpdateComm
sqlUpdateComm = "UPDATE communications SET address = ?, macaddress = ? WHERE comid = ?"
sqlUpdateComm = "UPDATE communications SET address = ?, macaddress = ?, isprimary = 1 WHERE comid = ?"
Set cmdUpdateComm = Server.CreateObject("ADODB.Command")
cmdUpdateComm.ActiveConnection = objConn
cmdUpdateComm.CommandText = sqlUpdateComm