<?php   
	include_once("../view/header-footer/header.php");  
?>  
  
  
  
   <!-- Features -->
   <div class="innerDeader">
      <div class="container">
       <a href="javascript:void(0);" id="go-back" class="goBack PaySound">
           <img src="<?php echo ROOTPATH;?>/images/Arrow 1.svg" alt="back">
       </a>  
          <h4>MY DIRECT REFERAL</h4>
     </div>    
   </div>
   <div class="innerBody">
       <div class="container">
         <di class="tableBox">
            <table>
                
                <tr>
                    <th   style="width:auto">S No.</th> 
                    <th   style="width:auto">Name</th>   
                    <th   style="width:auto">Id</th>   
                    <th   style="width:auto">Sponsor Id</th>   
                    <th   style="width:auto">Amount</th> 
                    <th   style="width:auto">On Date</th>    
                    <th   style="width:auto">Status</th>   
                </tr>  
                
                    <?php 
                                $sr = 1;
                                foreach($Result as $dmm) 
                                { 
                                        $stmt=$conn->prepare("select id,amt,Tdate  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->fetchAll(PDO::FETCH_OBJ);   
                                        foreach($Result1 as $dbbt) 
                                        {
                                        $amt = $dbbt->amt;    
                    ?>   
                    <tr>
                        <td><?php echo $sr++;?></td>
                        <td><?php echo $dmm->nm;?> </td>
                        <td><?php echo $dmm->cuurentId;?></td>  
                        <td><?php echo $_SESSION['userId'];?></td>  
                        <td>&#8377;<?php echo $amt;?></td>    
                        <td><?php echo $dbbt->Tdate;?></td>   
                        
                        <td><?php if($amt>0) echo "Active"; else echo "Inactive";?></td>     
                    </tr>
                    <?php                
                                } 
                              }
                    		}     
                    	?>
                    	
                    	  <?php 
		$sr = 1;
		foreach($Result as $dmm) 
		{ 
                $stmt=$conn->prepare("select id,amt,Tdate  from UI__DChstr  where Rid=:cuurentId  and typ=1 ");   
                $stmt->bindValue(':cuurentId',  $dmm->cuurentId , PDO::PARAM_INT);  
                $stmt->execute(); 
                $amt = 0;
                $Result1 = $stmt->fetch(PDO::FETCH_OBJ);  
                
                if($stmt->rowCount() < 1)
                {  
	?> 
	<tr>
		<td><?php echo $sr++;?></td>
		<td><?php echo $dmm->nm;?> </td>
		<td><?php echo $dmm->cuurentId;?></td>  
		<td><?php echo $amt;?></td>    
		<td><?php echo $dmm->phm;?></td>   
		<td><?php echo $Result1->Tdate;?></td>   
		<td><?php if($amt>0) echo "Active"; else echo "Inactive";?></td>     
	</tr>
	<?php                 
          }
		}     
	?> 
                 
              </table>
         </div>
       </div>
   </div> 
</div> 
<?php 
  include_once("../view/header-footer/footer.php");  
    unset($_SESSION['TpMsg']);