# AGENTS This project keeps the database schema in `db/schema.md`. Store schema-only dumps here (no data or credentials). When an icon is requested, use Bootstrap Icons. When generating PDFs in PHP, use dompdf and include it via: `require_once '/pdf/dompdf/autoload.inc.php';` When you need the database structure, read `db/schema.md`. This project currently uses PHP 7.4. However, all new PHP code and any updates to existing PHP code must be PHP 8.4 compliant whilst still working in a PHP 7.4 environment. At the end of each response, list the files that have been updated. ## Architecture This is a traditional PHP application without an MVC framework. **File Organization:** - Root-level PHP files = page views (dashboard.php, tickets.php, etc.) - `/php/objects/[domain]/[action].php` = action handlers (ticket-create.php, quote-edit.php) - `/data/[domain]/[endpoint].php` = data retrieval for AJAX/DataTables - `/inc/` = shared includes (navigation, modals, db-config.php) - `/auth/ASEngine/` = authentication system ## Authentication Every protected page must start with: ```php isLoggedIn()) { redirect("login.php"); } ``` Access current user via: `app('current_user')->role`, `app('current_user')->first_name`, etc. ## Database Connection Include database config and create PDO connection: ```php include('../../inc/db-config.php'); $dbh = new PDO($dsn, $username, $password); ``` For auth system, use: `app('db')` which provides helper methods like `select()`, `insert()`, `update()`. ## Naming Conventions **Database tables:** lowercase with underscores (tickets, ticket_notes, client_sites) **Database columns:** `[table]_[field]` format (ticket_reference, client_name, contact_first_name) **PHP files:** kebab-case (ticket-summary.php, client-create.php) **Reference numbers:** Tickets use `HDT` prefix (HDT12345) ## Frontend **Current Version (v4):** - Bootstrap 5.3.3 - DataTables 2.0.8 - jQuery 3.3.1 - Select2 4.1.0 - Font Awesome (local at /img/fontawesome/) - Template files: template-v4.php, inc/nav-v4.php - CSS: /css/style-v4.css **Brand color:** #f70000 (use CSS class `.bg-reddan` or `.reddan-text`) ## Common Patterns **Include paths vary by depth:** ```php include('../inc/db-config.php'); // from /php/objects/ include('../../inc/db-config.php'); // from /php/objects/domain/ include('../../../inc/db-config.php'); // from /data/domain/ ``` **DataTables server-side:** Use `SSP::complex()` from `/php/ssp.class.php` **Error handling:** PDO try/catch blocks. Debug mode set in auth/ASEngine/AS.php **API responses:** Return JSON with `header('Content-Type: application/json')` and `json_encode()`