<?php 	
    include_once('../../config.php');   	
    include_once(ABS_PATH.'/admin/login_check.php'); 
    
    
                                $stmt=$conn->prepare("select *  from UI__DailyROIGene    where custId=:sId    ");   
                                $stmt->bindValue(':sId',  $_REQUEST['userId'] , PDO::PARAM_STR);  
                                $stmt->execute(); 
                                $XUI__DailyROIGene = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                
                                
                                
                                foreach($XUI__DailyROIGene as $xx)
                                {
                                    $Tamnt +=$xx->amount;
                                }
                                
                                
                                
                                $stmt=$conn->prepare("select *  from UI__Bns    where Rid =:sId   ");   
                                $stmt->bindValue(':sId',   $_REQUEST['userId'] , PDO::PARAM_INT);  
                                $stmt->execute(); 
                                $UI__Bns = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                
                                 foreach($UI__Bns as $dddm)
                                 {
                                     $LevelI +=$dddm->Tamt;
                                 }
                                
                                                
                               $stmt=$conn->prepare("select *   from UI__Rgst where refId=:refId   ");   
                                $stmt->bindValue(':refId',  $_REQUEST['userId']  , PDO::PARAM_INT);  
                                $stmt->execute(); 
                                $Dbusiness = $stmt->fetchAll(PDO::FETCH_OBJ);  
                                
                                $directAmount = 0;
                                foreach($Dbusiness as $dmm)
                                {
                                        $stmt=$conn->prepare("select amt  from UI__DChstr  where Rid=:cuurentId  and typ=1 ");   
                                        $stmt->bindValue(':cuurentId',  $dmm->cuurentId , PDO::PARAM_INT);  
                                        $stmt->execute();  
                                        
                                        $amt = 0;
                                        if($stmt->rowCount()>0)
                                        { 
                                            $Result1 = $stmt->fetch(PDO::FETCH_OBJ); 
                                            $directAmount += $Result1->amt;  
                                        }      
                                }
                                
	
                                ////////////////////////   
                                
                                                    
                                function Refcall($ref)
                                {
                                    global $conn;
                                    $stmt=$conn->prepare("select cuurentId   from UI__Rgst where refId =:cuurentId ");   
                                    $stmt->bindValue(':cuurentId', $ref , PDO::PARAM_STR);  
                                    $stmt->execute(); 
                                    $Result = $stmt->fetchAll(PDO::FETCH_OBJ);   
                                    return $Result;
                                }
                                
                                  
                                $stmt=$conn->prepare("select cuurentId from UI__Rgst where custId =:custId ");   
                                $stmt->bindValue(':custId',  $_REQUEST['custid']  , PDO::PARAM_STR);  
                                $stmt->execute(); 
                                $Result = $stmt->fetch(PDO::FETCH_OBJ);     
                                $myRefId = $Result->cuurentId;
                                  
                                $stmt=$conn->prepare("select cuurentId   from UI__Rgst where refId =:cuurentId ");   
                                $stmt->bindValue(':cuurentId', $Result->cuurentId  , PDO::PARAM_INT);  
                                $stmt->execute(); 
                                
                     
                                
                                $myTT = 0;
                                if($stmt->rowCount()>0)
                                { 
                                    $Result = $stmt->fetchAll(PDO::FETCH_OBJ);     
                                     
                                    foreach($Result as $dtm) 
                                        $stepCt['step1']['id'][] = $dtm->cuurentId;
                                        
                                        
                                    $myTT +=count($stepCt['step1']['id']);       
                                    foreach($Result as $dtm) 
                                        $stepCt['step2']['id'][] =  Refcall($dtm->cuurentId); 
                                    
                                }
                                  
                                  
                                for($i=0;$i<count($stepCt['step2']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step2']['id'][$i])>0)
                                    {
                                           $myTT +=count($stepCt['step2']['id'][$i]);     
                                           
                                       foreach($stepCt['step2']['id'][$i] as $dtm)
                                         $stepCt['step3']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                    
                                } 
                                 
                                 
                                
                                for($i=0;$i<count($stepCt['step3']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step3']['id'][$i])>0)
                                    {
                                         $myTT +=count($stepCt['step3']['id'][$i]);     
                                         
                                       foreach($stepCt['step3']['id'][$i] as $dtm)
                                         $stepCt['step4']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                for($i=0;$i<count($stepCt['step4']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step4']['id'][$i])>0)
                                    {
                                        
                                       $myTT +=count($stepCt['step4']['id'][$i]);   
                                       
                                       foreach($stepCt['step4']['id'][$i] as $dtm)
                                         $stepCt['step5']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                for($i=0;$i<count($stepCt['step5']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step5']['id'][$i])>0)
                                    {
                                        
                                       $myTT +=count($stepCt['step5']['id'][$i]);   
                                       
                                       foreach($stepCt['step5']['id'][$i] as $dtm)
                                         $stepCt['step6']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                for($i=0;$i<count($stepCt['step6']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step6']['id'][$i])>0)
                                    {
                                        
                                       $myTT +=count($stepCt['step6']['id'][$i]);   
                                       
                                       foreach($stepCt['step6']['id'][$i] as $dtm)
                                         $stepCt['step7']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                for($i=0;$i<count($stepCt['step7']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step7']['id'][$i])>0)
                                    {
                                        
                                       $myTT +=count($stepCt['step7']['id'][$i]);   
                                       
                                       foreach($stepCt['step7']['id'][$i] as $dtm)
                                         $stepCt['step8']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                for($i=0;$i<count($stepCt['step8']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step8']['id'][$i])>0)
                                    {
                                        
                                       $myTT +=count($stepCt['step8']['id'][$i]);   
                                       
                                       foreach($stepCt['step8']['id'][$i] as $dtm)
                                         $stepCt['step9']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                
                                for($i=0;$i<count($stepCt['step9']['id']);$i++)
                                {
                                     
                                    if(count($stepCt['step9']['id'][$i])>0)
                                    {
                                        
                                       $myTT +=count($stepCt['step9']['id'][$i]);   
                                       
                                       foreach($stepCt['step9']['id'][$i] as $dtm)
                                         $stepCt['step10']['id'][] =  Refcall($dtm->cuurentId);  
                                    }
                                } 
                                
                                
                                
                                    $NBusinessAmt = 0;     
                                    foreach($stepCt['step1']['id'] as $dtm) 
                                    {      
                                        $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                        $stmt->bindValue(':Rid', $dtm , PDO::PARAM_STR);  
                                        $stmt->execute(); 
                                        $Resultx = $stmt->fetch(PDO::FETCH_OBJ); 
                                        $NBusinessAmt +=$Resultx->amt; 
                                    }
                                    
                                    foreach($stepCt['step2']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        {
                                              
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }
                                    
                                    foreach($stepCt['step3']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }
                                    
                                    foreach($stepCt['step4']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }
                                    
                                    foreach($stepCt['step5']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }  
                                    
                                    
                                     foreach($stepCt['step6']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }  
                                    
                                    
                                     foreach($stepCt['step7']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }  
                                    
                                    
                                     foreach($stepCt['step8']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }  
                                    
                                    
                                     foreach($stepCt['step9']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }  
                                    
                                    
                                     foreach($stepCt['step10']['id'] as $dtm) 
                                    {         
                                        foreach($dtm as $dtmx) 
                                        { 
                                            
                                            $stmt=$conn->prepare("select *  from UI__DChstr where Rid=:Rid and typ=1");   
                                            $stmt->bindValue(':Rid', $dtmx->cuurentId , PDO::PARAM_STR);  
                                            $stmt->execute(); 
                                            $Resultx = $stmt->fetch(PDO::FETCH_OBJ);  
                                            $NBusinessAmt +=$Resultx->amt; 
                                        } 
                                    }  
                                      
                                                              
                                    $stmt=$conn->prepare("select *  from UI__Fundtransfer    where userid =:sId  order by id desc  ");   
                                    $stmt->bindValue(':sId',  $_SESSION['userId'] , PDO::PARAM_INT);  
                                    $stmt->execute(); 
                                    $UI__Fundtransfer = $stmt->fetch(PDO::FETCH_OBJ); 
            
            
           
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> DASHBOARD </h3></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='userDashboard.php';" />
								  
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm" autocomplete="off"> 
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Trading Income</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo $Tamnt; ?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
								 
							 	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Level Income</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo $LevelI; ?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">My Direct Bussiness</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo $directAmount; ?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">My Level Bussiness</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo $NBusinessAmt; ?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">M Wallet</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo ($totalTrade+$totalBinary+$totalBooster+$totalDirect)-($totalWithdrwa);?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">F Wallet</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php if($UI__Fundtransfer->availableFund=='') echo 0; else echo $UI__Fundtransfer->availableFund;?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Total Income</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo ($Tamnt + $LevelI);?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								 
							 	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">My Business</label>
								    <div class="col-sm-3">    
								        <input type="text" value="<?php echo $NBusinessAmt; ?>" class="form-control"  disabled/>
								    </div>
								 </div>
								 <hr>
								   
								   
								</form>
								
								
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


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

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