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

@@ -167,13 +167,20 @@
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid"> <select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
<option value="">-- Select Machine Type --</option> <option value="">-- Select Machine Type --</option>
<% <%
Dim rsMachineTypes Dim rsMachineTypes, lastCat
strSQL = "SELECT * FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" strSQL = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objconn.Execute(strSQL) Set rsMachineTypes = objconn.Execute(strSQL)
lastCat = ""
While Not rsMachineTypes.EOF While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCat Then
If lastCat <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCat = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>") Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext rsMachineTypes.MoveNext
Wend Wend
If lastCat <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close rsMachineTypes.Close
Set rsMachineTypes = Nothing Set rsMachineTypes = Nothing
%> %>

View File

@@ -125,11 +125,66 @@
<div class="form-check"> <div class="form-check">
<input class="form-check-input model-type" type="checkbox" id="modelismachine" name="modelismachine" value="1"> <input class="form-check-input model-type" type="checkbox" id="modelismachine" name="modelismachine" value="1">
<label class="form-check-label" for="modelismachine"> <label class="form-check-label" for="modelismachine">
<i class="zmdi zmdi-memory"></i> Machine/Equipment <i class="zmdi zmdi-memory"></i> Machine/Equipment/Network Device
</label> </label>
</div> </div>
</div> </div>
<!-- Machine Type Selection (shown when Machine/Equipment is checked) -->
<div class="form-group" id="machineTypeSection" style="display:none;">
<label for="machinetypeid">Machine/Device Type</label>
<div class="input-group">
<select class="form-control" id="machinetypeid" name="machinetypeid">
<option value="">-- Select Type --</option>
<%
Dim rsMachineTypes, strMTSQL
strMTSQL = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objconn.Execute(strMTSQL)
Dim lastCategory
lastCategory = ""
While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCategory Then
If lastCategory <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCategory = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext
Wend
If lastCategory <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close
Set rsMachineTypes = Nothing
%>
<option value="new">+ Add New Type</option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new machine type -->
<div id="newMachineTypeSection" class="new-vendor-section" style="display:none; padding:15px; border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine/Device Type</h6>
<div class="form-group">
<label for="newmachinetypename">Type Name</label>
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
</div>
<div class="form-group">
<label for="newmachinetypecategory">Category</label>
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
<option value="Equipment">Equipment</option>
<option value="Network">Network Device</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div>
<div class="form-group"> <div class="form-group">
<label for="documentationpath">Documentation URL (Optional)</label> <label for="documentationpath">Documentation URL (Optional)</label>
<input type="url" class="form-control" id="documentationpath" name="documentationpath" <input type="url" class="form-control" id="documentationpath" name="documentationpath"
@@ -220,6 +275,32 @@
$('#isprinter, #ispc, #ismachine').prop('checked', false); $('#isprinter, #ispc, #ismachine').prop('checked', false);
}); });
// Show/hide machine type section when Machine/Equipment is checked
$('#modelismachine').on('change', function() {
if ($(this).is(':checked')) {
$('#machineTypeSection').slideDown();
} else {
$('#machineTypeSection').slideUp();
$('#machinetypeid').val('');
$('#newMachineTypeSection').slideUp();
}
});
// Show/hide new machine type section
$('#addMachineTypeBtn, #machinetypeid').on('change click', function() {
if ($('#machinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
$('#machinetypeid').val('new');
$('#newMachineTypeSection').slideDown();
$('#newmachinetypename').prop('required', true);
}
});
$('#cancelNewMachineType').on('click', function() {
$('#newMachineTypeSection').slideUp();
$('#machinetypeid').val('');
$('#newmachinetypename').val('').prop('required', false);
});
// Form validation - at least one model type must be selected // Form validation - at least one model type must be selected
$('#modelForm').on('submit', function(e) { $('#modelForm').on('submit', function(e) {
var atLeastOneChecked = $('.model-type:checked').length > 0; var atLeastOneChecked = $('.model-type:checked').length > 0;
@@ -236,6 +317,14 @@
$('#newvendorname').focus(); $('#newvendorname').focus();
return false; return false;
} }
// If adding new machine type, make sure name is filled
if ($('#machinetypeid').val() === 'new' && $('#newmachinetypename').val().trim() === '') {
e.preventDefault();
alert('Please enter a machine type name or select an existing one');
$('#newmachinetypename').focus();
return false;
}
}); });
}); });
</script> </script>

View File

@@ -236,20 +236,55 @@
<div class="form-group"> <div class="form-group">
<label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label> <label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label>
<div class="input-group">
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid"> <select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
<option value="">-- Select Machine Type --</option> <option value="">-- Select Machine Type --</option>
<% <%
Dim rsMachineTypes Dim rsMachineTypes, lastCat
strSQL3 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" strSQL3 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objConn.Execute(strSQL3) Set rsMachineTypes = objConn.Execute(strSQL3)
lastCat = ""
While Not rsMachineTypes.EOF While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCat Then
If lastCat <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCat = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>") Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext rsMachineTypes.MoveNext
Wend Wend
If lastCat <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close rsMachineTypes.Close
Set rsMachineTypes = Nothing Set rsMachineTypes = Nothing
%> %>
<option value="new">+ Add New Type</option>
</select> </select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new machine type -->
<div id="newMachineTypeSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine Type</h6>
<div class="form-group">
<label for="newmachinetypename">Type Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
</div>
<div class="form-group">
<label for="newmachinetypecategory">Category</label>
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
<option value="Equipment">Equipment</option>
<option value="Network" selected>Network Device</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -487,6 +522,21 @@ $(document).ready(function() {
$('#newvendorname').val('').prop('required', false); $('#newvendorname').val('').prop('required', false);
}); });
// Show/hide new machine type section
$('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() {
if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
$('#newmodelmachinetypeid').val('new');
$('#newMachineTypeSection').slideDown();
$('#newmachinetypename').prop('required', true);
}
});
$('#cancelNewMachineType').on('click', function() {
$('#newMachineTypeSection').slideUp();
$('#newmodelmachinetypeid').val('');
$('#newmachinetypename').val('').prop('required', false);
});
// Form validation // Form validation
$('form').on('submit', function(e) { $('form').on('submit', function(e) {
// If adding new model, make sure fields are filled // If adding new model, make sure fields are filled
@@ -513,6 +563,15 @@ $(document).ready(function() {
return false; return false;
} }
} }
// If machine type is 'new', check machine type name
if ($('#newmodelmachinetypeid').val() === 'new') {
if ($('#newmachinetypename').val().trim() === '') {
e.preventDefault();
alert('Please enter a machine type name or select an existing type');
$('#newmachinetypename').focus();
return false;
}
}
} }
}); });
}); });

View File

@@ -327,20 +327,55 @@
<div class="form-group"> <div class="form-group">
<label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label> <label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label>
<div class="input-group">
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid"> <select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
<option value="">-- Select Machine Type --</option> <option value="">-- Select Machine Type --</option>
<% <%
Dim rsMachineTypes Dim rsMachineTypes, lastCat
strSQL2 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" strSQL2 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objConn.Execute(strSQL2) Set rsMachineTypes = objConn.Execute(strSQL2)
lastCat = ""
While Not rsMachineTypes.EOF While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCat Then
If lastCat <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCat = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>") Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext rsMachineTypes.MoveNext
Wend Wend
If lastCat <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close rsMachineTypes.Close
Set rsMachineTypes = Nothing Set rsMachineTypes = Nothing
%> %>
<option value="new">+ Add New Type</option>
</select> </select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new machine type -->
<div id="newMachineTypeSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine Type</h6>
<div class="form-group">
<label for="newmachinetypename">Type Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
</div>
<div class="form-group">
<label for="newmachinetypecategory">Category</label>
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
<option value="Equipment">Equipment</option>
<option value="Network" selected>Network Device</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -594,6 +629,21 @@ $(document).ready(function() {
$('#newvendorname').val('').prop('required', false); $('#newvendorname').val('').prop('required', false);
}); });
// Show/hide new machine type section
$('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() {
if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
$('#newmodelmachinetypeid').val('new');
$('#newMachineTypeSection').slideDown();
$('#newmachinetypename').prop('required', true);
}
});
$('#cancelNewMachineType').on('click', function() {
$('#newMachineTypeSection').slideUp();
$('#newmodelmachinetypeid').val('');
$('#newmachinetypename').val('').prop('required', false);
});
// Form validation // Form validation
$('form').on('submit', function(e) { $('form').on('submit', function(e) {
// Validate IDF // Validate IDF
@@ -635,6 +685,15 @@ $(document).ready(function() {
return false; return false;
} }
} }
// If machine type is 'new', check machine type name
if ($('#newmodelmachinetypeid').val() === 'new') {
if ($('#newmachinetypename').val().trim() === '') {
e.preventDefault();
alert('Please enter a machine type name or select an existing type');
$('#newmachinetypename').focus();
return false;
}
}
} }
}); });
}); });

586
devicefirewall.asp Normal file
View File

@@ -0,0 +1,586 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!--#include file="./includes/header.asp"-->
<!--#include file="./includes/sql.asp"-->
<!--#include file="./includes/validation.asp"-->
</head>
<%
theme = Request.Cookies("theme")
IF theme = "" THEN
theme="bg-theme1"
END IF
Dim firewallid, isNewRecord
firewallid = Request.QueryString("id")
If firewallid = "" Or firewallid = "0" Then
isNewRecord = True
firewallid = 0
Else
isNewRecord = False
End If
' If editing, fetch existing data
Dim rs, firewallname, modelid, serialnumber, ipaddress, fqdn, description, maptop, mapleft, isactive
Dim vendorname, modelnumber, logicmonitorurl
If Not isNewRecord Then
Dim strSQL
strSQL = "SELECT mac.machineid, mac.alias AS firewallname, mac.modelnumberid AS modelid, " & _
"mac.serialnumber, mac.fqdn, mac.logicmonitorurl, mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, " & _
"m.modelnumber, v.vendor, c.address AS ipaddress " & _
"FROM machines mac " & _
"LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _
"LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _
"LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _
"WHERE mac.machineid = " & firewallid & " AND mac.machinetypeid = 46"
Set rs = objConn.Execute(strSQL)
If rs.EOF Then
Response.Write("firewall not found")
Response.End
End If
If Not IsNull(rs("firewallname")) Then firewallname = rs("firewallname") Else firewallname = ""
If Not IsNull(rs("modelid")) Then modelid = rs("modelid") Else modelid = ""
If Not IsNull(rs("serialnumber")) Then serialnumber = rs("serialnumber") Else serialnumber = ""
If Not IsNull(rs("ipaddress")) Then ipaddress = rs("ipaddress") Else ipaddress = ""
If Not IsNull(rs("fqdn")) Then fqdn = rs("fqdn") & "" Else fqdn = ""
If Not IsNull(rs("logicmonitorurl")) Then logicmonitorurl = rs("logicmonitorurl") & "" Else logicmonitorurl = ""
description = rs("description") & ""
If Not IsNull(rs("maptop")) Then maptop = rs("maptop") Else maptop = ""
If Not IsNull(rs("mapleft")) Then mapleft = rs("mapleft") Else mapleft = ""
If Not IsNull(rs("isactive")) Then isactive = rs("isactive") Else isactive = 1
If Not IsNull(rs("vendor")) Then vendorname = rs("vendor") Else vendorname = ""
If Not IsNull(rs("modelnumber")) Then modelnumber = rs("modelnumber") Else modelnumber = ""
rs.Close
Set rs = Nothing
Else
' New record defaults
firewallname = ""
modelid = ""
serialnumber = ""
ipaddress = ""
fqdn = ""
logicmonitorurl = ""
description = ""
maptop = ""
mapleft = ""
isactive = 1 ' Active by default for new records
vendorname = ""
modelnumber = ""
End If
%>
<body class="bg-theme <%Response.Write(theme)%>">
<!-- start loader -->
<div id="pageloader-overlay" class="visible incoming"><div class="loader-wrapper-outer"><div class="loader-wrapper-inner" ><div class="loader"></div></div></div></div>
<!-- end loader -->
<!-- Start wrapper-->
<div id="wrapper">
<!--#include file="./includes/leftsidebar.asp"-->
<!--Start topbar header-->
<!--#include file="./includes/topbarheader.asp"-->
<!--End topbar header-->
<div class="clearfix"></div>
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumb -->
<div class="row mt-3">
<div class="col-lg-12">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="networkdevices.asp">Network Devices</a></li>
<li class="breadcrumb-item"><a href="networkdevices.asp?filter=firewall">firewalls</a></li>
<li class="breadcrumb-item active"><%If isNewRecord Then Response.Write("Add firewall") Else Response.Write("Edit firewall")%></li>
</ol>
</nav>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">
<i class="zmdi zmdi-shield-security"></i>
<%If isNewRecord Then Response.Write("Add firewall") Else Response.Write("Edit firewall: " & Server.HTMLEncode(firewallname))%>
</h5>
<hr>
<form method="post" action="savenetworkdevice.asp">
<input type="hidden" name="type" value="firewall">
<input type="hidden" name="id" value="<%=firewallid%>">
<div class="form-group row">
<label class="col-sm-3 col-form-label">firewall Name <span class="text-danger">*</span></label>
<div class="col-sm-9">
<input type="text" name="firewallname" class="form-control"
value="<%=Server.HTMLEncode(firewallname)%>"
required maxlength="100"
placeholder="e.g., DB-firewall-01, App-firewall-Primary">
<small class="form-text text-muted">
Short name to identify this firewall
</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Model</label>
<div class="col-sm-9">
<div class="input-group">
<select name="modelid" id="modelid" class="form-control">
<option value="">-- Select Model --</option>
<%
Dim strSQL2, rsModels, currentModelId
' Show Firewall models (machinetypeid = 46) plus currently assigned model
If IsNumeric(modelid) Then currentModelId = CLng(modelid) Else currentModelId = 0
strSQL2 = "SELECT m.modelnumberid, m.modelnumber, v.vendor " & _
"FROM models m " & _
"INNER JOIN vendors v ON m.vendorid = v.vendorid " & _
"WHERE m.isactive = 1 AND (m.machinetypeid = 46 OR m.modelnumberid = " & currentModelId & ") " & _
"ORDER BY v.vendor, m.modelnumber"
Set rsModels = objConn.Execute(strSQL2)
Do While Not rsModels.EOF
Dim selected
selected = ""
If Not IsNull(modelid) And modelid <> "" Then
If CStr(rsModels("modelnumberid")) = CStr(modelid) Then
selected = "selected"
End If
End If
%>
<option value="<%=rsModels("modelnumberid")%>" <%=selected%>>
<%=Server.HTMLEncode(rsModels("vendor") & " - " & rsModels("modelnumber"))%>
</option>
<%
rsModels.MoveNext
Loop
rsModels.Close
Set rsModels = Nothing
%>
<option value="new">+ Add New Model</option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addModelBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
<small class="form-text text-muted">
Select a model or click "New" to add one
</small>
</div>
</div>
<!-- Hidden section for adding new model -->
<div id="newModelSection" class="form-group row" style="display:none;">
<div class="col-sm-9 offset-sm-3">
<div style="padding:15px; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.1); border-radius:5px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Model</h6>
<div class="form-group">
<label for="newmodelnumber">Model Number <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newmodelnumber" name="newmodelnumber"
maxlength="255" placeholder="e.g., PowerEdge R740">
</div>
<div class="form-group">
<label for="newvendorid">Vendor <span class="text-danger">*</span></label>
<div class="input-group">
<select class="form-control" id="newvendorid" name="newvendorid">
<option value="">-- Select Vendor --</option>
<%
Dim rsVendors
strSQL2 = "SELECT vendorid, vendor FROM vendors WHERE isactive = 1 ORDER BY vendor ASC"
Set rsVendors = objConn.Execute(strSQL2)
While Not rsVendors.EOF
Response.Write("<option value='" & rsVendors("vendorid") & "'>" & Server.HTMLEncode(rsVendors("vendor")) & "</option>")
rsVendors.MoveNext
Wend
rsVendors.Close
Set rsVendors = Nothing
%>
<option value="new">+ Add New Vendor</option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addVendorBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new vendor -->
<div id="newVendorSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Vendor</h6>
<div class="form-group">
<label for="newvendorname">Vendor Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newvendorname" name="newvendorname"
maxlength="50" placeholder="e.g., Dell, HP, Cisco">
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewVendor">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div>
<div class="form-group">
<label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label>
<div class="input-group">
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
<option value="">-- Select Machine Type --</option>
<%
Dim rsMachineTypes
strSQL2 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objConn.Execute(strSQL2)
Dim lastCat
lastCat = ""
While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCat Then
If lastCat <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCat = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext
Wend
If lastCat <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close
Set rsMachineTypes = Nothing
%>
<option value="new">+ Add New Type</option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new machine type -->
<div id="newMachineTypeSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine Type</h6>
<div class="form-group">
<label for="newmachinetypename">Type Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
</div>
<div class="form-group">
<label for="newmachinetypecategory">Category</label>
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
<option value="Equipment">Equipment</option>
<option value="Network" selected>Network Device</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div>
<div class="form-group">
<label for="newmodelnotes">Model Notes</label>
<textarea class="form-control" id="newmodelnotes" name="newmodelnotes"
rows="2" maxlength="255"
placeholder="Additional notes about this model..."></textarea>
</div>
<div class="form-group">
<label for="newmodeldocpath">Documentation Path</label>
<input type="text" class="form-control" id="newmodeldocpath" name="newmodeldocpath"
maxlength="255" placeholder="\\firewall\docs\model.pdf or http://...">
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewModel">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Serial Number</label>
<div class="col-sm-9">
<input type="text" name="serialnumber" class="form-control"
value="<%=Server.HTMLEncode(serialnumber)%>"
maxlength="100" placeholder="e.g., SN123456789">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">IP Address</label>
<div class="col-sm-9">
<input type="text" name="ipaddress" class="form-control"
value="<%=Server.HTMLEncode(ipaddress)%>"
maxlength="45" pattern="^[0-9\.:]*$"
placeholder="e.g., 192.168.1.100 or 2001:db8::1">
<small class="form-text text-muted">
IPv4 or IPv6 address
</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">FQDN</label>
<div class="col-sm-9">
<input type="text" name="fqdn" class="form-control"
value="<%=Server.HTMLEncode(fqdn)%>"
maxlength="255"
placeholder="e.g., firewall01.network.company.com">
<small class="form-text text-muted">
Fully Qualified Domain Name (optional)
</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Logic Monitor URL</label>
<div class="col-sm-9">
<input type="url" name="logicmonitorurl" class="form-control"
value="<%=Server.HTMLEncode(logicmonitorurl)%>"
maxlength="512"
placeholder="e.g., https://company.logicmonitor.com/santaba/uiv3/...">
<small class="form-text text-muted">
Link to this device in Logic Monitor (optional)
</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Description</label>
<div class="col-sm-9">
<textarea name="description" class="form-control" rows="3"
maxlength="255" placeholder="Detailed notes about this firewall..."><%=Server.HTMLEncode(description)%></textarea>
<small class="form-text text-muted">
Optional: Purpose, rack location, or other notes
</small>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label"></label>
<div class="col-sm-9">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="isactive" name="isactive" value="1"
<%If isactive = True Or isactive = 1 Then Response.Write("checked")%>>
<label class="custom-control-label" for="isactive">Active</label>
</div>
<small class="form-text text-muted">
Inactive devices are hidden from most lists and the network map
</small>
</div>
</div>
<!-- Hidden coordinate fields - populated by map selector -->
<input type="hidden" id="maptop" name="maptop" value="<%=maptop%>">
<input type="hidden" id="mapleft" name="mapleft" value="<%=mapleft%>">
<div class="form-group row">
<label class="col-sm-3 col-form-label">Map Position (Optional)</label>
<div class="col-sm-9">
<button type="button" class="btn btn-secondary" id="selectLocationBtn">
<i class="zmdi zmdi-pin"></i> Select Location on Map
</button>
<div id="coordinateDisplay" style="margin-top:10px; color:#aaa; font-size:13px;">
<%If maptop <> "" And mapleft <> "" Then
Response.Write("Current position: X=" & mapleft & ", Y=" & maptop)
Else
Response.Write("No position set - click button to select")
End If%>
</div>
<small class="form-text text-muted">
Click to select this firewall's position on the network map
</small>
</div>
</div>
<hr>
<div class="form-group row">
<div class="col-sm-9 offset-sm-3">
<button type="submit" class="btn btn-success">
<i class="zmdi zmdi-save"></i>
<%If isNewRecord Then Response.Write("Add firewall") Else Response.Write("Save Changes")%>
</button>
<a href="networkdevices.asp?filter=firewall" class="btn btn-secondary">
<i class="zmdi zmdi-close"></i> Cancel
</a>
<%If Not isNewRecord Then%>
<button type="button" class="btn btn-danger float-right" onclick="confirmDelete()">
<i class="zmdi zmdi-delete"></i> Delete
</button>
<%End If%>
</div>
</div>
</form>
</div>
</div>
</div>
</div><!--End Row-->
</div><!-- End container-fluid-->
</div><!--End content-wrapper-->
<!--Start Back To Top Button-->
<a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
<!--End Back To Top Button-->
<!--Start footer-->
<footer class="footer">
</footer>
<!--End footer-->
</div><!--End wrapper-->
<!-- Bootstrap core JavaScript-->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<!-- sidebar-menu js -->
<script src="assets/js/sidebar-menu.js"></script>
<!-- Custom scripts -->
<script src="assets/js/app-script.js"></script>
<script>
function confirmDelete() {
if (confirm('Are you sure you want to delete this firewall? This action cannot be undone.')) {
var form = document.createElement('form');
form.method = 'POST';
form.action = 'savenetworkdevice.asp';
var typeInput = document.createElement('input');
typeInput.type = 'hidden';
typeInput.name = 'type';
typeInput.value = 'firewall';
form.appendChild(typeInput);
var idInput = document.createElement('input');
idInput.type = 'hidden';
idInput.name = 'id';
idInput.value = '<%=firewallid%>';
form.appendChild(idInput);
var deleteInput = document.createElement('input');
deleteInput.type = 'hidden';
deleteInput.name = 'delete';
deleteInput.value = '1';
form.appendChild(deleteInput);
document.body.appendChild(form);
form.submit();
}
}
// Model/Vendor nested add functionality
$(document).ready(function() {
// Show/hide new model section
$('#addModelBtn, #modelid').on('change click', function() {
if ($('#modelid').val() === 'new' || $(this).attr('id') === 'addModelBtn') {
$('#modelid').val('new');
$('#newModelSection').slideDown();
$('#newmodelnumber').prop('required', true);
$('#newvendorid').prop('required', true);
}
});
$('#cancelNewModel').on('click', function() {
$('#newModelSection').slideUp();
$('#newVendorSection').slideUp();
$('#modelid').val('');
$('#newmodelnumber').val('').prop('required', false);
$('#newvendorid').val('').prop('required', false);
$('#newmodelnotes').val('');
$('#newmodeldocpath').val('');
$('#newvendorname').val('').prop('required', false);
});
// Show/hide new vendor section
$('#addVendorBtn, #newvendorid').on('change click', function() {
if ($('#newvendorid').val() === 'new' || $(this).attr('id') === 'addVendorBtn') {
$('#newvendorid').val('new');
$('#newVendorSection').slideDown();
$('#newvendorname').prop('required', true);
}
});
$('#cancelNewVendor').on('click', function() {
$('#newVendorSection').slideUp();
$('#newvendorid').val('');
$('#newvendorname').val('').prop('required', false);
});
// Show/hide new machine type section
$('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() {
if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
$('#newmodelmachinetypeid').val('new');
$('#newMachineTypeSection').slideDown();
$('#newmachinetypename').prop('required', true);
}
});
$('#cancelNewMachineType').on('click', function() {
$('#newMachineTypeSection').slideUp();
$('#newmodelmachinetypeid').val('');
$('#newmachinetypename').val('').prop('required', false);
});
// Form validation
$('form').on('submit', function(e) {
// If adding new model, make sure fields are filled
if ($('#modelid').val() === 'new') {
if ($('#newmodelnumber').val().trim() === '') {
e.preventDefault();
alert('Please enter a model number or select an existing model');
$('#newmodelnumber').focus();
return false;
}
if ($('#newvendorid').val() === '' || $('#newvendorid').val() === 'new') {
// If vendor is 'new', check vendor name
if ($('#newvendorid').val() === 'new') {
if ($('#newvendorname').val().trim() === '') {
e.preventDefault();
alert('Please enter a vendor name or select an existing vendor');
$('#newvendorname').focus();
return false;
}
} else {
e.preventDefault();
alert('Please select a vendor or add a new one');
$('#newvendorid').focus();
return false;
}
}
// If machine type is 'new', check machine type name
if ($('#newmodelmachinetypeid').val() === 'new') {
if ($('#newmachinetypename').val().trim() === '') {
e.preventDefault();
alert('Please enter a machine type name or select an existing type');
$('#newmachinetypename').focus();
return false;
}
}
}
});
});
</script>
<!--#include file="./includes/map_picker.asp"-->
</body>
</html>
<%
objConn.Close
%>

View File

@@ -233,20 +233,55 @@
<div class="form-group"> <div class="form-group">
<label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label> <label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label>
<div class="input-group">
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid"> <select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
<option value="">-- Select Machine Type --</option> <option value="">-- Select Machine Type --</option>
<% <%
Dim rsMachineTypes Dim rsMachineTypes, lastCat
strSQL3 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" strSQL3 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objConn.Execute(strSQL3) Set rsMachineTypes = objConn.Execute(strSQL3)
lastCat = ""
While Not rsMachineTypes.EOF While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCat Then
If lastCat <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCat = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>") Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext rsMachineTypes.MoveNext
Wend Wend
If lastCat <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close rsMachineTypes.Close
Set rsMachineTypes = Nothing Set rsMachineTypes = Nothing
%> %>
<option value="new">+ Add New Type</option>
</select> </select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new machine type -->
<div id="newMachineTypeSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine Type</h6>
<div class="form-group">
<label for="newmachinetypename">Type Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
</div>
<div class="form-group">
<label for="newmachinetypecategory">Category</label>
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
<option value="Equipment">Equipment</option>
<option value="Network" selected>Network Device</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -552,6 +587,21 @@ $(document).ready(function() {
$('#newvendorname').val('').prop('required', false); $('#newvendorname').val('').prop('required', false);
}); });
// Show/hide new machine type section
$('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() {
if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
$('#newmodelmachinetypeid').val('new');
$('#newMachineTypeSection').slideDown();
$('#newmachinetypename').prop('required', true);
}
});
$('#cancelNewMachineType').on('click', function() {
$('#newMachineTypeSection').slideUp();
$('#newmodelmachinetypeid').val('');
$('#newmachinetypename').val('').prop('required', false);
});
// Form validation // Form validation
$('form').on('submit', function(e) { $('form').on('submit', function(e) {
// If adding new model, make sure fields are filled // If adding new model, make sure fields are filled
@@ -578,6 +628,15 @@ $(document).ready(function() {
return false; return false;
} }
} }
// If machine type is 'new', check machine type name
if ($('#newmodelmachinetypeid').val() === 'new') {
if ($('#newmachinetypename').val().trim() === '') {
e.preventDefault();
alert('Please enter a machine type name or select an existing type');
$('#newmachinetypename').focus();
return false;
}
}
} }
}); });

View File

@@ -232,20 +232,59 @@
<div class="form-group"> <div class="form-group">
<label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label> <label for="newmodelmachinetypeid">Machine Type <span class="text-danger">*</span></label>
<div class="input-group">
<select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid"> <select class="form-control" id="newmodelmachinetypeid" name="newmodelmachinetypeid">
<option value="">-- Select Machine Type --</option> <option value="">-- Select Machine Type --</option>
<% <%
Dim rsMachineTypes Dim rsMachineTypes
strSQL2 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" strSQL2 = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC"
Set rsMachineTypes = objConn.Execute(strSQL2) Set rsMachineTypes = objConn.Execute(strSQL2)
Dim lastCat
lastCat = ""
While Not rsMachineTypes.EOF While Not rsMachineTypes.EOF
If rsMachineTypes("category") <> lastCat Then
If lastCat <> "" Then Response.Write("</optgroup>")
Response.Write("<optgroup label='" & Server.HTMLEncode(rsMachineTypes("category")) & "'>")
lastCat = rsMachineTypes("category")
End If
Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>") Response.Write("<option value='" & rsMachineTypes("machinetypeid") & "'>" & Server.HTMLEncode(rsMachineTypes("machinetype")) & "</option>")
rsMachineTypes.MoveNext rsMachineTypes.MoveNext
Wend Wend
If lastCat <> "" Then Response.Write("</optgroup>")
rsMachineTypes.Close rsMachineTypes.Close
Set rsMachineTypes = Nothing Set rsMachineTypes = Nothing
%> %>
<option value="new">+ Add New Type</option>
</select> </select>
<div class="input-group-append">
<button type="button" class="btn btn-info" id="addMachineTypeBtn">
<i class="zmdi zmdi-plus"></i> New
</button>
</div>
</div>
</div>
<!-- Hidden section for adding new machine type -->
<div id="newMachineTypeSection" style="display:none; padding:15px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.15); border-radius:5px; margin-bottom:15px;">
<h6 class="mb-3"><i class="zmdi zmdi-plus-circle"></i> New Machine Type</h6>
<div class="form-group">
<label for="newmachinetypename">Type Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="newmachinetypename" name="newmachinetypename"
maxlength="50" placeholder="e.g., Firewall, Router, UPS">
</div>
<div class="form-group">
<label for="newmachinetypecategory">Category</label>
<select class="form-control" id="newmachinetypecategory" name="newmachinetypecategory">
<option value="Equipment">Equipment</option>
<option value="Network" selected>Network Device</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-secondary" id="cancelNewMachineType">
<i class="zmdi zmdi-close"></i> Cancel
</button>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -483,6 +522,21 @@ $(document).ready(function() {
$('#newvendorname').val('').prop('required', false); $('#newvendorname').val('').prop('required', false);
}); });
// Show/hide new machine type section
$('#addMachineTypeBtn, #newmodelmachinetypeid').on('change click', function() {
if ($('#newmodelmachinetypeid').val() === 'new' || $(this).attr('id') === 'addMachineTypeBtn') {
$('#newmodelmachinetypeid').val('new');
$('#newMachineTypeSection').slideDown();
$('#newmachinetypename').prop('required', true);
}
});
$('#cancelNewMachineType').on('click', function() {
$('#newMachineTypeSection').slideUp();
$('#newmodelmachinetypeid').val('');
$('#newmachinetypename').val('').prop('required', false);
});
// Form validation // Form validation
$('form').on('submit', function(e) { $('form').on('submit', function(e) {
// If adding new model, make sure fields are filled // If adding new model, make sure fields are filled
@@ -509,6 +563,15 @@ $(document).ready(function() {
return false; return false;
} }
} }
// If machine type is 'new', check machine type name
if ($('#newmodelmachinetypeid').val() === 'new') {
if ($('#newmachinetypename').val().trim() === '') {
e.preventDefault();
alert('Please enter a machine type name or select an existing type');
$('#newmachinetypename').focus();
return false;
}
}
} }
}); });
}); });

View File

@@ -152,7 +152,10 @@ Function GetPrinterListCached()
' Fetch from database ' Fetch from database
Dim sql, rs_temp, resultArray(), count, i Dim sql, rs_temp, resultArray(), count, i
sql = "SELECT printers.printerid AS printer, printers.*, vendors.*, models.*, machines.* " & _ sql = "SELECT printers.printerid AS printer, models.image, printers.installpath, " & _
"printers.printercsfname, printers.ipaddress, printers.serialnumber AS printerserial, " & _
"machines.islocationonly, vendors.vendor, models.modelnumber, models.documentationpath, " & _
"machines.machinenumber, machines.machineid " & _
"FROM printers, vendors, models, machines " & _ "FROM printers, vendors, models, machines " & _
"WHERE printers.modelid=models.modelnumberid " & _ "WHERE printers.modelid=models.modelnumberid " & _
"AND models.vendorid=vendors.vendorid " & _ "AND models.vendorid=vendors.vendorid " & _
@@ -191,7 +194,7 @@ Function GetPrinterListCached()
resultArray(i, 7) = rs_temp("documentationpath") resultArray(i, 7) = rs_temp("documentationpath")
resultArray(i, 8) = rs_temp("printercsfname") resultArray(i, 8) = rs_temp("printercsfname")
resultArray(i, 9) = rs_temp("ipaddress") resultArray(i, 9) = rs_temp("ipaddress")
resultArray(i, 10) = rs_temp("serialnumber") resultArray(i, 10) = rs_temp("printerserial")
' Convert islocationonly bit to 1/0 integer (bit fields come as binary) ' Convert islocationonly bit to 1/0 integer (bit fields come as binary)
On Error Resume Next On Error Resume Next
@@ -225,7 +228,7 @@ End Function
' Render dropdown options from cached vendor data ' Render dropdown options from cached vendor data
Function RenderVendorOptions(selectedID) Function RenderVendorOptions(selectedID)
Dim vendors, output, i Dim vendors, output, i, safeSelectedID
vendors = GetPrinterVendorsCached() vendors = GetPrinterVendorsCached()
output = "" output = ""
@@ -236,8 +239,14 @@ Function RenderVendorOptions(selectedID)
End If End If
On Error Goto 0 On Error Goto 0
' Safely handle null/empty selectedID
safeSelectedID = 0
If Not IsNull(selectedID) And selectedID <> "" And IsNumeric(selectedID) Then
safeSelectedID = CLng(selectedID)
End If
For i = 0 To UBound(vendors) For i = 0 To UBound(vendors)
If CLng(vendors(i, 0)) = CLng(selectedID) Then If CLng(vendors(i, 0)) = safeSelectedID Then
output = output & "<option value='" & vendors(i, 0) & "' selected>" & vendors(i, 1) & "</option>" output = output & "<option value='" & vendors(i, 0) & "' selected>" & vendors(i, 1) & "</option>"
Else Else
output = output & "<option value='" & vendors(i, 0) & "'>" & vendors(i, 1) & "</option>" output = output & "<option value='" & vendors(i, 0) & "'>" & vendors(i, 1) & "</option>"
@@ -249,7 +258,7 @@ End Function
' Render dropdown options from cached model data ' Render dropdown options from cached model data
Function RenderModelOptions(selectedID) Function RenderModelOptions(selectedID)
Dim models, output, i Dim models, output, i, safeSelectedID
models = GetPrinterModelsCached() models = GetPrinterModelsCached()
output = "" output = ""
@@ -260,8 +269,14 @@ Function RenderModelOptions(selectedID)
End If End If
On Error Goto 0 On Error Goto 0
' Safely handle null/empty selectedID
safeSelectedID = 0
If Not IsNull(selectedID) And selectedID <> "" And IsNumeric(selectedID) Then
safeSelectedID = CLng(selectedID)
End If
For i = 0 To UBound(models) For i = 0 To UBound(models)
If CLng(models(i, 0)) = CLng(selectedID) Then If CLng(models(i, 0)) = safeSelectedID Then
output = output & "<option value='" & models(i, 0) & "' selected>" & models(i, 1) & "</option>" output = output & "<option value='" & models(i, 0) & "' selected>" & models(i, 1) & "</option>"
Else Else
output = output & "<option value='" & models(i, 0) & "'>" & models(i, 1) & "</option>" output = output & "<option value='" & models(i, 0) & "'>" & models(i, 1) & "</option>"
@@ -331,7 +346,7 @@ End Function
' Render dropdown options from cached support team data ' Render dropdown options from cached support team data
Function RenderSupportTeamOptions(selectedID) Function RenderSupportTeamOptions(selectedID)
Dim teams, output, i Dim teams, output, i, safeSelectedID
teams = GetSupportTeamsCached() teams = GetSupportTeamsCached()
output = "" output = ""
@@ -342,8 +357,14 @@ Function RenderSupportTeamOptions(selectedID)
End If End If
On Error Goto 0 On Error Goto 0
' Safely handle null/empty selectedID
safeSelectedID = 0
If Not IsNull(selectedID) And selectedID <> "" And IsNumeric(selectedID) Then
safeSelectedID = CLng(selectedID)
End If
For i = 0 To UBound(teams) For i = 0 To UBound(teams)
If CLng(teams(i, 0)) = CLng(selectedID) Then If CLng(teams(i, 0)) = safeSelectedID Then
output = output & "<option value='" & teams(i, 0) & "' selected>" & Server.HTMLEncode(teams(i, 1)) & "</option>" output = output & "<option value='" & teams(i, 0) & "' selected>" & Server.HTMLEncode(teams(i, 1)) & "</option>"
Else Else
output = output & "<option value='" & teams(i, 0) & "'>" & Server.HTMLEncode(teams(i, 1)) & "</option>" output = output & "<option value='" & teams(i, 0) & "'>" & Server.HTMLEncode(teams(i, 1)) & "</option>"

View File

@@ -9,7 +9,6 @@ function setCookie(value)
} }
</script> </script>
<header class="topbar-nav"> <header class="topbar-nav">
<nav class="navbar navbar-expand fixed-top"> <nav class="navbar navbar-expand fixed-top">
<ul class="navbar-nav mr-auto align-items-center"> <ul class="navbar-nav mr-auto align-items-center">

View File

@@ -20,6 +20,7 @@
Dim modelnumber, vendorid, notes, documentationpath Dim modelnumber, vendorid, notes, documentationpath
Dim newvendorname, isprinter, ispc, ismachine Dim newvendorname, isprinter, ispc, ismachine
Dim modelisprinter, modelispc, modelismachine Dim modelisprinter, modelispc, modelismachine
Dim machinetypeid, newmachinetypename, newmachinetypecategory
modelnumber = Trim(Request.Form("modelnumber")) modelnumber = Trim(Request.Form("modelnumber"))
vendorid = Trim(Request.Form("vendorid")) vendorid = Trim(Request.Form("vendorid"))
@@ -37,6 +38,11 @@
modelispc = Request.Form("modelispc") modelispc = Request.Form("modelispc")
modelismachine = Request.Form("modelismachine") modelismachine = Request.Form("modelismachine")
' Machine type fields
machinetypeid = Trim(Request.Form("machinetypeid"))
newmachinetypename = Trim(Request.Form("newmachinetypename"))
newmachinetypecategory = Trim(Request.Form("newmachinetypecategory"))
' Validate required fields ' Validate required fields
If modelnumber = "" Then If modelnumber = "" Then
objConn.Close objConn.Close
@@ -176,6 +182,87 @@
Set cmdUpdateVendor = Nothing Set cmdUpdateVendor = Nothing
End If End If
' Handle new machine type creation if needed
If machinetypeid = "new" Then
If newmachinetypename = "" Then
objConn.Close
ShowError "Machine type name is required when adding a new type.", "addmodel.asp"
Response.End
End If
If Len(newmachinetypename) > 50 Then
objConn.Close
ShowError "Machine type name too long.", "addmodel.asp"
Response.End
End If
' Check if machine type already exists
Dim checkMTSQL, rsMTCheck, cmdMTCheck
checkMTSQL = "SELECT COUNT(*) as cnt FROM machinetypes WHERE LOWER(machinetype) = LOWER(?)"
Set cmdMTCheck = Server.CreateObject("ADODB.Command")
cmdMTCheck.ActiveConnection = objConn
cmdMTCheck.CommandText = checkMTSQL
cmdMTCheck.CommandType = 1
cmdMTCheck.Parameters.Append cmdMTCheck.CreateParameter("@machinetype", 200, 1, 50, newmachinetypename)
Set rsMTCheck = cmdMTCheck.Execute
If Not rsMTCheck.EOF Then
If Not IsNull(rsMTCheck("cnt")) Then
If CLng(rsMTCheck("cnt")) > 0 Then
rsMTCheck.Close
Set rsMTCheck = Nothing
Set cmdMTCheck = Nothing
objConn.Close
ShowError "Machine type '" & Server.HTMLEncode(newmachinetypename) & "' already exists.", "addmodel.asp"
Response.End
End If
End If
End If
rsMTCheck.Close
Set rsMTCheck = Nothing
Set cmdMTCheck = Nothing
' Default category if not provided
If newmachinetypecategory = "" Then newmachinetypecategory = "Equipment"
' Insert new machine type
Dim mtSQL, cmdMT
mtSQL = "INSERT INTO machinetypes (machinetype, isactive, category) VALUES (?, 1, ?)"
Set cmdMT = Server.CreateObject("ADODB.Command")
cmdMT.ActiveConnection = objConn
cmdMT.CommandText = mtSQL
cmdMT.CommandType = 1
cmdMT.Parameters.Append cmdMT.CreateParameter("@machinetype", 200, 1, 50, newmachinetypename)
cmdMT.Parameters.Append cmdMT.CreateParameter("@category", 200, 1, 50, newmachinetypecategory)
On Error Resume Next
cmdMT.Execute
If Err.Number <> 0 Then
Set cmdMT = Nothing
objConn.Close
ShowError "Error creating machine type: " & Server.HTMLEncode(Err.Description), "addmodel.asp"
Response.End
End If
' Get the new machine type ID
Set rsMTCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid")
machinetypeid = 0
If Not rsMTCheck.EOF Then
If Not IsNull(rsMTCheck("newid")) Then
machinetypeid = CLng(rsMTCheck("newid"))
End If
End If
rsMTCheck.Close
Set rsMTCheck = Nothing
Set cmdMT = Nothing
On Error Goto 0
ElseIf machinetypeid <> "" Then
' Validate existing machine type ID
If Not IsNumeric(machinetypeid) Or CLng(machinetypeid) < 1 Then
machinetypeid = ""
End If
End If
' Check if model already exists for this vendor using parameterized query ' Check if model already exists for this vendor using parameterized query
checkSQL = "SELECT COUNT(*) as cnt FROM models WHERE LOWER(modelnumber) = LOWER(?) AND vendorid = ?" checkSQL = "SELECT COUNT(*) as cnt FROM models WHERE LOWER(modelnumber) = LOWER(?) AND vendorid = ?"
Set cmdCheck = Server.CreateObject("ADODB.Command") Set cmdCheck = Server.CreateObject("ADODB.Command")
@@ -203,7 +290,11 @@
' Insert the new model using parameterized query ' Insert the new model using parameterized query
Dim modelSQL, cmdModel Dim modelSQL, cmdModel
If machinetypeid <> "" And IsNumeric(machinetypeid) Then
modelSQL = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, machinetypeid, isactive) VALUES (?, ?, ?, ?, ?, 1)"
Else
modelSQL = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) VALUES (?, ?, ?, ?, 1)" modelSQL = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) VALUES (?, ?, ?, ?, 1)"
End If
Set cmdModel = Server.CreateObject("ADODB.Command") Set cmdModel = Server.CreateObject("ADODB.Command")
cmdModel.ActiveConnection = objConn cmdModel.ActiveConnection = objConn
cmdModel.CommandText = modelSQL cmdModel.CommandText = modelSQL
@@ -212,6 +303,9 @@
cmdModel.Parameters.Append cmdModel.CreateParameter("@vendorid", 3, 1, , CLng(vendorid)) cmdModel.Parameters.Append cmdModel.CreateParameter("@vendorid", 3, 1, , CLng(vendorid))
cmdModel.Parameters.Append cmdModel.CreateParameter("@notes", 200, 1, 255, notes) cmdModel.Parameters.Append cmdModel.CreateParameter("@notes", 200, 1, 255, notes)
cmdModel.Parameters.Append cmdModel.CreateParameter("@documentationpath", 200, 1, 255, documentationpath) cmdModel.Parameters.Append cmdModel.CreateParameter("@documentationpath", 200, 1, 255, documentationpath)
If machinetypeid <> "" And IsNumeric(machinetypeid) Then
cmdModel.Parameters.Append cmdModel.CreateParameter("@machinetypeid", 3, 1, , CLng(machinetypeid))
End If
On Error Resume Next On Error Resume Next
cmdModel.Execute cmdModel.Execute

View File

@@ -19,7 +19,7 @@ deviceId = Trim(Request.Form("id"))
isDelete = Trim(Request.Form("delete")) isDelete = Trim(Request.Form("delete"))
' Validate device type ' 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 objConn.Close
ShowError "Invalid device type.", "networkdevices.asp" ShowError "Invalid device type.", "networkdevices.asp"
Response.End Response.End
@@ -51,6 +51,11 @@ Select Case deviceType
nameField = "switchname" nameField = "switchname"
redirectUrl = "networkdevices.asp?filter=Switch" redirectUrl = "networkdevices.asp?filter=Switch"
deviceDisplayName = "Switch" deviceDisplayName = "Switch"
Case "firewall"
machineTypeId = 46
nameField = "firewallname"
redirectUrl = "networkdevices.asp?filter=Firewall"
deviceDisplayName = "Firewall"
Case "camera" Case "camera"
machineTypeId = 18 machineTypeId = 18
nameField = "cameraname" nameField = "cameraname"
@@ -192,6 +197,53 @@ If modelid = "new" Then
On Error Goto 0 On Error Goto 0
End If 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 ' Insert new model using parameterized query
Dim sqlNewModel, cmdNewModel Dim sqlNewModel, cmdNewModel
sqlNewModel = "INSERT INTO models (modelnumber, vendorid, machinetypeid, notes, documentationpath, isactive) VALUES (?, ?, ?, ?, ?, 1)" sqlNewModel = "INSERT INTO models (modelnumber, vendorid, machinetypeid, notes, documentationpath, isactive) VALUES (?, ?, ?, ?, ?, 1)"
@@ -201,7 +253,7 @@ If modelid = "new" Then
cmdNewModel.CommandType = 1 cmdNewModel.CommandType = 1
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@modelnumber", 200, 1, 50, newmodelnumber) cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@modelnumber", 200, 1, 50, newmodelnumber)
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@vendorid", 3, 1, , CLng(newvendorid)) 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)) cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@machinetypeid", 3, 1, , CLng(newmodelmachinetypeid))
Else Else
cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@machinetypeid", 3, 1, , Null) cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@machinetypeid", 3, 1, , Null)
@@ -313,6 +365,8 @@ Select Case deviceType
machinenumber = "SVR-" & Replace(deviceName, " ", "-") machinenumber = "SVR-" & Replace(deviceName, " ", "-")
Case "switch" Case "switch"
machinenumber = "SW-" & Replace(deviceName, " ", "-") machinenumber = "SW-" & Replace(deviceName, " ", "-")
Case "firewall"
machinenumber = "FW-" & Replace(deviceName, " ", "-")
Case "camera" Case "camera"
machinenumber = "CAM-" & Replace(deviceName, " ", "-") machinenumber = "CAM-" & Replace(deviceName, " ", "-")
Case "accesspoint" Case "accesspoint"
@@ -413,9 +467,9 @@ If ipaddress <> "" Then
Set rsComm = Nothing Set rsComm = Nothing
If commExists Then If commExists Then
' Update existing communication ' Update existing communication (ensure isprimary=1 so display query finds it)
Dim sqlUpdateComm, cmdUpdateComm 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") Set cmdUpdateComm = Server.CreateObject("ADODB.Command")
cmdUpdateComm.ActiveConnection = objConn cmdUpdateComm.ActiveConnection = objConn
cmdUpdateComm.CommandText = sqlUpdateComm cmdUpdateComm.CommandText = sqlUpdateComm

View File

@@ -564,6 +564,71 @@ Loop
rsPrinters.Close rsPrinters.Close
Set rsPrinters = Nothing 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) ' Sort combined results by relevance (bubble sort is fine for small arrays)
Dim i, j, tempType, tempData, tempRel, tempId Dim i, j, tempType, tempData, tempRel, tempId
For i = 0 To totalCount - 1 For i = 0 To totalCount - 1
@@ -810,6 +875,43 @@ Next
' Column 5: Share button ' 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>") 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>&nbsp;</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 End If
Response.Write("</tr>") 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) { function copyToClipboardFallback(text) {
var textArea = document.createElement("textarea"); var textArea = document.createElement("textarea");
textArea.value = text; textArea.value = text;
@@ -1080,6 +1200,8 @@ window.addEventListener('DOMContentLoaded', function() {
elementId = 'machine-result-' + highlightId; elementId = 'machine-result-' + highlightId;
} else if (highlightType === 'printer') { } else if (highlightType === 'printer') {
elementId = 'printer-result-' + highlightId; elementId = 'printer-result-' + highlightId;
} else if (highlightType === 'employee') {
elementId = 'employee-result-' + highlightId;
} else { } else {
// Default to KB article format // Default to KB article format
elementId = 'result-' + highlightId; elementId = 'result-' + highlightId;