<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>

<style>
li ul { display: none; }

ul li a {
  display: block;
  padding: 1em;
  text-decoration: none;
  white-space: nowrap;
  color: #00000;
}
ul li a:hover { background: #2c3e50; }

/* Display the dropdown */

li:hover > ul {
  display: block; 
}

li:hover li { float: right; }
/* li:hover a { background: #1bc2a2; } */

.main-navigation li ul li { border-top: 0; }

/* Displays second level dropdowns to the right of the first level dropdown */

ul ul ul {
  left: 100%;
  top: 0;
}
ul:before,
ul:after {
  content: " "; /* 1 */
  display: table; /* 2 */
}
ul:after { clear: both; }
.center 
{ 
    text-align-last: center; 
    border: 2px solid black; 
} 
</style>


<link rel="stylesheet" type="text/css" href="../Assets/css/tree_view.css" media="screen">
<body class="skin-default fixed-layout">

<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>
        
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">
<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->
<!-- Start Page Content -->
<!-- ============================================================== -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4>My Downline</h5>
<div class="scrollbar scrollbar1" id="style-2">
<div class="activity-row">
						
<div class="row p-t-20">
    <div class="col-md-2">                      
    </div>
    <div class="col-md-8">         
        <ul class="main-navigation">
        <?php echo get_menu_tree($ref_code);//start from root menus having parent id 0 ?>
        </ul> 
        <?php mysqli_close($con); ?>
    </div>
    <div class="col-md-2">
    </div>  
</div> 

<?php                    
function get_menu_tree($parent_id) 
{
	global $con;
	$menu = "";
	$sqlquery = " SELECT * FROM user 
    where sponsor_code='$parent_id'
    And status='1'";
	$res=mysqli_query($con,$sqlquery);
    while($row=mysqli_fetch_array($res,MYSQLI_ASSOC)) 
	{
        $name = $row['name'];
        $ref_code = $row['ref_code'];
        $type_of_user = $row['type_of_user'];
        
        $menu .="<li style='display: block;float: right;' class='center'><a href='#'>".$name." | ".$type_of_user."</a>";		   
		$menu .= "<ul style='list-style: none; padding: 0;margin: 0;background: #1bc2a2;'>".get_menu_tree($ref_code)."</ul>"; 		   
 		$menu .= "</li>";
    }  
    return $menu;
} 
?>
									 
</div>
</div>
</div>
</div>                      
</div>
</div>
<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->

      

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

</body>

</html>