<?php
$realmLabel=class_exists('NexoraRealm')?NexoraRealm::label():'Actual';
echo '<h2>Logs de códigos — '.htmlspecialchars($realmLabel,ENT_QUOTES,'UTF-8').'</h2>';
$r=new \Plugin\RedeemCode\RedeemCode(); if(isset($_GET['id'])) $r->setId($_GET['id']); $logs=$r->getLogs(); $codes=$r->getRedeemCodesList(); $map=array(); foreach($codes as $c)$map[(int)$c['id']]=$c['redeem_code'];
echo '<table class="table table-striped table-hover"><thead><tr><th>Código</th><th>Fecha</th><th>IP</th><th>Cuenta</th><th>Identificador crédito</th></tr></thead><tbody>';
foreach($logs as $l){$cid=(int)$l['code_id'];echo '<tr><td>'.htmlspecialchars($map[$cid]??('#'.$cid),ENT_QUOTES,'UTF-8').'</td><td>'.htmlspecialchars((string)$l['date_redeemed'],ENT_QUOTES,'UTF-8').'</td><td>'.htmlspecialchars((string)$l['ip_address'],ENT_QUOTES,'UTF-8').'</td><td>'.htmlspecialchars((string)($l['account_username']??''),ENT_QUOTES,'UTF-8').'</td><td>'.htmlspecialchars((string)$l['user_identifier'],ENT_QUOTES,'UTF-8').'</td></tr>';}
echo '</tbody></table>';
