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

<script>
function del_record(val)
{

	var r = confirm("Do you really want to delete record !");
	if (r == true) {    
	$.ajax({
	type: 'POST',
	url: "../ajax/default.php",
	//async: false,			 
	data: {del_city_names:1,val:val},	  
	success: function(ajaxresult){	     
		location.reload();	 	
	},
	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>Daily Payout </h3></div>
					
					<!--div align="right">  <input type="button"    class="btn btn-warning" name="btnback" id="btnback" value=" Add New User " onClick="javascript:location.href='#';" />
					</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>Date</th>    
								<th>Total Payout</th>    
							</tr>
						</thead>
						<tbody>
							<?php
							
							
							        
							        
							        $stmt=$conn->prepare("select  Tdate from  UI__DailyROIGene  group by Tdate ");
                                    //$stmt->bindValue(':Ttime', $InTime , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $UI__DailyROIGene = $stmt->fetchAll(PDO::FETCH_OBJ);
                                    
                                    foreach($UI__DailyROIGene as $K=>$mpp)
                                    { 
                                         
                                        $dp = '%'.$mpp->Tdate.'%'; 
                                        $stmt=$conn->prepare("select  * from  UI__DebitCredit  where Tdate like '".$dp."'  and (type=2)");  
                                        //$stmt->bindValue(':Ttime', $InTime , PDO::PARAM_STR);
                                        $stmt->execute(); 
                                        $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                         
                                        
                                        $dpBal = 0;
                                        foreach($AllUsers as $pp)
                                            $dpBal +=$pp->addDel;
                                         
                                        
                                        $ary[$K]['Tdate'] = $mpp->Tdate;  
                                        $ary[$K]['Bal'] = $dpBal;
                                    }
                                    
                                     
                                    
                                    
                                    $sr = 1;
								  foreach($ary as $users)
								  {       
                                            
							?>
							<tr class="odd gradeX">
								<td><?php echo $sr++;?> </td>   
								<td><?php echo $users['Tdate'];?></td>  
								<td><?php echo $users['Bal'];?></td> 
								 
								
							</tr>  
							<?php } ?>
						</tbody>
					</table>
					
					
					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr> 
								<th>Date</th>    
								<th>TODAYS PAYOUT</th>    
							</tr>
						</thead>
						<tbody>
							<?php
							
							
							        
							        
							        $stmt=$conn->prepare("select   cuurentId from  UI__Rgst   ");
                                    //$stmt->bindValue(':Ttime', $InTime , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $UI__DailyROIGene = $stmt->fetchAll(PDO::FETCH_OBJ);
                                    
                                    $Tamt = 0;
                                    foreach($UI__DailyROIGene as $K=>$mpp)
                                    { 
                                        
                                                                        
                                        $stmt=$conn->prepare("select *  from UI__DailyROIGene    where custId=:sId     ");   
                                        $stmt->bindValue(':sId',  $mpp->cuurentId , PDO::PARAM_INT);  
                                        $stmt->execute(); 
                                        $XUI__DailyROIGene = $stmt->fetchAll(PDO::FETCH_OBJ);  
                                        
                                        $Tamnt = 0;
                                        foreach($XUI__DailyROIGene as $xx)
                                        {
                                            $Tamnt +=$xx->amount;
                                        }      
                                        
                                        
                                         $stmt=$conn->prepare("select *  from UI__Bns    where Rid =:sId   ");   
                                            $stmt->bindValue(':sId',   $mpp->cuurentId , PDO::PARAM_INT);  
                                            $stmt->execute(); 
                                            $UI__Bns = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                            
                                             $LevelI = 0;
                                             foreach($UI__Bns as $dddm)
                                             {
                                                 $LevelI +=$dddm->Tamt;
                                             }
                                             
                                     
                                                $stmt=$conn->prepare("select Amt   from UI__Tpm where TopUpId=:refId   ");   
                                                $stmt->bindValue(':refId',   $mpp->cuurentId , PDO::PARAM_INT);  
                                                $stmt->execute(); 
                                                $MdirectB = $stmt->fetchAll(PDO::FETCH_OBJ);  
                                                
                                                $directIncome = 0;
                                                foreach($MdirectB as $dmm)
                                                    $directIncome += $dmm->Amt;                
                                            
                                            
                                        
                                        
                                        $stmt=$conn->prepare("select *  from UI__WithDraw    where userid=:sId and (accept=1 ||accept=2)  ");   
                                        $stmt->bindValue(':sId',   $mpp->cuurentId , PDO::PARAM_INT);  
                                        $stmt->execute(); 
                                        $UI__WithDraw = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                        
                                        
                                        $totalWithdrwa = 0;
                                        foreach($UI__WithDraw as $tl)
                                        {
                                        $totalWithdrwa +=$tl->amt;
                                        }
                                        
                                        
                                        
                                        
                                        $stmt=$conn->prepare("select availableFund from UI__Fundtransfer  where  userid=:userid  order by id desc  ");   
                                        $stmt->bindValue(':userid',   $mpp->cuurentId , PDO::PARAM_INT);  
                                        $stmt->execute(); 
                                        $UI__Fundtransfer = $stmt->fetch(PDO::FETCH_OBJ);      
                                    
                                        $PAYWAllet =  ($Tamnt+$LevelI+$directIncome+$UI__Fundtransfer->availableFund)-($totalWithdrwa);
                                        $Tamt +=$PAYWAllet; 
                                       
                                    }
                                    
                                    
                                    $sr = 1;
								       
                                            
							?>
							<tr class="odd gradeX"> 
								<td><?php echo date("d-M-Y");?></td>  
								<td><a href="<?php echo ROOTPATH;?>/admin/users/registered_users.php"> <?php echo $Tamt;?></a></td>   
							</tr>  
							 
						</tbody>
					</table>
					
					
  				</div>
  			</div>



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

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