<?php include('include/config.php');



if(!empty(htmlspecialchars($_GET['course'],ENT_QUOTES,'UTF-8'))){

  $course_url=htmlspecialchars($_GET['course'],ENT_QUOTES,'UTF-8');

}else{

  $course_url='';

}



// echo "<pre>";

// print_r($arr);exit;

// $cat_n = mysqli_query($db,"select * from courseprice WHERE status='active' and course_name='".$course_url."' and currency='".$currency."'");

// if(mysqli_num_rows($cat_n)==0){

//     include('404.php');

//     die();

// }

// $cat1=mysqli_fetch_assoc($cat_n);



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

  $_SESSION['course'] = htmlspecialchars($_POST['product'],ENT_QUOTES, 'UTF-8');

  $_SESSION['amount'] = htmlspecialchars($_POST['amount'],ENT_QUOTES, 'UTF-8');
  $_SESSION['name'] = htmlspecialchars($_POST['name'],ENT_QUOTES, 'UTF-8');
  $_SESSION['email'] = htmlspecialchars($_POST['email'],ENT_QUOTES, 'UTF-8');
  $_SESSION['phone'] = htmlspecialchars($_POST['phone'],ENT_QUOTES, 'UTF-8');
  $_SESSION['address'] = htmlspecialchars($_POST['address'],ENT_QUOTES, 'UTF-8');

  $gateway=htmlspecialchars($_POST['gateway'],ENT_QUOTES, 'UTF-8');

  if($gateway=='stripe'){

    header("Location:checkout.php");

    die();

  }elseif($gateway=='paypal'){

    header("Location:paypal.php");

    die();

  }elseif($gateway=='razorpay'){
    header("Location:pay.php");
    die();
  }
  elseif($gateway=='qrcode'){
    header("Location:qr-payment");
    die();
  }

  
}

// echo "<pre>";

// print_r($cat1);exit;

?>

<!doctype html>

<html class="no-js" lang="en">

<head>

    <meta charset="utf-8">

    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>Online Payment</title>

    <meta name="description" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <?php include('include/css.php'); ?>

    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css'>

</head>



<body>
<?php include('include/google-tag-manager.php'); ?>
    <div class="main-wrapper">

        <?php include('include/header.php'); ?>

        <!-- End Search Popup  -->

        <div class="edu-breadcrumb-area breadcrumb-style-1 ptb--60 ptb_md--40 ptb_sm--40 bg-image">

            <div class="container eduvibe-animated-shape">

                <div class="row">

                    <div class="col-lg-12">

                        <div class="breadcrumb-inner text-start">

                            <div class="page-title">

                                <h3 class="title">Online Payment</h3>

                            </div>

                            <nav class="edu-breadcrumb-nav">

                                <ol class="edu-breadcrumb d-flex justify-content-start liststyle">

                                    <li class="breadcrumb-item"><a href="/">Home</a></li>

                                    <li class="separator"><i class="ri-arrow-drop-right-line"></i></li>

                                    <li class="breadcrumb-item active" aria-current="page">Online Payment</li>

                                </ol>

                            </nav>

                        </div>

                    </div>

                </div>



                <div class="shape-dot-wrapper shape-wrapper d-xl-block d-none">

                    <div class="shape-dot-wrapper shape-wrapper d-xl-block d-none">

                        <div class="shape-image shape-image-1">

                            <img src="assets/images/shapes/shape-11-07.png" alt="Shape Thumb" />

                        </div>

                        <div class="shape-image shape-image-2">

                            <img src="assets/images/shapes/shape-01-02.png" alt="Shape Thumb" />

                        </div>

                        <div class="shape-image shape-image-3">

                            <img src="assets/images/shapes/shape-03.png" alt="Shape Thumb" />

                        </div>

                        <div class="shape-image shape-image-4">

                            <img src="assets/images/shapes/shape-13-12.png" alt="Shape Thumb" />

                        </div>

                        <div class="shape-image shape-image-5">

                            <img src="assets/images/shapes/shape-36.png" alt="Shape Thumb" />

                        </div>

                        <div class="shape-image shape-image-6">

                            <img src="assets/images/shapes/shape-05-07.png" alt="Shape Thumb" />

                        </div>

                    </div>

                </div>

            </div>

        </div>





        <style>

    



.payment-container {

      display: flex;

    flex-flow: row wrap;

    justify-content: center;

    gap: 30px;

}

.payment-container > .payment-radio-container {

  flex: 0;

  padding: 0.5rem;

}

input[type="radio"] {

  display: none;

}

input[type="radio"]:not(:disabled) ~ .pplogo-container {

  cursor: pointer;

  

}

input[type="radio"]:disabled ~ .pplogo-container {

  color: #2251fc;

  border-color: #2251fc;

  box-shadow: none;

  cursor: not-allowed;

}

.pplogo-container {

  height: 150px;

  display: flex;

  justify-content:canter;

  align-items:center;

  width:200px;

  background: white;

  border: 2px solid #2251fc;

  border-radius: 20px;

  padding: 1rem;

  //margin-bottom: 1rem;

  box-shadow: 0px 3px 10px -2px rgba(34, 81, 252, 0.5);

  position: relative;

}

input[type="radio"]:checked + .pplogo-container {

/*  background: #2251fc;*/

  color: white;

  box-shadow: 0px 0px 20px rgba(34, 81, 252, 0.75);

}

input[type="radio"]:checked + .pplogo-container::after {

  content: "\f058";

 font-family: "Font Awesome 5 Free";

  color: #2251fc;  

  border: 1px solid #2251fc;

  font-size: 2.5rem;

  font-weight:100;

  position: absolute;

  top: -25px;

  left: 50%;

  transform: translateX(-50%);

  height: 50px;

  width: 50px;

  line-height: 49px;

  text-align: center;

  border-radius: 50%;

  background: white;

  box-shadow: 0px 0px 20px rgb(255 209 168);

}

p {

  font-weight: 900;

}

@media only screen and (max-width: 700px) {

  section {

    flex-direction: column;

  }

}

    

</style>





<div class="payments__list__method edu-section-gap bg-color-white">

    <div class="container">

        <div class="row">

<form action="" class="login-form" method="POST">

                

<div class="col-md-12 mx-auto p-4 payment-container">

<div class="payment-radio-container">

  <input type="radio" id="payment-radio1" name="gateway" value="stripe" checked>

  <label for="payment-radio1" class="pplogo-container">

  <img class="img-fluid" alt="stripe"src="assets/images/payment/stripe.png">              

  </label>

</div>

  <?php if($currency!='INR'){ ?>

    <div class="payment-radio-container">

  <input type="radio" id="payment-radio2" name="gateway" value="paypal">

  <label for="payment-radio2" class="pplogo-container">

  <img class="img-fluid" alt="paypal"src="assets/images/payment/paypal.png">            

  </label>

</div>

  <?php } ?>

  <?php if($currency=='INR'||$currency=='USD'||$currency=='GBP'){ ?>

<div class="payment-radio-container">

<input type="radio" id="payment-radio3" name="gateway" value="razorpay">

<label for="payment-radio3" class="pplogo-container">

<img class="img-fluid" alt="razorpay"src="assets/images/payment/razorpay.png">            

</label>

</div>

<?php } ?>

<?php if($currency=='INR'){ ?>

<div class="payment-radio-container">

<input type="radio" id="payment-radio4" name="gateway" value="qrcode">

<label for="payment-radio4" class="pplogo-container">

<img class="img-fluid" alt="qrcode"src="assets/images/custom-qr.png">            

</label>

</div>

<?php } ?>









  

  

  <!-- <div class="payment-radio-container">

  <input type="radio" id="payment-radio3" name="gateway" value="razorpay">

  <label for="payment-radio3" class="pplogo-container">

    <img class="img-fluid" alt="razorpay"src="assets/images/payment/razorpay.png"> 

  </label>

</div> -->

    

  </div>



<div class="form__payment login-register-page-wrapper">

    <div class="container">

        <div class="row">

            <div class="col-xs-12 col-md-6 col-lg-6">

                <div class="img__sec">

                    <img src="assets/images/payment__now.png" alt="pay now">

                </div>

            </div>

            <div class="col-xs-12 col-md-6 col-lg-6  checkout-page-style">

                <div class="form__box login-form-box">

                    <div class="input-box mb--30">

                        <input type="text" name="name" required id="" value="" placeholder="Enter your Full Name">

                    </div>

                    <div class="input-box mb--30">

                        <input type="email" name="email" required id="" value="" placeholder="Enter your Email">

                    </div>

                    <div class="input-box mb--30">

                        <input type="number" name="phone" required id="" value="" placeholder="Enter your Number">

                    </div>

                    <div class="input-box mb--30">

                       <input type="text" name="product" required id="" value="<?php echo ucwords(str_replace('-',' ',$course_url)); ?>" placeholder="Course name"> 

                    </div>

                    <div class="input-box mb--30">

                        <input type="text" name="address" required id="" value="" placeholder="Enter your Address">

                    </div>

                    <div class="input-box mb--30">

                          <input type="number" name="amount" required id="total" placeholder="amount">

                    </div>


                    <h5 class="text-warning">*Optional</h5>
                    <div class="input-box mb--30">
                          <input type="text" id="coupon" placeholder="Coupon">
                          <button class="btn btn-primary" id="activate">Apply</button>
                    </div>
                    <div class="input-box mb--30">
                    <div id="result"></div>
                    </div>
                    


                    

  <button type="submit" class="edu-btn" name="submit" id="checkout-button">Checkout</button>

                </div>

            </div>

        </div>

    </div>

</div>



</form>

        </div><!-- row -->

    </div><!-- container -->

</div><!-- payments__list__method -->





        <?php /*<div class="login-register-page-wrapper payment__page__online edu-section-gap bg-color-white">

            <div class="container checkout-page-style">

                <div class="row d-flex g-5">

                    <div class="col-lg-6">

                        <div class="payment_gateway_img">

                            <img src="assets/images/payment_gateway.svg" alt="online Payment">

                        </div>

                    </div>

                    <div class="col-lg-6">

                        <div class="login-form-box">

                            <form action="checkout.php" method="POST">

                                <input type="text" name="product" required id="" placeholder="Course name">

                                <input type="number" name="amount" required id="" placeholder="amount">

                                <!-- <input type="number" name="currency" id="" placeholder="currency"> -->

                                <button type="submit" class="edu-btn" name="submit" id="checkout-button">Checkout</button>

                              </form>

                        </div>

                    </div>

                </div>

            </div>

        </div>*/ ?>












        <!-- Start Footer Area  -->

        <?php include('include/footer.php'); ?>

    </div>

    <div class="rn-progress-parent">

        <svg class="rn-back-circle svg-inner" width="100%" height="100%" viewBox="-1 -1 102 102">

            <path d="M50,1 a49,49 0 0,1 0,98 a49,49 0 0,1 0,-98" />

        </svg>

    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
	$(document).ready(function(){
		$('#activate').on('click', function(){
			var coupon = $('#coupon').val();
			var price = $('#price').val();
			var course = $('#course').val();
			if(coupon == ""){
				alert("Please enter a coupon code!");
			}else{
				$.post('check_discount.php', {coupon: coupon, price: price,course:course}, function(data){
					if(data == "error"){
						alert("Invalid Coupon Code!");
						$('#total').val(price);
						$('#result').html('');
					}else{
						var json = JSON.parse(data);
						if(json.type=='percent'){
							$('#result').html("<h4 class='pull-right text-danger'>"+json.discount+"% Off</h4>");
						}else{
							$('#result').html("<h4 class='pull-right text-danger'>"+json.discount+" Off</h4>");
						}
						
						$('#total').val(json.price);
					}
				});
			}
		});
	});
</script>


    <?php include('include/js.php'); ?>



</body>

</html>