<?php 
ob_start();
session_start();
include 'config/config.php';
include 'config/function.php';
if($_SESSION['member_user_id']=='')
{
    header("Location:Login");
    exit();
}

?>
<html lang="en">

<head>
    <title>Left Team : <?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">
    
    

</head>
<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">Left Team</h5>-->
                            <h6><?php echo $member_user_id=$_SESSION['member_user_id']; ?> (<?php echo $_SESSION['member_name'] ?>)</h6>
                        </div>
                       
                    </div>
                </div>
            </div>
        </div>
        <!-- [ breadcrumb ] end -->
        <!-- [ Main Content ] start -->
        <div class="row">
          <!-- prject ,team member start -->
            <div class="col-xl-12 col-md-12">
                <div class="card table-card">
                   
                    <div class="card-header">
                        <h5>LEFT TEAM</h5>
                    </div>
                    <div class="card-body p-0">
                        <div class="table-responsive">
                            <table class="table table-hover mb-0">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Associate Id</th>
                                        <th>Associate Name</th>
                                        <th>Sponsor Id</th>
                                        <th>Promoter Id</th>
                                        <th>Left Business</th>
                                        <th>Right Business</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   <?php
                                   $cnt=1;$total=0;
                                   $strI="Select * from tbl_memberreg where promoter_id='$member_user_id' and position='LEFT'";
                                   $resI=mysqli_query($connection,$strI) or die(mysqli_error($connection));
                                   while($rowI=mysqli_fetch_array($resI))
                                   {
                                          $data_array[]=$rowI['member_user_id'];                              if($rowI['is_customer']==0)
										{
										    echo "<tr>";
										}
										else
										{
                                 		 ?>
				                        <tr style="color:#c107c1">
				                    <?php } ?>
                                        <td><?php echo $cnt++; ?></td>
                                        <td><?php echo $rowI['member_user_id']; ?></td>
                                        <td><?php echo $rowI['member_name']; ?></td>
                                         <td><?php echo $rowI['sponcer_id']; ?></td>
                                          <td><?php echo $rowI['promoter_id']; ?></td>
                                         <td><?php echo $rowI['left_business']; ?></td>
                                         <td><?php echo $rowI['right_business']; ?></td>
                                    </tr>
                                    <?php } ?>
                                   
                                   
                                   <!-- downline List -->
				 						<?php
										while(count($data_array)>0)
										{
										$arrlength = count($data_array);
										for($x = 0; $x < $arrlength; $x++) 
										{
										$member_user_id1= $data_array[$x];
										$sql="select * from tbl_memberreg where  promoter_id='$member_user_id1'  order by member_id";
										$result=mysqli_query($connection,$sql);
										while($rowI = mysqli_fetch_array($result))
										{
										$list[]=$rowI['member_user_id'];
                                 		if($rowI['is_customer']==0)
										{
										    echo "<tr>";
										}
										else
										{
                                 		 ?>
				                        <tr style="color:#c107c1">
				                    <?php } ?>
				 		 <td><?php echo $cnt++; ?></td>
                                        <td><?php echo $rowI['member_user_id']; ?></td>
                                        <td><?php echo $rowI['member_name']; ?></td>
                                         <td><?php echo $rowI['sponcer_id']; ?></td>
                                          <td><?php echo $rowI['promoter_id']; ?></td>
                                         <td><?php echo $rowI['left_business']; ?></td>
                                         <td><?php echo $rowI['right_business']; ?></td>
			 	     </tr>
			 		  <?php
						$cnt++;
						}} 
							$data_array=$list;
							unset($list);
										}				
						?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        
        </div>
        <!-- [ Main Content ] end -->
    </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>
