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>
This commit is contained in:
@@ -77,26 +77,29 @@
|
||||
' NOTE: Use explicit column names to avoid wildcard conflicts between tables
|
||||
'=============================================================================
|
||||
' Phase 2: Only query columns that actually exist in machines table
|
||||
' NOTE: machinetypeid is now sourced from models table (models.machinetypeid) not machines table
|
||||
strSQL = "SELECT machines.machineid, machines.machinenumber, machines.alias, machines.hostname, " & _
|
||||
"machines.serialnumber, machines.machinenotes, machines.mapleft, machines.maptop, " & _
|
||||
"machines.modelnumberid, machines.businessunitid, machines.printerid, machines.pctypeid, machines.machinetypeid, " & _
|
||||
"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.lastupdated, machines.fqdn, " & _
|
||||
"machinetypes.machinetype, " & _
|
||||
"models.modelnumber, models.image, " & _
|
||||
"models.modelnumber, models.image, models.machinetypeid, " & _
|
||||
"businessunits.businessunit, " & _
|
||||
"functionalaccounts.functionalaccount, functionalaccounts.functionalaccountid, " & _
|
||||
"vendors.vendor, vendors.vendorid, " & _
|
||||
"printers.ipaddress AS printerip, " & _
|
||||
"printers.printercsfname, printers.printerwindowsname " & _
|
||||
"printers.printercsfname, printers.printerwindowsname, " & _
|
||||
"machinestatus.machinestatus " & _
|
||||
"FROM machines " & _
|
||||
"LEFT JOIN models ON machines.modelnumberid = models.modelnumberid " & _
|
||||
"LEFT JOIN machinetypes ON machines.machinetypeid = machinetypes.machinetypeid " & _
|
||||
"LEFT JOIN machinetypes ON models.machinetypeid = machinetypes.machinetypeid " & _
|
||||
"LEFT JOIN businessunits ON machines.businessunitid = businessunits.businessunitid " & _
|
||||
"LEFT JOIN functionalaccounts ON machinetypes.functionalaccountid = functionalaccounts.functionalaccountid " & _
|
||||
"LEFT JOIN vendors ON models.vendorid = vendors.vendorid " & _
|
||||
"LEFT JOIN printers ON machines.printerid = printers.printerid " & _
|
||||
"LEFT JOIN machinestatus ON machines.machinestatusid = machinestatus.machinestatusid " & _
|
||||
"WHERE machines.machineid = " & CLng(machineid)
|
||||
|
||||
Set rs = objConn.Execute(strSQL)
|
||||
@@ -174,12 +177,14 @@
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<p class="mb-2"><strong>Location:</strong></p>
|
||||
<p class="mb-2"><strong>Status:</strong></p>
|
||||
<p class="mb-2"><strong>Vendor:</strong></p>
|
||||
<p class="mb-2"><strong>Model:</strong></p>
|
||||
<p class="mb-2"><strong>Function:</strong></p>
|
||||
<p class="mb-2"><strong>BU:</strong></p>
|
||||
<p class="mb-2"><strong>IP Address:</strong></p>
|
||||
<p class="mb-2"><strong>MAC Address:</strong></p>
|
||||
<p class="mb-2"><strong>FQDN:</strong></p>
|
||||
<p class="mb-2"><strong>Controlling PC:</strong></p>
|
||||
<p class="mb-2"><strong>Printer:</strong></p>
|
||||
<p>
|
||||
@@ -188,12 +193,15 @@
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<%
|
||||
Dim machineNumVal, vendorValM, modelValM, machineTypeVal, buVal
|
||||
Dim machineNumVal, vendorValM, modelValM, machineTypeVal, buVal, statusValM
|
||||
|
||||
' Get values and default to N/A if empty
|
||||
machineNumVal = rs("machinenumber") & ""
|
||||
If machineNumVal = "" Then machineNumVal = "N/A"
|
||||
|
||||
statusValM = rs("machinestatus") & ""
|
||||
If statusValM = "" Then statusValM = "N/A"
|
||||
|
||||
vendorValM = rs("vendor") & ""
|
||||
If vendorValM = "" Then vendorValM = "N/A"
|
||||
|
||||
@@ -219,6 +227,7 @@ Else
|
||||
End If
|
||||
%>
|
||||
</p>
|
||||
<p class="mb-2"><%=Server.HTMLEncode(statusValM)%></p>
|
||||
<p class="mb-2"><%=Server.HTMLEncode(vendorValM)%></p>
|
||||
<p class="mb-2"><%=Server.HTMLEncode(modelValM)%></p>
|
||||
<p class="mb-2"><%=Server.HTMLEncode(machineTypeVal)%></p>
|
||||
@@ -262,19 +271,44 @@ Else
|
||||
Response.Write("<p class='mb-2'><span class='text-muted'>N/A</span></p>")
|
||||
End If
|
||||
|
||||
' Get controlling PC from relationships
|
||||
' Display FQDN
|
||||
Dim fqdnVal
|
||||
fqdnVal = rs("fqdn") & ""
|
||||
If fqdnVal <> "" Then
|
||||
Response.Write("<p class='mb-2'>" & Server.HTMLEncode(fqdnVal) & "</p>")
|
||||
Else
|
||||
Response.Write("<p class='mb-2'><span class='text-muted'>N/A</span></p>")
|
||||
End If
|
||||
|
||||
' Get controlling PC from relationships - check both directions
|
||||
' Direction 1: PC (machineid) controls this equipment (related_machineid)
|
||||
' Direction 2: This equipment (machineid) is controlled by PC (related_machineid)
|
||||
Dim rsControlPC, strControlPCSQL, controlPCHostname, controlPCID
|
||||
|
||||
' First check: PC controls this equipment (standard direction)
|
||||
strControlPCSQL = "SELECT m.machineid, m.hostname, m.machinenumber FROM machinerelationships mr " & _
|
||||
"JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _
|
||||
"JOIN machines m ON mr.machineid = m.machineid " & _
|
||||
"WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1 LIMIT 1"
|
||||
"WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1 " & _
|
||||
"AND m.machinetypeid >= 33 LIMIT 1"
|
||||
Set rsControlPC = ExecuteParameterizedQuery(objConn, strControlPCSQL, Array(machineid))
|
||||
|
||||
If rsControlPC.EOF Then
|
||||
rsControlPC.Close
|
||||
' Second check: This equipment has relationship to PC (reverse direction)
|
||||
strControlPCSQL = "SELECT m.machineid, m.hostname, m.machinenumber FROM machinerelationships mr " & _
|
||||
"JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _
|
||||
"JOIN machines m ON mr.related_machineid = m.machineid " & _
|
||||
"WHERE mr.machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1 " & _
|
||||
"AND m.machinetypeid >= 33 LIMIT 1"
|
||||
Set rsControlPC = ExecuteParameterizedQuery(objConn, strControlPCSQL, Array(machineid))
|
||||
End If
|
||||
|
||||
If Not rsControlPC.EOF Then
|
||||
controlPCHostname = rsControlPC("hostname") & ""
|
||||
controlPCID = rsControlPC("machineid")
|
||||
If controlPCHostname = "" Then controlPCHostname = rsControlPC("machinenumber") & ""
|
||||
Response.Write("<p class='mb-2'><a href='./displaymachine.asp?machineid=" & controlPCID & "'>" & Server.HTMLEncode(controlPCHostname) & "</a></p>")
|
||||
Response.Write("<p class='mb-2'><a href='./displaypc.asp?machineid=" & controlPCID & "'>" & Server.HTMLEncode(controlPCHostname) & "</a></p>")
|
||||
Else
|
||||
Response.Write("<p class='mb-2'><span class='text-muted'>N/A</span></p>")
|
||||
End If
|
||||
@@ -378,26 +412,16 @@ End If
|
||||
<tbody>
|
||||
<%
|
||||
' Query PCs that control this machine (directly or via dualpath)
|
||||
' First check for direct control, if none then check via dualpath partner
|
||||
' Check both directions - the PC is identified by machinetypeid IN (33-43)
|
||||
' Use GROUP_CONCAT to combine multiple IPs into one row per PC
|
||||
strSQL2 = "SELECT m.machineid, m.machinenumber, m.hostname, GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') as address, 'Controls' as relationshiptype " & _
|
||||
"FROM machinerelationships mr " & _
|
||||
"JOIN machines m ON mr.related_machineid = m.machineid " & _
|
||||
"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 = ? AND mr.relationshiptypeid = 3 AND m.pctypeid IS NOT NULL AND mr.isactive = 1 " & _
|
||||
"GROUP BY m.machineid, m.machinenumber, m.hostname " & _
|
||||
"UNION " & _
|
||||
"SELECT m.machineid, m.machinenumber, m.hostname, GROUP_CONCAT(DISTINCT c.address ORDER BY c.address SEPARATOR ', ') as address, 'Controls (via Dualpath)' as relationshiptype " & _
|
||||
"FROM machinerelationships mr_dual " & _
|
||||
"JOIN machinerelationships mr_control ON mr_dual.related_machineid = mr_control.machineid " & _
|
||||
"JOIN machines m ON mr_control.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_dual.machineid = ? AND mr_dual.relationshiptypeid = 1 " & _
|
||||
" AND mr_control.relationshiptypeid = 3 AND m.pctypeid IS NOT NULL " & _
|
||||
" AND mr_dual.isactive = 1 AND mr_control.isactive = 1 " & _
|
||||
" AND NOT EXISTS (SELECT 1 FROM machinerelationships mr_direct WHERE mr_direct.machineid = mr_dual.machineid AND mr_direct.relationshiptypeid = 3 AND mr_direct.isactive = 1) " & _
|
||||
"WHERE (mr.machineid = ? OR mr.related_machineid = ?) AND mr.relationshiptypeid = 3 " & _
|
||||
" AND m.machinetypeid IN (33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43) AND m.machineid <> ? AND mr.isactive = 1 " & _
|
||||
"GROUP BY m.machineid, m.machinenumber, m.hostname"
|
||||
Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid))
|
||||
Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid, machineid, machineid))
|
||||
|
||||
If rs2.EOF Then
|
||||
Response.Write("<tr><td colspan='3' class='text-muted text-center'>No controlling PC assigned</td></tr>")
|
||||
@@ -412,7 +436,7 @@ End If
|
||||
If pcIP = "" Then pcIP = "<span class='text-muted'>N/A</span>"
|
||||
|
||||
Response.Write("<tr>")
|
||||
Response.Write("<td><a href='./displaypc.asp?pcid=" & pcMachineID & "'>" & Server.HTMLEncode(pcHostname) & "</a></td>")
|
||||
Response.Write("<td><a href='./displaypc.asp?machineid=" & pcMachineID & "'>" & Server.HTMLEncode(pcHostname) & "</a></td>")
|
||||
Response.Write("<td>" & pcIP & "</td>")
|
||||
Response.Write("<td><span class='badge badge-primary'>" & Server.HTMLEncode(rs2("relationshiptype") & "") & "</span></td>")
|
||||
Response.Write("</tr>")
|
||||
@@ -447,7 +471,7 @@ End If
|
||||
"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 m.machinetypeid = mt.machinetypeid " & _
|
||||
"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))
|
||||
|
||||
@@ -500,7 +524,7 @@ End If
|
||||
"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 m.machinetypeid = mt.machinetypeid " & _
|
||||
"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))
|
||||
|
||||
@@ -552,7 +576,8 @@ End If
|
||||
"FROM machinerelationships mr " & _
|
||||
"JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _
|
||||
"LEFT JOIN machines m ON mr.related_machineid = m.machineid " & _
|
||||
"LEFT JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid " & _
|
||||
"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))
|
||||
|
||||
@@ -580,7 +605,8 @@ End If
|
||||
"FROM machinerelationships mr " & _
|
||||
"JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _
|
||||
"LEFT JOIN machines m ON mr.machineid = m.machineid " & _
|
||||
"LEFT JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid " & _
|
||||
"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))
|
||||
|
||||
@@ -738,10 +764,17 @@ End If
|
||||
'=============================================================================
|
||||
' SECURITY: Use parameterized query for installed applications
|
||||
'=============================================================================
|
||||
strSQL2 = "SELECT * FROM installedapps, applications WHERE installedapps.appid = applications.appid AND installedapps.isactive = 1 AND installedapps.machineid = ? ORDER BY appname ASC"
|
||||
Dim appDisplay, appVer
|
||||
strSQL2 = "SELECT a.appname, av.version FROM installedapps ia " & _
|
||||
"JOIN applications a ON ia.appid = a.appid " & _
|
||||
"LEFT JOIN appversions av ON ia.appversionid = av.appversionid " & _
|
||||
"WHERE ia.isactive = 1 AND ia.machineid = ? ORDER BY a.appname ASC"
|
||||
Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid))
|
||||
Do While Not rs2.EOF
|
||||
Response.Write("<tr><td><span class='float-left font-weight-bold'>" & Server.HTMLEncode(rs2("appname") & "") & "</span></td></tr>")
|
||||
appDisplay = Server.HTMLEncode(rs2("appname") & "")
|
||||
appVer = rs2("version") & ""
|
||||
If appVer <> "" Then appDisplay = appDisplay & " <span class='text-muted'>v" & Server.HTMLEncode(appVer) & "</span>"
|
||||
Response.Write("<tr><td><span class='float-left font-weight-bold'>" & appDisplay & "</span></td></tr>")
|
||||
rs2.MoveNext
|
||||
Loop
|
||||
rs2.Close
|
||||
|
||||
Reference in New Issue
Block a user