Files
shopdb/pcs.asp
cproudlock 8194f5cdf0 Standardize UI consistency across ShopDB pages
Security fixes:
- Add HTMLEncode to displaysubnets.asp output
- Add HTMLEncode to displayapplications.asp URL attributes

Icon standardization:
- Use zmdi-plus-circle for all Add buttons (displaypcs, pcs, pclist, computers, listpcs)
- Use zmdi-edit for all Edit tab icons (displayapplication, displayprinter, displaysubnet, displaydevice)
- Replace icon-note with zmdi icons throughout

Layout consistency:
- Standardize title row margin-bottom to 15px across all pages
- Add table-hover class to all data tables
- Fix editpc.asp title from "Edit Equipment" to "Edit PC"
- Fix editpc.asp back link to point to displaypcs.asp

Terminology:
- Change "Make" to "Vendor" in displayprinters.asp
- Standardize Back button text to "Back to [Page]" format

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 14:20:35 -05:00

298 lines
12 KiB
Plaintext

<%' Cache buster: 20251110-1430 %>
<!DOCTYPE html>
<html lang="en">
<head>
<!--#include file="./includes/header.asp"-->
<!--#include file="./includes/sql.asp"-->
</head>
<%
theme = Request.Cookies("theme")
IF theme = "" THEN
theme="bg-theme1"
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="row">
<div class="col-xl-auto">
<div class="card">
<div class="card-body">
<div style="margin-bottom:15px;">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:15px;">
<h5 class="card-title" style="margin:0;">PCs</h5>
<div>
<a href="./adddevice.asp" class="btn btn-primary">
<i class="zmdi zmdi-plus-circle"></i> Add Device
</a>
</div>
</div>
<%
Dim currentPCType, currentPCStatus, recentFilter, deviceTypeFilter, sel
currentPCType = Request.QueryString("pctype")
currentPCStatus = Request.QueryString("pcstatus")
recentFilter = Request.QueryString("recent")
deviceTypeFilter = Request.QueryString("devicetype")
%>
<div style="display:flex; gap:10px; flex-wrap:wrap; align-items:center;">
<select id="deviceTypeFilter" class="btn btn-secondary btn-sm" onchange="updateFilter('devicetype', this.value)">
<option value="">All Device Types</option>
<option value="laptop"<% If deviceTypeFilter = "laptop" Then Response.Write(" selected") End If%>>Laptops</option>
<option value="desktop"<% If deviceTypeFilter = "desktop" Then Response.Write(" selected") End If%>>Desktops</option>
</select>
<select id="pcTypeSelect" class="btn btn-secondary btn-sm" onchange="updateFilter('pctype', this.value)">
<option value="">All PC Types</option>
<%
Dim rsTypes, rsStatus, selectedAttr
Set rsTypes = objConn.Execute("SELECT pctypeid, typename FROM pctype WHERE isactive = '1' ORDER BY displayorder, typename")
While Not rsTypes.EOF
selectedAttr = ""
If CStr(rsTypes("pctypeid")) = CStr(currentPCType) Then
selectedAttr = " selected"
End If
Response.Write "<option value=""" & rsTypes("pctypeid") & """" & selectedAttr & ">" & rsTypes("typename") & "</option>" & vbCrLf
rsTypes.MoveNext
Wend
rsTypes.Close
Set rsTypes = Nothing
%>
</select>
<select id="pcStatusSelect" class="btn btn-secondary btn-sm" onchange="updateFilter('pcstatus', this.value)">
<option value="">All Statuses</option>
<%
Set rsStatus = objConn.Execute("SELECT machinestatusid, machinestatus FROM machinestatus WHERE isactive = 1 ORDER BY machinestatusid")
While Not rsStatus.EOF
selectedAttr = ""
If CStr(rsStatus("machinestatusid")) = CStr(currentPCStatus) Then
selectedAttr = " selected"
End If
Response.Write "<option value=""" & rsStatus("machinestatusid") & """" & selectedAttr & ">" & rsStatus("machinestatus") & "</option>" & vbCrLf
rsStatus.MoveNext
Wend
rsStatus.Close
Set rsStatus = Nothing
%>
</select>
<select id="recentFilter" class="btn btn-secondary btn-sm" onchange="updateFilter('recent', this.value)">
<option value="">All Time</option>
<option value="7"<% If recentFilter = "7" Then Response.Write(" selected") End If%>>Last 7 Days</option>
</select>
<% If currentPCType <> "" Or currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Then %>
<a href="listpcs.asp" class="btn btn-outline-secondary btn-sm">
<i class="zmdi zmdi-close"></i> Clear
</a>
<% End If %>
<button id="checkAllWarrantiesBtn" class="btn btn-info btn-sm" title="Check Dell warranty API for all PCs without warranty information" disabled>
<i class="zmdi zmdi-refresh"></i> Check Warranties
</button>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Hostname</th>
<th scope="col">Serial</th>
<th scope="col">IP</th>
<th scope="col">Model</th>
<th scope="col">OS</th>
<th scope="col">Machine</th>
</tr>
</thead>
<tbody>
<%
' Build query based on filters
Dim pcTypeFilter, pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, whereClause
pcTypeFilter = Request.QueryString("pctype")
pcStatusFilter = Request.QueryString("pcstatus")
recentDaysFilter = Request.QueryString("recent")
deviceTypeFilterSQL = Request.QueryString("devicetype")
' Base query with LEFT JOINs to show all PCs
strSQL = "SELECT m.machineid, m.hostname, m.alias, m.serialnumber, m.machinenumber, m.pctypeid, m.machinestatusid, " & _
"m.modelnumberid, m.businessunitid, m.osid, m.loggedinuser, m.lastupdated, " & _
"vendors.vendor, models.modelnumber, operatingsystems.operatingsystem, " & _
"c.address AS ipaddress, c.macaddress, " & _
"models.machinetypeid, pctype.typename, machinestatus.machinestatus " & _
"FROM machines m " & _
"LEFT JOIN models ON m.modelnumberid = models.modelnumberid " & _
"LEFT JOIN vendors ON models.vendorid = vendors.vendorid " & _
"LEFT JOIN operatingsystems ON m.osid = operatingsystems.osid " & _
"LEFT JOIN communications c ON c.machineid = m.machineid AND c.isprimary = 1 " & _
"LEFT JOIN pctype ON m.pctypeid = pctype.pctypeid " & _
"LEFT JOIN machinestatus ON m.machinestatusid = machinestatus.machinestatusid " & _
"WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL"
' Apply filters
whereClause = ""
If pcTypeFilter <> "" Then
whereClause = whereClause & "AND m.pctypeid = " & pcTypeFilter & " "
End If
If pcStatusFilter <> "" Then
whereClause = whereClause & "AND m.machinestatusid = " & pcStatusFilter & " "
End If
If recentDaysFilter <> "" And IsNumeric(recentDaysFilter) Then
whereClause = whereClause & "AND m.lastupdated >= DATE_SUB(NOW(), INTERVAL " & recentDaysFilter & " DAY) "
End If
' Filter by device type (laptop vs desktop) based on model name patterns
If deviceTypeFilterSQL = "laptop" Then
whereClause = whereClause & "AND (models.modelnumber LIKE '%Latitude%' OR models.modelnumber LIKE '%Precision%' AND (models.modelnumber NOT LIKE '%Tower%')) "
ElseIf deviceTypeFilterSQL = "desktop" Then
whereClause = whereClause & "AND (models.modelnumber LIKE '%OptiPlex%' OR models.modelnumber LIKE '%Tower%' OR models.modelnumber LIKE '%Micro%') "
End If
strSQL = strSQL & whereClause & " GROUP BY m.machineid ORDER BY m.machinenumber ASC, m.hostname ASC"
set rs = objconn.Execute(strSQL)
while not rs.eof
%>
<td><a href="./displaypc.asp?machineid=<%Response.Write(rs("machineid"))%>" title="Click to Show PC Details"><%
Dim displayName
If IsNull(rs("hostname")) Or rs("hostname") = "" Then
displayName = rs("serialnumber")
Else
displayName = rs("hostname")
End If
Response.Write(displayName)
%></a></td>
<td><%Response.Write(rs("serialnumber"))%></td>
<td><%Response.Write(rs("ipaddress"))%></td>
<td><%Response.Write(rs("modelnumber"))%></td>
<td><%Response.Write(rs("operatingsystem"))%></td>
<td><a href="./search.asp?search=<%Response.Write(rs("machinenumber"))%>" title="Click to Show Machine Details"><%Response.Write(rs("machinenumber"))%></td>
</tr>
<%
rs.movenext
wend
objConn.Close
%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div><!--End Row-->
<!-- 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">
</div>
</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>
<!-- simplebar js -->
<script src="assets/plugins/simplebar/js/simplebar.js"></script>
<!-- sidebar-menu js -->
<script src="assets/js/sidebar-menu.js"></script>
<!-- Custom scripts -->
<script src="assets/js/app-script.js"></script>
<!-- Filter Update Script -->
<script>
function updateFilter(param, value) {
var url = new URL(window.location.href);
var params = new URLSearchParams(url.search);
if (value === '') {
params.delete(param);
} else {
params.set(param, value);
}
window.location.href = 'listpcs.asp' + (params.toString() ? '?' + params.toString() : '');
}
</script>
<!-- Warranty Check Script -->
<script>
$(document).ready(function() {
$('#checkAllWarrantiesBtn').on('click', function() {
var $btn = $(this);
var originalHtml = $btn.html();
// Confirm with user
if (!confirm('This will check the Dell warranty API for all PCs without warranty information.\n\nContinue?')) {
return;
}
// Disable button and show loading
$btn.prop('disabled', true);
$btn.html('<i class="zmdi zmdi-refresh zmdi-hc-spin"></i> Checking...');
// Call warranty check endpoint
$.ajax({
url: './check_all_warranties.asp',
type: 'GET',
dataType: 'json',
timeout: 300000, // 5 minute timeout
success: function(response) {
if (response.success) {
var message = 'Warranty Check Complete!\n\n' +
'Total Devices: ' + response.total + '\n' +
'Successfully Updated: ' + response.updated + '\n' +
'Errors: ' + response.errors;
if (response.errorDetails && response.errorDetails.length > 0) {
message += '\n\nError Details:\n';
for (var i = 0; i < response.errorDetails.length; i++) {
var err = response.errorDetails[i];
message += '- ' + err.pc + ' (' + err.serial + '): ' + err.reason + '\n';
}
}
message += '\n\nThe page will now reload to show updated information.';
alert(message);
location.reload();
} else {
alert('Error: ' + (response.message || 'Unknown error occurred'));
$btn.prop('disabled', false);
$btn.html(originalHtml);
}
},
error: function(xhr, status, error) {
alert('Error checking warranties:\n' + error + '\n\nPlease try again or contact support.');
$btn.prop('disabled', false);
$btn.html(originalHtml);
}
});
});
});
</script>
</body>
</html>