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:
122
search.asp
122
search.asp
@@ -564,6 +564,71 @@ Loop
|
||||
rsPrinters.Close
|
||||
Set rsPrinters = Nothing
|
||||
|
||||
' Now get Employees (by first name, last name, or full name)
|
||||
' Uses the employee database connection
|
||||
On Error Resume Next
|
||||
Dim empConn, empCmd, empRs
|
||||
Set empConn = Server.CreateObject("ADODB.Connection")
|
||||
empConn.ConnectionString = GetEmployeeConnectionString()
|
||||
empConn.Open
|
||||
|
||||
If Err.Number = 0 Then
|
||||
Response.Write("<!-- DEBUG: Connected to employee database -->")
|
||||
|
||||
Set empCmd = Server.CreateObject("ADODB.Command")
|
||||
empCmd.ActiveConnection = empConn
|
||||
empCmd.CommandText = "SELECT SSO, First_Name, Last_Name, Team, Picture FROM employees " & _
|
||||
"WHERE First_Name LIKE ? OR Last_Name LIKE ? " & _
|
||||
"OR CONCAT(First_Name, ' ', Last_Name) LIKE ? " & _
|
||||
"ORDER BY Last_Name, First_Name LIMIT 10"
|
||||
empCmd.CommandType = 1
|
||||
|
||||
Dim empSearchPattern
|
||||
empSearchPattern = "%" & searchTerm & "%"
|
||||
|
||||
empCmd.Parameters.Append empCmd.CreateParameter("@first", 200, 1, 100, empSearchPattern)
|
||||
empCmd.Parameters.Append empCmd.CreateParameter("@last", 200, 1, 100, empSearchPattern)
|
||||
empCmd.Parameters.Append empCmd.CreateParameter("@full", 200, 1, 100, empSearchPattern)
|
||||
|
||||
Set empRs = empCmd.Execute()
|
||||
|
||||
If Err.Number = 0 Then
|
||||
Response.Write("<!-- DEBUG: Employee query executed -->")
|
||||
|
||||
Do While Not empRs.EOF And totalCount < 100
|
||||
Dim empSSO, empFirstName, empLastName, empTeam, empPicture, empFullName
|
||||
empSSO = empRs("SSO") & ""
|
||||
empFirstName = empRs("First_Name") & ""
|
||||
empLastName = empRs("Last_Name") & ""
|
||||
empTeam = empRs("Team") & ""
|
||||
empPicture = empRs("Picture") & ""
|
||||
empFullName = Trim(empFirstName & " " & empLastName)
|
||||
|
||||
Response.Write("<!-- DEBUG: Found employee - SSO: " & empSSO & ", Name: " & empFullName & " -->")
|
||||
|
||||
appResults(totalCount, 0) = "employee"
|
||||
' Format: sso|fullName|team|picture
|
||||
appResults(totalCount, 1) = empSSO & "|" & empFullName & "|" & empTeam & "|" & empPicture
|
||||
' Score of 20 for employees (higher than machines/printers)
|
||||
appResults(totalCount, 2) = 20
|
||||
appResults(totalCount, 3) = empSSO
|
||||
totalCount = totalCount + 1
|
||||
empRs.MoveNext
|
||||
Loop
|
||||
empRs.Close
|
||||
Else
|
||||
Response.Write("<!-- DEBUG: Employee query error: " & Err.Description & " -->")
|
||||
End If
|
||||
|
||||
Set empRs = Nothing
|
||||
Set empCmd = Nothing
|
||||
empConn.Close
|
||||
Set empConn = Nothing
|
||||
Else
|
||||
Response.Write("<!-- DEBUG: Could not connect to employee database: " & Err.Description & " -->")
|
||||
End If
|
||||
On Error Goto 0
|
||||
|
||||
' Sort combined results by relevance (bubble sort is fine for small arrays)
|
||||
Dim i, j, tempType, tempData, tempRel, tempId
|
||||
For i = 0 To totalCount - 1
|
||||
@@ -810,6 +875,43 @@ Next
|
||||
|
||||
' Column 5: Share button
|
||||
Response.Write("<td><button class='btn btn-sm btn-outline-primary share-btn' onclick='sharePrinterResult(" & printerId & ", """ & JavaScriptEncode(cleanSearch) & """)' title='Share this printer'><i class='zmdi zmdi-share'></i></button></td>")
|
||||
|
||||
ElseIf resultType = "employee" Then
|
||||
' Employee format: sso|fullName|team|picture
|
||||
Dim employeeSSO, employeeFullName, employeeTeam, employeePicture
|
||||
|
||||
employeeSSO = dataFields(0)
|
||||
employeeFullName = dataFields(1)
|
||||
If UBound(dataFields) >= 2 Then employeeTeam = dataFields(2) Else employeeTeam = ""
|
||||
If UBound(dataFields) >= 3 Then employeePicture = dataFields(3) Else employeePicture = ""
|
||||
|
||||
rowId = "employee-result-" & employeeSSO
|
||||
If highlightId <> "" And CStr(employeeSSO) = CStr(highlightId) And Request.QueryString("type") = "employee" Then
|
||||
rowStyle = " class='highlighted-result'"
|
||||
Else
|
||||
rowStyle = ""
|
||||
End If
|
||||
|
||||
Response.Write("<tr id='" & rowId & "'" & rowStyle & ">")
|
||||
|
||||
' Column 1: Empty for employees
|
||||
Response.Write("<td> </td>")
|
||||
|
||||
' Column 2: Employee icon
|
||||
Response.Write("<td><i class='zmdi zmdi-account text-success' style='margin-right: 5px;'></i>Employee</td>")
|
||||
|
||||
' Column 3: Employee name links to profile
|
||||
Response.Write("<td><a href='./displayprofile.asp?sso=" & Server.HTMLEncode(employeeSSO) & "'>" & Server.HTMLEncode(employeeFullName))
|
||||
If employeeTeam <> "" Then
|
||||
Response.Write(" <span class='badge badge-secondary'>" & Server.HTMLEncode(employeeTeam) & "</span>")
|
||||
End If
|
||||
Response.Write("</a></td>")
|
||||
|
||||
' Column 4: Relevance badge
|
||||
Response.Write("<td><span class='badge " & badgeClass & "'><i class='zmdi zmdi-trending-up'></i> " & FormatNumber(relevanceScore, 1) & "</span></td>")
|
||||
|
||||
' Column 5: Share button
|
||||
Response.Write("<td><button class='btn btn-sm btn-outline-primary share-btn' onclick='shareEmployeeResult(""" & Server.HTMLEncode(employeeSSO) & """, """ & JavaScriptEncode(cleanSearch) & """)' title='Share this employee'><i class='zmdi zmdi-share'></i></button></td>")
|
||||
End If
|
||||
|
||||
Response.Write("</tr>")
|
||||
@@ -1030,6 +1132,24 @@ function sharePrinterResult(printerId, searchTerm) {
|
||||
}
|
||||
}
|
||||
|
||||
function shareEmployeeResult(employeeSSO, searchTerm) {
|
||||
// Share link to search results with employee highlighted
|
||||
var baseUrl = window.location.origin + window.location.pathname;
|
||||
var cleanSearch = searchTerm.replace(/\s+/g, '+');
|
||||
var shareUrl = baseUrl + '?search=' + cleanSearch + '&highlight=' + employeeSSO + '&type=employee&shared=1';
|
||||
|
||||
// Copy to clipboard
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(shareUrl).then(function() {
|
||||
showToast();
|
||||
}).catch(function(err) {
|
||||
copyToClipboardFallback(shareUrl);
|
||||
});
|
||||
} else {
|
||||
copyToClipboardFallback(shareUrl);
|
||||
}
|
||||
}
|
||||
|
||||
function copyToClipboardFallback(text) {
|
||||
var textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
@@ -1080,6 +1200,8 @@ window.addEventListener('DOMContentLoaded', function() {
|
||||
elementId = 'machine-result-' + highlightId;
|
||||
} else if (highlightType === 'printer') {
|
||||
elementId = 'printer-result-' + highlightId;
|
||||
} else if (highlightType === 'employee') {
|
||||
elementId = 'employee-result-' + highlightId;
|
||||
} else {
|
||||
// Default to KB article format
|
||||
elementId = 'result-' + highlightId;
|
||||
|
||||
Reference in New Issue
Block a user