<?php
(@include ('../dt_page/lic.php')) or die("<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>");
//$lic=$license;if(!$lic){echo "<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>";}$svr=$_SERVER['SERVER_NAME'];$c=curl_init();curl_setopt($c,CURLOPT_URL,"http://www.primadesain.com/verifylicenses.php");curl_setopt($c,CURLOPT_TIMEOUT,30);curl_setopt($c,CURLOPT_POST,1);curl_setopt($c,CURLOPT_RETURNTRANSFER,1);$postfields='svr='.$svr.'&lic='.$lic;curl_setopt($c,CURLOPT_POSTFIELDS,$postfields);$result=curl_exec($c);if($result=="fail"){echo "<script>alert(\"You not have a license to use this script on this domain, Please contact www.primadesain.com to purchase a license.\");"."window.location = './index.php'</script>";die();}
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();} 
?>
<?php
if (empty($_SESSION["valid_admin"])){
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();}
?>
<script type="text/javascript">
<!--
function confirmation(noid) {
	var answer = confirm("Yakin akan menghapus data transaksi ini?")
	if (answer){
		//alert("Bye bye!")
		window.location = "?go=sellwallet&page=delete&no=" + noid;
		
	}
	
}
//-->
</script>
<h2><img src="images/icon-48-user.png" width="48" height="48" align="absmiddle" /> E-Walet Sell Balance</h2>
<p align="center">&nbsp;</p>
<p align="center"><font color="#FF0000"></font></p>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#EEEEEE">
  <tr align="center"> 
    <td width="6%"><strong>No.</strong></td>
    <td width="15%"><strong>Tanggal</strong></td>
	<td width="8%"><strong>Kode</strong></td>
    <td width="8%"><strong>Username</strong></td>
    <td width="10%"><strong>Jumlah</strong></td>
    <td width="7%"><strong>Status</strong></td>
	 <td width="15%"><strong>Tanggal Proses</strong></td>
    <td width="5%"><strong>Del</strong></td>
    <td width="5%"><strong>Detail</strong></td>
  </tr>
  <script>
		function confirmActionx1(){
      var confirmed = confirm("Yakin akan lakukan proses?");
      return confirmed;
}
</script>
  <script>
		function confirmActionx2(){
      var confirmed = confirm("Yakin akan lakukan pembatalan proses?");
      return confirmed;
}
</script>
<?php
$batas   = 25;
if(isset($_GET['halaman'])) { $halaman = anti_injection($_GET['halaman']); } 
if(empty($halaman)){
	$posisi  = 0;
	$halaman = 1;
}
else{
	$posisi = ($halaman-1) * $batas;
} 
$sql = mysql_query("select * from dataewalet2b order by id desc LIMIT $posisi,$batas");
$nom = 1;
while($row=mysql_fetch_row($sql)) {
if(is_odd($nom) == 0) {
		$class = "tblrow_ganjil";
	} else {
		$class = "tblrow_genap";
	}
if($row[9] > 0) {
		$img = "<a href='?go=sellwallet&page=publish&pub=0&no=$row[0]&mid=$row[2]&kode=$row[1]'><button class='primadetail' style='padding:0px 7px;font-size:11px;' onMouseover=\"ddrivetip('Klik disini untuk batalkan proses')\" onMouseout='hideddrivetip()' onclick='return confirmActionx2()'>Proses</button></a>";
	} else {
		$img = "<a href='?go=sellwallet&page=publish&pub=1&no=$row[0]&mid=$row[2]&kode=$row[1]'><button class='primaback' style='padding:0px 7px;font-size:11px;' onMouseover=\"ddrivetip('Klik disini untuk proses order')\" onMouseout='hideddrivetip()' onclick='return confirmActionx1()'>Pending</button></a>";
	}
	if($row[11] == "0000-00-00 00:00:00"){
		$dtpros = "---";
	}else{
		$dtpros = formatgl($row[11]);
	}
		
?> 
  <tr  class="<?php echo $class; ?>" > 
    <td align="right" bordercolor="#999999" bgcolor="#FFFFFF"> 
      <div align="center">
        <?php echo $nom; ?>
    </div></td>
    <td bordercolor="#999999" bgcolor="#FFFFFF"> 
      <div align="center">
        <?php echo formatgl($row[8]); ?>
    </div></td>
    <td bordercolor="#999999" bgcolor="#FFFFFF" > 
      <div align="center">
        <?php echo $row[1]; ?>
    </div></td>
     
   <td bordercolor="#999999" bgcolor="#FFFFFF"> 
      <div align="center">
        <?php echo $row[2]; ?>
    </div></td>
   
   
    <td align="center" bordercolor="#999999" bgcolor="#FFFFFF"> 
      <?php echo rupiah($row[3]); ?>    </td>
      
    <td align="center" bordercolor="#999999" bgcolor="#FFFFFF" ><?php echo $img; ?></td>
	 <td align="center" bordercolor="#999999" bgcolor="#FFFFFF" ><?php echo $dtpros; ?></td>
     <?php $sqlc = mysql_query("SELECT * FROM invoice WHERE kode='".$row[1]."'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$inv = $rowc['file']; 
   ?>
    
    <td align="center" bordercolor="#999999" bgcolor="#FFFFFF" ><a href="#" onClick="confirmation('<?php echo $row[1]; ?>', 'delete', 'delete')" style='cursor:hand'><img src="images/icon-32-delete_resize.png" width="17" height="22" border="0" title="Delete this Transaction" /></a></td>
    <td align="center"><font style="color:#555555"><a class='iframe7' href='page.php?go=detail-sellwalet&kode=<?php echo $row[1]; ?>'><img src="../images/view.png" title="Detail Order" width="17" /></a></font></td>
  </tr>
<?php
 $nom++;
 }
 ?>
</table>
<P>&nbsp;</P>
<?php
//Langkah 3: Hitung total data dan halaman 
$tampil2 = mysql_query("SELECT * FROM dataewalet2b");
$jmldata = mysql_num_rows($tampil2);
$jmlhal  = ceil($jmldata/$batas);
if($jmldata > 25){
echo "<div class=paging>";
// Link ke halaman sebelumnya (previous)
if($halaman > 1){
	$prev=$halaman-1;
	echo "<span class=prevnext><a href=?go=sellwallet&halaman=$prev>Prev</a></span> ";
}
else{ 
	echo "<span class=disabled>Prev</span> ";
}

// Tampilkan link halaman 1,2,3 ...
for($i=1;$i<=$jmlhal;$i++)
if ($i != $halaman){
	echo " <a href=?go=sellwallet&halaman=$i>$i</a> ";
}
else{
	echo " <span class=current>$i</span> ";
}

// Link kehalaman berikutnya (Next)
if($halaman < $jmlhal){
	$next=$halaman+1;
	echo "<span class=prevnext><a href=?go=sellwallet&halaman=$next>Next</a></span>";
}
else{ 
	echo "<span class=disabled>Next</span>";
}
echo "</div>";
echo "<br>";
echo "<p align=center>Total : <b>$jmldata</b> Deposit</p>";
}
?>
<?php
if (isset($_GET['page']) && $_GET['page'] == "publish") {
if(isset($_GET["no"])){ $no = $_GET["no"]; }
if(isset($_GET["pub"])){ $pub = $_GET["pub"]; }
if(isset($_GET["mid"])){ $mid = $_GET["mid"]; }
if(isset($_GET["kode"])){ $kode = $_GET["kode"]; }
			
		$db->update("dataewalet2b", "status='$pub', tglproses='$clientdate'", "id='$no'");
		$username = $mid;
		
		$query35 = "SELECT * FROM dataewalet2b WHERE kode='$kode'"; 
$result35 = mysql_query($query35);
$row35 = mysql_fetch_array($result35);
$username = $row35['username'];
$jumlah = $row35['jumlah'];
$jenis = $row35['jenis'];
$uraian = $row35['uraian'];
$jml_fee = $row35['fee'];
$tgle = $row35['tgl'];
$jml_byr = $row35['jumlahnet'];
$jmlrp = idr($jml_byr*$kurse);

$uraian1 = "Saldo E-wallet";
$balances = $db->myewalet($username);
$db->update("dataewalet", "status='1', tglproses='$clientdate'", "kode='$kode'");
			
		$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
		$hp = $db->dataku("hp", $username);
		$emailadmin = $db->config("email");
		$keterangan = $uraian;
		$invne = rupiah($jumlah);
		$tgl = formatgl($clientdate);
		$jumlahdepone = rupiah($jumlah);
		$jumlahdepone2 = rupiah($jumlah);
		
		
		$balance = $balances;
		$waktu = date("H:i:s");


//$isipesan = "".$nama.", penjualan balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$kode.", sudah di proses.";
//	mysql_query("insert into outbox values('', '$kode', '".$username."', '$hp', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//	sendsms($hp, $isipesan) ;
	
	
//$isipesan3 = "Sukses proses penjualan balance ".$jenis.", nama: ".$nama.", kode: ".$kode.", jumlah: ".rupiah($jumlahdepone).".";
	//sendsms($hpadmin, $isipesan3) ;


$isipesan = "Hello ".$nama.", Your withdrawal, amount ".$jumlahdepone." has been processed.";
	mysql_query("insert into outbox values('', '', '$username', '$hp', '$isipesan', '$clientdate', '1')") or die(mysql_error());
	if($smsgtw == 1 && $jsms == 1){
	$hpne = preg_replace('/\D+/', '', $hp);
	$sms = new smsreguler();
	$sms->username = $userkey;
		$sms->password = $passkey;
		$sms->apikey   = $apikey;
		$sms->setTo($hpne);
		$sms->setText($isipesan);
		$sms->smssend();
	}else if($smsgtw == 1 && $jsms == 2){
	$hpne = preg_replace('/\D+/', '', $hp);
	$sms = new smsmasking();
	$sms->username = $userkey;
		$sms->password = $passkey;
		$sms->apikey   = $apikey;
		$sms->setTo($hpne);
		$sms->setText($isipesan);
		$sms->smssend();
	}else if($smsgtw == 2){
	sendsms($hp, $isipesan) ;
	}else{}

$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Hello ".$nama." (".$username."),</p>
<p>Your Withdrawal has been processed.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee: ".$jml_fee."<br>
Transferred: ".$jml_byr."<br>
Date: ".$tgl."<br>
</p>
<p><br><br><br>
Regards,<br>
<b>".$bisnisname."</b><br>
".$domain."<br>".$emailadmin."<br>".$hpadmin."</p>";
	   
	    $mail3 = new PHPMailer;
        $mail3->setFrom($emailadmin, $bisnisname);
        $mail3->addAddress($email, $nama);
	    $mail3->IsHTML(true);       
        $mail3->Subject = ''.$nama.', Your Withdrawal has been processed';
        $mail3->msgHTML($isimail);
	   // $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	


		echo "<meta http-equiv='refresh' content='0;URL=?go=sellwallet'>";
?>
<?php		
} if (isset($_GET['page']) && $_GET['page'] == "unpublish") {
if(isset($_GET["no"])){ $no = $_GET["no"]; }
if(isset($_GET["pub"])){ $pub = $_GET["pub"]; }
if(isset($_GET["mid"])){ $mid = $_GET["mid"]; }
if(isset($_GET["kode"])){ $kode = $_GET["kode"]; }


$query35 = "SELECT * FROM dataewalet2b WHERE kode='$kode'"; 
$result35 = mysql_query($query35);
$row35 = mysql_fetch_array($result35);

$username = $row35['username'];
$jumlah = $row35['jumlah'];
$jenis = $row35['jenis'];
$uraian = $row35['uraian'];
$jml_fee = $row35['fee'];
$jml_byr = $row35['jumlahnet'];
$tgle = $row35['tgl'];
$jmldollar = dolar($jml_byr*$kurse_jual_us);
$jmlrp = idr($jml_byr*$kurse_jual_idr);


$uraian1 = "Saldo E-wallet";
$db->update("dataewalet", "status='0', tglproses=''", "kode='$kode'");
	


			$db->update("dataewalet2b", "status='$pub'", "id='$no'");
			
			
			$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
		$hp = $db->dataku("hp", $username);
		$emailadmin = $db->config("email");
		$keterangan = $uraian;
		$invne = rupiah($jumlah);
		$tgl = formatgl($clientdate);
		$jumlahdepone = rupiah($jumlah);
		$jumlahdepone2 = rupiah($jumlah);
		
		
		$balance = $balances;
		$waktu = date("H:i:s");


//$isipesan = "".$nama.", penjualan balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$kode.", status pending.";
	//mysql_query("insert into outbox values('', '$kode', '".$username."', '$hp', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//	sendsms($hp, $isipesan) ;
//	
//	$isipesan2 = "Status penjualan balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$kode.", user: ".$username." diubah pending.";
//	sendsms($hpadmin, $isipesan2) ;
	
	
			
			echo "<meta http-equiv='refresh' content='0;URL=?go=sellwallet'>";
?>
<?php		
} if (isset($_GET['page']) && $_GET['page'] == "delete") {
if(isset($_GET["no"])){ $no = $_GET["no"]; }
		
$query35 = "SELECT * FROM dataewalet2b WHERE kode='$no'"; 
$result35 = mysql_query($query35);
$row35 = mysql_fetch_array($result35);
$username = $row35['username'];
$jenis = $row35['jenis'];
$jumlah = $row35['jumlah'];
$jumlahdepone = rupiah($jumlah);



$db->delete("dataewalet", "kode='$no'");
	$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
		$hp = $db->dataku("hp", $username);
				
//$isipesan = "".$nama.", penjualan balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$no.", telah dibatalkan.";
//	mysql_query("insert into outbox values('', '$no', '".$username."', '$hp', '$isipesan', '$clientdate', '1')") or die(mysql_error());
//	sendsms($hp, $isipesan) ;	

		
//	$isipesan2 = "Status penjualan balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$kode.", user: ".$username." telah dihapus.";
//	sendsms($hpadmin, $isipesan2) ;
	
		$db->delete("dataewalet2b", "kode='$no'");
			
		
		echo "<meta http-equiv='refresh' content='0;URL=?go=sellwallet'>";
?>
<?php
}
?>