<?php require_once("header.php");?>

<?php
if(isset($_POST['send']))
{
    if($_POST['payment_method'] == "Razorpay")
    {
        header("location: donation-razorpay.php?last_id=".$_POST['last_id']);
    }
    else
    {
        //UPLOAD PAYMENT RECEIPT
    	if($_FILES['payment_receipt']['name']!="")
    	{	
    		$photopath = pathinfo($_FILES['payment_receipt']['name']);
    		$extension = $photopath['extension'];
    		$source = $_FILES['payment_receipt']['tmp_name'];
    		$payment_receipt = time().".".$extension;
    		$destination = "uploads/receipt/".$payment_receipt;
    		move_uploaded_file($source,$destination);
    	}
    	else
    	{
    		$payment_receipt = '';
    	}
    	
    	$sql_update = "UPDATE `pr_donation` SET `payment_method` = '".addslashes($_POST['payment_method'])."',`payment_receipt` = '".$payment_receipt."',`paymentStatus` = 'SUCCESS',`makertamp` = '".date('Y-m-d H:i:s',time())."'";
    	$exe_update = mysqli_query($connection,$sql_update);
    	
    	$_SESSION['msg_succ'] = 'Thanks for your payment.';
    	header("location: donation-option.php?last_id=".$_POST['last_id']);
    	exit;
    }
}
?>

            <script language="javascript" type="text/javascript">
            function qrsc()
            {
                $('#upi').show();
                $('#upi2').show();
            }
            
            function rzp()
            {
                $('#upi').hide();
                $('#upi2').hide();
            }
            </script>

			<!-- page template area start -->
			<section id="about">
				<div class="container mt-10 pb-10 pt-0">
					<div class="section-content">
						<div class="row">
						    <div class="col-md-12">
    						    <h1 class="title mt-0 mb-10" style="text-align:left;">Select Options <span style="color:#ed0d87;"> For Donation</span></h1> 
    						    <?php if(isset($_SESSION['msg_succ'])) { ?>
    							<p class="text-left"><img src="images/tick.png" alt="" /> <?php echo $_SESSION['msg_succ'];?></p>
    							<?php 
    							unset($_SESSION['msg_succ']);
    							} 
    							?>
                                <form id="contact_form" name="contact_form" class="" action="" method="post" enctype="multipart/form-data" onSubmit="return form_validation();">
                                <input type="hidden" name="last_id" id="last_id" value="<?php echo $_GET['last_id'];?>">
						        <div class="row">
                                    <div class="col-sm-12">
    									<div class="form-group">
    										<input type="radio" name="payment_method" id="payment_method" value="QR Scanner" onclick="qrsc();" checked> QR Code Scanner<br>
    										<input type="radio" name="payment_method" id="payment_method" value="Razorpay" onclick="rzp();"> Razorpay
    									</div>
								    </div>
								    <div class="col-sm-12" id="upi" style="display:block;">
    								    <p>SBI UPI NO : PORIBES@SBI</p>
                                        <p>A/C NAME : PORIBES FOUNDATION</p>
                                        <p>A/C NO. : 40659483503</p>
                                        <p>IFSC : SBIN0007468</p>
                                        <p><img src="https://prismonline.in/custom/poribes/images/poribes_qr.jpg" alt="Poribes Donation QR Code" class=""></p>
                                    </div>
                                    <div class="col-sm-12" id="upi2">
    									<div class="form-group">
    									    <p>Upload Payment Receipt *</p>
    										<input name="payment_receipt" id="payment_receipt" type="file">
    									</div>
								    </div>
    							</div>
    							<div class="form-group">
    								<input type="hidden" name="send" id="send" value="1" />
    								<button type="submit" class="btn btn-flat btn-theme-colored border-left-theme-color-2-4px">Submit</button>
							    </div>
                                </form>
                            </div>
                        </div>
                    </div>
				</div>
			</section>
			<!-- page template area end -->
  
<?php require_once("footer.php");?>