<% On Error Resume Next Dim deviceType, deviceId, machineid, mapleft, maptop, deviceName, strSQL, rs ' Support both old (machineid) and new (type+id) parameters machineid = Request.Querystring("machineid") deviceType = Trim(Request.Querystring("type")) deviceId = Trim(Request.Querystring("id")) ' Determine which query to use If machineid <> "" Then ' Old format: machineid parameter (for backwards compatibility) strSQL = "SELECT mapleft, maptop, machinenumber AS devicename FROM machines WHERE machineid = " & CLng(machineid) ElseIf deviceType <> "" And deviceId <> "" And IsNumeric(deviceId) Then ' New format: type + id parameters Select Case LCase(deviceType) Case "idf" strSQL = "SELECT mapleft, maptop, idfname AS devicename FROM idfs WHERE idfid = " & CLng(deviceId) Case "server" strSQL = "SELECT mapleft, maptop, servername AS devicename FROM servers WHERE serverid = " & CLng(deviceId) Case "switch" strSQL = "SELECT mapleft, maptop, switchname AS devicename FROM switches WHERE switchid = " & CLng(deviceId) Case "camera" strSQL = "SELECT mapleft, maptop, cameraname AS devicename FROM cameras WHERE cameraid = " & CLng(deviceId) Case "accesspoint", "access point" strSQL = "SELECT mapleft, maptop, apname AS devicename FROM accesspoints WHERE apid = " & CLng(deviceId) Case "printer" ' Printers have their own location coordinates in the printers table strSQL = "SELECT p.mapleft, p.maptop, m.machinenumber AS devicename FROM printers p " & _ "INNER JOIN machines m ON p.machineid = m.machineid WHERE p.printerid = " & CLng(deviceId) Case "machine" strSQL = "SELECT mapleft, maptop, COALESCE(alias, machinenumber) AS devicename FROM machines WHERE machineid = " & CLng(deviceId) Case Else Response.Write("

Unknown device type

") objConn.Close Response.End End Select Else Response.Write("

Invalid parameters

") objConn.Close Response.End End If Set rs = objConn.Execute(strSQL) If Not rs.EOF Then mapleft = rs("mapleft") maptop = rs("maptop") deviceName = rs("devicename") ' Check if location is set If IsNull(mapleft) Or IsNull(maptop) Or mapleft = "" Or maptop = "" Then Response.Write("

No location set

") rs.Close Set rs = Nothing objConn.Close Response.End End If ' Invert Y coordinate for Leaflet maptop = 2550 - maptop Else Response.Write("

Device not found

") rs.Close Set rs = Nothing objConn.Close Response.End End If rs.Close Set rs = Nothing objConn.Close %>