<?php    
	include_once("../view/header-footer/header.php");  
?>  
<style>
        #BnTrafer{
                    display:none;
        }
        
        
        #upiPay{
                    display:none;
        }
        
        
</style>
<script>  

                   
        var bkTransfer = 0;
        var upiTranser = 0;
        var optType = 0;
        
        function selectType(val)
        {    
            optType =  val;    
            if(val==1) {
                $("#BnTrafer").show(300);
                $("#upiPay").hide(300);
            }
            else {    
                $("#upiPay").show(300);
                $("#BnTrafer").hide(300);
            }
                  
        }
        
        
     
        
        function onCht(va)
        {
            
                upiTranser = va;
                myArray = va.split(",");  
                if(va!='')
                {
                    $("#PayId").removeClass("clrR");
                    $("#PayId").addClass("clrG");  
                    $("#UPI").val(myArray[0]);    
                    $("#PayId").val(myArray[1]); 
                    
                    
                }   
        }
        
        
        function verify()
        {    
                        
            if( ($("#accountNo").val()!='') && ($("#ifsc").val()!='') && ($("#mobile").val()!='')  ) 
            {     
                 
                     $.ajax({	
                        type: "POST",
                        url: URL+"/ajax/validation.php",
                        data: {BankVerify:1,accno:$("#accountNo").val(),ifsc:$("#ifsc").val(),mobile:$("#mobile").val()},
                        beforeSend: function(){ 
                        },
                        success: function(data)
                            {         
                                 if(data!='')
                                 $("#AvailbleId").html("<span style='color:green;'>"+data+" &#x2713</span>");
                            }
                        });   
                }else
                {
                    alert("Please fill the details");
                }
          }
        
        
        $(document).ready(function()
        {        
            
                $(".PaySound").click(function()
                {
                    
                    $('.loader').css('display','block');
                });  
                

            var URL = "<?php echo ROOTPATH;?>";    
            $( "#cuurentId" ).change(function() 
            {       
                  
                       
              $.ajax({	
                    type: "POST",
                    url: URL+"/ajax/validation.php",
                    data: {userDatacheckTop:1,Data:$("#cuurentId").val()},
                    beforeSend: function(){ 
                    },
                    success: function(data)
                        {       
                            $("#AvailbleId").html("<span style='color:green;'>"+data+" &#x2713</span>");
                        }
                    });   
            });  
             
             
                document.getElementById('amount').onkeyup = function () 
                {
                    document.getElementById('AmountDisplay').innerHTML = inWords(document.getElementById('amount').value);
                };  
            
        });  
        
        
        function PaySubmit()
        {   
                
                    
                    if(optType==1)
                        window.location.href = "P2PSERVICE3.php?amont="+$("#AMMT").val()+"&optType=1"+"&bkTransfer="+bkTransfer+"&p2pAgent="+$("#p2pAgent").val();   
                    else
                        window.location.href = "P2PSERVICE3.php?amont="+$("#AMMT").val()+"&optType=1"+"&upiTranser="+upiTranser+"&p2pAgent="+$("#p2pAgent").val();   
        }

        
        function SelecAcc(val)
        {
                   
                   bkTransfer = val;
                   $.ajax({	
                   type: "POST",
                    url: URL+"/ajax/validation.php",
                    data: {SelectACcount:1,AccId:val},
                    beforeSend: function(){ 
                    },
                    success: function(data)
                        {       
                            var Mydata = jQuery.parseJSON(data); 
                            
                            
                            
                            if(Mydata.apprvd==0)
                            {
                             $("#AccountAdd").html("Account approval is pending");   
                            }else{
                            $("#rname_").val(Mydata.accName);   
                            $("#accountNo").val(Mydata.accno);   
                            $("#ifsc").val(Mydata.ifsc);   
                            $("#AccountAdd").html(""); 
                            }
                        }
                    });  
        }
        
        function amtshow()
        {
             
            var UserId = "<?php echo $_SESSION['userId'];?>"
            {
                var payble = "<?php echo $UI__Deduction->charges;?>"; 
                if($("#amount").val()>1000)
                {
                    if(UserId!='DP841053')
                        var chr = ($("#amount").val()*1.5)/100;  
                    else    
                        var chr = payble;//($("#amount").val()*payble)/100;  
                }
                else
                    var chr = payble;//($("#amount").val()*payble)/100;  
            }
            
            /*$("#deduction").val((chr));
            $("#payble").val(($("#amount").val()-chr));*/
            
            
            $("#deduction").val(0);
            $("#payble").val(($("#amount").val()));
        }
    
     
    </script> 
<script type="text/javascript" src="<?php echo ROOTPATH;?>/view/js/tab/profile.js"> </script>
<script>
        //Function To Display Popup
    function div_show() {
    
    document.getElementById('abc').style.display = "block";
    }
    //Function to Hide Popup
    function div_hide(){
    document.getElementById('abc').style.display = "none";
    }
        
</script>
  
   
 <!-- Features -->
<div class="innerDeader">
    
<div class="loader">
    <div class="loaderInn">
        <img src="<?php echo ROOTPATH;?>/images/loader.gif" alt="loading" />
    </div>
</div>

      <div class="container">
       <a href="javascript:void(0);" id="go-back" class="goBack PaySound">
           <img src="<?php echo ROOTPATH;?>/images/Arrow 1.svg" alt="back">
       </a>   
          <h4> P2P  WITHDRAWAL </h4>  
          <?php 
            if(isset($_SESSION['topSuc'])) 
            {
          ?>
          <span style="font-size:13px;color:green;font-weight:bold;">
           <?php  
                if(isset($_SESSION['Regis']))  
                    echo $_SESSION['Regis'];
            ?>  
            </span>  
            <?php 
                } else { 
            ?> 
            <span style="font-size:13px;color:red;font-weight:bold;">
           <?php  
                if(isset($_SESSION['Regis']))  
                    echo $_SESSION['Regis'];
            ?>  
            </span>    
            <?php  } ?>  
            
            <span style="font-size:13px;color:red;font-weight:bold;" id="AccountAdd"></span>
     </div>  
    
       
   </div>
   <div class="innerBody">
       <div class="container">
        <div class="formBox">
          
          <?php 
            if($Result->p2p=='') 
            {
          ?>
          <form method="post" autocomplete="off"> 
          <div class="form-outline">
            <label class="form-label" for="form12">Select P2P Agent</label> 
            <select class="form-control"  name="p2pAgent" id="p2pAgent"  required>
                <option value="">Select Agent</option>
                <?php  
                       
                        foreach($p2pUsers as $data) 
                        {  
                            
                            $stmt=$conn->prepare("select nm from UI__Rgst  where  cuurentId=:cuurentId  ");   
                            $stmt->bindValue(':cuurentId',  $data->cuurentId , PDO::PARAM_STR);  
                            $stmt->execute();
                            $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);  
                ?>
                    <option value="<?php echo $data->cuurentId;?>"><?php echo $UI__Rgst->nm;?></option>
                <?php } ?>
            </select> 
          </div> 
          
          <div class="form-outline">
            <label class="form-label" for="form12">Select Type </label> <br>
            Bank Transfer: <input type="radio"    name="optType"        value="1"  required onclick="selectType(1);"  /> &nbsp;&nbsp;&nbsp;&nbsp;
            UPI: <input type="radio"    name="optType"   value="2"  required  onclick="selectType(2);"  /> 
          </div> 
          
        <div id="BnTrafer">  
          
          
          <div class="form-outline">
            <label class="form-label" for="form12">Select Account</label> 
            <select class="form-control"  name="AccountList" id="AccountList" onchange="SelecAcc(this.value)" required>
                <option value="">Select Account</option>
                <?php 
                        
                        $stmt=$conn->prepare("select * from UI__AddAccount  where  custId=:cuurentId  ");   
                        $stmt->bindValue(':cuurentId',  $_SESSION['userId'] , PDO::PARAM_STR);  
                        $stmt->execute();
                        $UI__AddAccount = $stmt->fetchAll(PDO::FETCH_OBJ);  
                        foreach($UI__AddAccount as $data) 
                        {  
                ?>
                    <option value="<?php echo $data->id;?>"><?php echo $data->accName;?></option>
                <?php } ?>
            </select>
            <input type="hidden"  class="form-control" name="mobile"  id="mobile"  required  value="<?php echo trim($Result->phm);?>" maxlength="10" />
          </div> 
          
          
        
                  <div class="form-outline">
                    <label class="form-label" for="form12">Receiver Name</label>
                    <input type="text"  class="form-control"  name="rname_"  id="rname_"  required  readonly/> 
                  </div> 
                  
                  <div class="form-outline">
                    <label class="form-label" for="form12">Receiver Acc No</label>
                    <input type="number"  class="form-control"     name="accountNo"  id="accountNo"  required  readonly/>
                  </div> 
        		  
        		  
        		  
        		  <div class="form-outline">
                    <label class="form-label" for="form12">Receiver IFSC</label>
                    <input type="text"  class="form-control"    name="ifsc"  id="ifsc"  required  readonly /> 
                  </div>  
                  
        	     <div class="form-outline">
                    <label class="form-label" for="form12">Available Balance</label>
                    <input type="text"   class="form-control"   value="₹<?php echo $PAYWAllet;?>" readonly  /> 
                  </div>
          
          </div>
		  
		  
		  <div id="upiPay">
		      
		      <div class="form-outline">
            <label class="form-label" for="form12">Select UPI</label>
            
            <select  name="DropUPI" id="DropUPI" class="form-control" onchange="onCht(this.value);">
                <option value="">Select UPI</option>    
                <?php 
                    foreach($UI__upi as $mpp) 
                    {
                ?>
                <option value="<?php echo $mpp->upi.",".$mpp->name;?>"><?php echo $mpp->upi." (".$mpp->name.")";?></option>
                <?php } ?>
            </select> 
          </div>
          
        <div class="form-outline">
            <label class="form-label" for="form12">Enter UPI</label>
            <input type="text"   class="form-control" <?php if(isset($_REQUEST['UPI'])) { ?>  value="<?php echo $MyUpi;?>" <?php } ?> name="UPI"  id="UPI"  required   onchange="verify();"  />
			<!--span id="AvailbleId" style='color:green;'><?php if(isset($_REQUEST['UPI'])) {  echo $MyUpiName; }?></span> 
			<span  id="UPIverify" style="float:right;margin-top:5px;color:#02b832" onclick="verify();"><B> ADD & VERIFY UPI</B></span--> 
		 
          </div>
		  
		  
		  
                   
        <div class="form-outline">
            <label class="form-label" for="form12">Payble Name</label> 
            <input type="text"   class="form-control "    id="PayId"   	value="<?php if(isset($_REQUEST['UPI'])) { if($MyUpiName!="Error") {  echo $MyUpiName; ?>"  style="color:green;font-weight:bold;" <?php } else {   echo $MyUpiName;  ?>  style="color:red;font-weight:bold;" <?php  } } ?>" />  
             
          </div>  
		  
		  </div>
		  
		  <input type="hidden" value="<?php echo $_REQUEST['amont'];?>" id="AMMT"  />
          
		  <input type="submit" class="btn btn-primary bigBtn PaySound mb-3 PaySound"   onclick="PaySubmit();"  name="submit" id="Mysubmit"  value="CONTINUE"/>  
		 
                    
		 
          </form>
          
          
          <?php } else {?>
          
          
            <form method="post" autocomplete="off"> 
          <div class="form-outline">
            <label class="form-label" for="form12">Select P2P Agent</label> 
            <select class="form-control"  name="p2pAgent" id="p2pAgent"  required>
                <option value="">Select Agent</option>
                <?php  
                       
                        foreach($p2pUsers as $data) 
                        {  
                            
                            $stmt=$conn->prepare("select nm from UI__Rgst  where  cuurentId=:cuurentId  ");   
                            $stmt->bindValue(':cuurentId',  $data->cuurentId , PDO::PARAM_STR);  
                            $stmt->execute();
                            $UI__Rgst = $stmt->fetch(PDO::FETCH_OBJ);  
                ?>
                    <option value="<?php echo $data->cuurentId;?>"><?php echo $UI__Rgst->nm;?></option>
                <?php } ?>
            </select> 
          </div>     
		  <input type="hidden" value="<?php echo $_REQUEST['amont'];?>" id="AMMT"  name="AMMT"/> 
		  <input type="submit" class="btn btn-primary bigBtn PaySound mb-3 PaySound"     name="submitAgent" id="Mysubmit"  value="CONTINUE"/>     
          </form> 
          <?php } ?>

        </div>  
       </div>
   </div>  
   
     
</div>
 
<?php 
  include_once("../view/header-footer/footer.php");  
unset($_SESSION['Regis']);  
unset($_SESSION['topSuc']); 
unset($_SESSION['QRSET']); 