<?php
session_start();
if (!isset($_SESSION['id'])) {
   header("location: main.php");
}
?>


<html lang="en">

<head>
   <!-- Google tag (gtag.js) -->
   <script async src="https://www.googletagmanager.com/gtag/js?id=G-GQPGJ4YN30"></script>
   <script>
      window.dataLayer = window.dataLayer || [];

      function gtag() {
         dataLayer.push(arguments);
      }
      gtag('js', new Date());

      gtag('config', 'G-GQPGJ4YN30');
   </script>


   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Bkash Verification</title>
   <!-- using online links -->
   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">

   <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">

   <link rel="stylesheet" href="//malihu.github.io/custom-scrollbar/jquery.mCustomScrollbar.min.css">

   <!-- CSS only -->
   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
   <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -->
   <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>




   <style>
      select[readonly] {
         background: #eee;
         /*Simular campo inativo - Sugestão @GabrielRodrigues*/
         pointer-events: none;
         touch-action: none;
      }

      .header img {
         float: left;
         width: 100px;
         height: 100px;
         /* background: #555; */
      }
   </style>
</head>

<body>


<?php
// $capchaval = substr(str_shuffle("1234abcdefghijkmnpqrABCDEFGHIJKL123456789stvwxyzMNPQRSTVWXYZ56789"), 0, 8);
error_reporting(0);
//session_start();
// include "fetch_data.php";
include "connection.php";
error_reporting(0);

$APP_ID = $_SESSION['id'];












// $APP_ID = 79;
$sql = "SELECT *  FROM AD_APP  WHERE APP_ID = '$APP_ID'";
$parse = ociparse($conn, $sql);
oci_execute($parse);

// print_r($sql);
while ($row = oci_fetch_assoc($parse)) {
   $user_row[] = $row;
}

// var_dump($division);
// echo count($division);
oci_free_statement($parse);


$SMS_MOBILE_NO =  $user_row[0]['SMS_MOBILE_NO'];




/* Start Procedure for Report */
$curs = oci_new_cursor($conn);

$stid = oci_parse($conn, "begin PKG_AD_APP_PAYMENT.DPD_AD_APP_Select_PAYMENT_int(:cur_data,:APP_ID); end;");


oci_bind_by_name($stid, ":cur_data", $curs, -1, OCI_B_CURSOR);
oci_bind_by_name($stid, ":APP_ID", $APP_ID, -1, SQLT_CHR);



oci_execute($stid);
oci_execute($curs);


while (($row = oci_fetch_array($curs, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {

   $report_output[] = $row;
}



// $TRX_ID =  $report_output[0]['TRX_ID'];
// echo "$TRX_ID";


/* End Procedure for Report */
$bool = true;












if (isset($_POST['submit'])) {



   $BKASH_TRX_ID = $_POST['bkash_trx_id'];








   $returnval = 0;
   $stid = oci_parse($conn, "begin PKG_AD_APP_PAYMENT.DPD_AD_APP_PAYMENT_int(:o_status,:APP_ID,:SMS_MOBILE_NO,:BKASH_TRX_ID); end;");


   oci_bind_by_name($stid, ":o_status", $returnval, -1, SQLT_INT);
   oci_bind_by_name($stid, ":APP_ID", $APP_ID, -1, SQLT_CHR);
   oci_bind_by_name($stid, ":SMS_MOBILE_NO", $SMS_MOBILE_NO, -1, SQLT_CHR);
   oci_bind_by_name($stid, ":BKASH_TRX_ID", $BKASH_TRX_ID, -1, SQLT_CHR);

   oci_execute($stid);

   oci_free_statement($stid);
   oci_close($conn);
   if ($returnval == '0') {
      // echo '<script>alert("System Error Please Try Latter.")
      // window.location.href = "https://ndc.iadmissionbd.net/view1.php";
      // </script>';

      echo '<script>
                Swal.fire({
                    icon: "error",
                    text: "System Error Please Try Latter. !",
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "OK"
                    }).then((result) => {
                    if (result.isConfirmed) {
                        window.location.href = "bkash_verify.php";
                    }
                    })


            </script>';
   } else if ($returnval == '1') {
      // echo '<script>
      // alert("This Transaction ID Already Used ");
      // // window.location.href = "https://www.itbadmission.com/ndc/view1.php";
      // // window.location.href = "http://localhost/ndc/view1.php";
      // window.location.href = "https://ndc.iadmissionbd.net/view1.php";
      // </script>';


      echo '<script>
                Swal.fire({
                    icon: "warning",
                    text: "This Transaction ID Already Used  !",
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "OK"
                    }).then((result) => {
                    if (result.isConfirmed) {
                        window.location.href = "bkash_verify.php";
                    }
                    })


            </script>';
   } else if ($returnval == '2') {
      // echo '<script>alert("Your Transaction ID Received successfully And Within Shot Time  You Will Get a SMS After Verification With Bkash !")
      // window.location.href = "https://ndc.iadmissionbd.net/view1.php";
      // </script>';
      echo '<script>
                Swal.fire({
                    icon: "success",
                    text: "Your Transaction ID Received successfully And Within Shot Time  You Will Get a SMS After Verification With Bkash !",
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "OK"
                    }).then((result) => {
                    if (result.isConfirmed) {
                        window.location.href = "bkash_verify.php";
                    }
                    })


            </script>';
   }else if ($returnval == '3') {
      // echo '<script>alert("Your Transaction ID is Duplicate !")
      // window.location.href = "https://ndc.iadmissionbd.net/view1.php";
      // </script>';

      echo '<script>
                Swal.fire({
                    icon: "warning",
                    text: "Your Transaction ID is Duplicate !",
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "OK"
                    }).then((result) => {
                    if (result.isConfirmed) {
                        window.location.href = "bkash_verify.php";
                    }
                    })


            </script>';
   }
}












?>








   <!-- dashboard start -->
   <?php include 'dashboard.php'; ?>
   <!-- dashboard end -->

   <form action="" method="POST" enctype="multipart/form-data">

      <div class="container" style="width: 1200px;margin: 50px;">
         <div class="card">
            <div class="card-body">



               <div class="row" style="margin-top: 30px;">
                  <div class="col-md-3">

                  </div>
                  <div class="col-md-7">




                     <div class="header">
                        <img src="assets/img/logo.jpg" alt="logo" width="60px" height="60px" />
                        <h4 style="font-weight: bold;text-align: center;">Admission Application Form 2024 </h4>
                        <h5 style="font-weight: bold;text-align: center;">Notre Dame College,Dhaka</h5>
                        <!-- <h6>Applied For Admission to Study : <label for="">Science(bangla)</label></h6> -->
                     </div>
                  </div>
                  <div class="col-md-2">
                  </div>
               </div>
               <div class="form-body">


                  <div class="row m-3">
                     <div class="col-lg-12 col-md-12 col-sm-12">
                        <div class="p-3 mb-2" style="background-color: #ABCDEF;">
                           <h4 class="text-center text-weight-bolder" style="color: red;">Bkash Transaction ID For Verification</h4>
                        </div>

                        <div class="row ">
                           <div class="col-lg-3 col-md-3 col-sm-12">
                              <label for="text" class="text-center" style="font-weight: bold; color: black;">Please Enter Your Bkash Transaction Id :</label>
                           </div>
                           <div class="col-lg-9 col-md-9 col-sm-12">
                              <input type="text" class="form-control" name="bkash_trx_id" id="bkash_trx_id" placeholder="Example(9L87K0SAWH)" value="<?php if (isset($_POST['bkash_trx_id'])) echo $_POST['bkash_trx_id']; ?>">
                           </div>
                        </div>
                     </div>

                  </div>





                  <div class="col text-center">
                     <button type="submit" class="btn btn-success m-3" name='submit' id='submit'>
                        Submit
                     </button>
                  </div>

   </form>




   <!-- Only Table Mini Start -->
   <div class="applicant-info" style="margin-top:20px;" id="mini-table">

      <div class="mini-tab">
         <div class="row">

            <div class="col-12">

               <!-- <div class="card-header" style="background-color: #ABCDEF;">
          <h4 class="text-center text-weight-bolder">Applicant Information</h4>
      </div> -->
               <div class="card-body" id="report">

                  <div class="p-3 mb-2" style="background-color: #ABCDEF;">
                     <h4 class="text-center text-weight-bolder">Previous Transaction Status</h4>
                  </div>

                  <!-- <a href="#" class="btn btn-info mb-2" onclick="full_det()">Full Details</a> -->

                  <table id="table_id" class="display" style="width:100%">
                     <thead>
                        <tr style="background:#11c7e0">
                           <!-- <th style="text-align: center;">Admit Card</th> -->
                           <th style="text-align: center;">SMS Mobile Number </th>
                           <th style="text-align: center;">Transaction Id</th>
                           <th style="text-align: center;">Transaction Status</th>
                           <th style="text-align: center;">AMOUNT</th>
                           <th style="text-align: center;">MSISDN</th>
                           <th style="text-align: center;">Transaction Date</th>
                           <th style="text-align: center;">Remarks</th>


                        </tr>
                     </thead>
                     <tbody style="font-size: 15px;">
                        <?php
                        if ($bool) {
                           for ($i = 0; $i < count($report_output); $i++) {


                        ?>
                              <tr style="color: black!important;">


                                 <td style="background: #3ab54a; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['SMS_MOBILE_NO'] ?>
                                    </a>
                                 </td>

                                 <td style="background: #FFBE5B; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['TRX_ID'] ?>
                                    </a>
                                 </td>


                                 <td style="background: #FFBE5B; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['TRX_STATUS'] ?>
                                    </a>
                                 </td>



                                 <td style="background: #FFBE5B; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['AMOUNT'] ?>
                                    </a>
                                 </td>



                                 <td style="background: #FFBE5B; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['MSISDN'] ?>
                                    </a>
                                 </td>



                                 <td style="background: #FFBE5B; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['TRX_DATE'] ?>
                                    </a>
                                 </td>



                                 <td style="background: #FFBE5B; text-align: center;">
                                    <a class="text-decoration-none">
                                       <?php echo $report_output[$i]['REMARKS'] ?>
                                    </a>
                                 </td>













                              </tr>
                        <?php }
                        } ?>
                     </tbody>
                  </table>

               </div>
            </div>

         </div>
      </div>
   </div>
   <!-- Only Table Mini End -->
   </div>
   </div>
   </div>
   </div>


   </form>


   <!-- using online scripts -->
   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
   <script src="//malihu.github.io/custom-scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
   <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>














</body>

</html>