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:
91
addmodel.asp
91
addmodel.asp
@@ -125,11 +125,66 @@
|
||||
<div class="form-check">
|
||||
<input class="form-check-input model-type" type="checkbox" id="modelismachine" name="modelismachine" value="1">
|
||||
<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>
|
||||
</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">
|
||||
<label for="documentationpath">Documentation URL (Optional)</label>
|
||||
<input type="url" class="form-control" id="documentationpath" name="documentationpath"
|
||||
@@ -220,6 +275,32 @@
|
||||
$('#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
|
||||
$('#modelForm').on('submit', function(e) {
|
||||
var atLeastOneChecked = $('.model-type:checked').length > 0;
|
||||
@@ -236,6 +317,14 @@
|
||||
$('#newvendorname').focus();
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user