Files
shopdb/displaylocation.asp
cproudlock 65b622c361 Add USB checkout system and SSO profile page
New Features:
- USB Device checkout/check-in system with barcode scanning
  - displayusb.asp: List all USB devices with status
  - addusb.asp: Add new USB devices via barcode scan
  - checkout_usb.asp/savecheckout_usb.asp: Check out USB to SSO
  - checkin_usb.asp/savecheckin_usb.asp: Check in with wipe confirmation
  - usb_history.asp: Full checkout history with filters
  - api_usb.asp: JSON API for AJAX lookups
- displayprofile.asp: SSO profile page showing user info and USB history
- Date/time format changed to 12-hour (MM/DD/YYYY h:mm AM/PM)
- SSO links in USB history now link to profile page via search

Database:
- New machinetypeid 44 for USB devices
- New usb_checkouts table for tracking checkouts

Cleanup:
- Removed v2 folder (duplicate/old files)
- Removed old debug/test files
- Removed completed migration documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 11:16:14 -05:00

198 lines
6.9 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<!--#include file="./includes/sql.asp"-->
<link rel="stylesheet" href="./leaflet/leaflet.css">
<script src="./leaflet/leaflet.js"></script>
</head>
<body>
<main>
<table>
<%
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
' All network devices now stored in machines table (machinetypeid 16-20)
' Printers have their own maptop/mapleft in the printers table
Select Case LCase(deviceType)
Case "printer"
' Printers have their own location in the printers table
strSQL = "SELECT p.mapleft, p.maptop, p.printerwindowsname AS devicename FROM printers p WHERE p.printerid = " & CLng(deviceId)
Case "idf", "server", "switch", "camera", "accesspoint", "access point"
' Query machines table for all network devices
strSQL = "SELECT mapleft, maptop, COALESCE(alias, machinenumber) AS devicename FROM machines WHERE machineid = " & CLng(deviceId)
Case "machine"
strSQL = "SELECT mapleft, maptop, COALESCE(alias, machinenumber) AS devicename FROM machines WHERE machineid = " & CLng(deviceId)
Case Else
Response.Write("<div style='padding:20px; text-align:center; color:#888;'><p>Unknown device type</p></div>")
objConn.Close
Response.End
End Select
Else
Response.Write("<div style='padding:20px; text-align:center; color:#888;'><p>Invalid parameters</p></div>")
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("<div style='padding:20px; text-align:center; color:#888;'><i class='zmdi zmdi-pin-off' style='font-size:48px; margin-bottom:10px;'></i><p>No location set</p></div>")
rs.Close
Set rs = Nothing
objConn.Close
Response.End
End If
' Invert Y coordinate for Leaflet
maptop = 2550 - maptop
Else
Response.Write("<div style='padding:20px; text-align:center; color:#888;'><p>Device not found</p></div>")
rs.Close
Set rs = Nothing
objConn.Close
Response.End
End If
rs.Close
Set rs = Nothing
objConn.Close
%>
<style>
html, body {
height: 100%;
margin: 0;
}
.leaflet-container {
height: 340px;
width: 440px;
max-width: 100%;
max-height: 100%;
}
/* Dark mode for all Leaflet controls */
.leaflet-control-zoom a {
background-color: #2a2a2a !important;
color: #fff !important;
border-color: #444 !important;
}
.leaflet-control-zoom a:hover {
background-color: #3a3a3a !important;
color: #fff !important;
}
.leaflet-bar {
border: 1px solid #444 !important;
}
/* Hide Leaflet attribution/logo */
.leaflet-control-attribution {
display: none !important;
}
</style>
<div id="map" style="width: 440px; height: 340px;"></div>
<script>
// Detect theme from parent window or cookie
function getTheme() {
try {
// Try to get theme from parent window
if (window.parent && window.parent.document && window.parent.document.body) {
var bodyClass = window.parent.document.body.className;
var themeMatch = bodyClass.match(/bg-theme(\d+)/);
if (themeMatch) {
return 'bg-theme' + themeMatch[1];
}
}
} catch(e) {
// Cross-origin restriction, fall back to cookie
}
// Fall back to cookie
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.indexOf('theme=') === 0) {
return cookie.substring(6);
}
}
return 'bg-theme1'; // default
}
var theme = getTheme();
// Theme-specific settings
var themeConfig = {
'bg-theme1': { bg: '#2a2a2a', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme2': { bg: '#2a2a2a', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme3': { bg: '#2a2a2a', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme4': { bg: '#2a2a2a', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme5': { bg: '#2a2a2a', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme6': { bg: '#2a2a2a', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme7': { bg: '#0c675e', filter: 'brightness(0.8) contrast(1.1) hue-rotate(-10deg)' },
'bg-theme8': { bg: '#4a3020', filter: 'brightness(0.75) contrast(1.1) saturate(0.8)' },
'bg-theme9': { bg: '#29323c', filter: 'brightness(0.7) contrast(1.1)' },
'bg-theme10': { bg: '#795548', filter: 'brightness(0.8) contrast(1.05) sepia(0.2)' },
'bg-theme11': { bg: '#1565C0', filter: 'brightness(0.85) contrast(1.05) hue-rotate(-5deg)' },
'bg-theme12': { bg: '#65379b', filter: 'brightness(0.8) contrast(1.1) hue-rotate(5deg)' },
'bg-theme13': { bg: '#d03050', filter: 'brightness(0.85) contrast(1.05) saturate(0.9)' },
'bg-theme14': { bg: '#2a7a2e', filter: 'brightness(0.8) contrast(1.1) saturate(0.95)' },
'bg-theme15': { bg: '#4643d3', filter: 'brightness(0.85) contrast(1.05) hue-rotate(-5deg)' },
'bg-theme16': { bg: '#6a11cb', filter: 'brightness(0.8) contrast(1.1)' }
};
var config = themeConfig[theme] || { bg: '#1a1a1a', filter: 'brightness(0.7) contrast(1.1)' };
// Apply background color
document.body.style.backgroundColor = config.bg;
document.getElementById('map').style.backgroundColor = config.bg;
var map = L.map('map', {
crs: L.CRS.Simple,
minZoom: -3
});
var sol = L.latLng([<%Response.Write(maptop)%>,<%Response.Write(mapleft)%>]);
L.marker(sol).bindPopup('hi');
L.marker(sol).addTo(map);
var bounds = [[0,0], [2550,3300]];
// Determine which map image to use based on theme
var lightThemes = ['bg-theme11', 'bg-theme13']; // Blue and red themes use light map
var imageUrl = lightThemes.includes(theme) ? './images/sitemap2025-light.png' : './images/sitemap2025-dark.png';
// Create image overlay with theme-specific filter
var imageOverlay = L.imageOverlay(imageUrl, bounds);
// Apply theme-specific filter when image loads
imageOverlay.on('load', function() {
var imgElement = this.getElement();
if (imgElement) {
imgElement.style.filter = config.filter;
}
});
imageOverlay.addTo(map);
map.fitBounds(bounds);
</script>