diff --git a/.gitignore b/.gitignore index a35d494..e5a154c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,16 @@ tests/test_results_*.csv installers/ v2/installers/ +# Database backups (should not be version-controlled) +shopdb-database-backup-*.sql +database-backup-*.sql +employee*-database-backup-*.sql +shopdb_backup_*.sql + +# Backup/scratch files +*.bak +*.pdf + # OS files .DS_Store Thumbs.db diff --git a/CLAUDE.md b/CLAUDE.md index 3ed3873..061fda9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,7 +23,7 @@ ShopDB is a Classic ASP/VBScript web application for managing manufacturing shop - Production IIS server - Production IIS logs - Production MySQL database -- Zabbix server (10.48.130.113) +- Zabbix server (zabbix.compute.geaerospace.net) - Employee database (wjf_employees) - used by displayprofile.asp (can update code, cannot test) For production tasks, user must: diff --git a/addmodel.asp b/addmodel.asp index 9c0d2dd..3a5eb42 100644 --- a/addmodel.asp +++ b/addmodel.asp @@ -138,17 +138,23 @@ <% Dim rsMachineTypes, strMTSQL - strMTSQL = "SELECT machinetypeid, machinetype, category FROM machinetypes WHERE isactive = 1 ORDER BY category, machinetype ASC" + strMTSQL = "SELECT machinetypeid, machinetype, " & _ + "CASE " & _ + " WHEN machinetypeid BETWEEN 1 AND 15 OR machinetypeid BETWEEN 21 AND 25 OR machinetypeid = 45 OR machinetypeid = 47 THEN 'Equipment' " & _ + " WHEN machinetypeid BETWEEN 16 AND 20 OR machinetypeid = 46 THEN 'Network' " & _ + " ELSE 'Other' " & _ + "END AS category " & _ + "FROM machinetypes WHERE isactive = 1 AND machinetypeid NOT IN (1, 33, 44) ORDER BY category, machinetype ASC" Set rsMachineTypes = objconn.Execute(strMTSQL) Dim lastCategory lastCategory = "" While Not rsMachineTypes.EOF - If rsMachineTypes("category") <> lastCategory Then + If rsMachineTypes("category") & "" <> lastCategory Then If lastCategory <> "" Then Response.Write("") - Response.Write("") - lastCategory = rsMachineTypes("category") + Response.Write("") + lastCategory = rsMachineTypes("category") & "" End If - Response.Write("") + Response.Write("") rsMachineTypes.MoveNext Wend If lastCategory <> "" Then Response.Write("") diff --git a/api.asp b/api.asp index 715f55d..e9c35ef 100644 --- a/api.asp +++ b/api.asp @@ -957,7 +957,7 @@ Sub GetPCMachineRelationships() Dim rsRel, strSQL, relList, relCount, relData - strSQL = "SELECT " & _ + strSQL = "SELECT DISTINCT " & _ "pc.machineid AS pc_id, " & _ "pc.machinenumber AS hostname, " & _ "c.address AS ip, " & _ @@ -978,7 +978,31 @@ Sub GetPCMachineRelationships() "AND eq.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ - "ORDER BY eq.machinenumber" + "UNION " & _ + "SELECT DISTINCT " & _ + "pc.machineid AS pc_id, " & _ + "pc.machinenumber AS hostname, " & _ + "c.address AS ip, " & _ + "dp.machineid AS machine_id, " & _ + "dp.machinenumber AS machine_number, " & _ + "v.vendor AS vendor, " & _ + "m.modelnumber AS model " & _ + "FROM machinerelationships dual_rel " & _ + "JOIN relationshiptypes drt ON dual_rel.relationshiptypeid = drt.relationshiptypeid AND drt.relationshiptype = 'Dualpath' " & _ + "JOIN machines dp ON dual_rel.related_machineid = dp.machineid " & _ + "JOIN machinerelationships mr ON mr.machineid = dual_rel.machineid AND mr.isactive = 1 " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid AND rt.relationshiptype IN ('Controls', 'Controlled By') " & _ + "JOIN machines pc ON mr.related_machineid = pc.machineid AND pc.pctypeid IS NOT NULL " & _ + "LEFT JOIN communications c ON pc.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ + "LEFT JOIN models m ON dp.modelnumberid = m.modelnumberid " & _ + "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ + "WHERE dual_rel.isactive = 1 " & _ + "AND dp.machinenumber IS NOT NULL AND dp.machinenumber != '' " & _ + "AND dp.machinenumber REGEXP '^[0-9]{4}$' " & _ + "AND dp.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ + "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ + "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ + "ORDER BY machine_number" Set rsRel = objConn.Execute(strSQL) diff --git a/displaylocations.asp b/displaylocations.asp new file mode 100644 index 0000000..cd344a1 --- /dev/null +++ b/displaylocations.asp @@ -0,0 +1,353 @@ +<%@ Language=VBScript %> +<% +Option Explicit +Dim theme, strSQL, rs, objConn, rsRel +%> + + + + + + + +<% + theme = Request.Cookies("theme") + IF theme = "" THEN + theme="bg-theme1" + END IF +%> + + + +
+ + +
+ + + + +
+
+
+
+
+
+
+
+
+ Locations +
+
+ +<% +' Get all active locations with PC counts and relationship counts +strSQL = "SELECT m.machineid, m.machinenumber, m.alias, m.machinenotes, m.mapleft, m.maptop, " & _ + " (SELECT COUNT(*) FROM machinerelationships mr " & _ + " JOIN machines pc ON mr.related_machineid = pc.machineid " & _ + " WHERE mr.machineid = m.machineid AND mr.isactive = 1 AND pc.pctypeid IS NOT NULL AND pc.isactive = 1) AS pc_count, " & _ + " (SELECT COUNT(*) FROM machinerelationships mr " & _ + " JOIN machines child ON mr.related_machineid = child.machineid " & _ + " WHERE mr.machineid = m.machineid AND mr.isactive = 1 AND child.islocationonly = 1 AND child.isactive = 1) AS sublocation_count " & _ + "FROM machines m " & _ + "WHERE m.islocationonly = 1 AND m.isactive = 1 AND m.machinenumber <> 'TBD' " & _ + "ORDER BY m.machinenumber" +Set rs = objConn.Execute(strSQL) + +' Build a dictionary of all relationships for location machines +' Key = machineid, Value = array of relationship info +Dim relDict, relSQL +Set relDict = Server.CreateObject("Scripting.Dictionary") + +relSQL = "SELECT mr.machineid AS loc_id, child.machineid AS child_id, child.machinenumber AS child_name, " & _ + " child.hostname AS child_hostname, child.alias AS child_alias, " & _ + " child.pctypeid, child.islocationonly, " & _ + " rt.relationshiptype, rt.relationshiptypeid, " & _ + " GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') AS child_ip " & _ + "FROM machinerelationships mr " & _ + "JOIN machines loc ON mr.machineid = loc.machineid " & _ + "JOIN machines child ON mr.related_machineid = child.machineid " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "LEFT JOIN communications c ON child.machineid = c.machineid AND c.comstypeid IN (1, 3) AND c.isactive = 1 " & _ + "WHERE loc.islocationonly = 1 AND loc.isactive = 1 AND mr.isactive = 1 AND child.isactive = 1 " & _ + "GROUP BY mr.machineid, child.machineid, child.machinenumber, child.hostname, child.alias, " & _ + " child.pctypeid, child.islocationonly, rt.relationshiptype, rt.relationshiptypeid " & _ + "ORDER BY mr.machineid, rt.relationshiptypeid, child.machinenumber" +Set rsRel = objConn.Execute(relSQL) + +Dim curLocId +Do While Not rsRel.EOF + curLocId = CStr(rsRel("loc_id")) + If Not relDict.Exists(curLocId) Then + relDict.Add curLocId, "" + End If + ' Build pipe-delimited entries: child_id|child_name|child_hostname|child_alias|child_ip|pctypeid|islocationonly|relationshiptype + Dim entry + entry = rsRel("child_id") & "|" & (rsRel("child_name") & "") & "|" & (rsRel("child_hostname") & "") & "|" & _ + (rsRel("child_alias") & "") & "|" & (rsRel("child_ip") & "") & "|" & _ + (rsRel("pctypeid") & "") & "|" & (rsRel("islocationonly") & "") & "|" & (rsRel("relationshiptype") & "") + If relDict(curLocId) <> "" Then + relDict(curLocId) = relDict(curLocId) & "~" & entry + Else + relDict(curLocId) = entry + End If + rsRel.MoveNext +Loop +rsRel.Close +Set rsRel = Nothing +%> + +
+ + + + + + + + + + + + + + +<% +Do While Not rs.EOF + Dim locName, locAlias, locNotes, pcCount, subCount, hasMap, mid, totalRels + mid = rs("machineid") + locName = rs("machinenumber") & "" + locAlias = rs("alias") & "" + locNotes = rs("machinenotes") & "" + pcCount = CLng(rs("pc_count") & "") + subCount = CLng(rs("sublocation_count") & "") + hasMap = Not (IsNull(rs("mapleft")) Or IsNull(rs("maptop"))) + totalRels = pcCount + subCount + + ' Check if this location has any relationships in our dict + Dim hasRels, midStr + midStr = CStr(mid) + hasRels = relDict.Exists(midStr) And relDict(midStr) <> "" +%> + class="loc-parent" data-mid="<%=mid%>" style="cursor:pointer;"<% End If %>> + + + + + + + + + +<% + ' Render hidden detail rows for this location's relationships + If hasRels Then + Dim entries, i, parts + entries = Split(relDict(midStr), "~") + For i = 0 To UBound(entries) + parts = Split(entries(i), "|") + ' parts: 0=child_id, 1=child_name, 2=child_hostname, 3=child_alias, 4=child_ip, 5=pctypeid, 6=islocationonly, 7=relationshiptype + Dim cId, cName, cHost, cAlias, cIp, cIsPC, cIsLoc, cRelType, cBadgeClass, cIcon, cLink + cId = parts(0) + cName = parts(1) + cHost = parts(2) + cAlias = parts(3) + cIp = parts(4) + cIsPC = (parts(5) <> "") + cIsLoc = (parts(6) = "1" Or parts(6) = "True") + cRelType = parts(7) + + ' Determine icon and badge + If cIsLoc Then + cIcon = "zmdi zmdi-pin text-info" + cBadgeClass = "badge-info" + cLink = "displaymachine.asp?machineid=" & cId + ElseIf cIsPC Then + cIcon = "zmdi zmdi-desktop-windows text-primary" + cBadgeClass = "badge-primary" + cLink = "displaypc.asp?machineid=" & cId + Else + cIcon = "zmdi zmdi-memory text-warning" + cBadgeClass = "badge-warning" + cLink = "displaymachine.asp?machineid=" & cId + End If + + ' Display name: use hostname for PCs if available, else machinenumber + Dim displayName + If cIsPC And cHost <> "" Then + displayName = cHost + Else + displayName = cName + End If +%> + + + + + + + + + +<% + Next + End If + + rs.MoveNext +Loop +rs.Close +Set rs = Nothing +Set relDict = Nothing +%> + +
LocationAliasPCsSub-locationsMapNotesActions
+<% If hasRels Then %> + +<% End If %> + + + <%=Server.HTMLEncode(locName)%> + + <%=Server.HTMLEncode(locAlias)%> +<% If pcCount > 0 Then %> + <%=pcCount%> +<% Else %> + 0 +<% End If %> + +<% If subCount > 0 Then %> + <%=subCount%> +<% Else %> + 0 +<% End If %> + +<% If hasMap Then %> + +<% Else %> + +<% End If %> + <% + If Len(locNotes) > 40 Then + Response.Write(Server.HTMLEncode(Left(locNotes, 40)) & "...") + Else + Response.Write(Server.HTMLEncode(locNotes)) + End If + %> + + + + + + +
+
+ +
+
+
+
+
+
+ + + + + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +<% + objConn.Close +%> diff --git a/displaymachine.asp b/displaymachine.asp index fb67272..22fa78b 100644 --- a/displaymachine.asp +++ b/displaymachine.asp @@ -83,7 +83,7 @@ "machines.modelnumberid, machines.businessunitid, machines.printerid, machines.pctypeid, " & _ "machines.loggedinuser, machines.osid, machines.machinestatusid, " & _ "machines.controllertypeid, machines.controllerosid, machines.requires_manual_machine_config, " & _ - "machines.lastupdated, machines.fqdn, " & _ + "machines.lastupdated, machines.fqdn, machines.islocationonly, " & _ "machinetypes.machinetype, " & _ "models.modelnumber, models.image, models.machinetypeid, " & _ "businessunits.businessunit, " & _ @@ -407,7 +407,44 @@ End If
Machine Relationships
- +<% + ' === Connected PCs (direct + inherited via dualpath) === + strSQL2 = "SELECT m.machineid, m.machinenumber, m.hostname, rt.relationshiptype, " & _ + "GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') as address " & _ + "FROM machinerelationships mr " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "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 m.pctypeid IS NOT NULL AND m.machineid <> ? AND mr.isactive = 1 " & _ + " AND rt.relationshiptype NOT IN ('Stored At', 'Contains') " & _ + "GROUP BY m.machineid, m.machinenumber, m.hostname, rt.relationshiptype " & _ + "UNION " & _ + "SELECT pc.machineid, pc.machinenumber, pc.hostname, 'Via Dualpath' as relationshiptype, " & _ + "GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') as address " & _ + "FROM machinerelationships dual_rel " & _ + "JOIN relationshiptypes drt ON dual_rel.relationshiptypeid = drt.relationshiptypeid AND drt.relationshiptype = 'Dualpath' " & _ + "JOIN machinerelationships mr2 ON mr2.isactive = 1 " & _ + " AND ((dual_rel.related_machineid = mr2.machineid AND dual_rel.machineid = ?) " & _ + " OR (dual_rel.machineid = mr2.machineid AND dual_rel.related_machineid = ?)) " & _ + "JOIN machines pc ON (mr2.machineid = pc.machineid OR mr2.related_machineid = pc.machineid) " & _ + " AND pc.pctypeid IS NOT NULL AND pc.machineid <> ? " & _ + "JOIN relationshiptypes rt2 ON mr2.relationshiptypeid = rt2.relationshiptypeid " & _ + " AND rt2.relationshiptype NOT IN ('Stored At', 'Contains', 'Dualpath') " & _ + "LEFT JOIN communications c ON pc.machineid = c.machineid AND c.comstypeid IN (1, 3) AND c.isactive = 1 " & _ + "WHERE dual_rel.isactive = 1 " & _ + " AND (dual_rel.machineid = ? OR dual_rel.related_machineid = ?) " & _ + " AND pc.machineid NOT IN ( " & _ + " SELECT m2.machineid FROM machinerelationships mr3 " & _ + " JOIN machines m2 ON (mr3.machineid = m2.machineid OR mr3.related_machineid = m2.machineid) " & _ + " WHERE (mr3.machineid = ? OR mr3.related_machineid = ?) AND m2.pctypeid IS NOT NULL AND m2.machineid <> ? AND mr3.isactive = 1) " & _ + "GROUP BY pc.machineid, pc.machinenumber, pc.hostname " & _ + "ORDER BY relationshiptype, hostname" + Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid, machineid, machineid, machineid, machineid, machineid, machineid, machineid, machineid, machineid)) + + Dim pcHostname, pcIP, pcMachineID, pcLocation, pcRelType + If Not rs2.EOF Then +%>
Connected PCs
@@ -421,25 +458,6 @@ End If <% - ' Query ALL PCs related to this machine via machinerelationships - ' Check both directions - the PC is identified by pctypeid IS NOT NULL - ' Use GROUP_CONCAT to combine multiple IPs into one row per PC - strSQL2 = "SELECT m.machineid, m.machinenumber, m.hostname, rt.relationshiptype, " & _ - "GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') as address " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "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 m.pctypeid IS NOT NULL AND m.machineid <> ? AND mr.isactive = 1 " & _ - "GROUP BY m.machineid, m.machinenumber, m.hostname, rt.relationshiptype " & _ - "ORDER BY rt.relationshiptype, m.hostname" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid, machineid)) - - Dim pcHostname, pcIP, pcMachineID, pcLocation, pcRelType - If rs2.EOF Then - Response.Write("") - Else Do While Not rs2.EOF pcHostname = rs2("hostname") & "" pcIP = rs2("address") & "" @@ -451,7 +469,6 @@ End If If pcIP = "" Then pcIP = "N/A" If pcLocation = "" Then pcLocation = "N/A" - ' Badge color based on relationship type Dim pcRelBadge Select Case LCase(pcRelType) Case "controls" @@ -472,15 +489,27 @@ End If Response.Write("") rs2.MoveNext Loop - End If - rs2.Close - Set rs2 = Nothing %>
No connected PCs
+<% + End If + rs2.Close + Set rs2 = Nothing - + ' === Machines Controlled === + strSQL2 = "SELECT m.machineid, m.machinenumber, mt.machinetype, mo.modelnumber, rt.relationshiptype " & _ + "FROM machinerelationships mr " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "JOIN machines m ON mr.related_machineid = m.machineid " & _ + "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ + "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ + "WHERE mr.machineid = ? AND rt.relationshiptype NOT IN ('Controls', 'Dualpath', 'Connected To', 'Stored At', 'Contains') AND mr.isactive = 1" + Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) + + If Not rs2.EOF Then +%>
Machines Controlled by This Machine
@@ -494,20 +523,6 @@ End If <% - ' Query other machines related to this one (excluding Controls which is shown in "Controlled By PC" section) - ' This shows relationships like Cluster Member, Backup For, Master-Slave, etc. - strSQL2 = "SELECT m.machineid, m.machinenumber, mt.machinetype, mo.modelnumber, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.related_machineid = m.machineid " & _ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ - "WHERE mr.machineid = ? AND rt.relationshiptype NOT IN ('Controls', 'Dualpath', 'Connected To') AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else Do While Not rs2.EOF Dim ctrlMachineNum, ctrlType, ctrlModel, ctrlMachineID ctrlMachineNum = rs2("machinenumber") & "" @@ -526,17 +541,29 @@ End If Response.Write("") rs2.MoveNext Loop - End If - rs2.Close - Set rs2 = Nothing %>
This machine does not control any other machines
+<% + End If + rs2.Close + Set rs2 = Nothing - + ' === Dualpath Relationships === + strSQL2 = "SELECT m.machineid, m.machinenumber, mt.machinetype, mo.modelnumber, rt.relationshiptype " & _ + "FROM machinerelationships mr " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "JOIN machines m ON mr.related_machineid = m.machineid " & _ + "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ + "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ + "WHERE mr.machineid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1" + Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) + + If Not rs2.EOF Then +%>
Dualpath / Redundant Machines
-
+
@@ -548,19 +575,6 @@ End If <% - ' Query dualpath relationships - strSQL2 = "SELECT m.machineid, m.machinenumber, mt.machinetype, mo.modelnumber, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.related_machineid = m.machineid " & _ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ - "WHERE mr.machineid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else Do While Not rs2.EOF Dim dualMachineNum, dualType, dualModel, dualMachineID dualMachineNum = rs2("machinenumber") & "" @@ -579,17 +593,42 @@ End If Response.Write("") rs2.MoveNext Loop - End If - rs2.Close - Set rs2 = Nothing %>
No dualpath relationships
+<% + End If + rs2.Close + Set rs2 = Nothing - + ' === Network Connections === + ' Query both directions for Connected To relationships + Dim hasNetConn + hasNetConn = False + + strSQL2 = "SELECT m.machineid, m.machinenumber, m.alias, mt.machinetype, rt.relationshiptype, 'to' AS direction " & _ + "FROM machinerelationships mr " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "LEFT JOIN machines m ON mr.related_machineid = m.machineid " & _ + "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ + "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ + "WHERE mr.machineid = ? AND rt.relationshiptype = 'Connected To' AND mr.isactive = 1 " & _ + "UNION ALL " & _ + "SELECT m.machineid, m.machinenumber, m.alias, mt.machinetype, rt.relationshiptype, 'from' AS direction " & _ + "FROM machinerelationships mr " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "LEFT JOIN machines m ON mr.machineid = m.machineid " & _ + "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ + "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ + "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Connected To' AND mr.isactive = 1" + Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid)) + + If Not rs2.EOF Then + hasNetConn = True +%>
Network Connections
-
+
@@ -601,66 +640,120 @@ End If <% - ' Query devices this machine is connected to (e.g., Camera -> IDF) - strSQL2 = "SELECT m.machineid, m.machinenumber, m.alias, mt.machinetype, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "LEFT JOIN machines m ON mr.related_machineid = m.machineid " & _ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ - "WHERE mr.machineid = ? AND rt.relationshiptype = 'Connected To' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If Not rs2.EOF Then While Not rs2.EOF - Dim connAlias, connType + Dim connAlias, connType, connDir connAlias = "" : If Not IsNull(rs2("alias")) Then connAlias = rs2("alias") & "" connType = "" : If Not IsNull(rs2("machinetype")) Then connType = rs2("machinetype") & "" + connDir = rs2("direction") & "" Response.Write("") Response.Write("") Response.Write("") Response.Write("") - Response.Write("") + If connDir = "from" Then + Response.Write("") + Else + Response.Write("") + End If Response.Write("") rs2.MoveNext Wend - Else - Response.Write("") - End If - rs2.Close - - ' Query devices connected to this machine (e.g., IDF -> Cameras) - strSQL2 = "SELECT m.machineid, m.machinenumber, m.alias, mt.machinetype, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "LEFT JOIN machines m ON mr.machineid = m.machineid " & _ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ - "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Connected To' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If Not rs2.EOF Then - While Not rs2.EOF - Dim connToAlias, connToType - connToAlias = "" : If Not IsNull(rs2("alias")) Then connToAlias = rs2("alias") & "" - connToType = "" : If Not IsNull(rs2("machinetype")) Then connToType = rs2("machinetype") & "" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Wend - End If - rs2.Close - Set rs2 = Nothing %>
" & Server.HTMLEncode(rs2("machinenumber") & "") & "" & Server.HTMLEncode(connAlias) & "" & Server.HTMLEncode(connType) & "" & Server.HTMLEncode(rs2("relationshiptype") & "") & "Connected From" & Server.HTMLEncode(rs2("relationshiptype") & "") & "
No network connections
" & Server.HTMLEncode(rs2("machinenumber") & "") & "" & Server.HTMLEncode(connToAlias) & "" & Server.HTMLEncode(connToType) & "Connected From
+<% + End If + rs2.Close + Set rs2 = Nothing +%> + +<% + ' Location-specific section: show stored items and sub-locations + Dim isLoc + isLoc = rs("islocationonly") & "" + If isLoc = "1" Or isLoc = "True" Then +%> + +
Stored Items & Sub-locations
+
+ + + + + + + + + + +<% + strSQL2 = "SELECT m.machineid, m.machinenumber, m.hostname, m.alias, m.pctypeid, m.islocationonly, " & _ + "rt.relationshiptype, mt.machinetype, " & _ + "GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') AS address " & _ + "FROM machinerelationships mr " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ + "JOIN machines m ON mr.related_machineid = m.machineid " & _ + "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ + "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ + "LEFT JOIN communications c ON m.machineid = c.machineid AND c.comstypeid IN (1, 3) AND c.isactive = 1 " & _ + "WHERE mr.machineid = ? AND rt.relationshiptype IN ('Stored At', 'Contains') AND mr.isactive = 1 AND m.isactive = 1 " & _ + "GROUP BY m.machineid, m.machinenumber, m.hostname, m.alias, m.pctypeid, m.islocationonly, rt.relationshiptype, mt.machinetype " & _ + "ORDER BY rt.relationshiptype, m.machinenumber" + Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) + + If rs2.EOF Then + Response.Write("") + Else + Do While Not rs2.EOF + Dim storedName, storedType, storedIP, storedRelType, storedBadge, storedLink, storedIcon + storedRelType = rs2("relationshiptype") & "" + + If (rs2("islocationonly") & "") = "1" Or (rs2("islocationonly") & "") = "True" Then + storedName = rs2("machinenumber") & "" + storedType = "Sub-location" + storedIcon = "zmdi-pin" + storedBadge = "badge-info" + storedLink = "displaymachine.asp?machineid=" & rs2("machineid") + ElseIf rs2("pctypeid") & "" <> "" Then + storedName = rs2("hostname") & "" + If storedName = "" Then storedName = rs2("machinenumber") & "" + storedType = "PC" + storedIcon = "zmdi-desktop-windows" + storedBadge = "badge-primary" + storedLink = "displaypc.asp?machineid=" & rs2("machineid") + Else + storedName = rs2("machinenumber") & "" + storedType = rs2("machinetype") & "" + If storedType = "" Then storedType = "Equipment" + storedIcon = "zmdi-memory" + storedBadge = "badge-warning" + storedLink = "displaymachine.asp?machineid=" & rs2("machineid") + End If + + storedIP = rs2("address") & "" + If storedIP = "" Then storedIP = "N/A" + + Response.Write("") + Response.Write("") + Response.Write("") + Response.Write("") + Response.Write("") + Response.Write("") + rs2.MoveNext + Loop + End If + rs2.Close + Set rs2 = Nothing +%> + +
NameTypeIP / InfoRelationship
No stored items or sub-locations
" & Server.HTMLEncode(storedName) & "") + If rs2("alias") & "" <> "" Then Response.Write(" (" & Server.HTMLEncode(rs2("alias") & "") & ")") + Response.Write("" & Server.HTMLEncode(storedType) & "" & storedIP & "" & Server.HTMLEncode(storedRelType) & "
+
+<% + End If +%>
Compliance & Security
diff --git a/displaypc.asp b/displaypc.asp index 452156d..56adb09 100644 --- a/displaypc.asp +++ b/displaypc.asp @@ -524,20 +524,6 @@ End If <% End If %> - -
Connected Equipment
-
- - - - - - - - - - - <% ' Query ALL equipment related to this PC via machinerelationships ' Check both directions - the equipment is identified by pctypeid IS NULL @@ -552,9 +538,22 @@ End If "ORDER BY rt.relationshiptype, m.machinenumber" Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid, machineid)) - If rs2.EOF Then - Response.Write("") - Else + If Not rs2.EOF Then +%> +
Connected Equipment
+
+
Machine NumberTypeModelLocationRelationship
No connected equipment
+ + + + + + + + + + +<% Do While Not rs2.EOF Dim ctrlMachineNum, ctrlType, ctrlModel, ctrlMachineID, ctrlRelType ctrlMachineNum = rs2("machinenumber") & "" @@ -567,7 +566,6 @@ End If If ctrlType = "" Then ctrlType = "N/A" If ctrlModel = "" Then ctrlModel = "N/A" - ' Badge color based on relationship type Dim ctrlRelBadge Select Case LCase(ctrlRelType) Case "controls" @@ -589,13 +587,15 @@ End If Response.Write("") rs2.MoveNext Loop - End If - rs2.Close - Set rs2 = Nothing %>
Machine NumberTypeModelLocationRelationship
+<% + End If + rs2.Close + Set rs2 = Nothing +%>
Compliance & Security
diff --git a/editmachine.asp b/editmachine.asp index 7839c14..105a9e6 100644 --- a/editmachine.asp +++ b/editmachine.asp @@ -141,6 +141,26 @@ Set rsDualpath = Nothing Set cmd = Nothing + ' Load parent location (this machine is contained by a location) + Dim parentlocationid + parentlocationid = "" + strSQL = "SELECT mr.machineid AS parentid FROM machinerelationships mr " &_ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ + "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Contains' AND mr.isactive = 1" + Set cmd = Server.CreateObject("ADODB.Command") + cmd.ActiveConnection = objConn + cmd.CommandText = strSQL + cmd.CommandType = 1 + cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) + Dim rsParentLoc + Set rsParentLoc = cmd.Execute + If NOT rsParentLoc.EOF Then + If NOT IsNull(rsParentLoc("parentid")) Then parentlocationid = rsParentLoc("parentid") + End If + rsParentLoc.Close + Set rsParentLoc = Nothing + Set cmd = Nothing + ' Load compliance data Dim thirdpartymanaged, thirdpartymanager, otassetsystem, dodassettype thirdpartymanaged = "NA" : thirdpartymanager = "" : otassetsystem = "" : dodassettype = "" @@ -589,7 +609,7 @@ <% Dim rsDualpathList - strSQL = "SELECT machineid, machinenumber, alias FROM machines WHERE pctypeid IS NULL AND isactive = 1 AND machineid <> ? ORDER BY machinenumber ASC" + strSQL = "SELECT machineid, machinenumber, alias FROM machines WHERE pctypeid IS NULL AND isactive = 1 AND (islocationonly IS NULL OR islocationonly = 0) AND machineid <> ? ORDER BY machinenumber ASC" Set cmd = Server.CreateObject("ADODB.Command") cmd.ActiveConnection = objConn cmd.CommandText = strSQL @@ -620,6 +640,38 @@ Select a backup/redundant machine (creates bidirectional relationship)
+
+ + + Select a location that contains this machine (e.g., IT Closet, Bin, Shelf) +
+
diff --git a/editpc.asp b/editpc.asp index ce64f1c..2939f26 100644 --- a/editpc.asp +++ b/editpc.asp @@ -146,6 +146,26 @@ Set rsDualpath = Nothing Set cmd = Nothing + ' Load parent location (this PC is contained by a location) + Dim parentlocationid + parentlocationid = "" + strSQL = "SELECT mr.machineid AS parentid FROM machinerelationships mr " &_ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ + "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Contains' AND mr.isactive = 1" + Set cmd = Server.CreateObject("ADODB.Command") + cmd.ActiveConnection = objConn + cmd.CommandText = strSQL + cmd.CommandType = 1 + cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) + Dim rsParentLoc + Set rsParentLoc = cmd.Execute + If NOT rsParentLoc.EOF Then + If NOT IsNull(rsParentLoc("parentid")) Then parentlocationid = rsParentLoc("parentid") + End If + rsParentLoc.Close + Set rsParentLoc = Nothing + Set cmd = Nothing + ' Load compliance data Dim thirdpartymanaged, thirdpartymanager, otassetsystem, dodassettype thirdpartymanaged = "NA" : thirdpartymanager = "" : otassetsystem = "" : dodassettype = "" @@ -621,7 +641,7 @@ Set rsMachineStatus = Nothing End Select strSQL = "SELECT m.machineid, m.machinenumber, m.alias FROM machines m " &_ "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " &_ - "WHERE m.pctypeid IS NULL AND m.isactive = 1" & equipmentTypeFilter & " ORDER BY m.machinenumber ASC" + "WHERE m.pctypeid IS NULL AND m.isactive = 1 AND (m.islocationonly IS NULL OR m.islocationonly = 0)" & equipmentTypeFilter & " ORDER BY m.machinenumber ASC" Set rsControlPCs = objconn.Execute(strSQL) While Not rsControlPCs.EOF Dim controlPCDisplay, selectedControlPC @@ -653,7 +673,37 @@ Set rsMachineStatus = Nothing %>
- +
+ + + Select a location that contains this PC (e.g., IT Closet) +
diff --git a/includes/config.asp b/includes/config.asp index d293faf..7a3e9ea 100644 Binary files a/includes/config.asp and b/includes/config.asp differ diff --git a/includes/config.asp.example b/includes/config.asp.example index ce44125..e3233d3 100644 --- a/includes/config.asp.example +++ b/includes/config.asp.example @@ -78,7 +78,7 @@ Const SNOW_TICKET_PREFIXES = "geinc,gechg,gerit,gesct" ' Valid ServiceNow ticke '----------------------------------------------------------------------------- ' External Services - Zabbix API '----------------------------------------------------------------------------- -Const ZABBIX_URL = "http://10.48.130.113:8080/api_jsonrpc.php" +Const ZABBIX_URL = "http://zabbix.compute.geaerospace.net/zabbix/api_jsonrpc.php" Const ZABBIX_API_TOKEN = "YOUR_ZABBIX_API_TOKEN" '----------------------------------------------------------------------------- diff --git a/includes/leftsidebar.asp b/includes/leftsidebar.asp index def49fe..d1d9f6f 100644 --- a/includes/leftsidebar.asp +++ b/includes/leftsidebar.asp @@ -87,6 +87,7 @@ fiscalWeek = Int(fwDaysFromStart / 7) + 1
  • Network
  • Network Devices
  • PC Admin
  • +
  • Locations
  • USB Devices
  • Notifications
  • Lobby Display
  • diff --git a/machineedit.asp b/machineedit.asp index 872594f..ac8bb7c 100644 --- a/machineedit.asp +++ b/machineedit.asp @@ -142,6 +142,26 @@ Set rsDualpath = Nothing Set cmd = Nothing + ' Load parent location (this machine is contained by a location) + Dim parentlocationid + parentlocationid = "" + strSQL = "SELECT mr.machineid AS parentid FROM machinerelationships mr " &_ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ + "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Contains' AND mr.isactive = 1" + Set cmd = Server.CreateObject("ADODB.Command") + cmd.ActiveConnection = objConn + cmd.CommandText = strSQL + cmd.CommandType = 1 + cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) + Dim rsParentLoc + Set rsParentLoc = cmd.Execute + If NOT rsParentLoc.EOF Then + If NOT IsNull(rsParentLoc("parentid")) Then parentlocationid = rsParentLoc("parentid") + End If + rsParentLoc.Close + Set rsParentLoc = Nothing + Set cmd = Nothing + ' Load compliance data Dim thirdpartymanaged, thirdpartymanager, otassetsystem, dodassettype thirdpartymanaged = "NA" : thirdpartymanager = "" : otassetsystem = "" : dodassettype = "" @@ -630,6 +650,38 @@ Select a backup/redundant machine (creates bidirectional relationship) +
    + + + Select a location that contains this machine (e.g., IT Closet, Bin, Shelf) +
    + diff --git a/pcmachinerelationships.asp b/pcmachinerelationships.asp index 9de7713..bb39dc6 100644 --- a/pcmachinerelationships.asp +++ b/pcmachinerelationships.asp @@ -35,7 +35,7 @@ <% Dim strSQL, rs -strSQL = "SELECT " & _ +strSQL = "SELECT DISTINCT " & _ "pc.machineid AS pc_id, " & _ "pc.machinenumber AS hostname, " & _ "c.address AS ip, " & _ @@ -56,7 +56,31 @@ strSQL = "SELECT " & _ "AND eq.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ - "ORDER BY eq.machinenumber" + "UNION " & _ + "SELECT DISTINCT " & _ + "pc.machineid AS pc_id, " & _ + "pc.machinenumber AS hostname, " & _ + "c.address AS ip, " & _ + "dp.machineid AS machine_id, " & _ + "dp.machinenumber AS machine_number, " & _ + "v.vendor AS vendor, " & _ + "m.modelnumber AS model " & _ + "FROM machinerelationships dual_rel " & _ + "JOIN relationshiptypes drt ON dual_rel.relationshiptypeid = drt.relationshiptypeid AND drt.relationshiptype = 'Dualpath' " & _ + "JOIN machines dp ON dual_rel.related_machineid = dp.machineid " & _ + "JOIN machinerelationships mr ON mr.machineid = dual_rel.machineid AND mr.isactive = 1 " & _ + "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid AND rt.relationshiptype IN ('Controls', 'Controlled By') " & _ + "JOIN machines pc ON mr.related_machineid = pc.machineid AND pc.pctypeid IS NOT NULL " & _ + "LEFT JOIN communications c ON pc.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ + "LEFT JOIN models m ON dp.modelnumberid = m.modelnumberid " & _ + "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ + "WHERE dual_rel.isactive = 1 " & _ + "AND dp.machinenumber IS NOT NULL AND dp.machinenumber != '' " & _ + "AND dp.machinenumber REGEXP '^[0-9]{4}$' " & _ + "AND dp.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ + "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ + "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ + "ORDER BY machine_number" Set rs = objConn.Execute(strSQL) diff --git a/printbadge.asp b/printbadge.asp index 347eecc..a163ba2 100644 --- a/printbadge.asp +++ b/printbadge.asp @@ -3,11 +3,48 @@ Option Explicit Dim objConn, rs %> + +<% +Dim machineid, strSQL, machineNumber, modelName, machineImage, isLocation + +machineid = Request.QueryString("machineid") +If machineid = "" Then machineid = "0" +If Not IsNumeric(machineid) Then machineid = "0" + +strSQL = "SELECT m.machinenumber, m.islocationonly, mo.modelnumber, mo.image FROM machines m LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid WHERE m.machineid = " & CLng(machineid) +Set rs = objConn.Execute(strSQL) + +If rs.EOF Then + machineNumber = "NOT FOUND" + modelName = "" + machineImage = "" + isLocation = False +Else + machineNumber = rs("machinenumber") & "" + modelName = rs("modelnumber") & "" + machineImage = rs("image") & "" + isLocation = (rs("islocationonly") & "" = "1") Or (rs("islocationonly") & "" = "True") +End If +rs.Close +Set rs = Nothing +objConn.Close +%> - Print Badge +<% If isLocation Then %> + + +<% Else %> +<% End If %> -<% -Dim machineid, strSQL, machineNumber, modelName, machineImage - -machineid = Request.QueryString("machineid") -If machineid = "" Then machineid = "0" -If Not IsNumeric(machineid) Then machineid = "0" - -strSQL = "SELECT m.machinenumber, mo.modelnumber, mo.image FROM machines m LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid WHERE m.machineid = " & CLng(machineid) -Set rs = objConn.Execute(strSQL) - -If rs.EOF Then - machineNumber = "NOT FOUND" - modelName = "" - machineImage = "" -Else - machineNumber = rs("machinenumber") & "" - modelName = rs("modelnumber") & "" - machineImage = rs("image") & "" -End If -rs.Close -Set rs = Nothing -objConn.Close -%> +<% If isLocation Then %> +
    +
    +
    +
    +
    <%=Server.HTMLEncode(machineNumber)%>
    +
    + +<% Else %>
    <%=Server.HTMLEncode(modelName)%>
    <% If machineImage <> "" Then %> @@ -60,5 +86,6 @@ objConn.Close +<% End If %> - \ No newline at end of file + diff --git a/savemachineedit.asp b/savemachineedit.asp index d1a2ccc..25453ea 100644 --- a/savemachineedit.asp +++ b/savemachineedit.asp @@ -651,6 +651,34 @@ Call SyncDualpathPartnerData(objConn, CLng(machineid), tempDualpathID) End If + '============================================================================= + ' INSERT PARENT LOCATION RELATIONSHIP (Contains) + '============================================================================= + Dim parentlocationid, containsTypeID + parentlocationid = Trim(Request.Form("parentlocationid")) + + If parentlocationid <> "" And IsNumeric(parentlocationid) And CLng(parentlocationid) > 0 Then + Set rsCheck = objConn.Execute("SELECT relationshiptypeid FROM relationshiptypes WHERE relationshiptype = 'Contains'") + If Not rsCheck.EOF Then containsTypeID = rsCheck("relationshiptypeid") + rsCheck.Close + + If Not IsEmpty(containsTypeID) Then + Dim cmdRelLoc + Set cmdRelLoc = Server.CreateObject("ADODB.Command") + cmdRelLoc.ActiveConnection = objConn + cmdRelLoc.CommandText = "INSERT INTO machinerelationships (machineid, related_machineid, relationshiptypeid, isactive) VALUES (?, ?, ?, 1)" + cmdRelLoc.CommandType = 1 + cmdRelLoc.Parameters.Append cmdRelLoc.CreateParameter("@machineid", 3, 1, , CLng(parentlocationid)) + cmdRelLoc.Parameters.Append cmdRelLoc.CreateParameter("@related_machineid", 3, 1, , CLng(machineid)) + cmdRelLoc.Parameters.Append cmdRelLoc.CreateParameter("@relationshiptypeid", 3, 1, , containsTypeID) + + On Error Resume Next + cmdRelLoc.Execute + Set cmdRelLoc = Nothing + On Error Goto 0 + End If + End If + '============================================================================= ' UPDATE OR INSERT COMPLIANCE DATA '============================================================================= diff --git a/secrets.md b/secrets.md index ea9a953..ab68a24 100644 Binary files a/secrets.md and b/secrets.md differ diff --git a/shopfloor-dashboard/index.html b/shopfloor-dashboard/index.html index 79e3c6c..977a500 100644 --- a/shopfloor-dashboard/index.html +++ b/shopfloor-dashboard/index.html @@ -1049,9 +1049,9 @@
    - +
    diff --git a/sql/add_inspection_machine_type.sql b/sql/add_inspection_machine_type.sql new file mode 100644 index 0000000..c7bd740 --- /dev/null +++ b/sql/add_inspection_machine_type.sql @@ -0,0 +1,19 @@ +-- Add Inspection machine type and update 06xx machines +-- Date: 2026-02-03 +-- Purpose: Create Inspection machine type for 0612-0615 machines so they +-- appear on displaymachines.asp (previously hidden as LocationOnly) + +-- 1. Add Inspection machine type +INSERT INTO machinetypes (machinetypeid, machinetype) VALUES (47, 'Inspection'); + +-- 2. Create Inspection model (linked to new type, default vendor WJDT) +INSERT INTO models (modelnumber, vendorid, machinetypeid, isactive) +VALUES ('Inspection', 1, 47, 1); + +-- 3. Update machines 0612-0615 to use the new Inspection model +UPDATE machines +SET modelnumberid = (SELECT modelnumberid FROM models WHERE modelnumber = 'Inspection' AND machinetypeid = 47 LIMIT 1) +WHERE machinenumber IN ('0612', '0613', '0614', '0615'); + +-- 4. Enable WJDT vendor in machine edit model dropdown +UPDATE vendors SET ismachine = 1 WHERE vendorid = 1; diff --git a/sql/add_location_relationship_types.sql b/sql/add_location_relationship_types.sql new file mode 100644 index 0000000..34dd2e6 --- /dev/null +++ b/sql/add_location_relationship_types.sql @@ -0,0 +1,14 @@ +-- Add relationship types for location management (bins, shelves, PC storage) +-- Run against production MySQL + +-- New relationship types +INSERT INTO relationshiptypes (relationshiptypeid, relationshiptype, description, isactive, displayorder) VALUES +(7, 'Contains', 'Location contains a sub-location (e.g., Bin contains Shelf)', 1, 7), +(8, 'Stored At', 'PC or device is stored at this location', 1, 8); + +-- Fix DT Office -> GJX9B2Z3ESF from "Controls" to "Stored At" +-- Verify relationshipid 69 matches on prod before running +UPDATE machinerelationships SET relationshiptypeid = 8 WHERE relationshipid = 69; + +-- Flag IT Closet as a location (machineid=258) +UPDATE machines SET islocationonly = 1 WHERE machineid = 258; diff --git a/sql/update_pctype_inspection.sql b/sql/update_pctype_inspection.sql new file mode 100644 index 0000000..06d7d6c --- /dev/null +++ b/sql/update_pctype_inspection.sql @@ -0,0 +1,24 @@ +-- ============================================================================ +-- Update PC Type #10: "Part Marker" → "Inspection" +-- ============================================================================ +-- Date: 2026-02-05 +-- Description: Rename pctype 10 from "Part Marker" to "Inspection" +-- +-- Run against: Production shopdb database +-- ============================================================================ + +-- Update the pctype record +UPDATE pctype +SET typename = 'Inspection', + description = 'Inspection system' +WHERE pctypeid = 10; + +-- Verify the change +SELECT pctypeid, typename, description +FROM pctype +WHERE pctypeid = 10; + +-- Show all PC types for reference +SELECT pctypeid, typename, description, displayorder +FROM pctype +ORDER BY displayorder; diff --git a/tv-dashboard/index.html b/tv-dashboard/index.html index 5254388..16d626c 100644 --- a/tv-dashboard/index.html +++ b/tv-dashboard/index.html @@ -139,6 +139,10 @@ function showError(message) { document.getElementById('slideshow').innerHTML = '

    Display Error

    ' + message + '

    '; + // Clear slides so the next successful fetch always re-renders + slides = []; + currentSlide = 0; + if (slideTimer) { clearTimeout(slideTimer); slideTimer = null; } } function startSlideshow() {