<?
	if($user_status > 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
//*********************************************************************************
?>
<style type="text/css">
<!--
.style5 {color: #CCCCCC; font-size: x-small; }
.style6 {color: #000000}
.style8 {font-size: 9px}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style9 {
	color: #000066;
	font-weight: bold;
}
.style14 {color: #333333; font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; }
.style16 {
	color: #FF0000;
	font-size: 11px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
-->
</style>
<div class="ch00">
  <table width="575" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="35" colspan="3"><div align="center" class="style9"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">FORM AMBIL KOMISI </font></div></td>
    </tr>
    <tr>
      <td width="10">&nbsp;</td>
      <td><p>
        <?
//$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;
$totale = $total0;
}	
?>
</p>
          <div id="module"> <font color="#FF6600">
            <?
if( $kirim == "submit") {
	$db->select("rp", "transfer", "userid='$user_session'");
	$tp = 0;
	$sql = mysql_query("select rp from transfer where userid='$user_session'");
	$hit = mysql_num_rows($sql);
	while($row=$db->fetch_row()) {
		$tp = $tp + $row[0];
	}
	if($komisi <= 5000) {
            warning("Maaf, komisi yang anda masukkan belum mencukupi untuk ditransfer!<br>Silahkan Ulangi lagi!<br>Komisi anda : ".rupiah($tarik)."");
            return false;
        }
	$pending = $totale - $tp;
	$kode = kwitansi();	
	if($komisi <= $pending) {
		if($tujuan == "E-walet") {
			$st = 1;
			$pesan = "Komisi Anda telah berhasil ditransfer ke akun E-walet Anda.";
			$tgbyr = $clientdate;
			$db->insert("dataewalet", "", "'', '$kode', 'admin-1', '$komisi', 'Transfer komisi', '$user_session', '$clientdate', 1"); 
			$db->insert("kwitansi", "", "'', '$kode', '$ket', '$clientdate'");
		} else {
			$st = 0;
			$pesan = "Permintaan penarikan komisi telah terkirim.";
		}	
	   if($komisi >= 5000 && $komisi <= $tarik) {
	   $feekomisi=(($komisi)*(95)/100);
		$db->insert("transfer", "", "'', '$user_session', '$clientdate', '$tgbyr', '$komisi', $st, '$tujuan', '$kode'");
		echo "<p align=center><b>$pesan</b></p>"; 
	   } else {
		// Insert your code for showing an error message here
		//echo "<p align=center><font color="#FF6600"><b>Maaf, komisi anda belum mencukupi untuk ditransfer atau angka yang anda masukkan melebihi jumlah komisi anda!</font>";
			warning("Maaf, komisi yang anda masukkan belum mencukupi untuk ditransfer!<br>Silahkan Ulangi lagi!<br>Komisi anda : ".rupiah($tarik)."");
			
	?>
          </font> </div>
          <form action="" method="post" name="form1" id="form1">
            <table width="535" border="0" align="center" cellpadding="2" cellspacing="0">
              <tr>
                <td align="right"><div align="center" class="style8"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong>Masukkan jumlah komisi yang akan diminta : </strong></font><font size="2" face="Arial, Helvetica, sans-serif"><br />
                        <span class="style6"><strong>Minimum Withdrawl (Rp 5.000)</strong></span></font><br />
                        <span class="style16">Masukkan nominal diatas 5000, misal 5500 </span></div></td>
              </tr>
              <tr>
                <td align="right"><div align="center"> <font size="2" face="Arial, Helvetica, sans-serif">
                    <input name="komisi" type="text" id="komisi" size="20" />
                    <input name="kirim" type="hidden" id="kirim" value="submit" size="10" />
                    <em style="font-size:10px"><br>
                </em></font></div></td>
              </tr>
              <tr>
                <td align="right"><div align="center" class="style5">
                    <p><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">(tanpa tanda titik, misal 5000) </font></p>
                </div></td>
              </tr>
              <tr>
                <td align="right"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
              </tr>
              <tr>
                <td align="right"><div align="center" class="style8"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"><strong>Komisi tersebut ditransfer ke :</strong></font></div></td>
              </tr>
              <tr>
                <td align="right"><font size="2" face="Arial, Helvetica, sans-serif">
                  <label> </label>
                  </font>
                    <div align="center"> <font size="2" face="Arial, Helvetica, sans-serif">
                      <select name="tujuan" id="tujuan">
                        <option value="bank" selected><?= $db->dataku("bank",$user_session)?></option>
                        <option>E-walet</option>
                      </select>
                  </font></div></td>
              </tr>
              <tr>
                <td align="center"><div align="center"><font size="2"><font face="Verdana, Arial, Helvetica, sans-serif"><font face="Arial, Helvetica, sans-serif"></font></font></font></div>
                    <font size="2" face="Arial, Helvetica, sans-serif">
                    <input type="submit" name="Submit" value="KIRIMKAN KOMISI SAYA" class="tombol" />
                  </font></td>
              </tr>
            </table>
          </form>
          <p>
            <?		
		}		
   } else {
   		$err = 1;
		$error = "<p align=center  style='color:#FF6600'><b>Maaf, komisi yang anda minta melebihi jumlah komisi yang dimiliki atau Anda telah melakukan penarikan komisi dan saat ini statusnya Pending!</b></font></p>";
	}	
} else {


?>
</p>
          <table width="535" border="0" align="center" cellpadding="2" cellspacing="1">
            <tr>
              <td height="25" align="center"><span style="color:#333333;"><strong><font size="2" face="tahoma,verdana,arial,helvetica,sans-serif">TOTAL KOMISI ANDA SAAT INI</font></strong></span></td>
            </tr>
          </table>
          <div align="center"> </div>
          <table width="200" border="0" align="center" cellpadding="2" cellspacing="1">
            <tr>
              <td height="25" align="center" bordercolor="#FFFFFF" bgcolor="#FF9933"><font color="#FF9900"><span style="color:#000000;"><strong><font color="#000000"><span style="color:#;"><strong>
                <?= rupiah($tarik); ?>
              </strong></span></font><font size="3"></font> </strong></span></font></td>
            </tr>
          </table>
          <div id="totkom">
            <div align="center"></div>
          </div>          
          <form action="" method="post" name="form1" id="form1">
            <table width="535" border="0" align="center" cellpadding="2" cellspacing="0">
              <tr>
                <td align="right"><div align="center">
                    <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Masukkan jumlah komisi yang akan diminta : </strong><br />
                            <span class="style6"><strong>Minimum Withdrawl (Rp 5.000)<br />
                            <span class="style16">Masukkan nominal diatas 5000, misal 5500</span></strong></span></font></p>
                </div></td>
              </tr>
              <tr>
                <td align="right"><div align="center"> <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                    <input name="komisi" type="text" id="komisi" size="20" />
                    <input name="kirim" type="hidden" id="kirim" value="submit" size="10" />
                </font></div></td>
              </tr>
              <tr>
                <td align="right"><div align="center" class="style5">
                    <p><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">(tanpa tanda baca, misal 5000) </font></p>
                </div></td>
              </tr>
              <tr>
                <td align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
              </tr>
              <tr>
                <td align="right"><div align="center" class="style8"><font color="#333333" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Komisi tersebut ditransfer ke :</strong></font></div></td>
              </tr>
              <tr>
                <td align="right"><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                  <label>
                          <select name="tujuan" id="tujuan">
                            <option value="Rekening Bank" selected><?= $db->dataku("bank",$user_session)?></option>
                            <option>E-walet</option>
                          </select>
                  </label>
                </font></div></td>
              </tr>
              <tr>
                <td align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
              </tr>
              <tr>
                <td align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
                  <input type="submit" name="Submit" value="KIRIMKAN KOMISI SAYA" class="tombol" />
                </font></td>
              </tr>
              <tr>
                <td align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
              </tr>
              <tr>
                <td align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
              </tr>
            </table>
          </form>          <p>
            <?
 }
 	if($err == 1) echo $error;
 ?>
          </p>
          <h2 align="center"><font color="#FF6633">WITHDRAWL HISTORY</font> </h2>
          <table width="100%" border="1" align="center" cellpadding="1" cellspacing="0">
            <tr class="tbl_header">
              <td width="5%" align="center"><span class="style14">NO.</span></td>
              <td width="16%" align="center"><span class="style14">TGL</span></td>
              <td width="16%" align="center"><span class="style14">JUMLAH</span></td>
              <td width="21%" align="center"><span class="style14">TRANSFER KE</span></td>
              <td width="16%" align="center"><span class="style14">STATUS</span></td>
            </tr>
            <?
$db->select("tglminta, rp, status, tglbayar, tujuan", "transfer", "userid='$user_session'", "tglbayar");
$nom=1;
while($row=$db->fetch_row()) {
	if(is_odd($nom) > 0) {
		$class = "tblrow_ganjil";
	} else {
		$class = "tblrow_genap";
	} 
	if($row[2] > 0) {
		$status = "<b>Sukses</b>";
	} else {
		$status = "Pending";
	}			
	echo "<tr class=$class>
       <td class='style6' align=center>$nom.</td>
       <td class='style6' align=center>".date("d-m-Y", strtotime($row[0]))."</td>
       <td class='style6' align=center>".rupiah($row[1])."</td>
       <td class='style6' align=center>$row[4]</td>
	    <td class='style6' align=center>$status</td>
     </tr>";
	 $nom++;
}	 
?>
      </table>          
          <p>&nbsp; </p></td>
      <td width="10">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>
</div>
<div class="cc01">
<div id="module">
  <p>
    <?
} else {
echo "<meta http-equiv=\"refresh\" content=\"1; url=illegal.html\">";
}
?>
    <script language="JavaScript" type="text/javascript">
 var frmvalidator = new Validator("form1");
  frmvalidator.addValidation("komisi","req","Berapa jumlah komisi yang anda minta?");
   </script>
  </p>
  <script language="JavaScript" type="text/javascript">
 var frmvalidator = new Validator("form1");
  frmvalidator.addValidation("komisi","req","Berapa jumlah komisi yang anda minta?");
   </script>
</div>
</div>
