<?php 
	include_once("../view/header-footer/InnerHeader.php");   
	include_once("leftMenu.php");   
?>  
<script> 
$(document).ready(function()
{   
 
              
        jQuery.validator.addMethod("lettersonly", function(value, element) 
        {
            return this.optional(element) || /^[a-z0-9\_\s]+$/i.test(value); 
        }, "Use alphanumaric & _ only"); 
        
        $( "#cuurentId" ).change(function() 
        {
            
              $.ajax({	
                    type: "POST",
                    url: URL+"/ajax/validation.php",
                    data: {TopUpDatacheck:1,Data:$(this).val()},
                    beforeSend: function(){ 
                    },
                    success: function(data)
                        {   
                            if(data==1)
                                 $("#AvailbleId").html("<span style='color:green;'>Valid Id  &#x2713</span>");
                            else  if(data==3) {
                                $("#cuurentId").val('');
                                 $("#AvailbleId").html("<span style='color:red;'>Invalid</span>"); 
                            }
                            else  if(data==2) {
                                $("#cuurentId").val('');
                                 $("#AvailbleId").html("<span style='color:red;'>Not Available X</span>");      
                            }
                        }
                    });
               
             
        });
        
        
         $( "#TopPin" ).change(function() 
        {
               
              $.ajax({	
                    type: "POST",
                    url: URL+"/ajax/validation.php",
                    data: {CheckDataPin:1,Data:$(this).val()},
                    beforeSend: function(){ 
                    },
                    success: function(data)
                        {    
                            var Data = JSON.parse(data);  
                            if(Data['Status']==1) 
                            {
                                 $("#MPINDetails").html("<span style='color:green;'>Valid PIN  Of Rs "+Data['Data']+" &#x2713 </span>");
                                 
                                 var newStr = Data['Data'].replace(',','')
                                 $("#TpMt").val(parseInt(newStr));  
                            }
                            else    {
                                 $("#MPINDetails").html("<span style='color:red;'>Invalid PIN</span>");      
                                 $("#TopPin").val('');
                            }
                        }
                    });
               
             
        });
        
      
        
 

	$("#_frm").validate({
		
		errorElement:'div',
		rules:{ 
		 
			TopPin:{
				required:true   	
			} ,
			cuurentId:{
				required:true,
				lettersonly:true
			} 
		},
		messages:{ 
		    
			TopPin:{
				required:"Enter PIN" 
			},
			cuurentId:{
				required:"Ener Top Up User ID " 
			} 
			 
		}
	}); 
}); 

</script>    



<div class="page-wrapper">
<div class="page-content"><link rel="stylesheet" href="./tree_files/bootstrap.min(1).css">
<script src="./tree_files/jquery.min.js.download"></script>
<script src="./tree_files/bootstrap.min.js(1).download"></script>

<style>
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;

  /* Position the tooltip */
  position: absolute;
  z-index: 1;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}
</style>
<style>
table.user_table_info_record.tree_detail th, td {
   
    font-size: 12px; 
}
   
    @media only screen and (max-width: 768px) {
  .pages{
   padding-left:15px !important;
  }
}


            @media only screen and (max-width: 600px) {
                .flex > .flex-item{
                         width : var(--item-width);
                         font-size:8px;
                     } 
                     .flex-item > span > .user {
                            width:25px;        
                        }
            }
            @media only screen and (min-width: 601px) {
                .flex >  .flex-item{
                         width : var(--item-width);
                         font-size:16px;
                     } 
                .flex-item > span > .user {
                    width:50px;        
                }  
            }

            .flex{
                    display: flex;
                    flex-wrap: nowrap;                
                                 
                }
               .table-bordered td, .table-bordered th {
    border: 1px solid #737785;
} 
              
              .table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #737785;
}

 select.form-control:not([size]):not([multiple]) {
    height: calc(3.25rem + 2px);
}

.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th {
    border: 1px solid #1a1919;
}
.footer_text_field {
   
    position: absolute !important;
    bottom: -276px !important;
    left: 30% !important;
}
table.user_table_info_record.tree_detail th, td {
    border: 1px solid #bdbdc1;
}
       </style>
<div class="container pages">
<div class="row pt-2 pb-2">
<div class="col-sm-12">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?php echo ROOTPATH;?>/dashboard">Home /</a></li>
<li class="breadcrumb-item"><a href="#">Team /</a></li>
<li class="breadcrumb-item active" aria-current="page"> Tree</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="color :black;">
<div class="row ">

 
 
</div><br>
<center>
<div class="card-body">
<div class="form-inline1 col-xl-8">

<nav class="navbar navbar-expand-lg navbar-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon "></span>
</button>   

</nav>
</div>
<center> 
				<?php
				
					$data = tree_data($search);  
					$query = mysqli_query($con,"select * from tree  where userid='$search'");
					$result = mysqli_fetch_array($query);   

 					$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$search'");
 					$queryNmR = mysqli_fetch_array($queryNm);    
 					
					$stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$search' and typ=1"); 
					$stmt->execute();   
					if($stmt->rowCount() > 0) 
					{ 
					    $searchCt = 1;
					    $FResult = $stmt->fetch(PDO::FETCH_OBJ);  
					    $Pck = $FResult->amt;
					}
					else     {
					$searchCt = 0;      
					$Pck = "NA";
					}
					
					 
					
					$string  = "Member Id: ".$search.", Member Name: ".$queryNmR['nm'].", Package: ".$Pck.", Joining Date: ".$queryNmR['RegOn'].", Sponser Id :".$queryNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business']; 
				?>

	<div class="flex text-muted">
		<div class="flex-item" style="--item-width:100% ">
		
		
				<span>
				<?php 
				if($searchCt==0)  {
				?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $string;?>" >
				<?php }else { ?>	
				<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $string;?>" >
				<?php } ?>
				</span>
			<br>
			<?php echo $search; ?> <br>
			<span>
			<?php 
			        echo substr($queryNmR['nm'],0,10);
			?>		
			 </span>
		</div>
	</div>

<div class="flex">
<div class="flex-item" style="--item-width:100%">
<img style="width:50%;min-width:50px;" src="<?php echo ROOTPATH;?>/view/images/arrow.png">
<div class="flex " style="color:#333;">
<div class="flex-item" style="--item-width:50%">

<?php
							
							$first_left_user = $data['left'];
							$first_right_user = $data['right']; 
								
                            $stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$first_left_user' and typ=1"); 
                            $stmt->execute();   
                            if($stmt->rowCount() > 0) 
                            {
								 $FResult = $stmt->fetch(PDO::FETCH_OBJ);  
								 $Pck = $FResult->amt;  
                                 $first_left_userCt = 1;
							}
                            else 
							{
                                $Pck = 0;
								$first_left_userCt = 0;    
							}
							
							$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$first_left_user'");
							$flectNmR = mysqli_fetch_array($queryNm); 
                                  
                            	
                            $stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$first_right_user' and typ=1"); 
                            $stmt->execute();   
                            if($stmt->rowCount() > 0) 
							{
                                $FResult = $stmt->fetch(PDO::FETCH_OBJ);  
								$PckR = $FResult->amt;  
								$first_right_userCt = 1; 
								
							}
                            else     {
                                $first_right_userCt = 0;    
								$PckR = 0;
							}
							
							
							$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$first_right_user'");
							$frictNmR = mysqli_fetch_array($queryNm);   
                            					 
                            $query = mysqli_query($con,"select * from tree  where userid='$first_left_user'");
                            $result = mysqli_fetch_array($query); 
                              
							$first_leftstring   = "Member Id: ".$first_left_user.", Member Name: ".$flectNmR['nm'].", Package: ".$Pck.", Joining Date: ".$flectNmR['RegOn'].", Sponser Id :".$flectNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business']; 
            
                            $query = mysqli_query($con,"select * from tree  where userid='$first_right_user'");
                            $result = mysqli_fetch_array($query);
                            
                                        
                            $first_rightstring  = "Member Id: ".$first_right_user.", Member Name: ".$frictNmR['nm'].", Package: ".$PckR.", Joining Date: ".$frictNmR['RegOn'].", Sponser Id :".$frictNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business'];  
							 
						 
							$data_first_left_user = tree_data($first_left_user);
							$second_left_user = $data_first_left_user['left'];
							$second_right_user = $data_first_left_user['right'];
						
						    $query = mysqli_query($con,"select * from tree  where userid='$second_left_user'");
                            $result = mysqli_fetch_array($query);  
							
							$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$second_left_user'");
							$slefctNmR = mysqli_fetch_array($queryNm);   
                                        
                           
                          
                            $query = mysqli_query($con,"select * from tree  where userid='$second_right_user'");
                            $result = mysqli_fetch_array($query); 
							
							$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$second_right_user'");
							$srifctNmR = mysqli_fetch_array($queryNm); 
                                        
                            
							
                            	
                            $stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$second_left_user' and typ=1"); 
                            $stmt->execute();   
                            if($stmt->rowCount() > 0) 
							{
                                $second_left_userCt = 1;
								$FResult = $stmt->fetch(PDO::FETCH_OBJ);  
								$PckR = $FResult->amt; 
							}
                            else     {
                                $second_left_userCt = 0;    
								$PckR= 0;
							}
                                
								
							 $second_leftstring  = "Member Id: ".$second_left_user.", Member Name: ".$slefctNmR['nm'].", Package: ".$PckR.", Joining Date: ".$slefctNmR['RegOn'].", Sponser Id :".$slefctNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business'];  
								
                           
                            $stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$second_right_user' and typ=1"); 
                            $stmt->execute();   
                            if($stmt->rowCount() > 0) 
							{
                                $second_right_userCt = 1;
								$FResult = $stmt->fetch(PDO::FETCH_OBJ);  
								$pk = $FResult->amt;
							}
                            else 
							{
                                $second_right_userCt = 0;    
								$pk = 0;
							}
                              
							  
							 $second_rightstring   = "Member Id: ".$second_right_user.", Member Name: ".$srifctNmR['nm'].", Package: ".$pk.", Joining Date: ".$srifctNmR['RegOn'].", Sponser Id :".$srifctNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business'];  
								
                          	
							
							$data_first_right_user = tree_data($first_right_user);
							$third_left_user = $data_first_right_user['left'];
							$thidr_right_user = $data_first_right_user['right'];
							
							
							
							
							
                            $stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$third_left_user' and typ=1"); 
                            $stmt->execute();   
                            if($stmt->rowCount() > 0) 
							{
                                $third_left_userCt = 1;
								$FResult = $stmt->fetch(PDO::FETCH_OBJ);  
								$pk = $FResult->amt;
							}
                            else     
							{
                                $third_left_userCt = 0;   
								$pk = 0;
							}
                        
                            	
                            $stmt=$conn->prepare("select id,amt from UI__DChstr  where Rid='$thidr_right_user' and typ=1"); 
                            $stmt->execute();   
                            if($stmt->rowCount() > 0) 
							{
                                $thidr_right_userCt = 1;
								$FResult = $stmt->fetch(PDO::FETCH_OBJ);  
								$pk1 = $FResult->amt;
								
							}
                            else {
                                $thidr_right_userCt = 0;    
								$pk1 = 0;
							}
                              
                            
                            $query = mysqli_query($con,"select * from tree  where userid='$third_left_user'");
                            $result = mysqli_fetch_array($query);
							
							$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$third_left_user'");
							$tleftfctNmR = mysqli_fetch_array($queryNm); 
                            
                                        
                            $third_leftstring   = "Member Id: ".$third_left_user.", Member Name: ".$tleftfctNmR['nm'].", Package: ".$pk.", Joining Date: ".$tleftfctNmR['RegOn'].", Sponser Id :".$tleftfctNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business'];  
								
                            
                            $query = mysqli_query($con,"select * from tree  where userid='$thidr_right_user'");
                            $result = mysqli_fetch_array($query); 
                                
							$queryNm = mysqli_query($con,"select nm,RegOn,refId from user   where cuurentId='$thidr_right_user'");
							$triftfctNmR = mysqli_fetch_array($queryNm);   
							
								
                            $thidr_right_userstring  =  "Member Id: ".$thidr_right_user.", Member Name: ".$triftfctNmR['nm'].", Package: ".$pk1.", Joining Date: ".$triftfctNmR['RegOn'].", Sponser Id :".$triftfctNmR['refId'].", Left Business ".$result['BusinessLeft'].", Right Business ".$result['BusinessRight'].", Total Business ".$result['Business'];  
								
                             
							
						
                                  
		?> 				
	<span> 
		<?php 
			if($first_left_userCt==1) 
			{
		?>
			<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $first_leftstring;?>">  
		<?php } else if($first_leftstring=='') { ?>
			<img class="user" src="<?php echo ROOTPATH;?>/view/images/tblack.png" title="<?php echo $first_leftstring;?>"> 
		<?php } else { ?> 
			<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $first_leftstring;?>"> 
		<?php } ?> 
		<p> 
			<a href="tree.php?search-id=<?php echo $first_left_user; ?>"> 
				<?php if($first_left_user!='') echo $first_left_user;  else echo "Not Available";?></a>
			<br>
		<?php 
			echo substr($flectNmR['nm'],0,10);
		?> 
		</p> 
	<div class="flex">
		<div class="flex-item" style="--item-width:100%">
			<img style="width:50%;min-width:50px;" src="<?php echo ROOTPATH;?>/view/images/arrow.png">
			 
			<div class="flex " style="color:#333;">
				<div class="flex-item" style="--item-width:50%">
					<span>  
					<?php 
					if($second_left_userCt==1) 
					{
				?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $second_leftstring;?>">  
				<?php } else if($second_left_user=='') { ?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tblack.png" title="<?php echo $second_leftstring;?>"> 
				<?php } else { ?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $first_leftstring;?>">  
				<?php }  ?>
					</span>
					<br>
					<span style="color:#333;&#39;"><a href="tree.php?search-id=<?php echo $second_left_user; ?>"><?php if($second_left_user!='') echo $second_left_user; else echo "Not Available";?></a><br>
					<?php 
						echo substr($slefctNmR['nm'],0,10);
					?>	
					</span><br>   
				</div>
				<div class="flex-item" style="--item-width:50%">
					<span>  
					<?php 
					if($second_right_userCt==1) 
					{
				?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $second_rightstring;?>"> 
				<?php } else if($second_right_user=='') { ?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tblack.png" title="<?php echo $second_rightstring;?>">  
				<?php }else { ?>
				<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $second_rightstring;?>">  
				<?php }  ?>
				
					</span>
					<br>
					<span style="color:#333;&#39;"><a href="tree.php?search-id=<?php echo $second_right_user;?>">  <?php if($second_right_user!='')echo $second_right_user; else echo "Not Available";?></a><br>
					<?php 
						echo substr($srifctNmR['nm'],0,10);
					?>	
					</span><br> 
				</div>
			</div> 
		</div>
	</div>
</div>

<div class="flex-item" style="--item-width:50%"> 
	<span>  
			<?php 
			if($first_right_userCt==1) 
			{
			?>
				<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $first_rightstring;?>">  
			<?php } else if($first_right_user=='') { ?>
				<img class="user" src="<?php echo ROOTPATH;?>/view/images/tblack.png" title="<?php echo $first_rightstring;?>">  
			<?php } else { ?>
				<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $first_rightstring;?>"> 
			<?php }  ?> 
	</span>
	<br>
	<span style="color:#333;&#39;"> <a href="tree.php?search-id=<?php echo $first_right_user; ?>"><?php if($first_right_user!='') echo $first_right_user; else echo "Not Available"; ?></a></span><br> 
	
	<?php 
		echo substr($frictNmR['nm'],0,10);
	?>	
	<div class="flex">
		<div class="flex-item" style="--item-width:100%">
			<img style="width:50%;min-width:50px;" src="<?php echo ROOTPATH;?>/view/images/arrow.png">
			<div class="flex " style="color:#333;">
				<div class="flex-item" style="--item-width:50%">
					<span>  
					<?php 
					if($third_left_userCt==1) 
					{
					?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $third_leftstring;?>">  
					<?php } else if($third_left_user=='') { ?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tblack.png" title="<?php echo $third_leftstring;?>"> 
					<?php }else { ?>		
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $third_leftstring;?>">  
					<?php }  ?>		 
					</span>
					<br>
					<span style="color:#333;&#39;"><a href="tree.php?search-id=<?php echo $third_left_user; ?>"> <?php if($third_left_user!='') echo $third_left_user; else echo "Not Available";?></a><Br>
					<?php 
						echo substr($tleftfctNmR['nm'],0,10);
					?>	
					</span><br> 
				 
				</div>
				<div class="flex-item" style="--item-width:50%">
					<span> 
					<?php 
					if($thidr_right_userCt==1) 
					{
					?>
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tgreen.png" title="<?php echo $thidr_right_userstring;?>">  
					<?php } else if($thidr_right_user=='') { ?>
						<img class="user" src="<?php echo ROOTPATH;?>/view/images/tblack.png" title="<?php echo $thidr_right_userstring;?>">  
					<?php } else {?> 
					<img class="user" src="<?php echo ROOTPATH;?>/view/images/tred.png" title="<?php echo $thidr_right_userstring;?>">  
					<?php }  ?> 
					</span>
					<br>
					<span style="color:#333;&#39;">
					    <a href="tree.php?search-id=<?php echo $thidr_right_user; ?>"> 
					            <?php 
					                if($thidr_right_user!='')  {
					                    echo $thidr_right_user; }
				                    else 
				                     echo "Not Available";
				                ?>
			            </a>
					<br>
					<?php 
						echo substr($triftfctNmR['nm'],0,10);
					?>	
					</span><br> <div class="flex"> 
					</div>
				</div>
			</div> 
		</div>
	</div>
</div>

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

</center>
</div></center>
<br>
</div>
</div>
</div>
</div>
<p>&nbsp;</p>
</div> 
<?php  
	include_once("../view/header-footer/footer.php");    
?>