<?php
include('header.php');
?>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap4.min.css">
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap4.min.js"></script>

<style>
.payment-form { max-width: 1100px; margin: 20px auto; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 4px 10px rgb(0 0 0 / 30%); }
.table thead th { vertical-align: middle; font-weight: 600; background: #343a40; color: #fff; }
.table tbody tr:hover { background: #f5f8ff; }
</style>

<div class="payment-form">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <a href="javascript:history.back()" class="btn btn-outline-primary">Go Back</a>
        <h5 class="mb-0 text-primary">All Pan Manual History</h5>
    </div>
    <hr>
    <div class="table-responsive">
        <table id="panTable" class="table table-hover table-striped text-center">
            <thead>
                <tr>
                    <th>SL.</th>
                    <th>Name</th>
                    <th>PAN NUMBER</th>
                    <th>FATHER</th>
                    <th>Date</th>
                    <th>PRINT</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $userid = $_SESSION['phone'];
                if ($_SESSION['usertype'] == 'admin')
                    $res = mysqli_query($conn, "SELECT * FROM panauto ORDER BY id DESC");
                else
                    $res = mysqli_query($conn, "SELECT * FROM panauto WHERE userid='$userid' ORDER BY id DESC");

                if ($res && mysqli_num_rows($res) > 0) {
                    $x = 0;
                    while ($data = mysqli_fetch_assoc($res)) {
                        $x++;
                ?>
                <tr>
                    <td><?= $x; ?></td>
                    <td><?= strtoupper($data['name']); ?></td>
                    <td><?= strtoupper($data['panno']); ?></td>
                    <td><?= strtoupper($data['fathername']); ?></td>
                    <td><?= $data['create_time']; ?></td>
                    <td>
                        <a class="btn btn-success btn-sm" href="pan/pan.php?searchid=<?= $data['id']; ?>" target="_blank">Print</a>
                    </td>
                </tr>
                <?php
                    }
                }
                ?>
            </tbody>
        </table>
    </div>
</div>

<script>
$(document).ready(function() {
    $('#panTable').DataTable({ lengthChange: false, pageLength: 10, order: [[0, "desc"]] });
});
</script>

<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<script src="dist/js/adminlte.js"></script>
</body>
</html>
