<?php
require_once __DIR__.'/../../config.php';
require_once __DIR__ . '/../../engine/Kernel.php';
require_once __DIR__.'/../../engine/Logger.php';
require_once __DIR__.'/../../engine/AccountingEngine.php';
$ctx = Kernel::handle(['auth' => true]);
$u   = $ctx['user'];
if(empty($u['is_admin'])){http_response_code(403);die(json_encode(['error'=>'admin_required']));}
$date = preg_replace('/[^0-9\-]/','', $_GET['date']??date('Y-m-d'));
$result = AccountingEngine::getAuditDashboard($date);
echo json_encode(['ok'=>true,'data'=>$result], JSON_UNESCAPED_UNICODE);
