<?php
if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)){
echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!";
echo "<meta http-equiv=\"refresh\" content=\"2; url=../index.php\">";
exit();} 
?>
   <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Refferal
      </h1>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="breadcrumb-item active">Refferal</li>
      </ol>
    </section>


    <section class="content">

<?php
if($db->dataku("status", $user_session) == 0 || $db->dataku("blokir", $user_session) == 1) {
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["status0"]."</div>";
}else{
?>
  <div class="row">
            <div class="col-md-6" style="margin-bottom:15px;">
                <div class="input-group p-b-10">
                    <input id="ref_url" class="form-control" name="ref_url" type="text" value="https://<?php echo $domain; ?>/?<?php echo $reffa; ?>=<?php echo $user_session; ?>">
                    <span class="input-group-btn">
                        <button id="copy-ref-url" class="btn btn-<?php echo $buttone; ?>" type="button" style="height:46px;">Copy Reff URL</button>
                    </span>
                </div>
                </div>

            </div>
            
            
            
            
   <div class="row">
            	<div class="col-md-12">
                
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Refferals [<?php $ceksponku="SELECT * FROM member where sponsor='".$user_session."'";
$queryspone=mysql_query($ceksponku);
$totalespone=mysql_num_rows($queryspone); if($totalespone>0){ echo $totalespone." USER"; } else { echo "EMPTY";} ?>]</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">            
         
            
                                  <thead>
                <tr>
                   <th align="center"><?php echo $LANG["dtsp_joindate"]?></th>
                        <th align="center">User ID</th> 
                        <th align="center"><?php echo $LANG["name"]?></th> 
                        <th align="center"><?php echo $LANG["email"]?></th> 
                        <th align="center">Phone</th> 
                        <th align="center">Status</th> 
                </tr>
              </thead>
              <tbody>
       <?

	$db->select("id, username, nama, foto, kota, propinsi, email, hp, status, sponsor, tgl", "member", "sponsor='$user_session'", "id desc");
	$ada = $db->num_rows();
		while($row=$db->fetch_row()) {
			
		
			if($row[8] > 0) {
				$st = "<span class='btn btn-success btn-xs'>Active</span>";
			} else {
				$st = "<span class='btn btn-danger btn-xs'>Inactive</span>";
			}		
	
	$userku=$row[1];
		$namaku = "SELECT * FROM member WHERE username='$userku'"; 
	 
        $resultku = mysql_query($namaku);


$rownamaku = mysql_fetch_array($resultku);
$namaku = $rownamaku['nama'];	
	
		$userspon=$row[9];
		$namaspon = "SELECT * FROM member WHERE username='$userspon'"; 
	 
        $resultnamaspon = mysql_query($namaspon);


$rownamaspon = mysql_fetch_array($resultnamaspon);
$namaspone = $rownamaspon['nama'];	
?>				
				
<tr>
                            <td align="center"><?php echo formatgl($row[10]); ?></td>
                            <td align="center"><?php echo $row[1]; ?></td>
                            <td align="center"><?php echo $row[2]; ?></td>
                            <td align="center"><?php echo $row[6]; ?></td>
                            <td align="center"><?php echo $row[7]; ?></td>
                            <td align="center"><?php echo $st; ?></td>
                        </tr>
                                                                    
             <?
		}
	?>
              </tbody>
            </table>
                                </div>
                    </div>
                </div>
                    </div>
			</div>
			<!-- END PAGE CONTENT -->  
                    <?php } ?>
</section>