<?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=deposit&page=delete&no=" + noid;
		
	}
	
}
//-->
</script>
<h2><img src="images/icon-48-user.png" width="48" height="48" align="absmiddle" /> E-Walet Add 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="9%"><strong>Tanggal</strong></td>
	<td width="8%"><strong>Kode Transaksi</strong></td>
    <td width="12%"><strong>Username</strong></td>
    <td width="12%"><strong>Nama</strong></td>
    <td width="13%"><strong>Jumlah Deposit </strong></td>
    <td width="7%"><strong>Status</strong></td>
	 <td width="12%"><strong>Tanggal Proses</strong></td>
    <td width="6%"><strong>Del</strong></td>
  </tr>
    <script>
		function confirmActionx1(){
      var confirmed = confirm("Yakin akan proses buy balance ini?");
      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 dataewalet2 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[7] > 0) {
		$img = "<a href='?go=deposit&page=unpublish&pub=0&no=$row[0]&mid=$row[2]&kode=$row[1]'><button class='primadetail' style='padding:0px 7px;font-size:11px;' onMouseover=\"ddrivetip('Proses Buy Balance')\" onMouseout='hideddrivetip()' onclick='return confirmActionx1()'>Process</button></a>";
	} else {
		$img = "<a href='?go=deposit&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('Proses Buy Balance')\" onMouseout='hideddrivetip()' onclick='return confirmActionx1()'>Pending</button></a>";
	}
	
	if(!$row[9] || $row[9] == "0000-00-00 00:00:00"){
		$dtpros = "---";
	}else{
		$dtpros = formatgl($row[9]);
	}
		
?>
  <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[6]); ?>
    </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 bordercolor="#999999" bgcolor="#FFFFFF"> 
      <div align="center">
        <?php echo $db->dataku("nama", $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>
    
    <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-buywalet&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 dataewalet2");
$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=deposit&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=deposit&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=deposit&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("dataewalet2", "status='$pub', tglproses='$clientdate'", "id='$no'");
		$username = $mid;
		
		$query35 = "SELECT * FROM dataewalet2 WHERE kode='$kode'"; 
$result35 = mysql_query($query35);
$row35 = mysql_fetch_array($result35);
$username = $row35['username'];
$jumlah = $row35['jumlah'];
$uraian = $row35['uraian'];
$tgle = $row35['tgl'];

$db->insert("dataewalet", "", "'', '$kode', 'administrator', '$jumlah', '', '$username', '$clientdate', 1, '$clientdate', 'administrator', '".$db->dataku("accid", $username)."'"); 
		
		$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
		$hp = $db->dataku("hp", $username);
		$emailadmin = $db->config("email");
		$keterangan = $uraian;
		$invne = rupiah($jumlah);
		$jumlahdepone = rupiah($jumlah);
		$jumlahdepone2 = rupiah($jumlah);
		
		
		$balance = $balances;
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");

//$isipesan = "".$nama.", pembelian 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) ;
	
///	 $isipesan2 = "".$nama.", anda mendapatkan tambahan saldo ".$jenis.", kode: ".$kode.", jumlah: ".$jumlahdepone.", pengirim: Administrator.";
//	mysql_query("insert into outbox values('', '".$kode."b', '".$username."', '$hp', '$isipesan2', '$clientdate', '1')") or die(mysql_error());
//	sendsms($hp, $isipesan2) ;
	
//$isipesan3 = "Sukses proses pembelian balance ".$jenis.", nama: ".$nama.", kode: ".$kode.", jumlah: ".rupiah($jumlahdepone).".";
//	sendsms($hpadmin, $isipesan3) ;



$isimail="<a href='http://".$domain."'><img src='".$logoinvoice."' style='display:inline;outline-style:none;text-decoration:none;' /></a><br><br><br>
<p>Helo ".$nama." (".$username."),</p>
<p>Your Add balance wallet has been processed.</p>
<p><strong>No: ".$kode."<br>
Amount: ".$jumlahdepone."<br>
Fee: -<br>
Add: ".$jumlahdepone."<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 Add balance wallet has been processed';
        $mail3->msgHTML($isimail);
	   // $mail3->AddAttachment("../invoice/".$invc.".pdf");      // attachment
        $mail3->send();	

		echo "<meta http-equiv='refresh' content='0;URL=?go=deposit'>";
?>
<?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 dataewalet2 WHERE kode='$kode'"; 
$result35 = mysql_query($query35);
$row35 = mysql_fetch_array($result35);
$username = $row35['username'];
$jenis = $row35['jenis'];

$jumlah = $row35['jumlah'];
$uraian = $row35['uraian'];
$tgle = $row35['tgl'];


$db->delete("dataewalet", "kode='$kode'");

		
			$db->update("dataewalet2", "status='$pub'", "id='$no'");
			
			 $bankexc1=$db->config("bank"); if($bankexc1){ 
			 $bccc1 = $bankexc1."<br>"; }else{ $bccc1 = "";}
			 $bankexc2=$db->config("bank1"); if($bankexc2){ 
			 $bccc2 = $bankexc2."<br>"; }else{ $bccc2 = "";}
			 $bankexc3=$db->config("bank2", $exchange); if($bankexc3){ 
			 $bccc3 = $bankexc3."<br>"; }else{ $bccc3 = "";}
			 $bankexc4=$db->config("bank3", $exchange); if($bankexc4){ 
			 $bccc4 = $bankexc4."<br>"; }else{ $bccc4 = "";}
			
	$nama = $db->dataku("nama", $username);
		$email = $db->dataku("email", $username);
		$hp = $db->dataku("hp", $username);
		$emailadmin = $db->config("email");
		$keterangan = $uraian;
		$invne = rupiah($jumlah);
		$jumlahdepone = rupiah($jumlah);
		
		
		$balance = $balances;
		$tgl = formatgl($clientdate);
		$waktu = date("H:i:s");


//$isipesan = "".$nama.", pembelian 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 pembelian balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$kode.", user: ".$username." diubah pending.";
//	sendsms($hpadmin, $isipesan2) ;



			
			
			echo "<meta http-equiv='refresh' content='0;URL=?go=deposit'>";





?>
<?php		
} if (isset($_GET['page']) && $_GET['page'] == "delete") {
if(isset($_GET["no"])){ $no = $_GET["no"]; }
		
$query35 = "SELECT * FROM dataewalet2 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.", pembelian 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 pembelian balance ".$jenis.", jumlah: ".$jumlahdepone.", kode: ".$kode.", user: ".$username." telah dihapus.";
//	sendsms($hpadmin, $isipesan2) ;
	
	
		$db->delete("dataewalet2", "kode='$no'");
		
	
		
		
		echo "<meta http-equiv='refresh' content='0;URL=?go=deposit'>";
?>
<?php
}
?>