 <?php 
   include('sms.php');
//   include('create_order.php');
   use PHPMailer\PHPMailer\PHPMailer;
   use PHPMailer\PHPMailer\SMTP;
   use PHPMailer\PHPMailer\Exception;

     
   require 'vendor/autoload.php';
   $id=$_GET['Id_2'];
   $book_id=$_GET['book_id'];
   $msg = "";
   

   $query= mysqli_query($conn,"SELECT DISTINCT * FROM subject_soes ,module_soes WHERE module_soes.course_code = subject_soes.course_code AND subject_soes.course_code='$id'")or die(mysqli_error());
   $row = mysqli_fetch_array($query);
   $subject_id=$row['subject_id'];
   $subject_name=$row['subject_name'];
   $student_name=$user_row['student_name'];
//   $student_contact_no="0757660790";
 

    $student_id=$user_row['student_id'];
    $invoice= mysqli_query($conn,"SELECT * FROM student_soes 
    INNER JOIN exam_invoice 
    ON exam_invoice.student_id = student_soes.student_id  WHERE exam_invoice.course_code ='$id' AND exam_invoice.student_id='$student_id' ")or die(mysqli_error());
    $invoice2 = mysqli_fetch_array($invoice);
    $order_id=$invoice2['order_id'];
    $student_contact_no=$invoice2['student_contact_no'];
    $date=date("M d, Y-H:i");
    $amount=$invoice2['amount'];
    $status=$invoice2['payment_status'];
    $invoice_id=$invoice2['invoice_id'];
    
    
  if (isset($_POST['update'])){
				$course_code = $_POST['course_code']; 
				$payment_code1 = $_POST['payment_code'];  
				$invoice_status='Enable';  
				$student_id = $_POST['student_id']; 

				$query1= mysqli_query($conn,"SELECT * FROM exam_invoice WHERE course_code='$course_code' AND student_id='$student_id'")or die(mysqli_error());
				$row1 = mysqli_fetch_array($query1);
				 $payment_code = $row1['payment_code'];  

				 if ($payment_code1 == "$payment_code" ){

				$query=mysqli_query($conn,"UPDATE exam_invoice set invoice_status='$invoice_status'  WHERE course_code='$course_code'");
				  if($query){ 
				       $s_mobile = "255757660790";
                          $message = "Cybercode Payment Confirmed: for Order id $order_id date $date amount $amount thanks";
                          send_message($s_mobile, $message);
				      ?>
				      <script type="text/javascript">
				          alert("Submition Successfuly, Welcome to cybercode");
				           window.location.href = 'admin.php?page=edr6728sr624gtt5678532srr5568exRestt578jjhggfr448w2&Id_2=<?php echo $id?>&book_id=<?php echo $book_id?>';
				        </script>
				        <?php  
				      }  
				      else{
				        ?>  
				        <script type="text/javascript">
				         alert("Sorry Submition not Successfuly Try Again");
				        </script>
				        <?php
				    }
				} else{
				        ?>  
				        <script type="text/javascript">
				         alert("Payment verification code is not correct Please use the first code provided, If the problem persist please contact support Team.");
				        </script>
				        <?php
				    }
			}   
    ?> 
  <style>
    
    .banner {
      width: 100%; 
      margin: 0 auto; 
      overflow: hidden;
    }
    .banner img {
      width: 100%;
      display: block;
    }
     .animated-button-invoice {
  background-color: #0aaefa;
  color: white;
  padding: 15px 30px;
  border: none;
  border-radius: 5px;
  font-size: 18px;
  cursor: pointer;
  animation: pulses 2s infinite alternate; /* Apply a pulsing animation */
}
 @keyframes pulses {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 255, 163, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px 5px rgba(0, 255, 163, 0.7);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 255, 163, 0.7);
  }
}  
    .animated-button {
  background-color: #e74c3c;
  color: white;
  padding: 15px 30px;
  border: none;
  border-radius: 5px;
  font-size: 18px;
  cursor: pointer;
  animation: pulse 2s infinite alternate; /* Apply a pulsing animation */
}


@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px 5px rgba(231, 76, 60, 0.7);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
  }
}

  </style>
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
   <div class="container">
      <div class="page-inner">
            <div class="page-header">
              <h3 class="fw-bold mb-3"><?php echo $user_row['course']; ?></h3>
              <ul class="breadcrumbs mb-3">
                <li class="nav-home">
                  <a href="admin.php?page=dashboard&Id_2=<?php echo $user_row['course']; ?>">
                    <i class="icon-home"></i>
                  </a>
                </li>
                <li class="separator">
                  <i class="icon-arrow-right"></i>
                </li>
                <li class="nav-item">
                  <a href="admin.php?page=dashboard&Id_2=<?php echo $user_row['course']; ?>"><?php echo $row['subject_name']; ?></a>
                </li>
                <li class="separator">
                  <i class="icon-arrow-right"></i>
                </li>
                <li class="nav-item">
                  <a href="admin.php?page=dashboard&Id_2=<?php echo $user_row['course']; ?>"><?php echo $row['code']; ?></a>
                </li>
              </ul>
            </div>
            <div class="row">
              <div class="col-md-12">
                <div class="card">
                  <div class="card-header">
                    <h4 class="card-title"><?php echo $row['subject_name']; ?> -(<?php echo $user_row['course']; ?>)</h4>
                  </div>
                  <div class="card-body"> 
                  <br>
				 
                      <div class="row"> 
			             <div class="row md-5 p-6">
			                 <div class="col-md-3">
			                </div>
			             <div class="col-md-6 ps-md-5 pe-md-1">
			                 <div class="card card-profile">
                  <div
                    class="card-header"
                    style="background-image: url('')"
                  >
                    <div class="profile-picture">
                      <div class="avatar avatar-xl">
                        
                    <button style="width: 70px; height: 70px;"
                        type="button"
                        class="btn btn-icon btn-round btn-success"  
                      >
                        <i class="fas fa-check"></i>
                      </button>

                      </div>
                    </div> 
                  </div>
                  <div class="card-body">
                    <div class="user-profile text-center ">
                       <h2 class="text-success">Payment Successfuly</h2>
                     	<h6>Examination Code</h6>
			         </div> 
                      <hr>
                      <form action="" method="post">
                        <div class="row"> 
	                     <div class="col-md-12">  
	                      	<br>
	                     <input type="hidden" name="course_code"  class="form-control" value="<?php echo $user_row['course']; ?>">
	                      <input type="hidden" name="student_id"  class="form-control" value="<?php echo $user_row['student_id']; ?>">
			              <input type="text" name="payment_code"  class="form-control" placeholder="Past Payment code..." required> 
			              </div> 
			              <br> 
			         </div> 
			         <br><br>
                      <div class="view-profile">
                        <div class="col-md-12" style="text-align: center;"> 
			              <button type="submit" name="update" class="btn btn-success btn-rounded btn-lg"><i class="fas fa-lock-open"></i> Unlock Exam</button>
			              </div>
                      </div>
                    </form>
                    </div>
                  </div> 
                </div>
			         
			            </div> 
			            
			         </div> 
			         <br> 
		                  <div class="card-footer"> 
		                  	<div class="row">  
                            <div class="col-md-12"  style="text-align: center;"> 
                        	 <form action="" method="post">  
					              <input type="hidden" name="description"  class="form-control" value="Payment for the course of <?php echo $subject_name; ?>">   
					              <input type="hidden" name="student_id"  class="form-control" value="<?php echo $user_row['student_id']; ?>"> 
					               <input type="hidden" name="student_email_id"  class="form-control" value="<?php echo $user_row['student_email_id']; ?>">
					               <input type="hidden" name="course_code"  class="form-control" value="<?php echo $user_row['course']; ?>">
					              <?php if (!$invoice2){?>
					             <p>Welcome to cybercode</p> 
					              <?php }else if ($invoice2["invoice_status"] == 'Enable'){?>
					              	<a href="orbital/exam.php" class="btn btn-success btn-round"><i class="fas fa-address-card"></i> Examination Portal</a>  
					              <?php }else{?>
					               <p>Your request is under review kindly wait while we process it.</p>
					              <?php  }?>
					         </form> 
                          </div>
                      </div> 
				      </div>
                  </div>
                </div>
              </div> 
            </div>
          </div>
        </div> 
 
 
 
 

    <!-- Fonts and icons -->
    <script src="../assets/js/plugin/webfont/webfont.min.js"></script>
    <script>
      WebFont.load({
        google: { families: ["Public Sans:300,400,500,600,700"] },
        custom: {
          families: [
            "Font Awesome 5 Solid",
            "Font Awesome 5 Regular",
            "Font Awesome 5 Brands",
            "simple-line-icons",
          ],
          urls: ["../assets/css/fonts.min.css"],
        },
        active: function () {
          sessionStorage.fonts = true;
        },
      });
    </script>

    <!-- CSS Files -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
    <link rel="stylesheet" href="assets/css/plugins.min.css" />
    <link rel="stylesheet" href="assets/css/kaiadmin.min.css" />

     
