# ShopDB Quick Reference Guide **For:** New team members and quick lookups **See Also:** ASP_DEVELOPMENT_GUIDE.md (development), STANDARDS.md (coding standards), API.md (REST API) --- ## Quick Access URLs - **Production:** http://your-production-server/ - **Beta/Staging:** http://your-production-server/v2/ - **Dev Environment:** http://192.168.122.151:8080 --- ## Database Quick Facts | Item | Count | Notes | |------|-------|-------| | **Tables** | 35 | Base tables (actual data) | | **Views** | 26 | Computed/joined data | | **PCs** | 242 | Active PCs in inventory | | **Machines** | 256 | CNC machines and locations | | **Printers** | 40 | Network printers | | **Applications** | 44 | Shopfloor software | | **KB Articles** | 196 | Troubleshooting docs | | **Network IFs** | 705 | Network interfaces tracked | | **Total Size** | ~3.5 MB | Small but mighty! | --- ## Core Tables Cheat Sheet ### Unified Machines Table (Phase 2 Schema) ```sql -- ALL PCs, Equipment, and Network Devices are in one table machines (machineid, hostname, serialnumber, alias, machinenumber, machinetypeid, pctypeid, modelnumberid, osid, printerid, loggedinuser, machinenotes, isactive, maptop, mapleft, lastupdated) -- Identify record type: -- PCs: pctypeid IS NOT NULL (machinetypeid 33+) -- Equipment: pctypeid IS NULL AND machinetypeid NOT IN (16,17,18,19,20) AND machinetypeid < 33 -- Network Devices: machinetypeid IN (16,17,18,19,20) -- Equipment types: 1-15, 21-25 (e.g., Lathe, Mill, CMM, Hobbing Machine, etc.) ``` ### PC-Related Tables ```sql -- PC Types pctype (pctypeid, typename) -- Values: Standard, Engineer, Shopfloor, CMM, Wax Trace, etc. -- Communication Config (serial ports for equipment) commconfig (configid, machineid, configtype, portid, baud, databits, parity, ipaddress) -- DNC Config dncconfig (dncid, machineid, site, cnc, ncif, dualpath_enabled, path1_name, path2_name) -- PC-to-Equipment Relationships machinerelationships (relationshipid, machineid, related_machineid, relationshiptypeid) -- relationshiptypeid 3 = "Controls" (PC controls equipment) ``` ### Network & Communications ```sql -- All network interfaces communications (comid, machineid, comstypeid, address, macaddress, subnetmask, defaultgateway, interfacename, isprimary, isactive) -- comstypeid 1 = Network Interface -- NOTE: Column is 'address' not 'ipaddress' -- Subnets subnets (subnetid, address, subnet, vlan, gateway, subnettypeid) ``` ### Equipment & Machine Types ```sql -- Machine Types (machinetypeid ranges) machinetypes (machinetypeid, machinetype) -- 1-15: Equipment (Vertical Lathe, Mill, CMM, etc.) -- 16-20: Network Devices (16=AP, 17=IDF, 18=Camera, 19=Switch, 20=Server) -- 33-35: PC Types (Desktop, Laptop, Workstation) -- Installed Apps on Equipment installedapps (machineid, applicationid) ``` ### Applications & KB ```sql -- Applications applications (applicationid, applicationname, appdescription, supportteamid) -- Knowledge Base knowledgebase (linkid, shortdescription, keywords, applicationid, linkurl, clicks) ``` ### Infrastructure ```sql -- Printers (separate table, not in machines) printers (printerid, printercsfname, modelid, serialnumber, ipaddress, fqdn, isactive) -- NOTE: Printers use 'ipaddress' (unlike communications which uses 'address') -- Notifications notifications (notificationid, notification, starttime, endtime, isactive, notificationtypeid) -- Warranties warranties (warrantyid, machineid, enddate, servicelevel, status, daysremaining) ``` ### Reference Data ```sql -- Core reference tables models (modelnumberid, modelnumber, vendorid) vendors (vendorid, vendor) operatingsystems (osid, osname) supportteams (supportteamid, supportteam) relationshiptypes (relationshiptypeid, relationshiptype) -- Additional lookup tables machinestatus (machinestatusid, machinestatus) -- TBD, In Use, Returned, etc. notificationtypes (notificationtypeid, typename) -- Awareness, Change, Incident comstypes (comstypeid, typename) -- IP, Serial, Network_Interface subnettypes (subnettypeid, subnettypename) -- Subnet type classifications topics (topicid, topic) -- KB topic categories appowners (appownerid, appowner) -- Application ownership appversions (appversionid, applicationid, version) -- Application version tracking businessunits (businessunitid, businessunit) -- Business unit classifications ``` --- ## File Structure Map ``` shopdb/ ├── *.asp # Main pages │ ├── default.asp # Dashboard │ ├── api.asp # REST API endpoint │ ├── search.asp # Unified search │ ├── display*.asp # View pages │ ├── add*.asp # Create forms │ ├── edit*.asp # Update forms │ └── printerlookup.asp # Zabbix printer lookup │ ├── includes/ # Shared code │ ├── sql.asp # DB connection │ ├── header.asp # HTML head │ ├── leftsidebar.asp # Navigation │ └── topbarheader.asp # Top bar │ ├── assets/ # Frontend resources │ ├── css/ # Stylesheets │ ├── js/ # JavaScript │ ├── images/ # Icons, logos │ └── plugins/ # Third-party libs │ ├── sql/ # Database scripts │ ├── view_consolidation.sql # All database views │ └── archive/ # Historical migrations │ └── docs/ # Documentation ├── API.md # REST API docs ├── ASP_DEVELOPMENT_GUIDE.md # Dev setup ├── STANDARDS.md # Coding standards ├── QUICK_REFERENCE.md # This file └── archive/ # Historical docs ``` --- ## Common Tasks ### Start Development Environment ```bash cd ~/projects/windows/shopdb ~/start-dev-env.sh # Starts Docker + Windows VM # Wait ~30 seconds for IIS to start curl http://192.168.122.151:8080 # Test ``` ### Database Access ```bash # Connect to MySQL docker exec -it dev-mysql mysql -u root -prootpassword shopdb # Backup database docker exec dev-mysql mysqldump -u root -prootpassword shopdb > backup.sql # Restore database docker exec -i dev-mysql mysql -u root -prootpassword shopdb < backup.sql # Check table counts docker exec dev-mysql mysql -u root -prootpassword shopdb \ -e "SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema='shopdb' ORDER BY table_rows DESC;" ``` ### Code Development ```bash # Edit files (auto-syncs to Windows via Samba) code ~/projects/windows/shopdb/ # Check syntax (if you have a validator) # ASP doesn't have great linters, test by loading in browser # View logs (Windows VM) # C:\inetpub\logs\LogFiles\ ``` ### Testing Changes 1. Save file on Linux (auto-syncs to Z:\shopdb\ on Windows) 2. Refresh browser (http://192.168.122.151:8080/yourfile.asp) 3. Check browser console for JS errors 4. Check IIS Express console for ASP errors 5. Check database for data changes --- ## Search System Quick Guide ### Search Syntax - **Exact match:** `"exact phrase"` (not yet implemented) - **Multiple words:** `word1 word2` (finds both) - **Short words:** < 4 characters use LIKE fallback automatically ### What's Searchable? - **Applications:** Name - **Knowledge Base:** Title, keywords, application name - **Notifications:** Notification text - **Machines:** Number, alias, type, vendor, notes - **Printers:** CSF name, model, serial number ### Smart Redirects - **Printer serial (exact):** → Printer detail page - **Printer FQDN (exact):** → Printer detail page - **Machine number (exact):** → Machine detail page --- ## Key VBScript Patterns ### Include Required Files ```vbscript ``` ### Safe Database Query ```vbscript <% ' Get and validate input Dim machineId machineId = GetSafeInteger("QS", "machineid", 0, 1, 999999) If machineId = 0 Then Response.Redirect("error.asp?code=INVALID_ID") Response.End End If ' Parameterized query strSQL = "SELECT * FROM machines WHERE machineid = ? AND isactive = 1" Set rs = ExecuteParameterizedQuery(objConn, strSQL, Array(machineId)) ' Use results If Not rs.EOF Then Response.Write Server.HTMLEncode(rs("machinenumber")) End If ' Cleanup rs.Close Set rs = Nothing Call CleanupResources() %> ``` ### Display a List ```vbscript <% strSQL = "SELECT machineid, machinenumber, alias FROM machines WHERE isactive=1 ORDER BY machinenumber" Set rs = objConn.Execute(strSQL) Do While Not rs.EOF %>