<?php
include "includes/db_connect.php";
include "includes/auth.php";
checkAdmin();

$msisdn = $_GET['msisdn'];

$daily = mysqli_fetch_assoc(mysqli_query($conn,"
SELECT IFNULL(SUM(amount),0) total FROM transactions
WHERE sender_msisdn='$msisdn' AND DATE(created_at)=CURDATE()
"));

$cum = mysqli_fetch_assoc(mysqli_query($conn,"
SELECT IFNULL(SUM(amount),0) total FROM transactions
WHERE sender_msisdn='$msisdn'
"));

$kill = mysqli_fetch_assoc(mysqli_query($conn,"
SELECT * FROM msisdn_kill_switch WHERE msisdn='$msisdn'
"));
?>
<h2>MSISDN Status: <?= $msisdn ?></h2>
<p>Daily Used: <?= number_format($daily['total'],2) ?></p>
<p>Cumulative Used: <?= number_format($cum['total'],2) ?></p>
<p>Status: <?= $kill && $kill['blocked'] ? 'BLOCKED' : 'ACTIVE' ?></p>
<p>Reason: <?= $kill['reason'] ?? '-' ?></p>
