 <?php
    ob_start();
    include('include/db_conx.php');

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

 <head>
     <!-- Required meta tags -->
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
     <title>Immigration, Refugees and Citizenship | Immigration, Réfugiés et Citoyenneté</title>
     <link rel="shortcut icon" href="assets/img/favicon.png" type="image/png" />


     <!-- Bootstrap CSS -->
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
     <script src="https://kit.fontawesome.com/6c2095599e.js" crossorigin="anonymous"></script>

 </head>

 <body>


     <style>
         p {
             font-size: 14px;
         }

         .body_wrap {
             border: 10px solid #aa2826;
             width: 100%;
             /* height: 10; */
             margin-top: 30px;
             margin-bottom: 30px;
         }

         .inner_wrap {
             margin: 40px;
         }

         .app_status {
             border: 2px solid #c6c6c6;
             border-radius: 5px;
             line-height: 31px;
         }

         .app_status_head {
             background-color: #f5f5f5;
             padding: 10px;
         }

         .app_info {
             display: flex;
             line-height: 25px;
         }

         .ds {
             width: 20px;
         }

         .qs {
             width: 15px;
         }

         img {
             max-width: 100%;
             max-height: 100%;
         }

    
     </style>

     <?php

        if (isset($_POST['submit'])) {
            $tracking_code = $db_conx->real_escape_string($_POST['tracking_code']);

            $sql_code = "SELECT * FROM clients WHERE tracking_code = '$tracking_code'";
            $query_code = $db_conx->query($sql_code);
            $code_check = mysqli_num_rows($query_code);

            if (!$code_check > 0) {
                header('location: index.php?error=true');
            } else {
                $sql_client = "SELECT * FROM clients WHERE tracking_code = '$tracking_code' ";
                $query = $db_conx->query($sql_client);

                $row = mysqli_fetch_assoc($query);

                $final_decision_date = $row['final_decision_date'];
                $principal_applicant  = $row['principal_applicant'];
                $uci  = $row['uci'];
                $application_number  = $row['application_number'];
                $date_received  = $row['date_received'];
                $biometrics_number = $row['biometrics_number'];
                $date_biometrics_enrolment = $row['date_biometrics_enrolment'];
                $expiry_date = $row['expiry_date'];
                $details_status = $row['details_status'];
                $review_of_eligibility = $row['review_of_eligibility'];
                $review_of_medical = $row['review_of_medical'];
                $review_of_additoinal_doc = $row['review_of_additoinal_doc'];
                $interview = $row['interview'];
                $biometrics = $row['biometrics'];
                $background_check = $row['background_check'];
                $final_decision = $row['final_decision'];



        ?>

             <section class='container '>

                 <div class='body_wrap'>
                     <div class='inner_wrap'>
                         <section class='row'>
                             <div class='col-6'>
                                 <div class='app_status'>
                                     <div class='app_status_head'>
                                         <h6> Application Status</h6>
                                     </div>

                                     <div class='app_stat_body p-2'>
                                         <p>
                                             We are processing your application. we will send you a
                                             message when there is an update or if we need more information
                                             from you.


                                         </p>

                                         <p>
                                             <b> Latest Update </b>
                                             <br />

                                             <b> Final Decision - <?= $final_decision_date ?>:</b>

                                             Your application was
                                             approved. You need to send us your valid passport to finalize your
                                             application. Check your messages below for details
                                         </p>


                                     </div>

                                 </div>

                             </div>

                             <!-- =============================== -->
                             <div class='col-6'>
                                 <div class='app_status'>
                                     <div class='app_status_head'>
                                         <h6> Application information</h6>
                                     </div>

                                     <div class='app_stat_body p-2'>


                                         <p>
                                             <span class='app_info'> <b> Principal Applicant: </b> <?= $principal_applicant ?> </span>
                                             <span class='app_info'> <b> Unique Client Identifier (UCI): </b> <?= $uci ?></span>
                                             <span class='app_info'> <b> Application number : </b> <?= $application_number ?> </span>
                                             <span class='app_info'> <b> Date Received : </b> <?= $date_received ?> </span>
                                             <span class='app_info'> <b> Biometrics: </b> </span>
                                             <span class='app_info ml-3'> <b> Biometrics Number : </b> <?= $biometrics_number ?> </span>
                                             <span class='app_info ml-3'> <b> Date of Biometrics Enrolment : </b> <?= $date_biometrics_enrolment ?> </span>
                                             <span class='app_info ml-3'> <b> Expiry Date : </b> <?= $expiry_date ?> </span>
                                         </p>


                                     </div>

                                 </div>

                             </div>

                         </section>

                         <!-- ============================================= -->
                         <hr>

                         <h2> Details about your application Status </h2>
                         <p>
                             <?= $details_status ?>
                         </p>

                         <div class='details_wrap'>
                             <img src='images/d_search.svg' class='ds mb-1'>
                             <span> <b>Review of Eligibility </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li><?= $review_of_eligibility ?>
                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->


                         <div class='details_wrap'>
                             <img src='images/medical.svg' class='ds mb-1'>
                             <span> <b>Review of medical results </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li><?= $review_of_medical ?>
                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->


                         <div class='details_wrap'>
                             <img src='images/document.svg' class='ds mb-1'>
                             <span> <b>Review of additional documents </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li><?= $review_of_additoinal_doc ?>
                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->

                         <div class='details_wrap'>
                             <img src='images/interview.svg' class='ds mb-1'>
                             <span> <b>Interview </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li><?= $interview ?>
                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->


                         <div class='details_wrap'>
                             <img src='images/biometrics.svg' class='ds mb-1'>
                             <span> <b>Biometrics </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li><?= $biometrics ?>
                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->

                         <div class='details_wrap'>
                             <img src='images/background.svg' class='ds mb-1'>
                             <span> <b>Background checks </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li><?= $background_check ?>
                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->


                         <div class='details_wrap'>
                             <img src='images/final.svg' class='ds mb-1'>
                             <span> <b>Final Decision </b> </span>
                             <img src='images/question.svg' class='qs'>

                             <ul>
                                 <li>
                                     <?= $final_decision ?>

                                 </li>
                             </ul>

                         </div>

                         <!-- ============================ -->







                     </div>


                 </div>

             </section>
     <?php
            }
        }


        ?>

     <!-- Optional JavaScript -->
     <!-- jQuery first, then Popper.js, then Bootstrap JS -->
     <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
     <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
     <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
 </body>

 </html>
 <?php
    ob_end_flush(); ?>