<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
 
  
		   
            $myIdset = 0;
            $type = 1; 
            if(isset($_REQUEST['PyId']))
            {     
                 
                if(isset($_REQUEST['type']))
                    $type = $_REQUEST['type'];
                    
                        
                        if($type==1) 
                        {
                            $myIdset = $_REQUEST['PyId']; 
                            $stmt=$conn->prepare("select  * from  UI__TxnFailUsers where id=:id  ");  
                            $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);
                            $stmt->execute(); 
                            $Mydetails = $stmt->fetch(PDO::FETCH_OBJ); 
                        }else  if($type==3) 
                        {
                            
                            $myIdset = $_REQUEST['PyId']; 
                            $stmt=$conn->prepare("select  * from   UI__TxnFailUsersPay2 where id=:id  ");  
                            $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);
                            $stmt->execute(); 
                            $Mydetails = $stmt->fetch(PDO::FETCH_OBJ); 
                        }
                
                    $sr = 1; 
            }
            
            
                    $Remail =  "dailypay2024@gmail.com";
                    $Rd =  "gp6ZiH";  
                    $access_token = '{"email":"'.$Remail.'","password":"'.$Rd.'"}';  
                    
                    
                    $ch = curl_init('https://erp.pay2all.in/api/token');                                             
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                    'x-tera-tenant-region: IN', 
                    'Content-Type: application/json', 
                    'Content-Length: ' . strlen($access_token))                                                                       
                    );       																		 
                    $response = curl_exec($ch); 
                    
                    $json_response = json_decode($response);   
                    $RechargeAccess_token = $json_response->token; 
                    
                    $ch = curl_init();
                    curl_setopt($ch, CURLOPT_URL,'https://erp.pay2all.in/api/user');
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
                    $headers = array();
                    $headers[] = "Accept: application/json";
                    $headers[] = "Authorization: Bearer ".$RechargeAccess_token;
                    $headers[] = "Content-Type: application/json";
                    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                    $result = curl_exec($ch); 
                    
                    
                    $Data = json_decode($result);    
                    $Pay2alllBal =  (int)str_replace(",","",$Data->data->balance->user_balance);    

					
					
					
					    
                    $access_token = ''; 
                    $ch = curl_init('https://grappay.com/api/telecom/v1/check-balance?api_token=HdL32mhRkJU7rbUwmXIvRHGqP53Bkwg8FRRWpZ7MNfryg35EiX5ESyJrk7KB');                                             
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");                                                                     
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                    'x-tera-tenant-region: IN', 
                    'Content-Type: application/json', 
                    'Content-Length: ' . strlen($access_token))                                                                       
                    );       																		 
                    $response = curl_exec($ch); 
                    $grappay1 = json_decode($response);   
                   
                   
                    $access_token = ''; 
                    $ch = curl_init('https://grappay.com/api/telecom/v1/check-balance?api_token=RdVFLtRb83jLrxM5mafitjRW6Gp4zbfiwYXfhr6FEg6n3w4RQXfC9pNkhEMd');                                             
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");                                                                     
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                    'x-tera-tenant-region: IN', 
                    'Content-Type: application/json', 
                    'Content-Length: ' . strlen($access_token))                                                                       
                    );       																		 
                    $response = curl_exec($ch); 
                    $grappay2 = json_decode($response); 
                   
                   
                  
		 
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  


 <script>
	$(function() {
		$( "#datepicker" ).datepicker(); 
	}); 
  
	$(document).ready(function()
	{   

	
	$("#product_frm").validate({
		
		errorElement:'div',
		rules:{ 
			city:{
				required:true				 
			} 
			
			
			
		},
		messages:{				
			 
			 city:{
				required:"Enter city name"				 
			} 
		}
	});


	});
 


</script>
		 
		 <div class="col-md-10">

	  			<div class="row">
	  				<div class="col-md-12">
	  					<div class="content-box-large">
							<div class="panel-heading">
								<div class="panel-title"> <h3> PAY TO USERS</h3></div>    
								
								<div class="panel-options"> 

								    
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal"  action="pgDmt.php"   method="post"  >       
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">REGULAR PAY2ALL </label>
								    <div class="col-sm-6"> 
								         <input type="radio" name="payselect" value="1"  checked /> 
								         &#x2713; <?php echo $Pay2alllBal;?>
								    </div>
								 </div>
								 <hr> 
								 
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">GRAP PAY - 1  </label>
								    <div class="col-sm-6"> 
								         <input type="radio" name="payselect" value="2"    /> 
								         
								         &#x2713; <?php echo $grappay1 ->balance->normal_balance;?>
								    </div>
								 </div>
								 <hr> 
								 
							 	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">GRAP PAY - 2  </label>
								    <div class="col-sm-6"> 
								         <input type="radio" name="payselect" value="3"    /> 
								         &#x2713; <?php echo $grappay2 ->balance->normal_balance;?>
								    </div>
								 </div>
								 <hr> 
								 
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">RUN PAISA  </label>
								    <div class="col-sm-6"> 
								         <input type="radio" name="payselect" value="4"/> 
								          &#x2713;
								    </div>
								 </div>
								 <hr> 
								 
								 
							 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Account Holder Name</label>
								    <div class="col-sm-6">  
								      <input type="text" value="<?php echo $Mydetails->holder;?>"  class="form-control"   readonly > 
								    </div>
								 </div>
								 <hr>  
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Account   No</label>
								    <div class="col-sm-6">  
								      <input type="text" value="<?php echo $Mydetails->accno;?>"  class="form-control"   readonly > 
								    </div>
								 </div>
								 <hr>  
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">IFSC</label>
								    <div class="col-sm-6">  
								      <input type="text" value="<?php echo $Mydetails->ifsc;?>"  class="form-control"  readonly > 
								    </div>
								 </div>
								 <hr>  
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Amount</label>
								    <div class="col-sm-6">  
								      <input type="text" value="<?php echo $Mydetails->amt;?>"   class="form-control" readonly   > 
								    </div>
								 </div>
								 <hr>  
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Password</label>
								    <div class="col-sm-6">  
								      <input type="text" name="pdddF"   class="form-control"  required  > 
								      <input type="hidden" name="PyId"   value="<?php echo $_REQUEST['PyId'];?>"   > 
								      <input type="hidden" name="type"   value="<?php echo $type;?>"   > 
								    </div>
								 </div>
								 <hr>  
								 
								 
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Submit</label>
										<div class="col-sm-6">
										  <input type="submit"    class="btn btn-primary"  name="PssSub" value="Submit">
										  <a href="payout-manage.php"  class="btn btn-primary" >  Cancel</a>
										</div>
								  </div>    
								  
								  
								</form>
								
								
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


	  		<!--  Page content -->
		  </div>
		</div>
    </div>

<?php  include ABS_PATH.'/admin/footer.php';	?>    