<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
 
                
            
            $myIdset = 0;
            if(isset($_REQUEST['PyId']))
            {     
                $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); 
                $sr = 1;

            }
                            
                            
                            
            
            if(isset($_REQUEST['PaidStatus']))
            {
                $stmt=$conn->prepare("update UI__TxnFailUsers set UTR=:UTR,status=1  where id=:id  ");  
                $stmt->bindValue(':UTR', "XXXXX" , PDO::PARAM_STR);
                $stmt->bindValue(':id', $_REQUEST['PaidStatus'] , PDO::PARAM_STR);
                $stmt->execute();    
                header("Location: payout-manage.php");   
                die;  
            }

			if(isset($_POST['submitP']))
			{     
			         
        			$stmt=$conn->prepare("update UI__UpiManage set   Upiselect=:Upiselect,updatedOn=:updatedOn  where typ=1"); 
                    $stmt->bindValue(':Upiselect',$_POST['UpiPay'], PDO::PARAM_STR);  
                    $stmt->bindValue(':updatedOn', date("d-M-Y H:i"), PDO::PARAM_STR);    
                    $stmt->execute();   
                    header("Location: payout-manage.php");  
    				die; 
			}  
			
			
			if(isset($_POST['submitA']))
			{         
        			$stmt=$conn->prepare("update UI__UpiManage set   Upiselect=:Upiselect,updatedOn=:updatedOn  where typ=2"); 
                    $stmt->bindValue(':Upiselect',$_POST['UpiPay1'], PDO::PARAM_STR);  
                    $stmt->bindValue(':updatedOn', date("d-M-Y H:i"), PDO::PARAM_STR);    
                    $stmt->execute();   
                    header("Location: payout-manage.php");   
    				die; 
			}  
			
			
			if(isset($_POST['submitAuaoMaual']))
			{         
        			$stmt=$conn->prepare("update UI__PayUAutoManual set   automaual=:automaual"); 
                    $stmt->bindValue(':automaual', $_POST['bnAuto'] , PDO::PARAM_STR);   
                    $stmt->execute();   
                    header("Location: payout-manage.php");   
    				die; 
			}    
			
			
			if(isset($_POST['submitAuaoMaualGp']))
			{         
        			$stmt=$conn->prepare("update UI__PayUAutoManual set   gpayAutoMan=:gpayAutoMan"); 
                    $stmt->bindValue(':gpayAutoMan', $_POST['bnAuto'] , PDO::PARAM_STR);   
                    $stmt->execute();   
                    header("Location: payout-manage.php");   
    				die; 
			}    
			
			
			
			
            $stmt=$conn->prepare("select *  from UI__UpiManage   where typ=1"); 
            //$stmt->bindValue(':UPI',  $_POST['UPI'] , PDO::PARAM_STR);  
            $stmt->execute();     
            $RstUxd = $stmt->fetch(PDO::FETCH_OBJ); 
            
            
            $stmt=$conn->prepare("select *  from UI__UpiManage   where typ=2"); 
            //$stmt->bindValue(':UPI',  $_POST['UPI'] , PDO::PARAM_STR);  
            $stmt->execute();     
            $RstUxd1 = $stmt->fetch(PDO::FETCH_OBJ); 
            
            $stmt=$conn->prepare("select *  from UI__PayUAutoManual   ");  
            $stmt->execute();     
            $RstUxd1Auto = $stmt->fetch(PDO::FETCH_OBJ); 
            
           
                    
                    $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); 
                    $gppay2 = json_decode($response);   
                    
                    
               
                   
					       
include ABS_PATH.'/admin/header.php';	
?>


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

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


	});
 


</script>



<script> 
$(document).ready(function()
{   
  
	
	    var URL = "<?php echo ROOTPATH; ?>";    
        $( "#userid" ).change(function() 
        {      
                   
                     
          $.ajax({	
                type: "POST",
                url: URL+"/ajax/validation.php",
                data: {userDatacheck:1,Data:$("#userid").val()},
                beforeSend: function(){ 
                },
                success: function(data)
                    {        
                        $("#AvailbleId").html("<span style='color:green;'>"+data+" &#x2713</span>");
                    }
                });   
        });
        
         $( "#useridA" ).change(function() 
        {      
                
                     
          $.ajax({	
                type: "POST",
                url: URL+"/ajax/validation.php",
                data: {userDatacheck:1,Data:$("#useridA").val()},
                beforeSend: function(){ 
                },
                success: function(data)
                    {        
                        
                        $("#AvailbleIdA").html("<span style='color:green;'>"+data+" &#x2713</span>");
                    }
                });   
        });
 
 
}); 

</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> ACCOUNTS BALANCE </h3></div>    
								<div class="panel-options">  
								   <a class="btn btn-warning" href="impspaidUser.php"> Paid User List</a> 
								    
								</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">  
								         &#x2713; <?php echo "Balance: Rs ".$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"> 
								        &#x2713; <?php echo "Balance: Rs ".$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"> 
								        &#x2713; <?php echo "Balance: Rs ".$gppay2->balance->normal_balance;?>
								    </div>
								 </div>
								 <hr> 
								 
								 </form>
								 
			  				<?php 
			  				    if($myIdset==0) 
			  				    {
			  				?>
	  				    <div class="panel-title"> <h3> PAY2 ALL List 2nd </h3></div>    	
	  				    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr> 
							
								<th>Sr</th>
								<th>UserID</th>  
								<th>User Name</th>  	   
								<th>Amount</th>  	   
								<th>Account Holder Name</th>  	   
								<th>Account No</th>  
								<th>IFSC</th>   
								<th>Date</th>   
								<th>Action</th>
								<th>Paid</th>
								<th>Type</th>
								<th>Rejection</th>
								<th>Update</th>
								
							</tr>
						</thead>
						<tbody>
							<?php
                                     $date1 = date("d-M-Y"); 
                                    $stmt=$conn->prepare("select  * from  UI__TxnFailUsers where impnft = 1  and Tdate not like '%$date1%' and UTR=''  order by id desc");  
                                    //$stmt->bindValue(':Ttime', $InTime , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                    $sr = 1;
								  foreach($AllUsers as $users)
								  {    
							          
							        $stmt=$conn->prepare("select  nm from   UI__Rgst where cuurentId=:cuurentId   ");  
                                    $stmt->bindValue(':cuurentId', $users->custId ,  PDO::PARAM_STR);
                                    $stmt->execute();  
                                    $NM = $stmt->fetch(PDO::FETCH_OBJ);     
                                                                               
							?>
							<tr class="odd gradeX" <?php if( ($users->response!='') && ($users->status!=1))  { ?>style="color:red;" <?php } ?> >
								<td><?php echo $sr++;?> </td>
								<td><?php echo $users->custId;?></td>
								<td><?php echo $NM->nm;?>  </td>   
								<td><?php echo $users->amt;?>  </td>   
								<td><?php echo $users->holder;?></td>
								<td><?php echo $users->accno;?></td>
								<td><?php echo $users->ifsc;?>  </td>   
								<td><?php echo $users->Tdate;?>  </td>    
								<td> <a href="customPay.php?PyId=<?php echo $users->id;?>">Pay</a>   </td>   
								<td><?php if($users->status==0)  { ?> <a href="payout-manage.php?PaidStatus=<?php echo $users->id;?>"> Unpaid </a>   <?php } else {   echo "Paid"; } ?>  </td>    
								<td><?php if($users->rtype==0) echo "Fresh";else echo "Refunded"; ?>  </td>    
								<td> <a href="rejectImps.php?PyId=<?php echo $users->id;?>&serKy=jspdfpofnpprimv00nF">Reject</a> </td>    
								<td> <a href="updateIMPS.php?PyId=<?php echo $users->id;?>">
								    
								    Update</a> 
								    <?php 
								        if( ($users->response!='') && ($users->status!=1)) 
								        echo $users->response;
								        ?>
								    </td>    
							</tr>  
							<?php } ?>
						</tbody>
					</table>
					
					
				
					
					
					 
					
					
					        
					
					    <!--div class="panel-title"> <h3><?php echo "UPI PAYOUT"; ?> </h3></div>    
					    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm"> 
							   	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">PAYOUT</label>
								    <div class="col-sm-6">  
								      Bharat Pay <input type="radio" value="1" name="UpiPay" <?php if($RstUxd->Upiselect==1) echo "checked"; ?> > &nbsp;&nbsp;
								      Ecuzen <input type="radio" value="2" name="UpiPay" <?php if($RstUxd->Upiselect==2) echo "checked"; ?>>
								      Pay2all <input type="radio" value="3" name="UpiPay" <?php if($RstUxd->Upiselect==3) echo "checked"; ?>>
								    </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="submitP" value="Submit">
										</div>
								  </div>   
								</form-->  
			  				</div>
			  			</div>
			  			
			  			
			  			
			  			
			  			<!--div class="content-box-large">
							<div class="panel-heading">
								<div class="panel-title"> <h3> </h3></div>    
								<div class="panel-title"> <h3><?php echo "BANK TRANSFER"; ?> </h3></div>    
							 
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm"> 
							   	  
								 
								 
								  
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">PAYOUT</label>
								    <div class="col-sm-6">  
								      Pay2All <input type="radio" value="1" name="UpiPay1" <?php if($RstUxd1->Upiselect==1) echo "checked"; ?> > &nbsp;&nbsp;
								      Ecuzen <input type="radio" value="2" name="UpiPay1" <?php if($RstUxd1->Upiselect==2) echo "checked"; ?>>
								      Airpay <input type="radio" value="3" name="UpiPay1" <?php if($RstUxd1->Upiselect==3) echo "checked"; ?>>
								    </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="submitA" value="Submit">
										</div>
								  </div>   
								</form>  
			  				</div>
			  			</div-->
			  			
			  			<?php  } else {?>
			  			
			  			
			  				<div class="content-box-large">
			  				<div class="panel-body">    
			  				
			  				</div>
			  				</div>
			  			
			  			<?php } ?>  
						
						
			  		 
			  			
			  			
			  		 
			  			
						
			  			
	  				</div> 
	  			</div>    
	  		<!--  Page content -->
		  </div>
		  
		</div>
    </div>

<?php  include ABS_PATH.'/admin/footer.php';	
    unset($_SESSION['userpanadhar']);
?>    