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("No connected PCs ")
- 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
%>
+<%
+ 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("This machine does not control any other machines ")
- 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
%>
+<%
+ 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("No dualpath relationships ")
- 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
%>
+<%
+ 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("" & Server.HTMLEncode(rs2("machinenumber") & "") & " ")
Response.Write("" & Server.HTMLEncode(connAlias) & " ")
Response.Write("" & Server.HTMLEncode(connType) & " ")
- Response.Write("" & Server.HTMLEncode(rs2("relationshiptype") & "") & " ")
+ If connDir = "from" Then
+ Response.Write("Connected From ")
+ Else
+ Response.Write("" & Server.HTMLEncode(rs2("relationshiptype") & "") & " ")
+ End If
Response.Write(" ")
rs2.MoveNext
Wend
- Else
- Response.Write("No network connections ")
- 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("" & Server.HTMLEncode(rs2("machinenumber") & "") & " ")
- Response.Write("" & Server.HTMLEncode(connToAlias) & " ")
- Response.Write("" & Server.HTMLEncode(connToType) & " ")
- Response.Write("Connected From ")
- Response.Write(" ")
- rs2.MoveNext
- Wend
- End If
- rs2.Close
- Set rs2 = Nothing
%>
+<%
+ 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
+
+
+
+
+ Name
+ Type
+ IP / Info
+ Relationship
+
+
+
+<%
+ 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("No stored items or sub-locations ")
+ 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("" & Server.HTMLEncode(storedName) & " ")
+ If rs2("alias") & "" <> "" Then Response.Write(" (" & Server.HTMLEncode(rs2("alias") & "") & ") ")
+ Response.Write(" ")
+ Response.Write("" & Server.HTMLEncode(storedType) & " ")
+ Response.Write("" & storedIP & " ")
+ Response.Write("" & Server.HTMLEncode(storedRelType) & " ")
+ Response.Write(" ")
+ rs2.MoveNext
+ Loop
+ End If
+ rs2.Close
+ Set rs2 = Nothing
+%>
+
+
+
+<%
+ 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
-
-
-
-
- Machine Number
- Type
- Model
- Location
- Relationship
-
-
-
<%
' 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("No connected equipment ")
- Else
+ If Not rs2.EOF Then
+%>
+ Connected Equipment
+
+
+
+
+ Machine Number
+ Type
+ Model
+ Location
+ Relationship
+
+
+
+<%
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
%>
+<%
+ 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 @@
-- None --
<%
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)
+
+ Parent Location
+
+ -- None --
+<%
+ Dim rsLocations
+ strSQL = "SELECT machineid, machinenumber, alias FROM machines WHERE islocationonly = 1 AND isactive = 1 AND machineid <> ? ORDER BY machinenumber ASC"
+ Set cmd = Server.CreateObject("ADODB.Command")
+ cmd.ActiveConnection = objConn
+ cmd.CommandText = strSQL
+ cmd.CommandType = 1
+ cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid)
+ Set rsLocations = cmd.Execute
+ While Not rsLocations.EOF
+ Dim locDisplay, selectedLoc
+ locDisplay = rsLocations("machinenumber") & ""
+ selectedLoc = ""
+ If NOT IsNull(rsLocations("alias")) AND rsLocations("alias") & "" <> "" Then
+ locDisplay = locDisplay & " (" & rsLocations("alias") & ")"
+ End If
+ If CStr(rsLocations("machineid")) = CStr(parentlocationid) Then selectedLoc = " selected"
+ Response.Write("" & Server.HTMLEncode(locDisplay) & " ")
+ rsLocations.MoveNext
+ Wend
+ rsLocations.Close
+ Set rsLocations = Nothing
+ Set cmd = Nothing
+%>
+
+ 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
%>
-
+
+ Parent Location
+
+ -- None --
+<%
+ Dim rsLocations
+ strSQL = "SELECT machineid, machinenumber, alias FROM machines WHERE islocationonly = 1 AND isactive = 1 AND machineid <> ? ORDER BY machinenumber ASC"
+ Set cmd = Server.CreateObject("ADODB.Command")
+ cmd.ActiveConnection = objConn
+ cmd.CommandText = strSQL
+ cmd.CommandType = 1
+ cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid)
+ Set rsLocations = cmd.Execute
+ While Not rsLocations.EOF
+ Dim locDisplay, selectedLoc
+ locDisplay = rsLocations("machinenumber") & ""
+ selectedLoc = ""
+ If NOT IsNull(rsLocations("alias")) AND rsLocations("alias") & "" <> "" Then
+ locDisplay = locDisplay & " (" & rsLocations("alias") & ")"
+ End If
+ If CStr(rsLocations("machineid")) = CStr(parentlocationid) Then selectedLoc = " selected"
+ Response.Write("" & Server.HTMLEncode(locDisplay) & " ")
+ rsLocations.MoveNext
+ Wend
+ rsLocations.Close
+ Set rsLocations = Nothing
+ Set cmd = 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)
+
+ Parent Location
+
+ -- None --
+<%
+ Dim rsLocations
+ strSQL = "SELECT machineid, machinenumber, alias FROM machines WHERE islocationonly = 1 AND isactive = 1 AND machineid <> ? ORDER BY machinenumber ASC"
+ Set cmd = Server.CreateObject("ADODB.Command")
+ cmd.ActiveConnection = objConn
+ cmd.CommandText = strSQL
+ cmd.CommandType = 1
+ cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid)
+ Set rsLocations = cmd.Execute
+ While Not rsLocations.EOF
+ Dim locDisplay, selectedLoc
+ locDisplay = rsLocations("machinenumber") & ""
+ selectedLoc = ""
+ If NOT IsNull(rsLocations("alias")) AND rsLocations("alias") & "" <> "" Then
+ locDisplay = locDisplay & " (" & rsLocations("alias") & ")"
+ End If
+ If CStr(rsLocations("machineid")) = CStr(parentlocationid) Then selectedLoc = " selected"
+ Response.Write("" & Server.HTMLEncode(locDisplay) & " ")
+ rsLocations.MoveNext
+ Wend
+ rsLocations.Close
+ Set rsLocations = Nothing
+ Set cmd = Nothing
+%>
+
+ 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
-%>
Print Badge
+<% 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
+