<?php
require_once 'db/config.php';

try {
    $pdo = db();
    $stmt = $pdo->query("SELECT id, code, name, is_active FROM process_definitions ORDER BY id");
    $definitions = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // Identify which processes appear on the dashboard
    foreach ($definitions as &$def) {
        if (!in_array($def['name'], ['Obsluga goscia', 'Przygotowanie spotkania grupy'])) {
            $def['on_dashboard'] = 'Yes';
        } else {
            $def['on_dashboard'] = 'No';
        }
    }

    echo "--- Process Definitions ---
";
    echo str_pad("ID", 5) . str_pad("Code", 40) . str_pad("Name", 40) . str_pad("Active", 10) . str_pad("On Dashboard", 15) . "\n";
    echo str_repeat("-", 110) . "\n";
    foreach ($definitions as $def) {
        echo str_pad($def['id'], 5) . str_pad($def['code'], 40) . str_pad($def['name'], 40) . str_pad($def['is_active'] ? 'Yes' : 'No', 10) . str_pad($def['on_dashboard'], 15) . "\n";
    }

} catch (PDOException $e) {
    die("DB ERROR: " . $e->getMessage());
}

