<?
//*********************************************************************************
// Original Website By : Niadesain.com Di Jual melalui http://niadesain.com
// Please Call / SMS : 081384745483 (support@niadesain.com)
// Niadesain.com - Jasa Pembuatan Website Paling Murah dan Paling Lengkap
//*********************************************************************************
?>
<?
	if($user_status > 0) {
?>

<?
$user = $user_session;
$data = preg_replace("{NAMAMEMBER}", $user_nama, $data);
$data = preg_replace("{USERNAME}", $user, $data);
?>
<div align="center">
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#FFFFFF">
      <td height="35" colspan="3"><div align="center"><font color="#FFFFFF"><strong><font color="#000066" size="2" face="Verdana, Arial, Helvetica, sans-serif">MEMBER AREA</font></strong></font></div></td>
    </tr>
    <tr>
      <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
      <td><div class="cc01">
          <?
	if($user_status > 0 and $user_blokir == 0) {
?>
<? 
$thn=substr($clientdate, 0, 4);
	$bln=substr($clientdate, 5, 2);
	$tgl=substr($clientdate, 8, 2);
	if(!$bulan && !$tahun) {
		$bulan = $bln;
		$tahun = $thn;
	}	
	$bulan0=array("Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
	$jbln=count($bulan0);
	if($bulan =="") {
		$bulan2 = $bln;
	} else {
		$bulan2 = $bulan;
	}
	for($b=0;$b<$jbln;$b++) {
		if($bulan2-1 == $b) {
			$pil="selected";
			} else {
			$pil="";
			}
			if($b+1 < 10) {
			$k2=$b+1;
			$k="0$k2";
			} else {
				$k=$b+1;
			}
	}
	$tgaktif = $db->dataku("tglaktif", $user_session); 
	$dtfrom = "$tahun-$bulan-01 00:00:00";
	$dtto = "$tahun-$bulan-31 23:59:59";
		?>
	
<?
	$sbl=mysql_query("select * from komisi where jenis='komsponsor' and username='$user_session' and (tglbayar between '$dtfrom' and '$dtto') order by tglbayar");
	$nom=1;
	$totsponsor = 0;
	while($row=mysql_fetch_row($sbl)) {
		
		$totsponsor = $totsponsor + $row[2];
		$nom++;
	}
	?>
	<?
	$sbl=mysql_query("select * from komisi where jenis='kompasangan' and username='$user_session' and (tglbayar between '$dtfrom' and '$dtto') order by tglbayar");
	$nom=1;
	$totpas = 0;
	while($row=mysql_fetch_row($sbl)) {
		$totpas = $totpas + $row[2];
		$nom++;
	}
	?>
	<?
			
	$sbl=mysql_query("select * from komisi where username='$user_session' and (tglbayar between '$dtfrom' and '$dtto') order by tglbayar");
	$nom=1;
	$totlevel = 0;
	while($row=mysql_fetch_row($sbl)) {
		if(substr($row[6],0,6) == "komlev") {
		$totlevel = $totlevel + $row[2];
		$nom++;
		}
	}
	
	
		$dtto2 = $dtfrom;
	$total0 = $db->totalkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto2')");
	?>
	                <?
	$sbl=mysql_query("select * from komisi where jenis='komgenerasi' and username='$user_session' and (tglbayar between '$dtfrom' and '$dtto') order by tglbayar");
	$nom=1;
	$totgen = 0;
	while($row=mysql_fetch_row($sbl)) {
		$totgen = $totgen + $row[2];
		$nom++;
	}
	?>
	            <?
	$sbl=mysql_query("select * from komisi where username='$user_session' and (tglbayar between '$dtfrom' and '$dtto') order by tglbayar");
	$nom=1;
	$totextra = 0;
	while($row=mysql_fetch_row($sbl)) {
		if(substr($row[6],0,7) == "komjual") {
			$totextra = $totextra + $row[2];
			$nom++;
		}
	}
	
	
	//$total0 = totalkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto2')");
	$bulan0=array("Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
	?>
<?
	$sbl=mysql_query("select * from komisi where jenis='komisiro' and username='$user_session' and (tglbayar between '$dtfrom' and '$dtto') order by tglbayar");
	$nom=1;
	$totrox = 0;
	while($row=mysql_fetch_row($sbl)) {
		 
		$totrox = $totrox + $row[2];
		$nom++;
	}
	?>
	<?
			//$totbln = $totblev + $bon_star + $broyalti + $unilevel;
			$saldo = $totsponsor +  $totpas + $totlevel + $totgen + $totextra + $totrox;
			//----------total downlline--------
			?>
<?
//$tgaktif = $db->dataku("tglaktif", $user_session);
$paket = $db->dataupline("paket", $user_session);
$db->select("tglbayar", "komisi", "username='$user_session'", "tglbayar asc");
$row=$db->fetch_row();		
$dtfrom2 = $row[0];
$dtto = date("Y-m-d H:i:s");
if($paket > 1 AND $paket <=3) {		
	$total0 = $db->totalkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl = $db->bayarkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total01 = $db->totalkomisi("$user_session-01", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl01 = $db->bayarkomisi("$user_session-01", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total02 = $db->totalkomisi("$user_session-02", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl02 = $db->bayarkomisi("$user_session-02", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	
	$totale = ($total0 + $total01 + $total02);
	$widrle = ($widrl + $widrl01 + $widrl02);
	$tarik = $totale - $widrle;

} elseif($paket > 3 AND $paket <=7) {		
	$total0 = $db->totalkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 and ");
	$widrl = $db->bayarkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total01 = $db->totalkomisi("$user_session-01", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl01 = $db->bayarkomisi("$user_session-01", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total02 = $db->totalkomisi("$user_session-02", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl02 = $db->bayarkomisi("$user_session-02", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total03 = $db->totalkomisi("$user_session-03", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl03 = $db->bayarkomisi("$user_session-03", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total04 = $db->totalkomisi("$user_session-04", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl04 = $db->bayarkomisi("$user_session-04", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total05 = $db->totalkomisi("$user_session-05", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl05 = $db->bayarkomisi("$user_session-05", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$total06 = $db->totalkomisi("$user_session-06", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl06 = $db->bayarkomisi("$user_session-06", "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	
	
	$totale = ($total0 + $total01 + $total02 + $total03 + $total04 + $total05 + $total06);
	$widrle = ($widrl + $widrl01 + $widrl02 + $widrl03 + $widrl04 + $widrl05 + $widrl06);
	$tarik = $totale - $widrle;

} else {
	$total0 = $db->totalkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto') and status=0 ");
	$widrl = $db->bayarkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto')");
	$tarik = $total0 - $widrl;
	$biayatrf = ($tarik)*($db->config("potpph"))/100;
	$potongan = $db->config("potadmin") + $biayatrf;
	$tarik2 = $tarik - $potongan;
	$minimalwd = $db->config("minwd") + 10000;
$totale = $total0;
}	
?>
          <div id="module">
            <section class="content">
        <div class="row">
            <div class="col-lg-3 col-xs-12">
                <div class="small-box bg-blue">
                    <div class="inner">
                        <h2><?= rupiah($saldo); ?></h2>
                        <p>Komisi Bulan ini</p>
                    </div>
                    <div class="icon">
                </div>
                </div>
            </div>
            <div class="col-lg-3 col-xs-12">
                <div class="small-box bg-blue">
                    <div class="inner">
                        <h2><?= rupiah($tarik); ?></h2>
                        <p>Saldo komisi</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-newspaper-o" style="margin-top: 10px"></i>
                    </div>
                </div>
            </div>
            <div class="col-lg-3 col-xs-12">
                <div class="small-box bg-blue">
                    <div class="inner">
                        <h2><?= memberkiri($user_session, "and b.status=1") + memberkanan($user_session, "and b.status=1")?></h2>
                        <p>Total Downline</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-newspaper-o" style="margin-top: 10px"></i>
                    </div>

                </div>
            </div>
             
        </div>

            <?
        $userid= $user_aktivasi;
	$user = $user_session;
$db->select("id, title, maintext", "content", "title='Home - Member Area'");
if($db->num_rows() > 0) 
//

$data = $db->result(0, "maintext");
$data = preg_replace("{NAMAMEMBER}", $user_nama, $data);
$data = preg_replace("{USERNAME}", $user, $data);
$data = preg_replace("{NOAKTIVASI}", $userid, $data);


echo $data;

?>
          </div>
        <?
} else {
	include "index0.php";
}
?>
        </div>
          <p align="center">&nbsp;</p></td>
      <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>    <?
} else {
	include "index0.php";
}
?>
  </p>
    </p>
</div>
</div>

  