Printing
Overview & Version Comparison
The Printing System bridges the CodeIgniter 4 web application and physical Zebra (ZT411, ZT411R, ZD421) label printers in the factory. Both v2 and v1 coexist in the codebase until v1 is deprecated; jobs are tagged via print_job.print_engine ('zpl' for v2, 'bartender' for v1).
| Capability | Printing System v2 (Current — Direct ZPL) | Printing System v1 (Legacy — BarTender) |
|---|---|---|
| Engine Flag | print_job.print_engine = 'zpl' | print_job.print_engine = 'bartender' |
| Worker / Agent | shelter-print-agent (Python service on SEI-APP1) | BarTender Automation Suite (.btin integrations on SEI-APP1 / PLANT 05) |
| Printer Transport | Direct raw TCP socket (Port 9100) using ZPL II & SGD | Windows Print Spooler via Print Maestro |
| Printer Registry | printer database table, managed at /admin/printers & synced via /api/printer/get_all | Hardcoded in .btin integrations & Windows queues |
| Templates | zpl_template table + shelter-print-agent/templates/*.zpl (managed at /admin/zpl_templates) | BarTender Designer .btw files |
| Progress & Telemetry | Live X / Y tracking (~HS + SGD odometer), ~HQES error bitmask decoding, live heartbeat | None (fire-and-forget queue) |
| Cancellation | Remote cancel via /api/printer/pending_cancellations -> Zebra ~JA RAM purge | Manual cancel in Print Maestro |
| Primary UI | /eifs/full_line_labels_v2 | /eifs/full_line_labels and legacy station views |
Printing System v2 (Current — Direct ZPL Architecture)
Architecture Flow
Web App (CI4) -> Insert row in print_job (print_engine='zpl')
-> shelter-print-agent polls GET /api/printer/pending_jobs & GET /api/printer/get_all
-> Renders .zpl template (substitutes {{vars}} + ^PQ{copies},0,1,Y)
-> Dispatches raw ZPL over TCP 9100 to target Zebra printer
-> Polls ~HS / ~HQES / SGD odometer -> POST /api/printer/job_progress & /api/printer/report_status
-> Label Printing Center v2 polls GET /api/printer/status every 3s
Database Schema (v2 Additions)
printerTable (migrations2026-10-23-151000_CreatePrinterTable&2026-11-24-154500_AddRoutingFieldsToPrinterTable):- Identity & network:
id,name,model,ip_address,port(default9100),windows_queue_name - Routing:
location_id(FK ->location.id),print_types(JSON array of ints, e.g.[2,3,4]),template_suffix(e.g._Rotation) - Live telemetry:
status,status_details,buffer_count,last_status_check - Archiving:
is_active(1= active,0= archived) - Model:
App\Models\Printer_model(normalizesprint_typestoint[])
- Identity & network:
zpl_template&zpl_template_historyTables (migration2026-11-23-231500_CreateZplTemplateTables):- Stores ZPL template source, dimensions (
width_in,height_in,dpmm), orientation metadata, content hashes, and revision history.
- Stores ZPL template source, dimensions (
print_jobVisibility & Deferred Inventory Columns (migrations2026-10-23-150000_UpdatePrintJobTableForVisibility,2026-11-24-140000_AddPrintEngineToPrintJob, &2026-11-24-213000_AddDeferredInventoryToPrintJob):- Adds
print_engine('zpl'/'bartender'), livestatus,printed_copies,error_message, cancellation tracking, and deferred inventory columns (inventory_payload,inventory_committed). - Also registers the
Print Job Cancellednotification type innotification_typefor mid-print cancellation alerts.
- Adds
v2 Controllers & API Endpoints
App\Controllers\Api\Printer (/api/printer/*)
GET /api/printer/get_all— Returns active printers (is_active = 1) withlocation,print_types, andtemplate_suffix. Pass?include_archived=1to include archived printers (used by/admin/printers).GET /api/printer/status— Returns active printers plus the cached print agent heartbeat summary for the Label Printing Center v2 UI.POST /api/printer/heartbeat— Lightweight agent heartbeat endpoint.POST /api/printer/report_status— Receives live Zebra telemetry (status,status_details,buffer_count) fromshelter-print-agent. Does not overwriteip_address(database is the source of truth).GET /api/printer/pending_jobs— Returns queued ZPL jobs forshelter-print-agentto execute.GET /api/printer/pending_cancellations— Returns jobs cancelled in the web UI so the agent can issue~JA.POST /api/printer/job_progress— Receives real-timeX / Yprogress, odometer readings, and terminal job states (completed,cancelled, error states). Automatically commits deferred inventory viaApp\Libraries\PrintInventoryServicewhen a ZPL job transitions tocompleted.POST /api/printer/create(Admin) — Adds a new printer to theprintertable.POST /api/printer/update/{id}(Admin) — Updates printer name, IP, port, model, location,print_types,template_suffix, orwindows_queue_name.POST /api/printer/set_archived/{id}(Admin) — Archives (is_active = 0) or restores (is_active = 1) a printer.
App\Controllers\Api\PrintJob (/api/print_job/*)
GET /api/print_job/for_job/{job_id}— Returns active/queued ZPL jobs, recent terminal jobs, active printers, and agent heartbeat scoped to a specific productionjob_id.POST /api/print_job/cancel/{id}— Cancels a queued or active ZPL print job. Accepts optionalcommit_partial(0/1) andpartial_quantityfor mid-print cancellations; records aPrint Job Cancellednotification detailing whether partial inventory was committed or 0 inventory was created.
App\Controllers\Api\ZplTemplate (/api/zpl_template/*)
- Lists active ZPL templates, renders live previews (with
uprightvsprinterorientation), and saves versioned template updates.
Admin & Operator Views (v2)
/eifs/full_line_labels_v2(Eifs::full_line_labels_v2,src/app/Views/eifs/full_line_labels_v2.php,src/public/js/eifs/full_line_labels_v2.js) — Label Printing Center v2 with live Zebra status cards, ZPL preview, active job progress, and cancel button./admin/printers(Admin::printers,src/app/Views/admin/printers.php,src/public/js/admin/printers.js) — Admin Printer Management UI (add, edit, search, archive/restore)./admin/zpl_templates(Admin::zpl_templates,src/app/Views/admin/zpl_templates.php,src/public/js/admin/zpl_templates.js) — Admin ZPL Template Manager & Live Preview Editor.- In-Progress Job Print Status Widget (Beta) (
src/app/Views/templates/job_print_status.php,src/public/js/templates/job_print_status.js) — Embedded on Shape Mold, RoboPack, and EIFS in-progress pages. PollsGET /api/print_job/for_job/{job_id}, displays target printer status and label progress, and handles print cancellation with deferred inventory (PrintInventoryService).- Go-Live Reminder (Admin-Only Gate): The in-progress Print v2.0 preview/toggle is currently restricted to
factory_adminand higher (inGroup('super_admin', 'admin', 'factory_admin')) via$can_use_print_v2inShapeMold::job_in_progress,Robopack::in_progress,Eifs::in_progress, andViews/templates/job_print_status.php. When moving Print v2.0 out of beta for all floor operators, remove that group restriction and switch the default from BarTender to ZPL.
- Go-Live Reminder (Admin-Only Gate): The in-progress Print v2.0 preview/toggle is currently restricted to
Python Print Agent (shelter-print-agent)
- Located in the
shelter-print-agentrepository; deployed onSEI-APP1. - Database-Driven Printer Sync: Pulls active printers from
GET /api/printer/get_allon startup and everyprinter_sync_interval_seconds(default30s) instead of reading a hardcoded"printers"array fromsettings.json. - Parallel Per-Printer Workers: Spawns one dedicated worker thread per printer key so jobs on different printers execute concurrently. Each worker resolves the latest synced printer record before dispatching so IP/port/routing edits apply without restarting the agent.
- Engine Isolation: Automatically skips
print_jobrows whereprint_engine == 'bartender'so v1 and v2 can run side-by-side safely.- Current Phased Rollout Status:
mass_send()(1),send_manual_shape_mold()(4),sill_seal_labels()(5), andsend_line()(6in ZPL mode) acceptprint_engine = 'zpl'and route viashelter-print-agent. In-progress station endpointssend()(Robo Pack0) andsend_shape_mold()(BuildBlock2/ CreteHeat3) now also acceptprint_engine = 'zpl'with deferred inventory commit (inventory_payload/inventory_committed), while defaulting toprint_engine = 'bartender'until the beta toggle is enabled (currently visible only tofactory_adminand higher).
- Current Phased Rollout Status:
- Job Routing Precedence (
resolve_printer_for_job):- Explicit
printer_iporprinter_idon the job - Matching
print_type+location_id - Matching
print_typewithlocation_id IS NULL - First printer matching
print_type
- Explicit
Printing System v1 (Legacy — BarTender Automation Suite)
Status: Legacy. Maintained alongside v2 until BarTender is fully deprecated.
v1 Architecture Flow
Web Application (CodeIgniter 4) -> Insert Row into print_job Table
-> BarTender Integration (SEI-APP1 Server) monitors database for new rows
-> BarTender Automation Engine populates .btw label template with data
-> Print Maestro manages Windows print queue -> Zebra Printer -> Printed Label
Currently, BarTender runs on SEI-APP1 (and PLANT 05 in the shipping office, accessible via realVNC).
1. Print Job Database Table (print_job)
Core fields driving both v1 and v2 job creation:
id: Primary keylabel_name: Template name (matches.btwin v1 or.zplin v2)copies: Number of identical labels to printprint_type: Integer (0–6) determining printer routing:0— Robo Pack EIFS1— Manual EIFS2— Shape Mold BuildBlock3— Shape Mold CreteHeat4— Manual Shape Mold5— Sill Seal6— Line Stickers (FullLot)
job_id: Foreign key linking to the parent joblocation_id: Foreign key linking to thelocationtable
Type-Specific Fields:
- EIFS:
lot_number,size_value,size_numerator,size_denominator, sequential numbering (size_count,size_total,job_count,job_total),pcs_per_bag,customer(12 char max),sales_order,bag_type(20 char max). - Shape Mold:
part_type,part_number,thickness,piece_count,operatorinitials,shift,web_location(BuildBlock),production_date(BuildBlock). - Line Sticker:
pagesand custom formatting fields.
2. BarTender Integration Files
Hosted on the local Windows Server (c:\Users\jmess\Downloads\Label Printing Files(1)):
- Integration Files (
.btin):Robo Pack Integration.btinShape Mold Integration.btinPrint Stickers Function.btin
- Label Templates (
.btw):FullLot.btw,divider.btw, and subdirectoriesEIFS,ShapeMold,SillSeal.
- BarTender Suite Applications: Administration Console, Integration Builder, and Print Maestro.
3. Shared Web Application Integration (App\Controllers\Api\PrintJob)
send()— Creates EIFS Robo Pack print jobs (print_type = 0). Validates parameters, finds EIFS bag type, calculates sequential numbers, creates EIFS bags, deducts inventory, and inserts intoprint_job.mass_send()— Batch EIFS print jobs (print_type = 1), incrementingjob_countacross all sizes.send_line()— Creates custom line sticker print jobs (print_type = 6, no inventory deduction).send_shape_mold()— Creates BuildBlock (2) or CreteHeat (3) labels with job context.send_manual_shape_mold()— Manual shape mold labels (print_type = 4).sill_seal_labels()— Sill Seal box/roll labels (print_type = 5).get_label_info()— Returns printed jobs and pending targets for an EIFS job.
Helper Functions (src/app/Helpers/print_job_helper.php)
get_eifs_target_print_label()— Determines template name (LotStickerEPS,LotStickerEPSFrac,LotStickerGPS,LotStickerGPSFrac, plusDBdrainage suffix)format_printed_jobs()— Transforms query resultsfind_starting_number()— Calculates next sequential number for 3-digit padded displaysfind_print_job_count()— Returns total labels for a jobdelete_previous_print_job()— Removes old jobs during a resend operationget_eifs_target_print_job()— Generates print job data structure
Label Templates Reference
- EIFS:
LotStickerEPS,LotStickerEPSFrac,LotStickerGPS,LotStickerGPSFrac(plusDBsuffix for drainage) - Shape Mold:
BuildBlock(Portrait & Landscape /_Rotation),CreteHeat(Portrait & Landscape /_Rotation) - Sill Seal:
SillSealBox(3.5, 5.5, 7.5)
SillSealRoll(3.5, 5.5, 7.5)
4. Data Flow & Integration Points
- Inventory Management: Print job creation deducts stickers (
remove_sticker()), deducts bags (remove_bag()), and createseifs_bagrecords (make_eifs_bags()). (Print jobs still succeed even if inventory is insufficient.) - Sequential Numbering:
size_countandjob_countare zero-padded to 3 digits; resend operations can intentionally create gaps. - Notifications: Resend operations and "Block not found" errors trigger admin notifications.
- Locations:
location_idlinksprint_jobandprinterto factory locations/buildings.
5. Legacy Front-End Files
- Robo Pack:
src/public/js/robopack/robo_pack_in_progress.js(/api/print_job/send) - Shape Mold:
src/public/js/shape_mold/shape_mold_in_progress.js(/api/print_job/send_shape_mold,/api/print_job/send_manual_shape_mold) - Full Line EIFS (v1):
src/public/js/eifs/full_line_labels.js(/api/print_job/mass_send)
6. v1 Known Limitations & Support Contacts
- Database polling latency, manual cleanup of old
print_jobrows, printer downtime queueing in Print Maestro,.btwtemplate edits requiring Integration Builder, and character limits (12 chars customer, 20 chars bag type). - BarTender Tech Support: (425) 274-3610
- SSE Technologies (Reseller):
- Adam Egert —
[email protected], 516-872-7000 x223 (Mobile: 516-902-3762) - Jonathan Negron —
[email protected], 516-872-7000 x230 - 791 Meacham Avenue, Elmont, NY 11003 | www.ssetechnologies.com
- Adam Egert —