Replace machinetypeid 33-43 checks with pctypeid throughout codebase

- PCs now identified by pctypeid IS NOT NULL (not machinetypeid >= 33)
- Equipment identified by pctypeid IS NULL (not machinetypeid < 33)
- Updated 8 files: search.asp, savemachineedit.asp, displaymachine.asp,
  displaypc.asp, displaypcs.asp, machine_map.asp, displaymachines.asp, api.asp
- Simplified queries and removed redundant machinetypeid checks
- Updated all related comments to reflect new pattern

🤖 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 07:24:20 -05:00
parent a52dd2e932
commit 81f905f0b0
8 changed files with 26 additions and 39 deletions

View File

@@ -65,20 +65,16 @@
' ------------------------------- Search For Machine Number or Hostname ----------------------------------------------------------
' Also search by hostname for PCs, and get machinetypeid from models table to determine PC vs Equipment
strSQL = "SELECT m.machineid, m.hostname, mo.machinetypeid FROM machines m " & _
"LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _
' Also search by hostname for PCs, use pctypeid to determine PC vs Equipment
strSQL = "SELECT m.machineid, m.hostname, m.pctypeid FROM machines m " & _
"WHERE (m.machinenumber = ? OR m.alias LIKE ? OR m.hostname = ?) AND m.isactive = 1"
Set rs = ExecuteParameterizedQuery(objConn, strSQL, Array(search, "%" & search & "%", search))
If Not rs.EOF Then
machineid = rs("machineid")
Dim searchMachTypeId, searchIsPC, searchRedirectPage, searchHostname
searchMachTypeId = 0
If Not IsNull(rs("machinetypeid")) Then searchMachTypeId = CLng(rs("machinetypeid"))
searchHostname = rs("hostname") & ""
' PC if machinetypeid 33-43, OR if machinetypeid is 1 (default) and has a hostname
searchIsPC = (searchMachTypeId >= 33 And searchMachTypeId <= 43) Or (searchMachTypeId = 1 And searchHostname <> "")
Dim searchIsPC, searchRedirectPage
' PC if pctypeid IS NOT NULL
searchIsPC = Not IsNull(rs("pctypeid"))
rs.Close
Set rs = Nothing
@@ -493,10 +489,9 @@ rsNotif.Close
Set rsNotif = Nothing
' Now get Machines (by machine number, alias, notes, machine type, or vendor)
' NOTE: machinetypeid is now sourced from models table (models.machinetypeid) not machines table
' Also search by hostname for PCs
Dim rsMachines
strSQL = "SELECT m.machineid, m.machinenumber, m.alias, m.hostname, mo.machinetypeid, mt.machinetype " & _
strSQL = "SELECT m.machineid, m.machinenumber, m.alias, m.hostname, m.pctypeid, mt.machinetype " & _
"FROM machines m " & _
"LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _
"LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _
@@ -511,12 +506,9 @@ Response.Write("<!-- DEBUG: Checking machines for search term -->")
Do While Not rsMachines.EOF And totalCount < 100
' Determine display text - use hostname for PCs, machinenumber for equipment
' PCs have machinetypeid 33-43, OR machinetypeid 1 (default) with a hostname
Dim isPC, machTypeId, loopHostname
machTypeId = 0
If Not IsNull(rsMachines("machinetypeid")) Then machTypeId = CLng(rsMachines("machinetypeid"))
loopHostname = rsMachines("hostname") & ""
isPC = (machTypeId >= 33 And machTypeId <= 43) Or (machTypeId = 1 And loopHostname <> "")
' PCs identified by pctypeid IS NOT NULL
Dim isPC
isPC = Not IsNull(rsMachines("pctypeid"))
If isPC Then
machineDispText = rsMachines("hostname") & ""