<?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();} 
?>
 <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    <img src="../themes/img/ico.png" alt="bonus" class="header-icon" width="30">
                    Bonus Reward
                </h1>
            </div>
        </div>
 

  
<?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{
?>
  <?



$rwww="SELECT peringkat2 FROM configuration"; 
$dtrwww=mysql_query($rwww);
$configrwww=mysql_fetch_array($dtrwww);
$batasrwd = explode("|", $configrwww['peringkat2']);
$rankrwd = explode("|", $configrwww['peringkat2']);
$rewardrwd = explode("|", $configrwww['peringkat2']);

$batasrwx1 = $batasrwd[0]; 
$batasrwx2 = $batasrwd[4]; 
$batasrwx3 = $batasrwd[8]; 
$batasrwx4 = $batasrwd[12]; 
$batasrwx5 = $batasrwd[16];
$batasrwx6 = $batasrwd[20];

$rankrwx1 = $rankrwd[1]; 
$rankrwx2 = $rankrwd[5]; 
$rankrwx3 = $rankrwd[9]; 
$rankrwx4 = $rankrwd[13]; 
$rankrwx5 = $rankrwd[17]; 
$rankrwx6 = $rankrwd[21]; 

$rewardx1 = $rewardrwd[2]; 
$rewardx2 = $rewardrwd[6]; 
$rewardx3 = $rewardrwd[10]; 
$rewardx4 = $rewardrwd[14]; 
$rewardx5 = $rewardrwd[18]; 
$rewardx6 = $rewardrwd[22]; 


$sql_rwd1 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='1'");
$rowcrwd1 = mysql_fetch_array($sql_rwd1);
if($rowcrwd1[0] > 0){
$point1 = $rowcrwd1[0];
$status1="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point1 = "";
$status1="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd2 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='2'");
$rowcrwd2 = mysql_fetch_array($sql_rwd2);
if($rowcrwd2[0] > 0){
$point2 = $rowcrwd2[0];
$status2="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point2 = "";
$status2="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd3 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='3'");
$rowcrwd3 = mysql_fetch_array($sql_rwd3);
if($rowcrwd3[0] > 0){
$point3 = $rowcrwd3[0];
$status3="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point3 = "";
$status3="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd4 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='4'");
$rowcrwd4 = mysql_fetch_array($sql_rwd4);
if($rowcrwd4[0] > 0){
$point4 = $rowcrwd4[0];
$status4="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point4 = "";
$status4="<img src='../images/publish_x.png' width='16' height='16' />";
}

$sql_rwd5 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='5'");
$rowcrwd5 = mysql_fetch_array($sql_rwd5);
if($rowcrwd5[0] > 0){
$point5 = $rowcrwd5[0];
$status5="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point5 = "";
$status5="<img src='../images/publish_x.png' width='16' height='16' />";
}
$sql_rwd6 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='6'");
$rowcrwd6 = mysql_fetch_array($sql_rwd6);
if($rowcrwd6[0] > 0){
$point6 = $rowcrwd6[0];
$status6="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point6 = "";
$status6="<img src='../images/publish_x.png' width='16' height='16' />";
}
$sql_rwd7 = mysql_query("select SUM(pointreward) from wd_reward where username='".$user_session."' and jenis='7'");
$rowcrwd7 = mysql_fetch_array($sql_rwd7);
if($rowcrwd7[0] > 0){
$point7 = $rowcrwd7[0];
$status7="<img src='../images/tick.png' width='16' height='16' />";
} else {
$point7 = "";
$status7="<img src='../images/publish_x.png' width='16' height='16' />";
}

$pointnya = $point1+$point2+$point3+$point4+$point5+$point6+$point7;
//$pointnyap = $pointnya/$kurspoin;

$memberix = omsetkiri($user_session);
$membernanx = omsetkanan($user_session);
$memberi = $memberix - $pointnya;
$membernan = $membernanx - $pointnya;
$memberip = $memberix - $pointnya;
$membernanp = $membernanx - $pointnya;
if($memberi > 0){
	$sldmemberi = $memberi;
	$sldmemberip = $memberip;
}else{
	$sldmemberi = "---";
	$sldmemberip = "---";
}
if($membernan > 0){
	$sldmembera = $membernan;
	$sldmemberap = $membernanp;

}else{
	$sldmembera = "---";
	$sldmemberap = "---";
}
if($pointnya > 0){
	$pointnyac = $pointnya;
	$pointnyacp = $pointnyap;
}else{
	$pointnyac = "---";
	$pointnyacp = "---";
}

if($memberip >= $batasrwx1 && $membernanp >= $batasrwx1){
$qualy1="Qualified";
$reward1=$rewardx1;
$ambil1= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy1="Not Qualified";
$reward1=$rewardx1;
$ambil1= "---";
}
if($memberip >= $batasrwx2 && $membernanp >= $batasrwx2){
$qualy2="Qualified";
$reward2=$rewardx2;
$ambil2= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy2="Not Qualified";
$reward2=$rewardx2;
$ambil2= "---";
}
if($memberip >= $batasrwx3 && $membernanp >= $batasrwx3){
$qualy3="Qualified";
$reward3=$rewardx3;
$ambil3= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy3="Not Qualified";
$reward3=$rewardx3;
$ambil3= "---";
}
if($memberip >= $batasrwx4 && $membernanp >= $batasrwx4){
$qualy4="Qualified";
$reward4=$rewardx4;
$ambil4= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy4="Not Qualified";
$reward4=$rewardx4;
$ambil4= "---";
}
if($memberip >= $batasrwx5 && $membernanp >= $batasrwx5){
$qualy5="Qualified";
$reward5=$rewardx5;
$ambil5= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy5="Not Qualified";
$reward5=$rewardx5;
$ambil5= "---";
}
if($memberip >= $batasrwx6 && $membernanp >= $batasrwx6){
$qualy6="Qualified";
$reward6=$rewardx6;
$ambil6= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy6="Not Qualified";
$reward6=$rewardx6;
$ambil6= "---";
}
if($memberip >= $batasrwx7 && $membernanp >= $batasrwx7){
$qualy7="Qualified";
$reward7=$rewardx7;
$ambil7= "<a class='btn btn-success btn-xs' href='index.php?go=withdrawalrw'><i class='fa fa-check'></i>&nbsp;Get Reward</a>";
} else {
$qualy7="Not Qualified";
$reward7=$rewardx7;
$ambil7= "---";
}


			
?>

<div class="row">
            	<div class="col-md-12">
                	
                    
                   <div class="panel panel-inverse">
                        <div class="panel-heading bg-grey">
                            <h4 class="text-white">Achievement :  <?php if($memberi>0) { echo "Left ".rupiah($memberi);}else{ echo "Left 0"; }?> | <?php if($membernan>0) { echo "Right ".rupiah($membernan);}else{ echo "Right 0"; }?></h4>
                        </div>
                        
                        <div class="panel-body">
                        
                        
                        
                        
                        
                                                          
                                    <table id="" class="table table-bordered" cellspacing="0" width="100%">
                    
                    
              <thead>
                <tr>
            <th>Reward</th>
                                    <th>Left</th>
                                    <th>Right</th>
                                    <th>Achievement</th>
                                    <th>Reward</th>
                                    <th>Collect Reward</th>
                </tr>
              </thead>
              <tbody>
	<?php if($batasrwx1 > 0){?>
     <tr> 
                            <td><?php echo $style; ?><?php echo $rankrwx1; ?></font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx1); ?> </font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx1); ?> </font></td>
                            <td><?php echo $style; ?><?php echo $qualy1; ?></font></td>
                            <td><?php echo $style; ?><?php echo $reward1; ?></font></td>
                            <td><?php echo $style; ?><?php echo $ambil1; ?></font></td>
                            <td><?php echo $style; ?><?php echo $status1; ?></font></td>
                        </tr>
                    <?php } ?>  
                    <?php if($batasrwx2 > 0){?>                                              
        <tr> 
                            <td><?php echo $style; ?><?php echo $rankrwx2; ?></font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx2); ?> </font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx2); ?> </font></td>
                            <td><?php echo $style; ?><?php echo $qualy2; ?></font></td>
                            <td><?php echo $style; ?><?php echo $reward2; ?></font></td>
                            <td><?php echo $style; ?><?php echo $ambil2; ?></font></td>
                            <td><?php echo $style; ?><?php echo $status2; ?></font></td>
                        </tr>
                    <?php } ?>  
                    <?php if($batasrwx3 > 0){?>       
	 <tr> 
                            <td><?php echo $style; ?><?php echo $rankrwx3; ?></font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx3); ?> </font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx3); ?> </font></td>
                            <td><?php echo $style; ?><?php echo $qualy3; ?></font></td>
                            <td><?php echo $style; ?><?php echo $reward3; ?></font></td>
                            <td><?php echo $style; ?><?php echo $ambil3; ?></font></td>
                            <td><?php echo $style; ?><?php echo $status3; ?></font></td>
                        </tr>
                    <?php } ?>  
                    <?php if($batasrwx4 > 0){?>   
                         <tr> 
                            <td><?php echo $style; ?><?php echo $rankrwx4; ?></font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx4); ?> </font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx4); ?> </font></td>
                            <td><?php echo $style; ?><?php echo $qualy4; ?></font></td>
                            <td><?php echo $style; ?><?php echo $reward4; ?></font></td>
                            <td><?php echo $style; ?><?php echo $ambil4; ?></font></td>
                            <td><?php echo $style; ?><?php echo $status4; ?></font></td>
                        </tr>
                    <?php } ?>  
                    <?php if($batasrwx5 > 0){?>   
                       <tr> 
                            <td><?php echo $style; ?><?php echo $rankrwx5; ?></font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx5); ?> </font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx5); ?> </font></td>
                            <td><?php echo $style; ?><?php echo $qualy5; ?></font></td>
                            <td><?php echo $style; ?><?php echo $reward5; ?></font></td>
                            <td><?php echo $style; ?><?php echo $ambil5; ?></font></td>
                            <td><?php echo $style; ?><?php echo $status5; ?></font></td>
                        </tr>
                    <?php } ?>  
                    <?php if($batasrwx6 > 0){?>   
                       <tr> 
                            <td><?php echo $style; ?><?php echo $rankrwx6; ?></font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx6); ?> </font></td>
                            <td><?php echo $style; ?><?php echo rupiah($batasrwx6); ?> </font></td>
                            <td><?php echo $style; ?><?php echo $qualy6; ?></font></td>
                            <td><?php echo $style; ?><?php echo $reward6; ?></font></td>
                            <td><?php echo $style; ?><?php echo $ambil6; ?></font></td>
                            <td><?php echo $style; ?><?php echo $status6; ?></font></td>
                        </tr>
                         <?php } ?> 
              </tbody>
            </table>
                        </div>
                    </div>
                </div>
			</div>
			<!-- END PAGE CONTENT -->                       



                     
<?php } ?>