Skip to content

SBCLockDevTeam/Inventory

Repository files navigation

QR Inventory/Asset Tracking System

QR Inventory/Asset tracking system for SBC.

It uses PHP, CSS, JavaScript, MariaDB.

See .agentic.yml and .agentic.workflow.yml for project rules.


Server Setup & Installation

1. Clone the repository

git clone git@github.com:SBCLockDevTeam/Inventory.git /var/www/html/sbcqr/qr/

2. Configure secrets

Copy the secrets template and fill in your database credentials:

cp /var/www/html/sbcqr/qr/config/secrets.php.example /var/www/html/sbcqr/qr/config/secrets.php

Then edit /var/www/html/sbcqr/qr/config/secrets.php and enter your database password and any other environment-specific credentials.

⚠️ secrets.php is excluded from Git and must be created manually on every server.

3. Compile the printer binary

The application includes a compiled C helper (bin/printer) for sending ESC/P label jobs to a network printer over TCP. This binary is not stored in Git (it is platform-specific) and must be compiled on each server after cloning.

Why it exists: PHP's fsockopen() had intermittent hostname resolution failures on some server configurations. This compiled helper bypasses that issue.

To compile:

gcc -o /var/www/html/sbcqr/qr/bin/printer /var/www/html/sbcqr/qr/bin/printer.c

No special libraries are required — only standard gcc and POSIX system libraries (available on any standard Linux server).

To verify it compiled correctly:

/var/www/html/sbcqr/qr/bin/printer

You should see: Usage: printer <host> <port>

Usage: The binary reads a raw ESC/P payload from stdin and sends it to the printer at <host>:<port> over TCP. It accepts both hostnames and IP addresses.

Brother TD-4D Printer:

The Brother TD-4420DN uses ESC/P commands. AI agents will often removed the required initialization code. The fault is not intermittent: after a power cycle, the printer won’t work until it’s initialized. Once initialized, it prints reliably. Best practice: send the init sequence at the start of every print job.

4. Set file permissions

chmod +x /var/www/html/sbcqr/qr/bin/printer

Dependencies

Dependency Version Notes
PHP 7.4+
MariaDB 10.x+ Database: SBCInv
Apache 2.4+ Document root: /var/www/html/sbcqr/
gcc Any modern Required to compile bin/printer.c

Directory Structure

/qr/
├── /assets/       # Images and media
├── /bin/          # Compiled binaries (built on server, not tracked in Git)
│   ├── printer.c  # Source code for printer helper (tracked in Git)
│   └── printer    # Compiled binary (NOT tracked in Git — compile from printer.c)
├── /config/       # Configuration files
│   ├── secrets.php         # NOT tracked in Git — create from .example
│   └── secrets.php.example # Template — tracked in Git
├── /css/          # Stylesheets
├── /js/           # JavaScript
├── /lib/          # PHP utility/helper functions
├── /templates/    # HTML templates (header, footer, menu, etc.)
└── /uploads/      # User-uploaded files (not tracked in Git)

Git Workflow

  • AI writes changes to Git (main branch) first.
  • User pulls changes to the server after.
  • Never commit config/secrets.php or the compiled bin/printer binary.
  • Work on main branch only — no pull requests.

About

SBC Inventory/Asset Tracking System

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors