<?php
require_once dirname(__DIR__) . '/bootstrap/chairman_bootstrap.php';
$raceDate = isset($_GET['race_date']) ? chairman_safe_date($_GET['race_date']) : date('Y-m-d');
$venue = isset($_GET['venue']) ? $_GET['venue'] : '';
$raceNum = isset($_GET['race_num']) ? intval($_GET['race_num']) : 0;
$result=$Chairman->runProductionEngine($raceDate,$venue,$raceNum);
?>
<!doctype html><html lang="zh-Hant"><head><meta charset="utf-8"><title>Chairman Engine Test v2.0</title>
<style>body{background:#050914;color:#e7fbff;font-family:Arial,'Microsoft JhengHei';padding:25px}.box{border:1px solid #283c59;background:#0c1423;padding:18px;border-radius:12px;margin-bottom:15px}.gold{color:#ffc107}.ok{color:#32ffa7}table{width:100%;border-collapse:collapse}th,td{border-bottom:1px solid #243650;padding:8px}th{background:#101a2c}pre{white-space:pre-wrap;color:#9ed9ff}</style></head>
<body><h1>Chairman Production Engine v2.0</h1>
<div class="box"><p class="ok">Engine OK</p><p>Ranking Rows: <span class="gold"><?=count($result['ranking'])?></span></p><p>Decision Races: <span class="gold"><?=count($result['decision'])?></span></p></div>
<div class="box"><h2>Decision</h2><table><tr><th>Race</th><th>Top</th><th>Q</th><th>Trio</th><th>Horse Count</th></tr>
<?php foreach($result['decision'] as $d): ?>
<tr><td>R<?=chairman_h($d['race_num'])?></td><td class="gold"><?=chairman_h(isset($d['top']['horse_num'])?$d['top']['horse_num']:'')?></td><td><?php foreach($d['q'] as $q){ echo chairman_h($q['horse_num']).' '; } ?></td><td><?php foreach($d['trio'] as $t){ echo chairman_h($t['horse_num']).' '; } ?></td><td><?=chairman_h($d['horse_count'])?></td></tr>
<?php endforeach; ?>
</table></div>
<div class="box"><h2>Events</h2><pre><?=chairman_h(json_encode($result['events'],JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT))?></pre></div>
</body></html>
