<?
	if($user_status >= 0 and $user_blokir == 0) {
?>

<?
//*********************************************************************************
// 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($print == 1) {
	include "../setdatabase.php";
include "../master.php";
//include "mydb.php";
$db = new db_mysql($server_name, $userdb, $passdb, $databasename,"");
include "../func.php";
	$user_session = $mid;
	$pr = "<body onLoad=\"javascript:print()\" style='font-family:Verdana, Arial, Helvetica, sans-serif'>";
	$bd = "</body>";
}	
echo $pr;
?><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="35" colspan="3"><div align="center"><font color="#FFFFFF"><strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">ARSIP KOMISI</font></strong></font></div></td>
  </tr>
  <tr>
    <td width="10">&nbsp;</td>
    <td><p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <?
if($db->dataupline("paket", $user_session) > 1) {
	include "komlev.php";
} else {	
?>
    </font></strong></p>
        <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="bordertable">
          <tr class="tbl_header">
            <td colspan="2" align="center" style="padding:5px"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">DETAIL KOMISI :
                  <?= $user_session; ?>
      s/d 
      <?= date("d-m-Y"); ?>
            </font></td>
          </tr>
          <tr>
            <td width="50%" align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Nama : </font></td>
            <td width="50%"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
              <?= $db->dataku("nama", $user_session); ?>
            </font></strong></td>
          </tr>
          <tr>
            <td align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Sponsor : </font></td>
            <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
              <?= $db->dataku("sponsor", $user_session)." (".$db->dataku("nama", $db->dataku("sponsor", $user_session)).")"; ?>
            </font></strong></td>
          </tr>
          <tr>
            <td align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><span jsaction="mouseup:Sxi9L,BR6jm; mousedown:qjlr0e" jsname="jqKxS" lang="en"><span jsaction="agoMJf:PFBcW;MZfLnc:P7O7bd;nt4Alf:pvnm0e,pfE8Hb,PFBcW;B01qod:dJXsye;H1e5u:iXtTIf;lYIUJf:hij5Wb;bmeZHc:iURhpf;Oxj3Xe:qAKMYb,yaf12d" jsname="txFAF" jscontroller="Gn4SMb"><span jsaction="click:E6Tfl,GFf3ac,tMZCfe; contextmenu:Nqw7Te,QP7LD; mouseout:Nqw7Te; mouseover:E6Tfl,c2aHje" jsname="W297wb">Tgl Aktivasi</span></span></span> : </font></td>
            <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
              <?= $db->dataku("tglaktif", $user_session); ?>
            </font></strong></td>
          </tr>
          <?



?>
        </table>        
        <form action="" method="post" name="form1" id="form1">
          <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">
            <tr>
              <td width="38%"><div align="right"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><span jsaction="mouseup:Sxi9L,BR6jm; mousedown:qjlr0e" jsname="jqKxS" lang="en"><span jsaction="agoMJf:PFBcW;MZfLnc:P7O7bd;nt4Alf:pvnm0e,pfE8Hb,PFBcW;B01qod:dJXsye;H1e5u:iXtTIf;lYIUJf:hij5Wb;bmeZHc:iURhpf;Oxj3Xe:qAKMYb,yaf12d" jsname="txFAF" jscontroller="Gn4SMb"><span jsaction="click:E6Tfl,GFf3ac,tMZCfe; contextmenu:Nqw7Te,QP7LD; mouseout:Nqw7Te; mouseover:E6Tfl,c2aHje" jsname="W297wb">Komisi Bulan </span></span></span> : </font></strong></div></td>
              <td width="62%"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                <? 
		$thn=substr($clientdate, 0, 4);
	$bln=substr($clientdate, 5, 2);
	$tgl=substr($clientdate, 8, 2);
	if(!$bulan && !$tahun) {
		$bulan = $bln;
		$tahun = $thn;
	}	
		echo "<select name=bulan size=1 class=form>";
	$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;
			}
		echo "<option value=$k $pil>$bulan0[$b]</option>";
	}
	echo "</select>";
	echo "<select name=tahun size=1 class=form>";
	$jthn=15;
	for($t=8;$t<$jthn;$t++) {
		$thn2 = (2015 + $t);	
		if($tahun == $thn2) {
			$pil="selected";
			} else {
			$pil="";
			}
		echo "<option value='$thn2' $pil>$thn2</option>";
	}
	echo "</select>";
	$tgaktif = $db->dataku("tglaktif", $user_session); 
	$dtfrom = "$tahun-$bulan-01 00:00:00";
	$dtto = "$tahun-$bulan-31 23:59:59";
		?>
                <input type="submit" name="Submit2" value="LIHAT KOMISI" class="tombol" />
              </font></strong></td>
            </tr>
          </table>
        </form>
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E7E5D9">
          <tr>
            <td height="25" background="../images/left_head_1px.gif"><div align="center"><font color="#FFFF00" size="2" face="Verdana, Arial, Helvetica, sans-serif">(1) Komisi Sponsoring</font></div></td>
          </tr>
          <tr>
            <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
                <tr>
                  <td width="4%" height="25" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">No.</font></td>
                  <td width="15%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Tgl</font></td>
                  <td width="21%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Dari</font></td>
                  <td width="20%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Nama</font></td>
                  <td width="21%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Commission </font></td>
                  <td width="19%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Jumlah</font></td>
                </tr>
                <?
	$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)) {
		echo "<tr bgcolor=#FFFFFF>
          <td align=center height=25>$nom.</td>
           <td align=center height=25>".date("d-m-Y",strtotime($row[3]))."</td>
          <td align=center height=25>$row[7]</td>
          <td align=center height=25>".$db->dataku("nama", $row[7])."</td>
		  <td align=center height=25>Referral Commision</td>
          <td align=right>".rupiah($row[2])."</td>
        </tr>";
		$totsponsor = $totsponsor + $row[2];
		$nom++;
	}
	?>
                <tr>
                  <td height="25" colspan="5" align="right" bgcolor="#E8E8E8"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">TOTAL </font></strong></td>
                  <td bgcolor="#E8E8E8" align="right"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                    <?= rupiah($totsponsor); ?>
                  </font></strong></td>
                </tr>
            </table></td>
          </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E7E5D9">
        <tr>
          <td height="25" background="../images/left_head_1px.gif"><div align="center"><font color="#FFFF00" size="2" face="Verdana, Arial, Helvetica, sans-serif">(2) Komisi Titik</font></div></td>
        </tr>
        <tr>
          <td bgcolor="#FCEFED"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
            <tr>
              <td width="4%" height="25" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">No.</font></td>
              <td width="15%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Tgl</font></td>
              <td width="21%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Dari</font></td>
              <td width="20%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Nama</font></td>
              <td width="21%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Commission </font></td>
              <td width="19%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Jumlah</font></td>
            </tr>
            <?
			
	$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") {
		echo "<tr bgcolor=#FFFFFF>
          <td align=center height=25>$nom.</td>
          <td align=center height=25>".date("d-m-Y",strtotime($row[3]))."</td>
          <td align=center height=25>$row[7]</td>
          <td align=center height=25>".$db->dataku("nama", $row[7])."</td>
		  <td align=center>$row[6]</td>
          <td align=right>".rupiah($row[2])."</td>
        </tr>";
		$totlevel = $totlevel + $row[2];
		$nom++;
		}
	}
	
	
		$dtto2 = $dtfrom;
	$total0 = $db->totalkomisi($user_session, "AND (tglbayar BETWEEN '$dtfrom2' AND '$dtto2')");
	?>
            <tr>
              <td height="25" colspan="5" align="right" bgcolor="#E8E8E8"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">TOTAL </font></strong></td>
              <td bgcolor="#E8E8E8" align="right"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                <?= rupiah($totlevel); ?>
              </font></strong></td>
            </tr>
          </table></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E7E5D9">
        <tr>
          <td height="25" background="../images/left_head_1px.gif"><div align="center"><font color="#FFFF00" size="2" face="Verdana, Arial, Helvetica, sans-serif">(3) <span jsaction="mouseup:Sxi9L,BR6jm; mousedown:qjlr0e" jsname="jqKxS" lang="en"><span jsaction="agoMJf:PFBcW;MZfLnc:P7O7bd;nt4Alf:pvnm0e,pfE8Hb,PFBcW;B01qod:dJXsye;H1e5u:iXtTIf;lYIUJf:hij5Wb;bmeZHc:iURhpf;Oxj3Xe:qAKMYb,yaf12d" jsname="txFAF" jscontroller="Gn4SMb"><span jsaction="click:E6Tfl,GFf3ac,tMZCfe; contextmenu:Nqw7Te,QP7LD; mouseout:Nqw7Te; mouseover:E6Tfl,c2aHje" jsname="W297wb">Komisi Penjualan</span></span></span></font></div></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
            <tr>
              <td width="4%" height="25" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">No.</font></td>
              <td width="15%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Tgl</font></td>
              <td width="21%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Dari</font></td>
              <td width="20%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Nama</font></td>
              <td width="21%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Komisi</font></td>
              <td width="19%" align="center" bgcolor="#F2F1EC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Jumlah</font></td>
            </tr>
            <?
	$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") {
			echo "<tr bgcolor=#FFFFFF>
			  <td align=right>$nom.</td>
			  <td>".date("d-m-Y",strtotime($row[3]))."</td>
			  <td>$row[7]</td>
			  <td>".$db->dataku("nama", $row[7])."</td>
			  <td align=center height=25>Sales Commission</td>
			  <td align=right>".rupiah($row[2])."</td>
			</tr>";
			$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");
	?>
            <tr>
              <td height="25" colspan="5" align="right" bgcolor="#E8E8E8"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">TOTAL</font></strong></td>
              <td bgcolor="#E8E8E8" align="right"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                <?= rupiah($totextra); ?>
              </font></strong></td>
            </tr>
          </table></td>
        </tr>
      </table>
      <p>&nbsp;</p>
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E7E5D9">
          <tr>
            <td height="27" background="../images/left_head_1px.gif"><div align="center"><strong><font color="#66FF00" size="2" face="Verdana, Arial, Helvetica, sans-serif">SUMMARY</font></strong></div></td>
          </tr>
          <tr>
            <td bgcolor="#FCEFED"><table width="100%" border="0" cellspacing="1" cellpadding="1">
                <tr>
                  <td width="8%" height="25" align="center" bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">1</font></td>
                  <td width="57%" bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Komisi Sponsoring</font></td>
                  <td width="35%" align="right" bgcolor="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                    <?= rupiah($totsponsor); ?>
                  </font></strong></td>
                </tr>
                <tr>
                  <td height="25" align="center" bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">2</font></td>
                  <td bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Komisi Titik</font></td>
                  <td align="right" bgcolor="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                    <?= rupiah($totlevel); ?>
                  </font></strong></td>
                </tr>
                <tr>
                  <td height="25" align="center" bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">3</font></td>
                  <td bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Komisi Penjualan </font></td>
                  <td align="right" bgcolor="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                    <?= rupiah($totextra); ?>
                  </font></strong></td>
                </tr>
                <tr>
                  <td height="25" colspan="2" align="right" bgcolor="#E8E8E8"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> TOTAL KOMISI BULAN INI (
                            <?= $bulan0[$bulan-1]." $tahun"; ?>
              ) </font></div></td>
                  <td align="right" bgcolor="#E8E8E8"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                    <?
			//$totbln = $totblev + $bon_star + $broyalti + $unilevel;
			$saldo = $totsponsor + $totlevel + $totextra ;
			echo rupiah($saldo); 
			//----------total downlline--------
			?>
                  </font></strong></td>
                </tr>
            </table></td>
          </tr>
      </table>        
        <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
        <?
} //---if paket
if(!$print) {
?>
        <?
}
?>
        </font></strong></p>
        <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <?= $bd; ?>
    </font></strong> </p></td>
    <td width="10">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
  </tr>
</table>
<strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
</font></strong>
<?
} else {
echo "<meta http-equiv=\"refresh\" content=\"1; url=illegal.html\">";
}
?>