<?php 
ob_start();
session_start();
include("config/config.php");	
include("config/function.php"); 
	 $member_user_id=$_SESSION['member_user_id'];
	 $pruserid=$_SESSION['member_id'];
	 $userid=$_REQUEST['QWDRFTGYYHHH'];
	if(!$_REQUEST['QWDRFTGYYHHH'])
	{
	 $pruserid=$userid;
	}
	else
	{
		$pruserid=$_REQUEST['QWDRFTGYYHHH'];
	}

	 $sqlu="select * from tbl_memberreg where member_id='$userid'";
	$result=mysqli_query($connection,$sqlu);
	$left_pv=0;$right_pv=0;$direct_member=0;$left_member=0;$right_member=0;
   while($row = mysqli_fetch_array($result))
   {
    	$login_member=$row['member_name'];
		$member_user_name=$row['member_user_id'];
     	$member_id=$row['member_id'];
		 $is_customer=$row['is_customer'];
		 if($is_customer==1)
		 {
		     $status=2;
		 }
		 else
		 {
		     $status=$row['status'];
		 }
      	$lmember_name=$row['member_name'];
    	$promoter_id=$row['promoter_id'];
        $left_member=$row['left_member'];
        $right_member=$row['right_member'];
		$left_business=$row['left_business'];
		$right_business=$row['right_business'];
		$direct_business=$row['direct_business'];
			$paid_business=$row['paid_business'];
		
     }
	if($member_id<$pruserid)
	{
	header("Location:MyTree.php?QWDRFTGYYHHH=$userid");
	}
	
?>

<html lang="en">

<head>
    <title>My Tree : <?php echo get_company(); ?> </title>
   
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="Phoenixcoded">
    <!-- Favicon icon -->
    <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">

    <!-- vendor css -->
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" type="text/css" href="assets/css/binary.css">

</head>
<style>
    .crm-card:after {
    content: "";
    position: absolute;
    z-index: -1;
    height: 100%;
    width: 100%;
    inset-inline-end: -1.85rem;
   
    background-image: url(assets/images/cardbackground.png);
    background-repeat: no-repeat;
    opacity: 0.4;
    transform: scaleX(-1);
}
.crm-card {
  position: relative;
  overflow: hidden;
  z-index: 0;
  background:white;
  /*box-shadow:0px 3px 15px #ccc;*/
  margin-bottom:10px;

}
</style>
<body class="">
	<!-- [ Pre-loader ] start -->
	<div class="loader-bg">
		<div class="loader-track">
			<div class="loader-fill"></div>
		</div>
	</div>
	<!-- [ Pre-loader ] End -->
	<!-- [ Header ]  -->
<?php include 'inc/vertical.php'; ?>

<!-- [ Main Content ] start -->
<div class="pcoded-main-container">
    <div class="pcoded-content">
        <!-- [ breadcrumb ] start -->
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                            <h5 class="m-b-10">My Tree</h5>
                            <h6><?php echo $member_user_id=$_SESSION['member_user_id']; ?> (<?php echo $_SESSION['member_name'] ?>)</h6>
                        </div>
                       
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
             <div class="col-md-12 col-xl-4">
          <div class="card custom-card crm-card card_border">
        <div class="card-body">
          <div class="d-flex flex-column mt-1">
                    <!--<img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="40" >-->
               <h5>LEFT BUSINESS</h5>
              <h5 class="mb-0 d-flex align-items-center"><i class="fas fa-rupee-sign" style="color: #000;font-size: 15px;margin-top: 2px;}"></i> <span style="margin-left:6px"><?php echo $left_business; ?> </span>
                </h5>
            </div>
        </div>
    </div>
            </div>
             <div class="col-md-12 col-xl-4">
          <div class="card custom-card crm-card card_border">
        <div class="card-body">
          <div class="d-flex flex-column mt-1">
                    <!--<img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="40" >-->
               <h5>RIGHT BUSINESS</h5>
              <h5 class="mb-0 d-flex align-items-center"><i class="fas fa-rupee-sign" style="color: #000;font-size: 15px;margin-top: 2px;}"></i> <span style="margin-left:6px"><?php echo $right_business; ?> </span>
                </h5>
            </div>
        </div>
    </div>
            </div>
             <div class="col-md-12 col-xl-4">
          <div class="card custom-card crm-card card_border">
        <div class="card-body">
          <div class="d-flex flex-column mt-1">
                    <!--<img src="assets/images/withdrawal.png" class="img-fluid img-4x " alt="" width="40" >-->
               <h5>PAID BUSINESS</h5>
              <h5 class="mb-0 d-flex align-items-center"><i class="fas fa-rupee-sign" style="color: #000;font-size: 15px;margin-top: 2px;}"></i> <span style="margin-left:6px"><?php echo $paid_business; ?> </span>
                </h5>
            </div>
        </div>
    </div>
            </div>
         
      
        </div>
         <div class="row">
            <div class="col-xl-12 col-md-12">
              <div class="card" style="overflow:scroll;">
                <div class="card-header">
                 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="text-align:center;" class="center">
				 <tr align="center">
				  <td colspan="4">
				   <div class="col-lg-4 col-md-6 col-sm-6"></div>
				   <div class="col-lg-4 col-md-6 col-sm-6">
				       <center>
				       <a href="#">
							<img src="images/<?php echo $status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
						<span style="color:#FFFFFF"><i class="icon-user-follow font-large-1"></i></span>
						</a>
						<span class="wrap_content"><a href="#"><p><?php echo $lmember_name; ?></br><?php echo $member_user_name; ?></a></p></span>
				    </center>
				   </div>
				   <div class="col-lg-4 col-md-6 col-sm-6"></div>
				    </td>
                 </tr>
                  <tr >
				 <td colspan="4"  width="100%">
				 <div > 
				 <img src="images/line.png" style="height:auto; width:50%; float:none; margin:auto;padding:10px" /> 
				 </div>
				 </td>
				 </tr>
				 
				  <!-- For Second Level Id -->
				 
				 <div class="tree_row">
				  <div class="row">
				<tr align="center">
				  <td colspan="2" width="50%"> 
				  <div class="col-lg-12" style="text-align:center;">
				    <?php
						 $lsql="select * from tbl_memberreg where promoter_id='$member_user_name' and position='LEFT'";
						$lresult=mysqli_query($connection,$lsql);
						if(mysqli_num_rows($lresult)==1) {
						 $row = mysqli_fetch_array($lresult);
						 $left_id=$row['member_user_id'];
						 $left_member_id=$row['member_id'];
						 $member_name=$row['member_name'];
						 $is_customer=$row['is_customer'];
						 if($is_customer==1)
						 {
						     $left_status=2;
						 }
						 else
						 {
						     $left_status=$row['status'];
						 }
						 $sponcer_id=$row['sponcer_id'];
						 $sponcer_name=$row['sponcer_name'];
						 $eft_business=$row['left_business'];
						 $right_business=$row['right_business'];
						$direct_business=$row['direct_business'];
						?>  
						<center>
				        <a href="MyTree.php?QWDRFTGYYHHH=<?php echo $left_member_id; ?>&pg=mt" data-toggle="tooltip" data-html="true" data-placement="top" title="Left Business : <?php echo $left_business; ?></br> Right Business : <?php echo $right_business; ?>">
						<img src="images/<?php echo $left_status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
					    </a>
					    <span class="wrap_content"><a href="MyTree.php?QWDRFTGYYHHH=<?php echo $left_member_id; ?>&pg=mt"><p><?php echo $left_id; ?></br><?php echo $member_name; ?></p></a></span>
					    	<?php } else {?>
						<img src="images/blank.png" height="60" width:"60">
					
						<span class="wrap_content"><a href="#" target="_blank"><h6>Join</h6></a></span>

						<?php } ?>
					    
					    </center>
				  </div>
				  </td>
				  <td colspan="2" width="50%"> 
				  <div class="col-lg-12" style="text-align:center;">
				    <?php
						 $lsql="select * from tbl_memberreg where promoter_id='$member_user_name' and position='RIGHT'";

						$lresult=mysqli_query($connection,$lsql);
						if(mysqli_num_rows($lresult)==1) {
						 $row = mysqli_fetch_array($lresult);
						 $right_id=$row['member_user_id'];
						 $right_member_id=$row['member_id'];
						 $member_name=$row['member_name'];
						 $is_customer=$row['is_customer'];
						 if($is_customer==1)
						 {
						     $status=2;
						 }
						 else
						 {
						     $status=$row['status'];
						 }
					
						 $sponcer_id=$row['sponcer_id'];
						 $sponcer_name=$row['sponcer_name'];
						 $eft_business=$row['left_business'];
						 $right_business=$row['right_business'];
						$direct_business=$row['direct_business'];
						?>  
						<center>
				      <a href="MyTree.php?QWDRFTGYYHHH=<?php echo $right_member_id; ?>&pg=mt" data-toggle="tooltip" data-placement="top" data-html="true" title="Left Business : <?php echo $left_business; ?> Right Business : <?php echo $right_business; ?>">
						<img src="images/<?php echo $status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
					    </a>
					    <span class="wrap_content"><a href="MyTree.php?QWDRFTGYYHHH=<?php echo $right_member_id; ?>&pg=mt"><p><?php echo $right_id; ?></br><?php echo $member_name; ?></p></a></span>
					    	<?php } else {?>
						<img src="images/blank.png" height="60" width:"60">
					
						<span class="wrap_content"><a href="#" target="_blank"><p>Join</p></a></span>

						<?php } ?>
					    
					    </center>
				  </div>
				  </td>
				  </tr>
				   <tr >
				 <td colspan="2"  width="50%">
				 <div > 
				 <img src="images/line.png" style="height:auto; width:50%; float:none; margin:auto;padding:10px" /> 
				 </div>
				 </td>
				  <td colspan="2"  width="50%">
				 <div > 
				 <img src="images/line.png" style="height:auto; width:50%; float:none; margin:auto;padding:10px" /> 
				 </div>
				 </td>
				 </tr>
				  
				  
				 <div class="tree_row" >
				  <div class="row">
				  
				  <tr align="center">
				  <td  width="25%">
				    <div class="col-lg-12" style="text-align:center;">  
				    <?php if($left_id=="00"){ ?>
						<img src="images/blank.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
						<span class="wrap_content"><a href="#"><a href="#"><p><?php echo "Open"; ?></p></a></a></span>
						<?php } else { 
						 $llsql="select * from tbl_memberreg where promoter_id='$left_id' and position='LEFT'";
						$llresult=mysqli_query($connection,$llsql);
						if(mysqli_num_rows($llresult)==1) 
						{
						 $row = mysqli_fetch_array($llresult);
						 $left3left1=$row['member_user_id'];
						 $member_name=$row['member_name'];
						 $is_customer=$row['is_customer'];
						 if($is_customer==1)
						 {
						     $status=2;
						 }
						 else
						 {
						     $status=$row['status'];
						 }
						 $sponcer_id=$row['sponcer_id'];
						 $sponcer_name=$row['sponcer_name'];
						 $left_member=$row['left_member'];
						 $right_member=$row['right_member'];
						 $eft_business=$row['left_business'];
						 $right_business=$row['right_business'];
						
						?>
				    	<a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt" data-toggle="tooltip" data-placement="top" data-html="true" title="Left Business : <?php echo $left_business; ?>  Right Business : <?php echo $right_business; ?>">
						<img src="images/<?php echo $status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
					    </a>
					
						<span class="wrap_content"><a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt"><p><?php echo $member_name; ?></br><?php echo $left3left1; ?></p></a></span>
						<?php } else { ?>
						<img src="images/blank.png" height="60" width:"60">
						<span class="wrap_content"><a href="#" target="_blank"><p><?php echo "Join"; ?></p></a></span>
						<?php } }?>
				    </div>
				  </td>
				  <td  width="25%">
				      <div class="col-lg-12" style="text-align:center;">
				          <?php if($left_id=="00"){ ?>
						<img src="images/blank.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
						<span class="wrap_content"><a href="#"><a href="#"><p><?php echo "Open"; ?></p></a></a></span>
						<?php } else { 
						 $llsql="select * from tbl_memberreg where promoter_id='$left_id' and position='RIGHT'";
						$llresult=mysqli_query($connection,$llsql);
						if(mysqli_num_rows($llresult)==1) 
						{
						 $row = mysqli_fetch_array($llresult);
						 $left3left1=$row['member_user_id'];
						 $member_name=$row['member_name'];
						 $is_customer=$row['is_customer'];
						 if($is_customer==1)
						 {
						     $status=2;
						 }
						 else
						 {
						     $status=$row['status'];
						 }
						 $sponcer_id=$row['sponcer_id'];
						 $sponcer_name=$row['sponcer_name'];
						 $left_member=$row['left_member'];
						 $right_member=$row['right_member'];
						 $eft_business=$row['left_business'];
						 $right_business=$row['right_business'];
						
						?>
				    	<a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt" data-toggle="tooltip" data-placement="top" data-html="true" title="Left Business : <?php echo $left_business; ?>  Right Business : <?php echo $right_business; ?>">
						<img src="images/<?php echo $status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
					    </a>
						
						<span class="wrap_content"><a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt"><p><?php echo $member_name; ?></br><?php echo $left3left1; ?></p></a></span>
						<?php } else { ?>
						<img src="images/blank.png" height="60" width:"60">
						<span class="wrap_content"><a href="#" target="_blank"><p><?php echo "Join"; ?></p></a></span>
						<?php } }?>
				      </div>
				  </td>
				  <td  width="25%">
				      <div class="col-lg-12" style="text-align:center;">
				           <?php if($left_id=="00"){ ?>
						<img src="images/blank.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
						<span class="wrap_content"><a href="#"><a href="#"><p><?php echo "Open"; ?></p></a></a></span>
						<?php } else { 
						 $llsql="select * from tbl_memberreg where promoter_id='$right_id' and position='LEFT'";
						$llresult=mysqli_query($connection,$llsql);
						if(mysqli_num_rows($llresult)==1) 
						{
						 $row = mysqli_fetch_array($llresult);
						 $left3left1=$row['member_user_id'];
						 $member_name=$row['member_name'];
						  $is_customer=$row['is_customer'];
						 if($is_customer==1)
						 {
						     $status=2;
						 }
						 else
						 {
						     $status=$row['status'];
						 }
						 $sponcer_id=$row['sponcer_id'];
						 $sponcer_name=$row['sponcer_name'];
						 $left_member=$row['left_member'];
						 $right_member=$row['right_member'];
						 $eft_business=$row['left_business'];
						 $right_business=$row['right_business'];
						
						?>
				    	<a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt" data-toggle="tooltip" data-placement="top" data-html="true" title="Left Business : <?php echo $left_business; ?> Right Business : <?php echo $right_business; ?>">
						<img src="images/<?php echo $status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
					    </a>
					
						<span class="wrap_content"><a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt"><p><?php echo $member_name; ?></br><?php echo $left3left1; ?></p></a></span>
						<?php } else { ?>
						<img src="images/blank.png" height="60" width:"60">
						<span class="wrap_content"><a href="#" target="_blank"><p><?php echo "Join"; ?></p></a></span>
						<?php } }?>
				      </div>
				  </td>
				  <td  width="25%">
				      <div class="col-lg-12" style="text-align:center;">
				           <?php if($left_id=="00"){ ?>
						<img src="images/blank.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
						<span class="wrap_content"><a href="#"><a href="#"><p><?php echo "Open"; ?></p></a></a></span>
						<?php } else { 
						 $llsql="select * from tbl_memberreg where promoter_id='$right_id' and position='RIGHT'";
						$llresult=mysqli_query($connection,$llsql);
						if(mysqli_num_rows($llresult)==1) 
						{
						 $row = mysqli_fetch_array($llresult);
						 $left3left1=$row['member_user_id'];
						 $member_name=$row['member_name'];
						 $is_customer=$row['is_customer'];
						 if($is_customer==1)
						 {
						     $status=2;
						 }
						 else
						 {
						     $status=$row['status'];
						 }
						 $sponcer_id=$row['sponcer_id'];
						 $sponcer_name=$row['sponcer_name'];
						 $left_member=$row['left_member'];
						 $right_member=$row['right_member'];
						 $eft_business=$row['left_business'];
						 $right_business=$row['right_business'];
						
						?>
				    	<a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt" data-toggle="tooltip" data-placement="top" data-html="true" title="Left Business : <?php echo $left_business; ?><p>Right Business : <?php echo $right_business; ?></p>">
						<img src="images/<?php echo $status; ?>.png" height="60" width="60" style="position:relative; top:0px; left:15px;">
					    </a>
						
						<span class="wrap_content"><a href="MyTree.php?QWDRFTGYYHHH=<?php echo $row['member_id']; ?>&pg=mt"><p><?php echo $member_name; ?></br><?php echo $left3left1; ?></p></a></span>
						<?php } else { ?>
						<img src="images/blank.png" height="60" width:"60">
						<span class="wrap_content"><a href="#" target="_blank"><p><?php echo "Join"; ?></p></a></span>
						<?php } }?>
				      </div>
				  </td>
				  </tr>
				  </div>
				  </div>
				  
				  
				  
				  </div>
				  </div>
                 </table>
                </div>
            </div>
             </div>
          </div>
    </div>
</div>

    <!-- Required Js -->
    <script src="assets/js/vendor-all.min.js"></script>
    <script src="assets/js/plugins/bootstrap.min.js"></script>
    <script src="assets/js/pcoded.min.js"></script>

<!-- Apex Chart -->
<script src="assets/js/plugins/apexcharts.min.js"></script>


<!-- custom-chart js -->
<script src="assets/js/pages/dashboard-main.js"></script>
</body>

</html>
