# Machine Management - Quick Reference Guide **Last Updated:** 2025-11-07 --- ## Quick Links | Page | URL | Purpose | |------|-----|---------| | **View All Machines** | `displaymachines.asp` | List of all equipment (excludes PCs) | | **View Machine** | `displaymachine.asp?machineid=XXX` | Display single machine details | | **Add Machine** | `addmachine.asp` | Create new machine | | **Edit Machine** | `editmachine.asp?machineid=XXX` | Edit existing machine | --- ## File Structure ``` /home/camp/projects/windows/shopdb/ ├── displaymachines.asp # List all machines (equipment only, no PCs) ├── displaymachine.asp # Display single machine (5 tabs) ├── addmachine.asp # Add new machine form (5 tabs) ├── editmachine.asp # Edit machine form (5 tabs) ├── savemachine_direct.asp # Save new machine handler ├── savemachineedit.asp # Save machine edits handler └── docs/ ├── MACHINE_MANAGEMENT_COMPLETE.md # Comprehensive overview ├── MACHINE_EDIT_FORM_IMPLEMENTATION.md # Edit form details ├── ADD_EDIT_MACHINE_UPDATES.md # Add form details └── DISPLAY_PAGES_UPDATE_SUMMARY.md # Display page details ``` --- ## Database Tables ### machines Primary table for all equipment and PCs - `machineid` - Primary key - `machinenumber` - Equipment number (unique, required) - `modelnumberid` - Foreign key to models - `businessunitid` - Foreign key to businessunits - `pctypeid` - NULL for equipment, NOT NULL for PCs - `alias` - Friendly name - `machinenotes` - Notes - `mapleft`, `maptop` - Location coordinates ### communications Network interface data (up to 3 per machine) - `comid` - Primary key - `machineid` - Foreign key to machines - `address` - IP address - `macaddress` - MAC address - `interfacename` - "Interface 1", "Interface 2", "Interface 3" - `isprimary` - 1 for primary, 0 for secondary ### machinerelationships Relationships between machines - `relationshipid` - Primary key - `machineid` - Source machine - `related_machineid` - Target machine - `relationshiptypeid` - Foreign key to relationshiptypes **Relationship Types:** - **Controls** (one-way): PC → Equipment - **Dualpath** (bidirectional): Machine ↔ Machine ### compliance Compliance and security data - `complianceid` - Primary key - `machineid` - Foreign key to machines - `is_third_party_managed` - ENUM('Yes', 'No', 'NA') - `third_party_vendorid` - Foreign key to vendors - `ot_asset_system` - OT classification - `ot_asset_device_type` - DoD classification --- ## Common Queries ### Get Machine with All Data ```sql SELECT m.*, mo.modelnumber, v.vendor, bu.businessunit, mt.machinetype FROM machines m LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid LEFT JOIN vendors v ON mo.vendorid = v.vendorid LEFT JOIN businessunits bu ON m.businessunitid = bu.businessunitID LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid WHERE m.machineid = ? ``` ### Get Network Interfaces ```sql SELECT * FROM communications WHERE machineid = ? AND isactive = 1 ORDER BY isprimary DESC, interfacename ASC ``` ### Get Controlling PC ```sql SELECT m.machineid, m.hostname, c.address FROM machinerelationships mr JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid JOIN machines m ON mr.machineid = m.machineid LEFT JOIN communications c ON m.machineid = c.machineid AND c.isprimary = 1 WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' ``` ### Get Dualpath Machines ```sql SELECT m.machineid, m.machinenumber, mt.machinetype, mo.modelnumber 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' ``` ### Get Compliance Data ```sql SELECT c.*, v.vendor AS third_party_vendor_name FROM compliance c LEFT JOIN vendors v ON c.third_party_vendorid = v.vendorid WHERE c.machineid = ? ``` --- ## Form Field Reference ### Basic Info Tab - `machinenumber` - Equipment number (required, unique, readonly on edit) - `modelid` - Model dropdown (required) - `businessunitid` - Business unit dropdown (required) - `alias` - Friendly name (optional) - `machinenotes` - Notes (optional) ### Network Tab - `ip1`, `mac1` - Primary interface (Interface 1) - `ip2`, `mac2` - Optional interface (Interface 2) - `ip3`, `mac3` - Optional interface (Interface 3) ### Relationships Tab - `controllingpc` - PC dropdown (WHERE pctypeid IS NOT NULL) - `dualpathid` - Machine dropdown (WHERE pctypeid IS NULL) ### Compliance Tab - `thirdpartymanaged` - Dropdown (N/A, Yes, No) - `thirdpartyvendorid` - Vendor dropdown - `otassetsystem` - Text input (100 chars) - `dodassettype` - Text input (100 chars) ### Location Tab - `mapleft` - X coordinate (from map picker) - `maptop` - Y coordinate (from map picker) --- ## Code Patterns ### Parameterized Query Example ```asp Dim strSQL, rsResult strSQL = "SELECT * FROM machines WHERE machineid = ?" Set rsResult = ExecuteParameterizedQuery(objConn, strSQL, Array(machineid)) If Not rsResult.EOF Then ' Process results End If rsResult.Close Set rsResult = Nothing ``` ### HTML Encoding Pattern ```asp Response.Write("