Add printer QR code printing and Windows name auto-update

- Add printerqrcode.asp for single printer QR code labels (ULINE S-20135)
- Add printerqrbatch.asp for batch printing multiple printers (6 per page)
- Add auto-update of Windows name when changing associated machine
- Windows name follows naming standard: [CSF]-[Machine]-[Vendor][Model]
- Remove UDC integrations from displaymachine.asp
- Add toner_inventory.csv for HP printer toner tracking
- Fix printerqrbatch.asp to show all printers, not just CSF ones

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-19 16:38:38 -05:00
parent 51f4c078c7
commit 84c2120652
5 changed files with 1844 additions and 1638 deletions

View File

@@ -113,23 +113,6 @@
Response.End
End If
' Check if machine has UDC data (only for equipment with machinenumber)
Dim rsUDCCheck, hasUDCData, strSQL2, machineNum
hasUDCData = False
machineNum = rs("machinenumber") & ""
If machineNum <> "" Then
strSQL2 = "SELECT COUNT(*) as cnt FROM udcparts p " & _
"JOIN udcsessions s ON p.sessionid = s.sessionid " & _
"WHERE s.machinenumber = ?"
Set rsUDCCheck = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineNum))
If Not rsUDCCheck Is Nothing Then
If Not rsUDCCheck.EOF Then
If CLng(rsUDCCheck("cnt") & "0") > 0 Then hasUDCData = True
End If
rsUDCCheck.Close
Set rsUDCCheck = Nothing
End If
End If
%>
<body class="bg-theme <%=Server.HTMLEncode(theme)%>">
@@ -192,11 +175,6 @@
<li class="nav-item">
<a href="javascript:void();" data-target="#applications" data-toggle="pill" class="nav-link"><i class="zmdi zmdi-apps"></i> <span class="hidden-xs">Applications</span></a>
</li>
<% End If %>
<% If hasUDCData Then %>
<li class="nav-item">
<a href="javascript:void();" data-target="#udc" data-toggle="pill" class="nav-link"><i class="zmdi zmdi-chart"></i> <span class="hidden-xs">UDC</span></a>
</li>
<% End If %>
<li class="nav-item">
<a href="./machineedit.asp?machineid=<%=Server.HTMLEncode(machineid)%>" class="nav-link" style="background: linear-gradient(45deg, #667eea 0%, #764ba2 100%); color: white;"><i class="zmdi zmdi-edit"></i> <span class="hidden-xs">Edit Machine</span></a>
@@ -819,338 +797,6 @@ End If
</table>
</div>
</div>
<% End If %>
<% If hasUDCData Then %>
<div class="tab-pane" id="udc">
<h5 class="mb-3">UDC Performance Data</h5>
<!-- Today's Stats Summary Cards -->
<div class="row mb-4">
<%
' Get today's UDC stats for this machine
Dim rsUDCToday, todayParts, todayOOT, todayAvgCycle, todayLastBadge
strSQL2 = "SELECT COUNT(*) as partstoday, " & _
"SUM(ootcount) as oottoday, " & _
"AVG(cycletime) as avgcycle, " & _
"(SELECT badgenumber FROM udcparts p2 JOIN udcsessions s2 ON p2.sessionid = s2.sessionid " & _
" WHERE s2.machinenumber = ? ORDER BY p2.programend DESC LIMIT 1) as lastbadge " & _
"FROM udcparts p " & _
"JOIN udcsessions s ON p.sessionid = s.sessionid " & _
"WHERE s.machinenumber = ? AND DATE(p.programstart) = CURDATE()"
Set rsUDCToday = ExecuteParameterizedQuery(objConn, strSQL2, Array(rs("machinenumber") & "", rs("machinenumber") & ""))
If Not rsUDCToday.EOF Then
todayParts = CLng(rsUDCToday("partstoday") & "0")
todayOOT = CLng(rsUDCToday("oottoday") & "0")
If Not IsNull(rsUDCToday("avgcycle")) Then
todayAvgCycle = FormatNumber(CDbl(rsUDCToday("avgcycle")) / 60, 1)
Else
todayAvgCycle = "0"
End If
todayLastBadge = rsUDCToday("lastbadge") & ""
Else
todayParts = 0
todayOOT = 0
todayAvgCycle = "0"
todayLastBadge = ""
End If
rsUDCToday.Close
Set rsUDCToday = Nothing
%>
<div class="col-md-3">
<div class="card bg-success text-white">
<div class="card-body text-center">
<h3 class="mb-0"><%=todayParts%></h3>
<small>Parts Today</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-info text-white">
<div class="card-body text-center">
<h3 class="mb-0"><%=todayAvgCycle%>m</h3>
<small>Avg Cycle Time</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card <% If todayOOT > 0 Then Response.Write("bg-danger") Else Response.Write("bg-secondary") End If %> text-white">
<div class="card-body text-center">
<h3 class="mb-0"><%=todayOOT%></h3>
<small>OOT Today</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-primary text-white">
<div class="card-body text-center">
<h3 class="mb-0"><%If todayLastBadge <> "" Then Response.Write(Server.HTMLEncode(todayLastBadge)) Else Response.Write("-")%></h3>
<small>Current Operator</small>
</div>
</div>
</div>
</div>
<!-- Recent Activity Log -->
<h6 class="mb-2"><i class="zmdi zmdi-time-restore"></i> Recent Activity</h6>
<div class="table-responsive mb-4">
<table class="table table-hover table-striped table-sm">
<thead>
<tr>
<th>Time</th>
<th>Type</th>
<th>Badge</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<%
' Get recent activity (violations + badge changes) for this machine
Dim rsActivity, actBadge
strSQL2 = "SELECT * FROM (" & _
"SELECT eventtime, 'Violation' as acttype, badgenumber, " & _
"CONCAT(crossingdesc, ': ', previousval, ' -> ', currentval) as details " & _
"FROM udcviolations WHERE machinenumber = ? " & _
"UNION ALL " & _
"SELECT eventtime, 'Badge Change' as acttype, badgenumber, details " & _
"FROM udcheaderupdates WHERE machinenumber = ? " & _
") combined ORDER BY eventtime DESC LIMIT 15"
Set rsActivity = ExecuteParameterizedQuery(objConn, strSQL2, Array(rs("machinenumber") & "", rs("machinenumber") & ""))
If rsActivity.EOF Then
Response.Write("<tr><td colspan='4' class='text-muted text-center'>No recent activity</td></tr>")
Else
Do While Not rsActivity.EOF
If rsActivity("acttype") = "Violation" Then
actBadge = "<span class='badge badge-light'>Setting Change</span>"
Else
actBadge = "<span class='badge badge-info'>Badge</span>"
End If
Response.Write("<tr>")
Response.Write("<td class='small'>" & Server.HTMLEncode(rsActivity("eventtime") & "") & "</td>")
Response.Write("<td>" & actBadge & "</td>")
Response.Write("<td>" & Server.HTMLEncode(rsActivity("badgenumber") & "") & "</td>")
Response.Write("<td class='small'>" & Server.HTMLEncode(rsActivity("details") & "") & "</td>")
Response.Write("</tr>")
rsActivity.MoveNext
Loop
End If
rsActivity.Close
Set rsActivity = Nothing
%>
</tbody>
</table>
</div>
<!-- Tool Health Section -->
<h6 class="mb-2 mt-4"><i class="zmdi zmdi-settings"></i> Tool Health</h6>
<%
' Get tool health summary for this machine (last 30 days)
Dim rsToolSummary, toolCount, toolMeasurements, toolOOT, toolLastCheck
strSQL2 = "SELECT COUNT(DISTINCT t.toolnumber) as unique_tools, " & _
"COUNT(*) as total_measurements, " & _
"SUM(t.oot) as oot_count, " & _
"MAX(t.eventtime) as last_check " & _
"FROM udctooldata t " & _
"JOIN udcsessions s ON t.sessionid = s.sessionid " & _
"WHERE s.machinenumber = ? AND t.eventtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)"
Set rsToolSummary = ExecuteParameterizedQuery(objConn, strSQL2, Array(rs("machinenumber") & ""))
If Not rsToolSummary.EOF Then
toolCount = CLng(rsToolSummary("unique_tools") & "0")
toolMeasurements = CLng(rsToolSummary("total_measurements") & "0")
toolOOT = CLng(rsToolSummary("oot_count") & "0")
toolLastCheck = rsToolSummary("last_check") & ""
Else
toolCount = 0
toolMeasurements = 0
toolOOT = 0
toolLastCheck = ""
End If
rsToolSummary.Close
Set rsToolSummary = Nothing
If toolMeasurements > 0 Then
%>
<!-- Tool Health Summary Cards -->
<div class="row mb-3">
<div class="col-md-3">
<div class="card bg-secondary text-white">
<div class="card-body text-center py-2">
<h4 class="mb-0"><%=toolCount%></h4>
<small>Tools Monitored</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-info text-white">
<div class="card-body text-center py-2">
<h4 class="mb-0"><%=toolMeasurements%></h4>
<small>Measurements (30d)</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card <% If toolOOT > 0 Then Response.Write("bg-danger") Else Response.Write("bg-success") End If %> text-white">
<div class="card-body text-center py-2">
<h4 class="mb-0"><%=toolOOT%></h4>
<small>Out of Tolerance</small>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-primary text-white">
<div class="card-body text-center py-2">
<h6 class="mb-0"><%If toolLastCheck <> "" Then Response.Write(Server.HTMLEncode(Left(toolLastCheck, 16))) Else Response.Write("-")%></h6>
<small>Last Tool Check</small>
</div>
</div>
</div>
</div>
<!-- Tool Status Table -->
<div class="table-responsive mb-3">
<table class="table table-hover table-striped table-sm">
<thead>
<tr>
<th>Tool #</th>
<th>Description</th>
<th>Checks</th>
<th>Avg Dev</th>
<th>Max Dev</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<%
' Get tool status by tool number
Dim rsTools, toolStatus, toolStatusClass, toolAvgDev, toolMaxDev, toolDevPct
strSQL2 = "SELECT t.toolnumber, " & _
"MAX(t.description) as description, " & _
"COUNT(*) as measurements, " & _
"ROUND(AVG(t.deviation), 4) as avg_deviation, " & _
"ROUND(MAX(ABS(t.deviation)), 4) as max_deviation, " & _
"MAX(ABS(t.minval)) as tolerance_ref, " & _
"SUM(t.oot) as oot_count " & _
"FROM udctooldata t " & _
"JOIN udcsessions s ON t.sessionid = s.sessionid " & _
"WHERE s.machinenumber = ? AND t.eventtime >= DATE_SUB(NOW(), INTERVAL 30 DAY) " & _
"GROUP BY t.toolnumber " & _
"ORDER BY oot_count DESC, measurements DESC " & _
"LIMIT 10"
Set rsTools = ExecuteParameterizedQuery(objConn, strSQL2, Array(rs("machinenumber") & ""))
If rsTools.EOF Then
Response.Write("<tr><td colspan='6' class='text-muted text-center'>No tool data available</td></tr>")
Else
Do While Not rsTools.EOF
' Calculate status based on OOT and deviation
If CLng(rsTools("oot_count") & "0") > 0 Then
toolStatus = "<i class='zmdi zmdi-alert-circle'></i> <strong>OOT</strong>"
toolStatusClass = "bg-danger text-white"
Else
toolStatus = "<i class='zmdi zmdi-check-circle text-success'></i> OK"
toolStatusClass = ""
End If
If Not IsNull(rsTools("avg_deviation")) Then
toolAvgDev = FormatNumber(CDbl(rsTools("avg_deviation")), 4)
Else
toolAvgDev = "-"
End If
If Not IsNull(rsTools("max_deviation")) Then
toolMaxDev = FormatNumber(CDbl(rsTools("max_deviation")), 4)
Else
toolMaxDev = "-"
End If
Response.Write("<tr class='" & toolStatusClass & "'>")
Response.Write("<td><strong>" & Server.HTMLEncode(rsTools("toolnumber") & "") & "</strong></td>")
Response.Write("<td class='small'>" & Server.HTMLEncode(Left(rsTools("description") & "", 30)) & "</td>")
Response.Write("<td>" & rsTools("measurements") & "</td>")
Response.Write("<td>" & toolAvgDev & "</td>")
Response.Write("<td>" & toolMaxDev & "</td>")
Response.Write("<td>" & toolStatus & "</td>")
Response.Write("</tr>")
rsTools.MoveNext
Loop
End If
rsTools.Close
Set rsTools = Nothing
%>
</tbody>
</table>
</div>
<%
' Check for recent OOT events
Dim rsOOT, ootEventCount
strSQL2 = "SELECT COUNT(*) as cnt FROM udctooldata t " & _
"JOIN udcsessions s ON t.sessionid = s.sessionid " & _
"WHERE s.machinenumber = ? AND t.oot = 1 AND t.eventtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)"
Set rsOOT = ExecuteParameterizedQuery(objConn, strSQL2, Array(rs("machinenumber") & ""))
ootEventCount = 0
If Not rsOOT.EOF Then ootEventCount = CLng(rsOOT("cnt") & "0")
rsOOT.Close
Set rsOOT = Nothing
If ootEventCount > 0 Then
%>
<!-- Recent OOT Events -->
<h6 class="mb-2"><i class="zmdi zmdi-alert-triangle text-warning"></i> Recent Out-of-Tolerance Events (7 days)</h6>
<div class="table-responsive mb-3">
<table class="table table-hover table-sm">
<thead class="thead-light">
<tr>
<th>Time</th>
<th>Tool #</th>
<th>Description</th>
<th>Actual</th>
<th>Min/Max</th>
<th>Deviation</th>
</tr>
</thead>
<tbody>
<%
Dim rsOOTEvents
strSQL2 = "SELECT t.eventtime, t.toolnumber, t.description, " & _
"t.actualval, t.minval, t.maxval, t.deviation " & _
"FROM udctooldata t " & _
"JOIN udcsessions s ON t.sessionid = s.sessionid " & _
"WHERE s.machinenumber = ? AND t.oot = 1 AND t.eventtime >= DATE_SUB(NOW(), INTERVAL 7 DAY) " & _
"ORDER BY t.eventtime DESC LIMIT 10"
Set rsOOTEvents = ExecuteParameterizedQuery(objConn, strSQL2, Array(rs("machinenumber") & ""))
Do While Not rsOOTEvents.EOF
Response.Write("<tr class='bg-warning'>")
Response.Write("<td class='small'>" & Server.HTMLEncode(rsOOTEvents("eventtime") & "") & "</td>")
Response.Write("<td><strong>" & Server.HTMLEncode(rsOOTEvents("toolnumber") & "") & "</strong></td>")
Response.Write("<td class='small'>" & Server.HTMLEncode(Left(rsOOTEvents("description") & "", 25)) & "</td>")
Response.Write("<td>" & FormatNumber(CDbl(rsOOTEvents("actualval") & "0"), 4) & "</td>")
Response.Write("<td class='small'>" & FormatNumber(CDbl(rsOOTEvents("minval") & "0"), 4) & " / " & FormatNumber(CDbl(rsOOTEvents("maxval") & "0"), 4) & "</td>")
Response.Write("<td class='text-danger'><strong>" & FormatNumber(CDbl(rsOOTEvents("deviation") & "0"), 4) & "</strong></td>")
Response.Write("</tr>")
rsOOTEvents.MoveNext
Loop
rsOOTEvents.Close
Set rsOOTEvents = Nothing
%>
</tbody>
</table>
</div>
<%
End If ' ootEventCount > 0
Else ' toolMeasurements = 0
%>
<div class="alert alert-secondary">
<i class="zmdi zmdi-info-outline"></i> No tool measurement data available for this machine.
</div>
<%
End If ' toolMeasurements > 0
%>
<!-- Link to Full Dashboard -->
<div class="text-center">
<a href="./displayudc.asp?machine=<%=Server.URLEncode(rs("machinenumber") & "")%>" class="btn btn-primary">
<i class="zmdi zmdi-chart"></i> View Full UDC Dashboard
</a>
</div>
</div>
<% End If %>
</div>
</div>