<?php
require_once __DIR__ . '/includes/init.php';
$db = getDBConnection();

echo "<h3>Users - division values</h3><pre>";
$users = dbRows($db, "SELECT id, full_name, role, division FROM users ORDER BY role, full_name");
foreach($users as $u) {
    echo $u['id'].' | '.$u['role'].' | '.$u['full_name'].' | '.$u['division']."\n";
}
echo "</pre>";

echo "<h3>Consumers - distinct divisions</h3><pre>";
$divs = dbRows($db, "SELECT DISTINCT division, COUNT(*) as cnt FROM consumers WHERE division IS NOT NULL AND division != '' GROUP BY division ORDER BY division");
foreach($divs as $d) {
    echo $d['division'].' ('.$d['cnt'].')'."\n";
}
echo "</pre>";
?>
