Update pages to use pctypeid instead of machinetypeid IN (33-43)
- PCs identified by pctypeid IS NOT NULL instead of machinetypeid list - Equipment identified by pctypeid IS NULL instead of NOT IN list - Fixed devicecamera.asp: IDF dropdown uses machinetypeid 17, not 34 - Fixed displaypcs.asp: measuring tool filter uses pctypeid = 7 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -402,7 +402,7 @@
|
||||
<option value="">-- None --</option>
|
||||
<%
|
||||
Dim rsControlPCs
|
||||
strSQL = "SELECT machineid, machinenumber, hostname FROM machines WHERE machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) AND isactive = 1 ORDER BY machinenumber ASC"
|
||||
strSQL = "SELECT machineid, machinenumber, hostname FROM machines WHERE pctypeid IS NOT NULL AND isactive = 1 ORDER BY machinenumber ASC"
|
||||
Set rsControlPCs = objconn.Execute(strSQL)
|
||||
While Not rsControlPCs.EOF
|
||||
Dim controlPCDisplay
|
||||
|
||||
10
api.asp
10
api.asp
@@ -257,7 +257,7 @@ Sub UpdateCompleteAsset()
|
||||
' Check if PC exists
|
||||
Dim strSQL, rsResult, safeHostname, safeSerial
|
||||
safeHostname = Replace(hostname, "'", "''")
|
||||
strSQL = "SELECT machineid FROM machines WHERE hostname = '" & safeHostname & "' AND machinetypeid IN (33,34,35,36,37,38,39,40,41,42,43)"
|
||||
strSQL = "SELECT machineid FROM machines WHERE hostname = '" & safeHostname & "' AND pctypeid IS NOT NULL"
|
||||
Set rsResult = objConn.Execute(strSQL)
|
||||
If Err.Number <> 0 Then
|
||||
SendError debugMsg & "8-PC check failed: " & Err.Description
|
||||
@@ -850,7 +850,7 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT
|
||||
' Check if PC already exists (Phase 2: identify PCs by machinetypeid 33,34,35)
|
||||
Dim strSQL, rsResult, safeHostname
|
||||
safeHostname = Replace(hostname, "'", "''")
|
||||
strSQL = "SELECT machineid FROM machines WHERE hostname = '" & safeHostname & "' AND machinetypeid IN (33,34,35,36,37,38,39,40,41,42,43)"
|
||||
strSQL = "SELECT machineid FROM machines WHERE hostname = '" & safeHostname & "' AND pctypeid IS NOT NULL"
|
||||
Set rsResult = objConn.Execute(strSQL)
|
||||
|
||||
Dim machineid
|
||||
@@ -928,7 +928,7 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT
|
||||
"osid = " & sqlOsId & ", " & _
|
||||
"machinestatusid = " & sqlStatusId & ", " & _
|
||||
"lastupdated = NOW() " & _
|
||||
"WHERE machineid = " & CLng(machineid) & " AND machinetypeid IN (33,34,35,36,37,38,39,40,41,42,43)"
|
||||
"WHERE machineid = " & CLng(machineid) & " AND pctypeid IS NOT NULL"
|
||||
|
||||
LogToFile "UPDATE SQL built: " & Left(strSQL, 200) & "..."
|
||||
|
||||
@@ -1034,7 +1034,7 @@ Function GetMachineidByHostname(hostname)
|
||||
|
||||
Dim strSQL, rsResult, safeHostname
|
||||
safeHostname = Replace(hostname, "'", "''")
|
||||
strSQL = "SELECT machineid FROM machines WHERE hostname = '" & safeHostname & "' AND machinetypeid IN (33,34,35,36,37,38,39,40,41,42,43)"
|
||||
strSQL = "SELECT machineid FROM machines WHERE hostname = '" & safeHostname & "' AND pctypeid IS NOT NULL"
|
||||
Set rsResult = objConn.Execute(strSQL)
|
||||
|
||||
If Not rsResult.EOF Then
|
||||
@@ -1340,7 +1340,7 @@ Function CreatePCMachineRelationship(pcMachineid, machineNumber)
|
||||
' Find equipment by machine number (Phase 2: PCs are machinetypeid 33-43, Equipment is 1-32)
|
||||
Dim strSQL, rsResult, safeMachineNumber
|
||||
safeMachineNumber = Replace(machineNumber, "'", "''")
|
||||
strSQL = "SELECT machineid FROM machines WHERE machinenumber = '" & safeMachineNumber & "' AND machinetypeid NOT IN (33,34,35,36,37,38,39,40,41,42,43)"
|
||||
strSQL = "SELECT machineid FROM machines WHERE machinenumber = '" & safeMachineNumber & "' AND pctypeid IS NULL"
|
||||
LogToFile "CreatePCMachineRelationship: Executing SQL: " & strSQL
|
||||
Set rsResult = objConn.Execute(strSQL)
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ Set rsStatus = Nothing
|
||||
"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.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL"
|
||||
|
||||
' Apply filters
|
||||
whereClause = ""
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
<option value="">-- Select IDF --</option>
|
||||
<%
|
||||
Dim strSQL2, rsIDFs
|
||||
strSQL2 = "SELECT machineid, alias AS idfname FROM machines WHERE machinetypeid = 34 AND isactive = 1 ORDER BY alias"
|
||||
strSQL2 = "SELECT machineid, alias AS idfname FROM machines WHERE machinetypeid = 17 AND isactive = 1 ORDER BY alias"
|
||||
Set rsIDFs = objConn.Execute(strSQL2)
|
||||
|
||||
If rsIDFs.EOF Then
|
||||
|
||||
@@ -419,7 +419,7 @@ End If
|
||||
"JOIN machines m ON (mr.machineid = m.machineid OR mr.related_machineid = m.machineid) " & _
|
||||
"LEFT JOIN communications c ON m.machineid = c.machineid AND c.comstypeid IN (1, 3) AND c.isactive = 1 " & _
|
||||
"WHERE (mr.machineid = ? OR mr.related_machineid = ?) AND mr.relationshiptypeid = 3 " & _
|
||||
" AND m.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) AND m.machineid <> ? AND mr.isactive = 1 " & _
|
||||
" AND m.pctypeid IS NOT NULL AND m.machineid <> ? AND mr.isactive = 1 " & _
|
||||
"GROUP BY m.machineid, m.machinenumber, m.hostname"
|
||||
Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid, machineid))
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
"LEFT JOIN functionalaccounts ON machinetypes.functionalaccountid = functionalaccounts.functionalaccountid " & _
|
||||
"INNER JOIN vendors ON models.vendorid = vendors.vendorid " & _
|
||||
"LEFT JOIN printers ON machines.printerid = printers.printerid " & _
|
||||
"WHERE machines.machineid = " & CLng(machineid) & " AND machines.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE machines.machineid = " & CLng(machineid) & " AND machines.pctypeid IS NOT NULL"
|
||||
|
||||
Set rs = objConn.Execute(strSQL)
|
||||
|
||||
@@ -502,7 +502,7 @@ End If
|
||||
"LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _
|
||||
"LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _
|
||||
"WHERE (mr.machineid = ? OR mr.related_machineid = ?) AND mr.relationshiptypeid = 3 " & _
|
||||
" AND m.machinetypeid NOT IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) AND m.machineid <> ? AND mr.isactive = 1 " & _
|
||||
" AND m.pctypeid IS NULL AND m.machineid <> ? AND mr.isactive = 1 " & _
|
||||
"ORDER BY machinenumber"
|
||||
Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid, machineid))
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ deviceTypeFilter = Request.QueryString("devicetype")
|
||||
Dim rsUnlinked, unlinkedCount
|
||||
unlinkedCount = 0
|
||||
Set rsUnlinked = objConn.Execute("SELECT COUNT(*) as cnt FROM machines m " & _
|
||||
"WHERE m.machinetypeid IN (41, 42, 43) AND m.isactive = 1 " & _
|
||||
"WHERE m.pctypeid = 7 AND m.isactive = 1 " & _
|
||||
"AND NOT EXISTS (SELECT 1 FROM machinerelationships mr WHERE (mr.machineid = m.machineid OR mr.related_machineid = m.machineid) AND mr.relationshiptypeid = 3 AND mr.isactive = 1)")
|
||||
If Not rsUnlinked.EOF Then
|
||||
unlinkedCount = CLng(rsUnlinked("cnt") & "")
|
||||
@@ -141,7 +141,7 @@ Set rsStatus = Nothing
|
||||
"LEFT JOIN machinestatus ON m.machinestatusid = machinestatus.machinestatusid " & _
|
||||
"LEFT JOIN machinerelationships mr ON (mr.machineid = m.machineid OR mr.related_machineid = m.machineid) AND mr.isactive = 1 AND mr.relationshiptypeid = 3 " & _
|
||||
"LEFT JOIN machines eq ON (eq.machineid = mr.related_machineid OR eq.machineid = mr.machineid) AND eq.machineid <> m.machineid AND eq.machinetypeid < 33 " & _
|
||||
"WHERE m.isactive = 1 AND m.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL"
|
||||
|
||||
' Apply filters
|
||||
whereClause = ""
|
||||
@@ -162,7 +162,7 @@ Set rsStatus = Nothing
|
||||
|
||||
' Filter for specialized PCs needing equipment relationships
|
||||
If needsRelationshipFilter = "1" Then
|
||||
whereClause = whereClause & "AND m.machinetypeid IN (41, 42, 43) " & _
|
||||
whereClause = whereClause & "AND m.pctypeid = 7 " & _
|
||||
"AND NOT EXISTS (SELECT 1 FROM machinerelationships mr WHERE (mr.machineid = m.machineid OR mr.related_machineid = m.machineid) AND mr.relationshiptypeid = 3 AND mr.isactive = 1) "
|
||||
End If
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
'-------------------------------------------------------Is this the IP address of a PC---------------------------------------------------
|
||||
IF search <> "" THEN
|
||||
' PHASE 2: Query communications table instead of pc_network_interfaces
|
||||
strSQL = "SELECT c.machineid FROM communications c JOIN machines m ON c.machineid = m.machineid WHERE c.address='" &search &"' AND m.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) LIMIT 1"
|
||||
strSQL = "SELECT c.machineid FROM communications c JOIN machines m ON c.machineid = m.machineid WHERE c.address='" &search &"' AND m.pctypeid IS NOT NULL LIMIT 1"
|
||||
set rs = objconn.Execute(strSQL)
|
||||
IF NOT rs.EOF THEN
|
||||
machineid = rs("machineid")
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"LEFT JOIN vendors v ON mo.vendorid = v.vendorid " &_
|
||||
"LEFT JOIN businessunits bu ON m.businessunitid = bu.businessunitid " &_
|
||||
"LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " &_
|
||||
"WHERE m.machineid = ? AND m.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.machineid = ? AND m.pctypeid IS NOT NULL"
|
||||
|
||||
Dim cmd, rsMachine
|
||||
Set cmd = Server.CreateObject("ADODB.Command")
|
||||
|
||||
@@ -559,7 +559,7 @@
|
||||
<option value="">-- None --</option>
|
||||
<%
|
||||
Dim rsControlPCs
|
||||
strSQL = "SELECT machineid, machinenumber, hostname FROM machines WHERE machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) AND isactive = 1 ORDER BY machinenumber ASC"
|
||||
strSQL = "SELECT machineid, machinenumber, hostname FROM machines WHERE pctypeid IS NOT NULL AND isactive = 1 ORDER BY machinenumber ASC"
|
||||
Set rsControlPCs = objconn.Execute(strSQL)
|
||||
While Not rsControlPCs.EOF
|
||||
Dim controlPCDisplay, selectedControlPC
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"LEFT JOIN vendors v ON mo.vendorid = v.vendorid " &_
|
||||
"LEFT JOIN businessunits bu ON m.businessunitid = bu.businessunitid " &_
|
||||
"LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " &_
|
||||
"WHERE m.machineid = ? AND m.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.machineid = ? AND m.pctypeid IS NOT NULL"
|
||||
|
||||
Dim cmd, rsMachine
|
||||
Set cmd = Server.CreateObject("ADODB.Command")
|
||||
|
||||
@@ -133,7 +133,7 @@ Set rsStatus = Nothing
|
||||
"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.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL"
|
||||
|
||||
' Apply filters
|
||||
whereClause = ""
|
||||
|
||||
@@ -570,7 +570,7 @@
|
||||
<option value="">-- None --</option>
|
||||
<%
|
||||
Dim rsControlPCs
|
||||
strSQL = "SELECT machineid, machinenumber, hostname FROM machines WHERE machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) AND isactive = 1 ORDER BY machinenumber ASC"
|
||||
strSQL = "SELECT machineid, machinenumber, hostname FROM machines WHERE pctypeid IS NOT NULL AND isactive = 1 ORDER BY machinenumber ASC"
|
||||
Set rsControlPCs = objconn.Execute(strSQL)
|
||||
While Not rsControlPCs.EOF
|
||||
Dim controlPCDisplay, selectedControlPC
|
||||
|
||||
@@ -133,7 +133,7 @@ Set rsStatus = Nothing
|
||||
"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.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL"
|
||||
|
||||
' Apply filters
|
||||
whereClause = ""
|
||||
|
||||
2
pcs.asp
2
pcs.asp
@@ -133,7 +133,7 @@ Set rsStatus = Nothing
|
||||
"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.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
"WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL"
|
||||
|
||||
' Apply filters
|
||||
whereClause = ""
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
' Check if serial number already exists - PHASE 2: Use machines table
|
||||
Dim checkSQL, rsCheck, existingMachineID
|
||||
checkSQL = "SELECT machineid FROM machines WHERE serialnumber = ? AND machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
checkSQL = "SELECT machineid FROM machines WHERE serialnumber = ? AND pctypeid IS NOT NULL"
|
||||
Set rsCheck = ExecuteParameterizedQuery(objConn, checkSQL, Array(serialnumber))
|
||||
|
||||
If Not rsCheck.EOF Then
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
End If
|
||||
|
||||
' Add lastupdated timestamp and WHERE clause
|
||||
updateSQL = updateSQL & "lastupdated = NOW() WHERE machineid = ? AND machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
updateSQL = updateSQL & "lastupdated = NOW() WHERE machineid = ? AND pctypeid IS NOT NULL"
|
||||
paramList(paramIndex) = pcid
|
||||
|
||||
' Execute parameterized update
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
' Verify the PC exists using parameterized query - PHASE 2: Use machines table
|
||||
Dim checkSQL, rsCheck, cmdCheck
|
||||
checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machineid = ? AND machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machineid = ? AND pctypeid IS NOT NULL"
|
||||
Set cmdCheck = Server.CreateObject("ADODB.Command")
|
||||
cmdCheck.ActiveConnection = objConn
|
||||
cmdCheck.CommandText = checkSQL
|
||||
@@ -191,7 +191,7 @@
|
||||
|
||||
' Build UPDATE statement for PC using parameterized query - PHASE 2: Use machines table
|
||||
Dim strSQL, cmdUpdate
|
||||
strSQL = "UPDATE machines SET modelnumberid = ?, machinenumber = ?, lastupdated = NOW() WHERE machineid = ? AND machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43)"
|
||||
strSQL = "UPDATE machines SET modelnumberid = ?, machinenumber = ?, lastupdated = NOW() WHERE machineid = ? AND pctypeid IS NOT NULL"
|
||||
Set cmdUpdate = Server.CreateObject("ADODB.Command")
|
||||
cmdUpdate.ActiveConnection = objConn
|
||||
cmdUpdate.CommandText = strSQL
|
||||
|
||||
Reference in New Issue
Block a user