<?php 	
    include_once('../../config.php');   	
    include_once(ABS_PATH.'/admin/login_check.php');     
    include ABS_PATH.'/admin/header.php';	
    ?>  

<script>
function GetWallet(val)
{
     
     console.log(fruits);
     
    URL = "<?php echo ROOTPATH;?>";
                    	var r = confirm("Do you really update wallet");
                    	if (r == true) 
                    	{  
                             
                            $.ajax({	
                            type: "POST",
                            url: "ajax-file.php",
                            data:{UpdateWvallAmt:1,mobileno:fruits.toString()},	
                            beforeSend: function(){ 
                            //$('#update_wallet').addClass('disableloginbtn');
                            },
                            success: function(val)
                            { 
                                 alert("Comepleted!!");    
                                 // window.location.href= URL+"/admin/wallet/BaseConfWallet.php";
                            } 
                            });   	
                    	
                    	
                    	}	
                    	
                    	
	
}

var fruits = [];

function arpush(id) 
{ 
      
    if ($('#idcheck'+id).prop('checked')==true)
    { 
        fruits.push(id);
    }else
    {
        var index = fruits.indexOf(id);    
        if (index > -1) 
        { // only splice array when item is found
            fruits.splice(index, 1); // 2nd parameter means remove one item only
        }
    } 
    
    
}


 function GetBalance(sr,Id)
            {
                
                    $.ajax({
                    type: 'POST',
                    url: "../../config.php",
                    //async: false,			 
                    data: {gtMybal:1,Id:Id},	  
                    success: function(ajaxresult)
                    {	      
                        $("#MyBal"+sr).html(ajaxresult);     
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) 
                    { 
                    
                            alert('Error');
                            
                    }
                    });
            
            }
                    	
</script>
		 
		<div class="col-md-10">  
  			<div class="content-box-large">
  				<div class="panel-heading">
					<div class="panel-title"><h3>Update Wallet</h3></div>
					
					<div align="right">  <input type="button"    class="btn btn-warning" name="btnback" id="btnback" value="Update " onClick="GetWallet();" />
					</div>
					
				</div>
				
  				<div class="panel-body">
  					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
								<th>Sr</th>
								<th>Name</th>  	  
								<th>UserID</th>   
								<th>Phone</th>  
								<th>Wallet</th>  
								<th>TopUp</th>  
								<th>Checcked</th>
								 
							</tr>
						</thead>
						<tbody>
							<?php
                                    $stmt=$conn->prepare("select  * from  UI__Rgst  where is_active=1 order by id");  
                                    //$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  id,amt from   UI__DChstr where Rid=:sId and Rid!='DP112233'  and typ=1");  
                                    $stmt->bindValue(':sId', $users->cuurentId , PDO::PARAM_STR);
                                    $stmt->execute();  
                                    $count = $stmt->rowCount();    
                                        
                                    $MyTp = 0;    
                                   if($count > 0) 
                                   {
                                       $TopUp = $stmt->fetchAll(PDO::FETCH_OBJ);   
                                       foreach($TopUp as $Mpp)
                                            $MyTp +=$Mpp->amt;
							?>
							<tr class="odd gradeX">
								<td><?php echo $sr++;?> </td>
								<td><?php echo $users->nm;?> </td>
								<td><?php echo $users->cuurentId;?></td> 
								<td><?php echo $users->phm;?>  </td> 
								<td>
								        <span id="MyBal<?php echo $sr;?>"><a href="javascript:void(0);" onclick="GetBalance(<?php echo $sr;?>,'<?php echo $users->cuurentId;?>')">View</a></span>
								        <?php // if($users->cuurentId!='DP112233') echo  GetBalance($users->cuurentId);?> 
							    </td> 
								<td><?php echo $MyTp;?>  </td>    
								<td> <input type="checkbox" id="idcheck<?php echo $users->id;?>" onclick="arpush(<?php echo $users->id;?>);" /> </td>
								<!--td><a href="javascript:void(0);" onclick="GetWallet('<?php echo $users->cuurentId;?>')">  Confirme </a></td--> 
								
							</tr>  
							<?php } 
							  }
							?>
						</tbody>
					</table>
  				</div>
  			</div>



		  </div>
		</div>
    </div>

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