New version

This commit is contained in:
2026-01-24 01:42:46 +01:00
parent 6063ae4193
commit f3f24cebba
68 changed files with 3136 additions and 407 deletions

View File

@@ -1 +0,0 @@

View File

@@ -1,21 +0,0 @@
<?php
function tools_build_pdo(): PDO
{
$cfg = require __DIR__ . '/../src/config.php';
if (!is_array($cfg)) {
throw new RuntimeException('DB config did not return an array.');
}
$required = ['db_host', 'db_name', 'db_user', 'db_pass', 'db_charset'];
foreach ($required as $key) {
if (!array_key_exists($key, $cfg)) {
throw new RuntimeException('Missing DB config key: ' . $key);
}
}
$dsn = "mysql:host={$cfg['db_host']};dbname={$cfg['db_name']};charset={$cfg['db_charset']}";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
];
return new PDO($dsn, $cfg['db_user'], $cfg['db_pass'], $options);
}

View File

@@ -1,6 +0,0 @@
<?php
function tools_fetch_active_printers(PDO $pdo): array
{
$stmt = $pdo->query("SELECT * FROM printers WHERE is_active = 1 ORDER BY name");
return $stmt->fetchAll();
}