<?php
include('../includes/session.php');
include('../includes/config.php');
include('../template/tngweb/header.php');
?>
<!--start page wrapper -->
<div class="page-wrapper">
<div class="page-content">
    <div class="card radius-10">
        <div class="card-body">
                <div class="mb-4">
        <a href="javascript:history.back()" class="back-btn">
            <i class="bi bi-arrow-left-circle"></i> Go Back
        </a>
    </div>
            <h5 class="mb-0">BIHAR RTPS  PDF LIST</h5>
            <hr>
            <div class="table-responsive">
                <table id="example2" class="table align-middle mb-0">
                    <thead class="table-light">
                        <tr>
                            <th class="text-center">SL.</th>
                            <th class="text-center">Name</th>
                            <th class="text-center">Application No</th>
                            <th class="text-center">Apply Date</th>
                            <th class="text-center">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                       <?php
                        if($udata['type']=='admin') {
                            $res = mysqli_query($tng_conn, "SELECT * FROM rtps_pdf ORDER BY id DESC");
                        } else {
                            $res = mysqli_query($tng_conn, "SELECT * FROM rtps_pdf WHERE username='".$udata['phone']."' ORDER BY id DESC");
                        }

                        if(mysqli_num_rows($res) > 0){
                            $x = 0;
                            while($data = mysqli_fetch_assoc($res)){
                                $x++;
                        ?>
                                <tr>
                                    <td class="text-center"><?= $x ?></td>
                                    <td class="text-center"><?= htmlspecialchars($data['name']) ?></td>
                                    <td class="text-center"><?= htmlspecialchars($data['aadhar']) ?></td>
                                    <td class="text-center"><?= strtoupper($data['date']) ?></td>
                                    <td class="text-center">
                                        <a href="<?= $data['pdf'] ?>" download="RtpsPdf_<?= $data['aadhar'] ?>.pdf" class="btn btn-success btn-sm">Download</a>
                                    </td>
                                </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                  </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</div>
<!--end page wrapper -->
<?php include('../template/tngweb/footer.php'); ?>

<!-- Bootstrap & Plugins JS -->
<script src="../template/tngweb/assets/js/bootstrap.bundle.min.js"></script>
<script src="../template/tngweb/assets/js/jquery.min.js"></script>
<script src="../template/tngweb/assets/plugins/simplebar/js/simplebar.min.js"></script>
<script src="../template/tngweb/assets/plugins/metismenu/js/metisMenu.min.js"></script>
<script src="../template/tngweb/assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js"></script>
<script src="../template/tngweb/assets/js/index.js"></script>
<script src="../template/tngweb/assets/js/app.js"></script>

<!-- Datatables -->
<script src="../template/tngweb/assets/plugins/datatable/js/jquery.dataTables.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/dataTables.bootstrap5.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/dataTables.buttons.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/buttons.bootstrap5.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/jszip.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/pdfmake.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/vfs_fonts.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/buttons.html5.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/buttons.print.min.js"></script>
<script src="../template/tngweb/assets/plugins/datatable/js/buttons.colVis.min.js"></script>

<script>
$(document).ready(function() {
    $('#example2').DataTable({
        lengthChange: false,
        buttons: [ 'copy', 'excel', 'pdf', 'print', 'colvis' ]
    }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)');
});
</script>
