Fix pctypeid in inline UpdateCompleteAsset, add HEATTREAT variant, add relationship notification

api.asp:
- Add pctypeid to inline UPDATE and INSERT statements in UpdateCompleteAsset
- Call GetPCTypeIdFromPCType to properly map pcType string to pctypeid
- Add "HEATTREAT" (no space) variant to GetPCTypeIdFromPCType function

displaypc.asp:
- Add relationship notification for PC types that can control equipment
  (CMM=5, Wax/Trace=6, Keyence=7, Genspect=8, Heat Treat=9, Part Marker=10)
- Shows info alert with link to Edit Machine page

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-09 10:36:08 -05:00
parent 1eb3aceeb4
commit 6785a51da0
2 changed files with 28 additions and 22 deletions

30
api.asp
View File

@@ -246,24 +246,14 @@ Sub UpdateCompleteAsset()
End If
debugMsg = debugMsg & "6-modelId=" & modelId & ","
' Get machine type ID
Select Case LCase(pcType)
Case "standard"
' Get machine type ID (all PCs use 33)
machineTypeId = 33
Case "engineer", "engineering"
machineTypeId = 34
Case "shopfloor", "shop floor"
machineTypeId = 35
Case "cmm"
machineTypeId = 41
Case "wax trace", "waxtrace", "wax"
machineTypeId = 42
Case "keyence", "measuring", "measuring tool"
machineTypeId = 43
Case Else
machineTypeId = 33
End Select
debugMsg = debugMsg & "7-typeId=" & machineTypeId & ","
debugMsg = debugMsg & "7-machineTypeId=" & machineTypeId & ","
' Get PC type ID from pcType string
Dim pctypeId
pctypeId = GetPCTypeIdFromPCType(pcType)
debugMsg = debugMsg & "7b-pctypeId=" & pctypeId & ","
' Check if PC exists
Dim strSQL, rsResult, safeHostname, safeSerial
@@ -308,7 +298,7 @@ Sub UpdateCompleteAsset()
Else
lastBootPart = ""
End If
strSQL = "UPDATE machines SET serialnumber='" & safeSerial & "', modelnumberid=" & modelId & ", machinetypeid=" & machineTypeId & ", osid=" & osid & ", isvnc=" & vncValue & ", iswinrm=" & winrmValue & lastBootPart & ", lastupdated=NOW() WHERE machineid=" & machineid
strSQL = "UPDATE machines SET serialnumber='" & safeSerial & "', modelnumberid=" & modelId & ", machinetypeid=" & machineTypeId & ", pctypeid=" & pctypeId & ", osid=" & osid & ", isvnc=" & vncValue & ", iswinrm=" & winrmValue & lastBootPart & ", lastupdated=NOW() WHERE machineid=" & machineid
objConn.Execute strSQL
If Err.Number <> 0 Then
SendError debugMsg & "10-UPDATE failed: " & Err.Description
@@ -348,7 +338,7 @@ Sub UpdateCompleteAsset()
lastBootColInsert = ""
lastBootValInsert = ""
End If
strSQL = "INSERT INTO machines (hostname, serialnumber, modelnumberid, machinetypeid, osid, machinestatusid, isvnc, iswinrm, lastupdated" & lastBootColInsert & ") VALUES ('" & safeHostname & "', '" & safeSerial & "', " & modelId & ", " & machineTypeId & ", " & osid & ", " & pcstatusid & ", " & vncValueInsert & ", " & winrmValueInsert & ", NOW()" & lastBootValInsert & ")"
strSQL = "INSERT INTO machines (hostname, serialnumber, modelnumberid, machinetypeid, pctypeid, osid, machinestatusid, isvnc, iswinrm, lastupdated" & lastBootColInsert & ") VALUES ('" & safeHostname & "', '" & safeSerial & "', " & modelId & ", " & machineTypeId & ", " & pctypeId & ", " & osid & ", " & pcstatusid & ", " & vncValueInsert & ", " & winrmValueInsert & ", NOW()" & lastBootValInsert & ")"
objConn.Execute strSQL
If Err.Number <> 0 Then
SendError debugMsg & "10-INSERT failed: " & Err.Description
@@ -2041,7 +2031,7 @@ Function GetPCTypeIdFromPCType(pcTypeString)
GetPCTypeIdFromPCType = 7
Case "GENSPECT", "EAS1000"
GetPCTypeIdFromPCType = 8 ' Genspect / EAS1000
Case "HEAT TREAT", "HEATTTREAT"
Case "HEAT TREAT", "HEATTTREAT", "HEATTEAT", "HEAT_TREAT", "HEATTREAT"
GetPCTypeIdFromPCType = 9
Case "PART MARKER", "PARTMARKER"
GetPCTypeIdFromPCType = 10

View File

@@ -253,6 +253,11 @@ If machineTypeVal = "" Then machineTypeVal = "N/A"
buVal = rs("businessunit") & ""
If buVal = "" Then buVal = "N/A"
' Get pctypeid for relationship notification
Dim pctypeidVal
pctypeidVal = 0
If Not IsNull(rs("pctypeid")) Then pctypeidVal = CLng(rs("pctypeid"))
%>
<p class="mb-2"><%=Server.HTMLEncode(serialNumVal)%></p>
<p class="mb-2"><%=Server.HTMLEncode(hostnameVal)%></p>
@@ -479,7 +484,18 @@ End If
</div>
<div class="tab-pane" id="relationships">
<h5 class="mb-3">Machine Relationships</h5>
<%
' Show notification for PC types that can have equipment relationships
' CMM=5, Wax/Trace=6, Keyence=7, Genspect=8, Heat Treat=9, Part Marker=10
If pctypeidVal >= 5 And pctypeidVal <= 10 Then
%>
<div class="alert alert-info mb-3">
<i class="zmdi zmdi-info-outline"></i>
This PC type can be assigned to control equipment. Use <a href="editmachine.asp?machineid=<%=machineid%>">Edit Machine</a> to set up relationships.
</div>
<%
End If
%>
<!-- Machines Controlled by This PC -->
<h6 class="mt-3 mb-2"><i class="zmdi zmdi-settings"></i> Machines Controlled by This PC</h6>
<div class="table-responsive mb-4">