api.asp: archive stale PC->equipment relationships on new PC self-registration
When a new PC POSTs updateCompleteAsset for a machine number, the previous PC's "Controls" relationship to that equipment is now soft-archived (isactive=0) before the new relationship is created. Prevents duplicate active relationships when PCs are replaced floor-wide. Display pages already filter on isactive=1 so archived rows just disappear from inventory views (history preserved). displaymachine.asp: added Controller field populated via the controllertypes join. displaypc.asp: fixed top-bar search bug - searching a machine number was returning the PC row instead of the machine. Three lookup queries now scope to pctypeid IS NOT NULL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
IF machinenumber <> "" THEN
|
||||
' Look up machineid by machinenumber
|
||||
Dim rsLookup, strLookupSQL
|
||||
strLookupSQL = "SELECT machineid FROM machines WHERE machinenumber = ? AND isactive = 1"
|
||||
strLookupSQL = "SELECT machineid FROM machines WHERE machinenumber = ? AND isactive = 1 AND pctypeid IS NOT NULL"
|
||||
Set rsLookup = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(machinenumber))
|
||||
IF NOT rsLookup.EOF THEN
|
||||
machineid = rsLookup("machineid")
|
||||
@@ -49,13 +49,13 @@
|
||||
' We have a machineid, but it might actually be a machine number
|
||||
' Try to look it up as a machineid first
|
||||
Dim rsCheck
|
||||
strLookupSQL = "SELECT machineid FROM machines WHERE machineid = ? AND isactive = 1"
|
||||
strLookupSQL = "SELECT machineid FROM machines WHERE machineid = ? AND isactive = 1 AND pctypeid IS NOT NULL"
|
||||
Set rsCheck = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(machineid))
|
||||
|
||||
' If no machine found with that machineid, try treating it as a machine number
|
||||
IF rsCheck.EOF THEN
|
||||
rsCheck.Close
|
||||
strLookupSQL = "SELECT machineid FROM machines WHERE machinenumber = ? AND isactive = 1"
|
||||
strLookupSQL = "SELECT machineid FROM machines WHERE machinenumber = ? AND isactive = 1 AND pctypeid IS NOT NULL"
|
||||
Set rsCheck = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(CStr(machineid)))
|
||||
IF NOT rsCheck.EOF THEN
|
||||
machineid = rsCheck("machineid")
|
||||
|
||||
Reference in New Issue
Block a user