<?php

	include 'header.php';
	include 'navbar.php';

	require_once('includes/API_Config.php');
    
	$obj = new API_Config;
	$data = array();
	$data['referID'] = $_SESSION['refer_id'];
	$response = json_decode($obj->call_API("API_network_list.php", $data), true);
	$data_list = $response['members'];
	$srNo =0;
	//var_dump($data_list);

?>



<div class="row">
		<div class="col-md-6 grid-margin">
			<div class="card">
				<div class="card-body">
					<h4 class="card-title mb-0">Left Leg Details:</h4><br/>
					<div class="table-responsive">
					  <table class="table center-aligned-table">
						<thead>
						  <tr class="bg-light">
							<th class="border-bottom-0">Paid Members</th>
							<th class="border-bottom-0">Unpaid Members</th>
							<th class="border-bottom-0">Total Members</th>
						  </tr>
						</thead>
						<tbody>
						  <tr>
							<td><a href="leg-details.php?type=paid&leg=l"  target="_blank" style="text-decoration: none;"><?php  echo $response['leftPaid'];   ?></a></td>
							<td><a href="leg-details.php?type=unpaid&leg=l" target="_blank" style="text-decoration: none;"><?php echo ($response['leftCount'] - $response['leftPaid']); ?></a></td>
							<td><a href="leg-details.php?type=total&leg=l" target="_blank" style="text-decoration: none;"><?php  echo $response['leftCount'];	 ?></a></td>
						  </tr>
						</tbody>
					  </table>
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-6 grid-margin">
			<div class="card">
				<div class="card-body">
					<h4 class="card-title mb-0">Right Leg Details:</h4><br/>
					<div class="table-responsive">
					  <table class="table center-aligned-table">
						<thead>
						  <tr class="bg-light">
							<th class="border-bottom-0">Paid Members</th>
							<th class="border-bottom-0">Unpaid Members</th>
							<th class="border-bottom-0">Total Members</th>
						  </tr>
						</thead>
						<tbody>
						  <tr>
							<td><a href="leg-details.php?type=paid&leg=r" target="_blank" style="text-decoration: none;"><?php  echo $response['rightPaid'];   ?></a></td>
							<td><a href="leg-details.php?type=unpaid&leg=r" target="_blank" style="text-decoration: none;"><?php echo ($response['rightCount'] - $response['rightPaid']); ?></a></td>
							<td><a href="leg-details.php?type=total&leg=r" target="_blank" style="text-decoration: none;"><?php  echo $response['rightCount'];	 ?></a></td>
						  </tr>
						</tbody>
					  </table>
					</div>
				</div>
			</div>
		</div>
	</div>

			<div class="card">
            <div class="card-body">
              <h4 class="card-title">My Network</h4>
              <div class="row">
                <div class="col-12 table-responsive">
                  <table id="order-listing" class="table">
                    <thead>
                      <tr>
                          <th>Sr No.</th>
                          <th>Member Name</th>
                          <th>Member ID</th>
                          <th>Joining Date</th>
                          <th>Purchased PV</th>
                          <th>Leg</th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						if(!empty($data_list))
						{
							$i=1;

							foreach($data_list as $row)
							{
								echo "<tr>";
								echo "<td>". $i++  ."</td>";
								echo "<td>". $row['name'] ."</td>";
								echo "<td>". $row['refer_id'] ."</td>";
								
								echo "<td>";
									if(!empty($row['purchase_date']))
										echo $row['purchase_date'];
									else
										echo "--";
								echo "</td>";

								
								echo "<td>";
									if(!empty($row['purchase']))
										echo $row['purchase'];
									else
										echo "--";
								echo "</td>";


								echo "<td>";
									if($row['leg']==0)
										echo "Left";

									else
										echo "Right";


								echo "</td>";

								echo "</tr>";

							}
							
						}


						else
							echo "No Member found in a network.";

					?>

                      
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>


<?php
	include 'footer.php';
?>