<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

include('../includes/session.php');
include('../includes/config.php');
include('../template/tngweb/header.php');
?>

<div class="container mt-5">

    <div class="card shadow">
        <div class="card-header bg-primary text-white">
            📋 RC TO MOBILE LINK LIST
        </div>

        <div class="card-body">

            <div class="table-responsive">
                <table class="table table-bordered table-striped align-middle">
                    <thead class="table-dark text-center">
                        <tr>
                            <th>#</th>
                            <th>RC Number</th>
                            <th>New Mobile</th>
                            <th>Status</th>
                            <th>Date</th>
                        </tr>
                    </thead>
                    <tbody>

<?php
$i = 1;
$q = mysqli_query($tng_conn, "SELECT * FROM rc_mobile_link ORDER BY id DESC");

if (mysqli_num_rows($q) > 0) {
    while ($row = mysqli_fetch_assoc($q)) {
        ?>
        <tr class="text-center">
            <td><?= $i++; ?></td>
            <td><?= htmlspecialchars($row['rc_number']); ?></td>
            <td><?= htmlspecialchars($row['new_mobile']); ?></td>
            <td>
                <?php if ($row['status'] == 'Pending') { ?>
                    <span class="badge bg-warning text-dark">Pending</span>
                <?php } elseif ($row['status'] == 'Approved') { ?>
                    <span class="badge bg-success">Approved</span>
                <?php } else { ?>
                    <span class="badge bg-danger">Rejected</span>
                <?php } ?>
            </td>
            <td><?= date('d-m-Y h:i A', strtotime($row['date'])); ?></td>
        </tr>
        <?php
    }
} else {
    echo "<tr><td colspan='5' class='text-center text-danger'>No Record Found</td></tr>";
}
?>

                    </tbody>
                </table>
            </div>

        </div>
    </div>

</div>

<?php include('../template/tngweb/footer.php'); ?>
