# Printer Mapping Migration Report **Date:** 2025-10-22 **Author:** Development Team **Status:** Analysis Complete - Ready for Implementation --- ## Executive Summary The `printers` table now has `maptop` and `mapleft` columns added for direct printer location mapping on the shop floor map. This migration report outlines the necessary code changes to transition from machine-based printer positioning to direct printer positioning. ### Database Changes Completed - Added `maptop INT(11)` column to `printers` table - Added `mapleft INT(11)` column to `printers` table - Both columns are nullable (default NULL) - Positioned after `machineid` column --- ## Current Implementation Analysis ### 1. **printermap.asp** - Main Map View **Current Behavior:** - Queries printers joined with machines to get map coordinates - Uses `machines.maptop` and `machines.mapleft` for printer positioning - Shows printer at machine location - Requires `printers.machineid != 1` (excludes unassigned printers) **SQL Query (Lines 186-189):** ```sql SELECT machines.mapleft, machines.maptop, machines.machinenumber, printers.printerid, printers.printercsfname, printers.printerwindowsname, models.modelnumber, models.image, printers.ipaddress, printers.fqdn, machines.machinenotes, machines.alias FROM machines, printers, models WHERE printers.modelid = models.modelnumberid AND printers.machineid != 1 AND printers.machineid = machines.machineid AND printers.isactive = 1 ``` **Location Display (Lines 202-207):** ```vbscript ' Uses alias if available, otherwise machinenumber if NOT IsNull(rs("alias")) AND rs("alias") <> "" THEN location = rs("alias") else location = rs("machinenumber") end if ``` **Issues:** - Printers without machine assignment (`machineid=1`) are excluded from map - Multiple printers at same machine appear stacked on same coordinate - Cannot position printer independently of machine --- ### 2. **addprinter.asp** - Add New Printer Form **Current Behavior:** - Form includes machine dropdown (required field) - Uses machineid to determine printer location - No map coordinate input fields **Location Field (Lines 174-197):** ```vbscript
<%Response.Write(rs("machinenumber"))%>
``` **Issues:** - Still references machine location - No display of printer's actual map coordinates --- ## Required Code Changes ### Priority 1: Core Map Functionality #### 1. **printermap.asp** - Update Query to Use Printer Coordinates **Change SQL Query (Lines 186-189):** ```vbscript <% ' OLD (commented out): ' strSQL = "SELECT machines.mapleft, machines.maptop, machines.machinenumber, ... FROM machines, printers ..." ' NEW - Use printer coordinates, fallback to machine if not set strSQL = "SELECT " &_ "COALESCE(printers.mapleft, machines.mapleft) AS mapleft, " &_ "COALESCE(printers.maptop, machines.maptop) AS maptop, " &_ "machines.machinenumber, machines.alias, " &_ "printers.printerid, printers.printercsfname, printers.printerwindowsname, " &_ "models.modelnumber, models.image, printers.ipaddress, printers.fqdn, " &_ "printers.maptop AS printer_maptop, printers.mapleft AS printer_mapleft " &_ "FROM printers " &_ "INNER JOIN models ON printers.modelid = models.modelnumberid " &_ "LEFT JOIN machines ON printers.machineid = machines.machineid " &_ "WHERE printers.isactive = 1 " &_ " AND (printers.maptop IS NOT NULL OR machines.maptop IS NOT NULL)" set rs = objconn.Execute(strSQL) while not rs.eof mapleft = rs("mapleft") maptop = rs("maptop") maptop = 2550 - maptop ' Coordinate transformation ' ... rest of code %> ``` **Benefits:** - Uses printer coordinates if available - Falls back to machine coordinates if printer coordinates not set - Includes printers without machine assignment (if they have coordinates) - Backward compatible during migration --- #### 2. **addprinter.asp** & **editprinter.asp** - Add Map Picker **Add New Form Fields (after line 197 in addprinter.asp):** ```html