From 3bce4852db26bf04a3c22fc208bfd0604e931cbe Mon Sep 17 00:00:00 2001 From: cproudlock Date: Thu, 11 Dec 2025 17:02:18 -0500 Subject: [PATCH] Update QUICK_REFERENCE.md for Phase 2 schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rewrite Core Tables section for unified machines table - Update PC/Equipment/Network device identification queries - Add communications table (replaces pc_network_interfaces) - Update column names (address not ipaddress, machineid not pcid) - Update Important Views section with current views - Fix SQL query examples for new schema - Update file structure and resource references - Update database credentials 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- docs/QUICK_REFERENCE.md | 253 +++++++++++++++++++++++----------------- 1 file changed, 149 insertions(+), 104 deletions(-) diff --git a/docs/QUICK_REFERENCE.md b/docs/QUICK_REFERENCE.md index d2d71b6..94831b6 100644 --- a/docs/QUICK_REFERENCE.md +++ b/docs/QUICK_REFERENCE.md @@ -1,7 +1,7 @@ # ShopDB Quick Reference Guide **For:** New team members and quick lookups -**See Also:** DEEP_DIVE_REPORT.md (comprehensive), ASP_DEVELOPMENT_GUIDE.md (development), STANDARDS.md (coding standards) +**See Also:** ASP_DEVELOPMENT_GUIDE.md (development), STANDARDS.md (coding standards), API.md (REST API) --- @@ -31,66 +31,86 @@ ## Core Tables Cheat Sheet -### PC Management +### Unified Machines Table (Phase 2 Schema) ```sql --- Main PC table -pc (pcid, hostname, serialnumber, pctypeid, machinenumber, modelnumberid, osid) +-- 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) --- PC Types -pctype (Standard, Engineer, Shopfloor, Server, Laptop, VM) - --- PC Status -pcstatus (In Use, Spare, Retired, Broken, Unknown) - --- Network -pc_network_interfaces (pcid, ipaddress, subnetmask, macaddress, isdhcp) - --- Communication -pc_comm_config (pcid, configtype, portid, baud, databits, ipaddress) - --- DNC -pc_dnc_config (pcid, site, cnc, ncif, dualpath_enabled, path1_name, path2_name) +-- Identify record type: +-- PCs: pctypeid IS NOT NULL (machinetypeid 33-35) +-- Equipment: pctypeid IS NULL AND machinetypeid < 16 +-- Network Devices: machinetypeid IN (16,17,18,19,20) ``` -### Machine Management +### PC-Related Tables ```sql --- Machines -machines (machineid, machinenumber, alias, machinetypeid, printerid, ipaddress1/2) +-- PC Types +pctype (pctypeid, typename) +-- Values: Standard, Engineer, Shopfloor, CMM, Wax Trace, etc. --- Machine Types -machinetypes (Vertical Lathe, Horizontal Lathe, 5-Axis Mill, CMM, Part Washer, etc.) +-- PC Communication Config (serial ports) +pc_comm_config (commconfigid, machineid, portname, baudrate, databits, parity, stopbits) --- Installed Apps -installedapps (appid, machineid) -- Junction table +-- PC DNC Config +pc_dnc_config (dncconfigid, 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 (replaces pc_network_interfaces) +communications (comid, machineid, comstypeid, address, macaddress, + subnetmask, gateway, 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 (appid, appname, appdescription, supportteamid, isinstallable) +applications (applicationid, applicationname, appdescription, supportteamid) -- Knowledge Base -knowledgebase (linkid, shortdescription, keywords, appid, linkurl, clicks) +knowledgebase (linkid, shortdescription, keywords, applicationid, linkurl, clicks) ``` ### Infrastructure ```sql --- Printers -printers (printerid, printercsfname, modelid, serialnumber, ipaddress, fqdn, machineid) - --- Subnets -subnets (subnetid, ipaddress, subnet, vlan, gateway, subnettypeid) +-- Printers (separate table, not in machines) +printers (printerid, printercsfname, modelid, serialnumber, address, fqdn, isactive) +-- NOTE: Column is 'address' not 'ipaddress' -- Notifications -notifications (notificationid, notification, starttime, endtime, isactive) +notifications (notificationid, notification, starttime, endtime, isactive, notificationtypeid) ``` ### Reference Data ```sql models (modelnumberid, modelnumber, vendorid) vendors (vendorid, vendor) -operatingsystems (osid, operatingsystem) +operatingsystems (osid, osname) supportteams (supportteamid, supportteam) +relationshiptypes (relationshiptypeid, relationshiptype) ``` --- @@ -99,25 +119,20 @@ supportteams (supportteamid, supportteam) ``` shopdb/ -├── *.asp # Main pages (91 files) +├── *.asp # Main pages │ ├── default.asp # Dashboard +│ ├── api.asp # REST API endpoint │ ├── search.asp # Unified search -│ ├── calendar.asp # Notification calendar │ ├── display*.asp # View pages │ ├── add*.asp # Create forms │ ├── edit*.asp # Update forms -│ ├── save*.asp # Backend processors -│ └── api_*.asp # JSON APIs +│ └── printerlookup.asp # Zabbix printer lookup │ ├── includes/ # Shared code │ ├── sql.asp # DB connection │ ├── header.asp # HTML head │ ├── leftsidebar.asp # Navigation -│ ├── topbarheader.asp # Top bar -│ ├── error_handler.asp # Error handling -│ ├── validation.asp # Input validation -│ ├── db_helpers.asp # DB utilities -│ └── data_cache.asp # Caching system +│ └── topbarheader.asp # Top bar │ ├── assets/ # Frontend resources │ ├── css/ # Stylesheets @@ -125,18 +140,16 @@ shopdb/ │ ├── images/ # Icons, logos │ └── plugins/ # Third-party libs │ -├── images/ # Dashboard images -│ └── 1-9.jpg # Rotating images -│ ├── sql/ # Database scripts -│ └── database_updates_for_production.sql +│ ├── view_consolidation.sql # All database views +│ └── archive/ # Historical migrations │ └── docs/ # Documentation - ├── DEEP_DIVE_REPORT.md # Comprehensive guide + ├── API.md # REST API docs ├── ASP_DEVELOPMENT_GUIDE.md # Dev setup ├── STANDARDS.md # Coding standards - ├── NESTED_ENTITY_CREATION.md # Complex forms - └── QUICK_REFERENCE.md # This file + ├── QUICK_REFERENCE.md # This file + └── archive/ # Historical docs ``` --- @@ -154,16 +167,16 @@ curl http://192.168.122.151:8080 # Test ### Database Access ```bash # Connect to MySQL -docker exec -it dev-mysql mysql -u 570005354 -p570005354 shopdb +docker exec -it dev-mysql mysql -u root -prootpassword shopdb # Backup database -docker exec dev-mysql mysqldump -u 570005354 -p570005354 shopdb > backup.sql +docker exec dev-mysql mysqldump -u root -prootpassword shopdb > backup.sql # Restore database -docker exec -i dev-mysql mysql -u 570005354 -p570005354 shopdb < backup.sql +docker exec -i dev-mysql mysql -u root -prootpassword shopdb < backup.sql # Check table counts -docker exec dev-mysql mysql -u 570005354 -p570005354 shopdb \ +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;" ``` @@ -301,26 +314,39 @@ End If ## Important Views to Know -### PC-Related Views -- `vw_shopfloor_pcs` - Shopfloor PCs with machine assignments -- `vw_active_pcs` - PCs updated in last 30 days -- `vw_pc_summary` - Overall PC inventory -- `vw_pc_network_summary` - Network configuration overview +All views defined in `sql/view_consolidation.sql` + +### Display Page Views +- `vw_equipment_list` - Equipment for displaymachines.asp +- `vw_pc_list` - PCs for displaypcs.asp +- `vw_printer_list` - Printers for displayprinters.asp +- `vw_machine_detail` - Full details for detail pages +- `vw_network_devices` - Network devices (APs, switches, etc.) + +### Map Views +- `vw_map_equipment` - Equipment with map positions +- `vw_map_printers` - Printers with map positions +- `vw_map_network_devices` - Network devices on map +- `vw_network_map_devices` - Combined printers + network devices + +### Relationship Views +- `vw_equipment_pc_relationships` - PC-to-equipment links +- `vw_machine_relationships` - All machine relationships + +### Summary Views - `vw_warranty_status` - Warranty tracking -- `vw_warranties_expiring` - Expiring in next 90 days +- `vw_warranty_summary` - Warranty stats by status +- `vw_pctype_summary` - Counts by PC type +- `vw_equipment_type_summary` - Counts by equipment type -### Machine-Related Views -- `vw_machine_assignments` - PC-to-machine relationships -- `vw_machine_type_stats` - Counts by machine type -- `vw_multi_pc_machines` - Machines with multiple PCs -- `vw_unmapped_machines` - Missing map coordinates -- `vw_dualpath_management` - DualPath CNCs +### Notification Views +- `vw_active_notifications` - Current/recent notifications +- `vw_upcoming_notifications` - Scheduled notifications -### Reporting Views -- `vw_vendor_summary` - PC counts by manufacturer -- `vw_pcs_by_hardware` - Hardware distribution -- `vw_pctype_config` - Configuration by PC type -- `vw_recent_updates` - Recent changes +### Application Views +- `vw_applications_list` - Apps with KB counts +- `vw_knowledge_base` - KB articles with app info +- `vw_installed_apps_summary` - App installation stats --- @@ -330,8 +356,8 @@ End If - Host: 192.168.122.1 (from Windows VM) - Port: 3306 - Database: shopdb -- User: 570005354 -- Password: 570005354 +- User: root +- Password: rootpassword **Production Database:** - See production server documentation (credentials secured) @@ -387,51 +413,70 @@ Before deploying code, verify: ## Useful SQL Queries -### Find PCs by Machine Number +### Get All PCs ```sql -SELECT p.hostname, p.serialnumber, p.machinenumber, pt.typename -FROM pc p -JOIN pctype pt ON p.pctypeid = pt.pctypeid -WHERE p.machinenumber = '3104' - AND p.isactive = 1; +SELECT m.machineid, m.hostname, m.serialnumber, pt.typename AS pctype +FROM machines m +JOIN pctype pt ON m.pctypeid = pt.pctypeid +WHERE m.pctypeid IS NOT NULL AND m.isactive = 1 +ORDER BY m.hostname; ``` -### Machines Without Assigned PCs +### Get All Equipment ```sql -SELECT m.machinenumber, m.alias, mt.machinetype +SELECT m.machineid, m.machinenumber, m.alias, mt.machinetype FROM machines m -LEFT JOIN pc p ON p.machinenumber = m.machinenumber AND p.isactive = 1 JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid -WHERE p.pcid IS NULL - AND m.isactive = 1 - AND m.islocationonly = 0; +WHERE m.pctypeid IS NULL AND m.machinetypeid < 16 AND m.isactive = 1 +ORDER BY m.machinenumber; +``` + +### Get Network Devices +```sql +SELECT m.machineid, m.alias, mt.machinetype, c.address +FROM machines m +JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid +LEFT JOIN communications c ON m.machineid = c.machineid AND c.isprimary = 1 +WHERE m.machinetypeid IN (16,17,18,19,20) AND m.isactive = 1; +``` + +### Find PC by Hostname with IP +```sql +SELECT m.hostname, m.serialnumber, c.address AS ipaddress, pt.typename +FROM machines m +JOIN pctype pt ON m.pctypeid = pt.pctypeid +LEFT JOIN communications c ON m.machineid = c.machineid AND c.isprimary = 1 +WHERE m.hostname = 'PC-NAME' AND m.pctypeid IS NOT NULL; +``` + +### Equipment with Controlling PCs +```sql +SELECT + equipment.machinenumber AS equipment, + equipment.alias, + pc.hostname AS controlling_pc +FROM machinerelationships mr +JOIN machines equipment ON mr.machineid = equipment.machineid +JOIN machines pc ON mr.related_machineid = pc.machineid +WHERE mr.relationshiptypeid = 3 AND mr.isactive = 1; ``` ### Most Clicked KB Articles ```sql -SELECT k.shortdescription, a.appname, k.clicks, k.linkurl +SELECT k.shortdescription, a.applicationname, k.clicks, k.linkurl FROM knowledgebase k -JOIN applications a ON k.appid = a.appid +JOIN applications a ON k.applicationid = a.applicationid WHERE k.isactive = 1 ORDER BY k.clicks DESC LIMIT 20; ``` -### Warranties Expiring This Month -```sql -SELECT hostname, serialnumber, warrantyenddate, warrantydaysremaining -FROM vw_warranties_expiring -WHERE warrantyenddate BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 30 DAY) -ORDER BY warrantyenddate; -``` - ### DualPath PCs ```sql -SELECT p.hostname, d.primary_machine, d.secondary_machine, dnc.dualpath_enabled -FROM pc p -JOIN pc_dualpath_assignments d ON p.pcid = d.pcid -JOIN pc_dnc_config dnc ON p.pcid = dnc.pcid -WHERE dnc.dualpath_enabled = 1; +SELECT m.hostname, dnc.dualpath_enabled, dnc.path1_name, dnc.path2_name +FROM machines m +JOIN pc_dnc_config dnc ON m.machineid = dnc.machineid +WHERE dnc.dualpath_enabled = 1 AND m.pctypeid IS NOT NULL; ``` --- @@ -439,10 +484,10 @@ WHERE dnc.dualpath_enabled = 1; ## Resources ### Documentation -- **Comprehensive Guide:** docs/DEEP_DIVE_REPORT.md +- **REST API:** docs/API.md - **Development Setup:** docs/ASP_DEVELOPMENT_GUIDE.md - **Coding Standards:** docs/STANDARDS.md -- **Complex Forms:** docs/NESTED_ENTITY_CREATION.md +- **Project Context:** CLAUDE.md ### External Links - **Classic ASP Reference:** https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525334(v=vs.90) @@ -496,6 +541,6 @@ WHERE dnc.dualpath_enabled = 1; --- -**Last Updated:** 2025-10-20 +**Last Updated:** 2025-12-11 **Maintained By:** Development Team -**Review:** Update when major changes occur +**Schema:** Phase 2 (unified machines table)