<?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=transwallet&page=delete&no=" + noid;
		
	}
	
}
//-->
</script>
<h2><img src="images/icon-48-user.png" width="48" height="48" align="absmiddle" /> E-Walet Transfer Balance</h2>
<p align="center">&nbsp;</p>

<?php		
if (isset($_GET['page']) && $_GET['page'] == "delete") {
if(isset($_GET["no"])){ $no = $_GET["no"]; }
		
$query35 = "SELECT * FROM dataewalet2c 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'");
				
//$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("dataewalet2c", "kode='$no'");
		
		
$sqlc = mysql_query("SELECT * FROM invoice WHERE kode='$no'");
$numc = mysql_num_rows($sqlc);
$rowc = mysql_fetch_array($sqlc);
$inv = $rowc['file'];
unlink("../invoice/$inv.pdf");	
		$db->delete("invoice", "kode='$no'");			
		
		echo "<meta http-equiv='refresh' content='0;URL=?go=transwallet'>";
?>
<?php } else { ?>
<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="8%"><strong>Tujuan</strong></td>
    <td width="7%"><strong>Status</strong></td>
	 <td width="5%"><strong>Invoice</strong></td>
	 <td width="5%"><strong>Dell</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 dataewalet2c 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 = "<span class='badge badge-success'>Success</span>";
	} else {
		$img = "<span class='badge badge-important'>Pending</span>";
	}
	
		
?> 
  <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 align="center" bordercolor="#999999" bgcolor="#FFFFFF"> 
      <?php echo rupiah($row[3]); ?>    </td>
      
    <td align="center" bordercolor="#999999" bgcolor="#FFFFFF" > <?php echo $row[5]; ?></td>
	 <td align="center" bordercolor="#999999" bgcolor="#FFFFFF" ><?php echo $img; ?></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"><a href='../invoice/<?php echo $inv;?>.pdf' download='<?php echo $inv;?>.pdf'><img src='../images/pdf16.png' border='0' /></a></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="Cancel this Transaction" /></a></td>  
  </tr>
<?php
 $nom++;
 }
 ?>
</table>
<P>&nbsp;</P>
<?php
//Langkah 3: Hitung total data dan halaman 
$tampil2 = mysql_query("SELECT * FROM dataewalet2c");
$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=transwallet&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=transwallet&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=transwallet&halaman=$next>Next</a></span>";
}
else{ 
	echo "<span class=disabled>Next</span>";
}
echo "</div>";

}
?>


<?php
}
?>