<?php
    session_start();
    include "../../db.php";
    date_default_timezone_set('Asia/Kolkata');
    $currentTime = date('M j, Y g:i a');

    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) ) {
        header("Location: logout.php");
        exit();
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Admin Panel</title>

    <link href="css/all.min.css" rel="stylesheet" type="text/css">
    <link href="css/sb-admin-2.min.css" rel="stylesheet">
    <link href="css/alltable.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
</head>
<body id="page-top" class="mt-55">

<div class="overlay"></div>

    <div id="wrapper">

        <div id="content-wrapper" class="d-flex flex-column">

            <div id="content">

                <?php include "includes/topbar.php"; ?>

                <div class="container-fluid px-0">

                    <div class="card shadow mb-4">
                        <div class="card-body">

                            <h1 class="h3 mb-2 text-gray-800 text-center text-sm-left">Online Applications</h1>
                            <hr>

                         

                            <div class="row m-0">

                                <div class="col-md-12 p-0">
                                    <div class="table-responsive">
                                        <table class="table table-hover table-bordered table-sm" id="thisismytable">
                                            <thead>
                                                <tr>
                                                    <th style='max-width:100px'>No.</th>
                                                    <th>Details</th>
                                                    <th>Message</th>
                                                    <th>action</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    $sql = "SELECT * FROM admission_form  WHERE adm_by = '$_SESSION[uid]' ORDER BY adm_sl DESC";
                                                    $run = mysqli_query($con, $sql);

                                                    $c = 1;
                                                    while ( $rows = mysqli_fetch_assoc($run) )
												{
														
                                                        echo "
                                                        <tr>
                                                            <td>
                                                                <span class='badge badge-info badge-pill'>$c</span>
                                                            </td>
                                                            <td>
                                                         
																Date -: $rows[adm_uploadDT]<br>
															Name : $rows[adm_name]
															 <br>
															Contact : $rows[adm_ph]
															 <br>
															Email id :  $rows[adm_email]
															 <br>
                                                            City :  $rows[adm_city] <br>
                                                            State :  $rows[adm_state] <br>
                                                            Pin :  $rows[adm_pin]      <br>
																
                                                            </td>
                                                            <td cla ss='text-center align-middle sm all'>
                                                         Course :   $rows[adm_programme]
															<br>
                                                        Category :   $rows[adm_category]
                                                            <br>
														Message : 	$rows[adm_query]
                                                            </td>
                                                        <td>
                                                        "; ?>
                                                            <a href='online_application.php?del_id=<?php echo $rows["adm_sl"]; ?>' class='delete m-2 btn btn-danger btn-sm rounded-circle' title='Click to Delete'> <i class='fas fa-trash'></i> </a>
                                                        <?php
                                                        echo "
                                                        </td>
                                                        </tr>
                                                        ";
                                                        $c++;
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

            <?php include "includes/footer.php"; ?>

        </div>

    </div>







    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.easing.min.js"></script>
    <script src="js/sb-admin-2.min.js"></script>
    <script src="js/sweetalert2.min.js"></script>
    <script src="js/jquery.dataTables.min.js"></script>
    <script src="js/dataTables.bootstrap4.min.js"></script>
    <script src="js/datatables.mark.min.js"></script>
    <script src="js/jquery-ui-custom.min.js"></script>
    <script src="js/custom.js"></script>
<script>
        $(document).ready(function(){
            $('#thisismytable').DataTable();          
        });
   </script>
 

</body>
</html>



<?php
  if ( isset($_GET["del_id"]) ) {
           
        $del_sql = "DELETE FROM admission_form WHERE adm_sl = '$_GET[del_id]'" ;

        if ( mysqli_query($con, $del_sql) ) {
            ?>
            <script>window.location = "online_application.php";</script>
            <?php
        } else {
            ?>
            <script>
                alert('OOPS !!!!');
                setTimeout(() => {
                    window.location = 'online_application.php';
                }, 1200);
            </script>
            <?php
        }
        
    }

   
?>