<?php   
	include_once("../view/header-footer/header.php");  
?>  
<style>
  #SuccImg{
        display:none;
    }
    #submit{
        display:none;
    }
    #TxnPwdShow{
        display:none;
    }
    #MsgShow{
        display:none;
    }
    #PayAgian{
        display:none;
    } 
    #PgFail{
        display:none;
    }
    
    .clrG{
        color:green;
        font-weight:bold;
    }
    .clrR{
        color:red;
        font-weight:bold;
    }
</style>  
<script>
    
    
    
     function amtshow()
        {
            var payble = "<?php echo $UI__Deduction->charges;?>";  
            var CHR = ($("#AMMT").val()*payble)/100;  
            
            
            /*$("#deduction").val(15); 
            $("#payble").val(parseInt($("#AMMT").val())+15);*/
            
            $("#deduction").val(0); 
            $("#payble").val(parseInt($("#AMMT").val()));
        }        
    
        function verify()
        {    
            
          
                        
            if($("#UPI").val()!='') 
            {     
                     $.ajax({	
                        type: "POST",
                        url: URL+"/ajax/validation.php",
                        data: {UpiVarify:1,Data:$("#UPI").val()},
                        beforeSend: function(){ 
                        },
                        success: function(data)
                            {     
                                 if(data!='Error') 
                                 {
                                    //$("#AvailbleId").html("<span style='color:green;'>"+data+" &#x2713</span>");
                                      
                                    $("#PayId").removeClass("clrR");
                                    $("#PayId").addClass("clrG");
                                    $("#PayId").val(data+" ✓"); 
                                    
                                 }else
                                 { 
                                    $("#PayId").removeClass("clrG");
                                    $("#PayId").addClass("clrR");
                                    $("#PayId").val("Invalid UPI"); 
                                 }
                            }
                        });   
                }       
          }
        
        
        function functionCalled1()
        {
                if($("#TxnPwd").val()!='') 
                {      
                        $.ajax({	
                        type: "POST",
                        url: URL+"/ajax/validation.php",
                        data: {FormDataSubmit:1,UPI:$("#UPI").val(),AMMT:$("#AMMT").val(),TxnPwd:$("#TxnPwd").val()},
                        beforeSend: function()
                        {
                            
                        },
                        success: function(data)
                            {       
                                $("#MsgShow").hide(300);
                                $("#submit").hide(300); 
                                $("#PayAgian").show(300) ;
                                
                                 
                                 
                                if(data==1) 
                                { 
                                    
                                    /*var audioElement2 = document.createElement('audio');
                                    audioElement2.setAttribute('src', 'https://www.dailypayservices.in/mob/sound/paidamt.mp3'); 
                                    audioElement2.addEventListener('', function() 
                                    {
                                    //this.play();
                                    }, false);
                                    audioElement2.play();  */    
                                    
                                    ////
                                    $('.loader').css('display','block');
                                    $.ajax({	
                                    type: "POST",
                                    url: URL+"/ajax/validation.php",
                                    data: {FormDataSubmitAgn:1,UPI:$("#UPI").val(),AMMT:$("#AMMT").val(),TxnPwd:$("#TxnPwd").val()},
                                    beforeSend: function()
                                    {
                                        
                                    },
                                    success: function(data)
                                    {       
                                            $("#UPI").val('');
                                            $("#AMMT").val('');
                                            $("#TxnPwd").val(''); 
                                            $('.loader').css('display','none'); 
                                            
                                           
                                            
                                            if( (data!=2)  && (data!=0) &&  (data!=5)  &&  (data!=6) && (data!=3) && (data!=7) && (data!=9) && (data!=10) )
                                            {
                                                window.location.href  = URL+"/dashboard/viewRecUpi.php?id="+data;   
                                                $("#SuccImg").show(300);  
                                            }else if(data==2)
                                            {
                                                $("#PgFail").html("Please complete your E-KYC & Try Again!!");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                                
                                            }else if(data==3)
                                            {
                                                $("#PgFail").html("Your Daily Limit Has Been Over!!");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                            }else if(data==5)
                                            {
                                                $("#PgFail").html("Please Transfer Minimum 100 Rs/-");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                            }else if(data==6)
                                            {
                                                $("#PgFail").html("Please use ID TO ID Tranfer Option for this UPI");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                            }else if(data==7)
                                            {
                                                $("#PgFail").html("Verify UPI & Try Again");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                            }else if(data==9)
                                            {
                                                $("#PgFail").html("Todays limit exceed");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                            }else if(data==10)
                                            {
                                                $("#PgFail").html("Today's UPI transfer service has been closed, please try on next day");  
                                                $("#AvailbleId").html("");  
                                                $("#PgFail").show();   
                                            }else 
                                                $("#PgFail").show();                    
                                    }   
                                    }); 
                                    //   
                                    
                                }else if(data==2)
                                {
                                    alert("Error: 303");
                                }else 
                                {
                                        $("#PgFail").html("Please Enter correct Transaction Password");  
                                        $("#AvailbleId").html("");  
                                        $("#PgFail").show();         
                                }
                            
                            }
                        }); 
                }
        }
        
        function functionCalled()
        {
            
                   
         
            if(($("#AMMT").val()!='') && (($("#UPI").val()!=''))) 
            {
                    if($("#AMMT").val()<=1000)
                    {
                        $("#proceed").hide(300);     
                        $("#submit").show(300);    
                        $("#TxnPwdShow").show(300);     
                    }else
                    {
                        
                         $.ajax({	
                            type: "POST",
                            url: URL+"/ajax/validation.php",
                            data: {CheckDpay:1,Data:$("#UPI").val()},
                            beforeSend: function(){ 
                            },
                            success: function(data)
                                {       
                                     if(data>0)
                                     {
                                        $("#proceed").hide(300);     
                                        $("#submit").show(300);    
                                        $("#TxnPwdShow").show(300); 
                                        
                                     }else
                                     {
                                        $("#AmmTPorc").html("For Above ₹1000/- Use Bank Transfer Option");   
                                     } 
                                }
                            });  
                    }
                    
            }
        }   
        
        $(document).ready(function()
        {       
            var URL = "<?php echo ROOTPATH;?>";   
            
            $(".PayOutSound").click(function()
            {       
            var audioElement = document.createElement('audio');
            audioElement.setAttribute('src', 'https://www.dailypayservices.in/mob/sound/button-16.mp3'); 
            audioElement.addEventListener('', function() 
            {
            //this.play();
            }, false);
            audioElement.play();  
            });	
             
              
                
            document.getElementById('AMMT').onkeyup = function () 
            {    
                document.getElementById('AmountDisplay').innerHTML = inWords(document.getElementById('AMMT').value);
            };     
     
        });    
    
     
    </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";
    }
        
        function onCht(va)
        {
                myArray = va.split(",");  
                if(va!='')
                {
                    $("#PayId").removeClass("clrR");
                    $("#PayId").addClass("clrG");  
                    $("#UPI").val(myArray[0]);    
                    $("#PayId").val(myArray[1]+" ✓"); 
                    
                    
                }   
        }
        
    </script>




<div class="loader">
    <div class="loaderInn">
        <img src="<?php echo ROOTPATH;?>/images/loader.gif" alt="loading" />
    </div>
</div>

 <!-- Features -->
   <div class="innerDeader">
      <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>UPI PAYOUT</h4> 
          <span>
           <?php  
                if(isset($_SESSION['Regis']))  
                    echo $_SESSION['Regis'];     
            ?>
          </span>
     </div>    
   </div>
   <br>
   
   <?php 
    
   ?>
    <!--div class="innerBody">
       <div class="container">
           <h5 style="font-size:15px;">* Kindly use bank transfer option right now </h5>
     </div>
    </div!--> 
   <?php  { ?>
       
   <div class="innerBody">
       <div class="container">
        <div class="formBox">
            <form method="post" autocomplete="off">
          
          <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 class="form-outline">
            <label class="form-label" for="form12" style="width: 100%;">Amount</label>
            <div style="float: left;font-weight: bold;font-size: 20px;width: 31px;border-left: 1px solid #dee0e2;border-top: 1px solid #dee0e2;border-bottom: 1px solid #dee0e2;border-right:1px solid #dee0e2;background-color:#dee0e2;text-align:center;border-radius: .25rem;height:38px">₹</div> 
             
            <input type="number"   class="form-control"   name="AMMT"  id="AMMT"  required    onchange="amtshow();"  style="float: left; width: 90%;"  required /> 
            <span id="AmountDisplay"> </span>
            </div>
          
           <div class="form-outline">
            <label class="form-label" for="form12">Deduction</label> 
            <input type="number"   class="form-control"    readonly    id="deduction"    />  
             
          </div>  
		  
		  
		  
           <div class="form-outline">
            <label class="form-label" for="form12">Total Payble</label> 
            <input type="number"   class="form-control"    readonly  id="payble"    />   
          </div>  
          
		  
		  
		   <div class="form-outline">
            <label class="form-label" for="form12">By</label>
            <input type="text"   class="form-control"   value="<?php echo $BY;?>" 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 class="form-outline"  id="TxnPwdShow">
            <label class="form-label" for="form12">Enter Transaction Password</label>
            <input type="password"   class="form-control"    name="TxnPwd"  id="TxnPwd" required  minlength="6"   maxlength="6"  pattern="[0-9]*"  inputmode="numeric" /> 
          </div>
          
          
          
		   <div class="form-outline">
		        <?php  
                        if(isset($_SESSION['Regis']))
                        {
                            if(!isset($_SESSION['topSuc'])) 
							{ 
                    ?> 
            <label class="form-label" for="form12" style="color:red;font-weight:bold">Payment Failed</label>
             <?php  } 
                        }
                    ?> 
                <label id="PgFail" style="color:red;font-weight:bold"> Please try for bank transfer option due to technical issues  </label>    
          </div>
              
         
        
        <div class="form-outline"  id="proceed">
            <a href="javascript:void(0);"  class="btn btn-primary bigBtn PayOutSound"      onclick="functionCalled();"  > Proceed </a>  
            <!--a href="javascript:void(0);"  class="btn btn-primary bigBtn PayOutSound"       > Please try with IMPS/NEFT </a-->  
            <span id="AmmTPorc"></span>
        </div>
        
        
        <div class="form-outline"  id="submit">
            <a href="javascript:void(0);"   class="btn btn-primary bigBtn  PayOutSound mb-2" onclick="functionCalled1();"  />   Pay </a>
            <span id="AmmTPorc1"></span>
            
        </div>  
          
         <div class="form-outline"  id="MsgShow">
            <img src="<?php echo ROOTPATH;?>/view/images/procc.gif"  width="80"/>
        </div>
        
         <div class="form-outline"  id="SuccImg">
            <span><img src="<?php echo ROOTPATH;?>/view/images/pgdone.gif" /></span><br>
        </div>    
        
        
        
        <a href="AddPAccount.php"class="PaySound " style="background-color: #055e06;
                    border: none;
                    color: #fff;
                    padding: 5px 10px;
                    text-align: center;
                    text-decoration: none;
                    display: inline-block;
                    width:100%; 
                    border-radius:5px;
                    font-size: 15px;
                    margin: 4px 2px;
                    cursor: pointer;" >ADD UPI
            </a>    
            
             <a href="DeletePupi.php" class="PaySound " style="background-color: #fc4444;
                    border: none;
                    color: #fff;
                    padding: 5px 10px;
                    text-align: center;
                    text-decoration: none;
                    display: inline-block;
                    width:100%; 
                    border-radius:5px;
                    font-size: 15px;
                    margin: 4px 2px;
                    cursor: pointer;" >DELETE UPI 
            </a>  
         
         
         <a href="javascript:void(0);" id="go-backDown" class="PaySound " style="background-color: #747474;
                    border: none;
                    color: #fff;
                    padding: 5px 10px;
                    text-align: center;
                    text-decoration: none;
                    display: inline-block;
                    width:100%; 
                    border-radius:5px;
                    font-size: 15px;
                    margin: 4px 2px;
                    cursor: pointer;" >Go Back</a>
                    
                    
            

          </form>

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