<?php
session_start();
// // session_destroy();

if (isset($_SESSION['log_session']) && !empty($_SESSION['log_session'] && $_SESSION['log_session']['user_role_id'] == '1')) { // Student

    $user_id = $_SESSION['log_session']['user_id'];
    $user_role_name = $_SESSION['log_session']['user_role_name'];
    $user_role_id = $_SESSION['log_session']['user_role_id'];
    $user_first_name =  $_SESSION['log_session']['user_first_name'];
} else {
    header('Location: ../login.php');
    exit();
}
// Include the database connection file
include('../includes/DB/Connection.php');

include('../academic-admin/includes/update.php');


?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description"
        content="Multikart admin is super flexible, powerful, clean &amp; modern responsive bootstrap 4 admin template with unlimited possibilities.">
    <meta name="keywords"
        content="admin template, Multikart admin template, dashboard template, flat admin template, responsive admin template, web app">
    <meta name="author" content="pixelstrap">
    <link rel="icon" href="../assets/images/dashboard/favicon.png" type="image/x-icon">
    <link rel="shortcut icon" href="../assets/images/dashboard/favicon.png" type="image/x-icon">
    <title>AIC/IMC</title>

    <!-- Google font-->
    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,500;1,600;1,700;1,800;1,900&display=swap">

    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap">

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    <!-- Font Awesome
    -->
    <link rel="stylesheet" type="text/css" href="../assets/css/vendors/font-awesome.css">

    <!-- Flag icon-->
    <link rel="stylesheet" type="text/css" href="../assets/css/vendors/flag-icon.css">

    <!-- Bootstrap css-->
    <link rel="stylesheet" type="text/css" href="../assets/css/vendors/bootstrap.css">

    <!-- App css-->
    <link rel="stylesheet" type="text/css" href="../assets/css/style.css">
</head>

<body>

    <!-- page-wrapper Start-->
    <div class="page-wrapper">

        <!-- page-header Start-->
        <?php include('../includes/headers/header.php'); ?>
        <!-- page-header end-->

        <!-- Page Body Start-->
        <div class="page-body-wrapper">

            <!-- Page Sidebar Start-->
            <?php include('../includes/Sidebar/sidebar.php'); ?>
            <!-- Page Sidebar Ends-->

            <!-- Right sidebar Start-->
            <?php include('../includes/rightsidebar/rightsiderbar.php'); ?>
            <!-- Right sidebar Ends-->

            <div class="page-body">
                <!-- Container-fluid starts-->
                <div class="container-fluid">
                    <div class="page-header">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="page-header-left">
                                    <h3>Student Details
                                        <small>AIC/IMC</small>
                                    </h3>
                                </div>
                            </div>
                            <div class="col-lg-6">
                                <ol class="breadcrumb pull-right">
                                    <li class="breadcrumb-item">
                                        <a href="./dashboard.php">
                                            <i data-feather="home"></i>
                                        </a>
                                    </li>
                                    <li class="breadcrumb-item">Dashboard</li>
                                    <li class="breadcrumb-item active">View Details</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Container-fluid Ends-->

                <!-- Container-fluid starts-->
                <div class="container-fluid">
                    <div class="row">

                        <div class="col-xl-12">
                            <div class="card ">
                                <div class="card-body">

                                    <div class="tab-content" id="top-tabContent">
                                        <div class="tab-pane fade show active" id="top-profile" role="tabpanel"
                                            aria-labelledby="top-profile-tab">
                                            <h5 class="f-w-600"></h5>
                                            <div class="table-responsive profile-table">
                                                <table class="table table-borderless">
                                                    <tbody>

                                                        <div class="profile-details text-center">
                                                            <img src="assets/images/image.png" alt=""
                                                                class="img-fluid img-90 rounded-circle blur-up lazyloaded">
                                                        </div>

                                                        <tr>
                                                            <td><strong>First Name:</strong></td>
                                                            <td><?php echo $student_row['student_first_name']; ?></td>
                                                        </tr>
                                                        <tr>
                                                            <td><strong>Last Name:</strong></td>
                                                            <td><?php echo $student_row['student_last_name']; ?></td>
                                                        </tr>
                                                        <tr>
                                                            <td><strong>Email:</strong></td>
                                                            <td><?php echo $student_row['student_email']; ?></td>
                                                        </tr>
                                                        <tr>
                                                            <td><strong>Address:</strong></td>
                                                            <td><?php echo $student_row['student_address']; ?></td>
                                                        </tr>
                                                        <tr>
                                                            <td><strong>Contact No:</strong></td>
                                                            <td><?php echo $student_row['student_phone_1'] . " , " . $student_row['student_phone_2']; ?>
                                                            </td>
                                                        </tr>


                                                        <tr>
                                                            <td><strong>O/L Certificate:</strong></td>
                                                            <td>
                                                                <?php if ($has_ol_Certificates) : ?>
                                                                <form action="" method="post">
                                                                    <?php foreach ($ol_certificates as $certificate) : ?>
                                                                    <div
                                                                        style="display: flex; align-items: center; margin-bottom: 5px; position: relative;">
                                                                        <!-- Checkbox for selecting the document -->
                                                                        <div style="flex: 1;">
                                                                            <input type="checkbox"
                                                                                name="selected_docs[]"
                                                                                value="<?php echo htmlspecialchars($certificate['doc_path']); ?>">
                                                                        </div>

                                                                        <!-- Document URL and Qualification ID -->
                                                                        <div
                                                                            style="flex: 4; display: flex; align-items: center; min-width: 400px; margin-left: 10px;">

                                                                            <div
                                                                                style="flex: 1; display: flex; align-items: center; position: relative;">
                                                                                <a href="../<?php echo htmlspecialchars($certificate['doc_path']); ?>"
                                                                                    target="_blank"
                                                                                    style="margin-right: 150px;">View
                                                                                    <?php echo htmlspecialchars($certificate['qual_name']); ?>
                                                                                    Document</a>


                                                                                <!-- Badge displayed after the URL -->
                                                                                <?php
                                                                                        echo "<span style='position: absolute; right: 0;'>";
                                                                                        if (isset($_SESSION['doc_status']) && in_array($certificate['doc_path'], $_SESSION['updated_docs'])) {
                                                                                            if ($_SESSION['doc_status'] == 'accepted') {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($_SESSION['doc_status'] == 'rejected') {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            }
                                                                                        } else {
                                                                                            if ($certificate['doc_status'] == 2) {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($certificate['doc_status'] == 3) {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            } elseif ($certificate['doc_status'] == 1) {
                                                                                                echo "<span class='badge badge-info'>Not Verified</span>";
                                                                                            }
                                                                                        }
                                                                                        echo "</span>";
                                                                                        ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <?php endforeach; ?>

                                                                    <!-- Clear session after displaying badges -->
                                                                    <?php
                                                                        unset($_SESSION['doc_status']);
                                                                        unset($_SESSION['updated_docs']);
                                                                        ?>

                                                                    <!-- Accept and Reject Buttons for the form -->
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="accept_selected">Accept</button></td>
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="reject_selected">Reject</button></td>
                                                            </form>
                                                            <?php else : ?>
                                                            <span class='badge badge-danger'>Document Not Found</span>
                                                            <?php endif; ?>
                                                            </td>
                                                        </tr>





                                                        <tr>
                                                            <td><strong>A/L Certificate:</strong></td>
                                                            <td>
                                                                <?php if ($has_al_Certificates) : ?>
                                                                <form action="" method="post">
                                                                    <?php foreach ($al_certificates as $certificate) : ?>
                                                                    <div
                                                                        style="display: flex; align-items: center; margin-bottom: 5px;">
                                                                        <!-- Checkbox for selecting the document -->
                                                                        <div style="flex: 1;">
                                                                            <input type="checkbox"
                                                                                name="selected_docs[]"
                                                                                value="<?php echo htmlspecialchars($certificate['doc_path']); ?>">
                                                                        </div>

                                                                        <!-- Document URL and Qualification ID -->
                                                                        <div
                                                                            style="flex: 4; display: flex; align-items: center; min-width: 400px; margin-left: 10px;">

                                                                            <div
                                                                                style="flex: 1; display: flex; align-items: center; position: relative;">
                                                                                <a href="../<?php echo  htmlspecialchars($certificate['doc_path']); ?>"
                                                                                    target="_blank"
                                                                                    style="margin-right: 150px;">View
                                                                                    <?php echo htmlspecialchars($certificate['qual_name']); ?>
                                                                                    Document</a>

                                                                                <!-- Badge displayed after the URL -->
                                                                                <?php
                                                                                        echo "<span style='position: absolute; right: 0;'>";
                                                                                        if (isset($_SESSION['doc_status']) && in_array($certificate['doc_path'], $_SESSION['updated_docs'])) {
                                                                                            if ($_SESSION['doc_status'] == 'accepted') {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($_SESSION['doc_status'] == 'rejected') {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            }
                                                                                        } else {
                                                                                            if ($certificate['doc_status'] == 2) {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($certificate['doc_status'] == 3) {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            } elseif ($certificate['doc_status'] == 1) {
                                                                                                echo "<span class='badge badge-info'>Not Verified</span>";
                                                                                            }
                                                                                        }
                                                                                        echo "</span>";
                                                                                        ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <?php endforeach; ?>

                                                                    <!-- Clear session after displaying badges -->
                                                                    <?php
                                                                        unset($_SESSION['doc_status']);
                                                                        unset($_SESSION['updated_docs']);
                                                                        ?>

                                                                    <!-- Accept and Reject Buttons for the form -->
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="accept_selected">Accept</button></td>
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="reject_selected">Reject</button></td>
                                                            </form>
                                                            <?php else : ?>
                                                            <span class='badge badge-danger'>Document Not Found</span>
                                                            <?php endif; ?>
                                                            </td>
                                                        </tr>

                                                        <tr>
                                                            <td><strong>Higher education Certificates:</strong></td>
                                                            <td>
                                                                <?php if ($has_higher_edu_Certificates) : ?>
                                                                <form action="" method="post">
                                                                    <?php foreach ($higher_edu_certificates as $certificate) : ?>
                                                                    <div
                                                                        style="display: flex; align-items: center; margin-bottom: 5px;">
                                                                        <!-- Checkbox for selecting the document -->
                                                                        <div style="flex: 1;">
                                                                            <input type="checkbox"
                                                                                name="selected_docs[]"
                                                                                value="<?php echo htmlspecialchars($certificate['doc_path']); ?>">
                                                                        </div>

                                                                        <!-- Document URL and Qualification ID -->
                                                                        <div
                                                                            style="flex: 4; display: flex; align-items: center; min-width: 400px; margin-left: 10px;">

                                                                            <div
                                                                                style="flex: 1; display: flex; align-items: center; position: relative;">
                                                                                <a href="../<?php echo htmlspecialchars($certificate['doc_path']); ?>"
                                                                                    target="_blank"
                                                                                    style="margin-right: 150px;">View
                                                                                    <?php echo htmlspecialchars($certificate['qual_name']); ?>
                                                                                    Document</a>

                                                                                <!-- Badge displayed after the URL -->
                                                                                <?php
                                                                                        echo "<span style='position: absolute; right: 0;'>";
                                                                                        if (isset($_SESSION['doc_status']) && in_array($certificate['doc_path'], $_SESSION['updated_docs'])) {
                                                                                            if ($_SESSION['doc_status'] == 'accepted') {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($_SESSION['doc_status'] == 'rejected') {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            }
                                                                                        } else {
                                                                                            if ($certificate['doc_status'] == 2) {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($certificate['doc_status'] == 3) {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            } elseif ($certificate['doc_status'] == 1) {
                                                                                                echo "<span class='badge badge-info'>Not Verified</span>";
                                                                                            }
                                                                                        }
                                                                                        echo "</span>";
                                                                                        ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <?php endforeach; ?>

                                                                    <!-- Clear session after displaying badges -->
                                                                    <?php
                                                                        unset($_SESSION['doc_status']);
                                                                        unset($_SESSION['updated_docs']);
                                                                        ?>

                                                                    <!-- Accept and Reject Buttons for the form -->
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="accept_selected">Accept</button></td>
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="reject_selected">Reject</button></td>
                                                            </form>
                                                            <?php else : ?>
                                                            <span class='badge badge-danger'>Document Not Found</span>
                                                            <?php endif; ?>
                                                            </td>
                                                        </tr>


                                                        <tr>
                                                            <td><strong>Other Documents:</strong></td>
                                                            <td>
                                                                <?php if ($has_other_Certificates) : ?>
                                                                <form action="" method="post">
                                                                    <?php foreach ($other_certificates as $certificate) : ?>
                                                                    <div
                                                                        style="display: flex; align-items: center; margin-bottom: 5px;">
                                                                        <!-- Checkbox for selecting the document -->
                                                                        <div style="flex: 1;">
                                                                            <input type="checkbox"
                                                                                name="selected_docs[]"
                                                                                value="<?php echo htmlspecialchars($certificate['doc_path']); ?>">
                                                                        </div>

                                                                        <!-- Document URL and Qualification ID -->
                                                                        <div
                                                                            style="flex: 4; display: flex; align-items: center; min-width: 400px; margin-left: 10px;">

                                                                            <div
                                                                                style="flex: 1; display: flex; align-items: center; position: relative;">
                                                                                <a href="../<?php echo  htmlspecialchars($certificate['doc_path']); ?>"
                                                                                    target="_blank"
                                                                                    style="margin-right: 150px;">View
                                                                                    <?php echo htmlspecialchars($certificate['qual_name']); ?>
                                                                                    Document</a>

                                                                                <!-- Badge displayed after the URL -->
                                                                                <?php
                                                                                        echo "<span style='position: absolute; right: 0;'>";
                                                                                        if (isset($_SESSION['doc_status']) && in_array($certificate['doc_path'], $_SESSION['updated_docs'])) {
                                                                                            if ($_SESSION['doc_status'] == 'accepted') {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($_SESSION['doc_status'] == 'rejected') {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            }
                                                                                        } else {
                                                                                            if ($certificate['doc_status'] == 2) {
                                                                                                echo "<span class='badge badge-success'>Accepted</span>";
                                                                                            } elseif ($certificate['doc_status'] == 3) {
                                                                                                echo "<span class='badge badge-warning'>Rejected</span>";
                                                                                            } elseif ($certificate['doc_status'] == 1) {
                                                                                                echo "<span class='badge badge-info'>Not Verified</span>";
                                                                                            }
                                                                                        }
                                                                                        echo "</span>";
                                                                                        ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <?php endforeach; ?>

                                                                    <!-- Clear session after displaying badges -->
                                                                    <?php
                                                                        unset($_SESSION['doc_status']);
                                                                        unset($_SESSION['updated_docs']);
                                                                        ?>

                                                                    <!-- Accept and Reject Buttons for the form -->
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="accept_selected">Accept</button></td>
                                                            <td><button class="btn btn-primary" type="submit"
                                                                    name="reject_selected">Reject</button></td>
                                                            </form>
                                                            <?php else : ?>
                                                            <span class='badge badge-danger'>Document Not Found</span>
                                                            <?php endif; ?>
                                                            </td>
                                                        </tr>







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

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Container-fluid Ends-->
            </div>

            <!-- footer start-->
            <?php include('../includes/footers/footer.php'); ?>
            <!-- footer end-->
        </div>
    </div>

    <!-- latest jquery-->
    <script src="../assets/js/jquery-3.3.1.min.js"></script>

    <!-- Bootstrap js-->
    <script src="../assets/js/bootstrap.bundle.min.js"></script>

    <!-- feather icon js-->
    <script src="../assets/js/icons/feather-icon/feather.min.js"></script>
    <script src="../assets/js/icons/feather-icon/feather-icon.js"></script>

    <!-- Sidebar jquery-->
    <script src="../assets/js/sidebar-menu.js"></script>
    <script src="../assets/js/slick.js"></script>

    <!-- lazyload js-->
    <script src="../assets/js/lazysizes.min.js"></script>

    <!--right sidebar js-->
    <script src="../assets/js/chat-menu.js"></script>

    <!--script admin-->
    <script src="../assets/js/admin-script.js"></script>

    <!-- Sweetalert2 js-->
    <script src="../assets/custom-assets/lib/sweetalert2/sweetalert2.all.min.js"></script>

    <!-- Moment js-->
    <script src="../assets/custom-assets/lib/momentjs/moment.min.js"></script>

    <!-- JDataTable js -->
    <script src="../assets/lib/DataTables/datatables.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
    <script
        src="https://cdn.datatables.net/v/dt/jszip-3.10.1/dt-1.13.6/af-2.6.0/b-2.4.2/b-colvis-2.4.2/b-html5-2.4.2/b-print-2.4.2/cr-1.7.0/date-1.5.1/fc-4.3.0/fh-3.4.0/kt-2.10.0/r-2.5.0/rg-1.4.1/rr-1.4.1/sc-2.2.0/sb-1.6.0/sp-2.2.0/sl-1.7.0/sr-1.3.0/datatables.min.js">
    </script>


    <!-- dashbaord.js -->
    <script src="../assets/custom-assets/js/dashboard.js"></script>



</body>

</html>