<?php
require_once("conn.php");

$idpel=$_GET['idpel'];
$tanggal=$_GET['tanggal'];
$jenis=$_GET['jenis'];
$iadmin=$_GET['admin'];

$conn=mysqli_connect("$host","$user","$pass") or die("koneksi gagal");
mysqli_select_db($conn,"$db");
$exe = mysqli_query($conn,"SELECT * FROM transaksi where kode_produk = '$jenis' and tujuan= '$idpel' and tanggal= '$tanggal' order by kode asc");

while($record = mysqli_fetch_array($exe)){
                       
	$sn = $record['sn'];   
    $para = explode('/',$sn);
    
    if (strpos(strtoupper($sn),"REF:")==0)
    {
        $ref=idate("U");
    }
    else
    {
         $ref=substr($para[9],4);
    }
    
    $nama=substr($para[0],5);
    $tarif=substr($para[3],3);
    $daya=$para[4];
    $bulan=substr($para[1],5);
   //$bulan=$para[2];
    $meter=substr($para[5],3);
    
    //$iadmin=substr($para[3],3);
    $admin = number_format($iadmin,2,",",".");
    
    $itagihan = substr($para[6],4);
	$tagihan = number_format($itagihan,2,",",".");
	
    $ippn=0;
    $ppn = number_format($ippn,2,",",".");
	
    $ippj=0;
    $ppj = number_format($ippj,2,",",".");

    $irptoken=number_format($nominal-$ippn-$ippj,2,",",".");
    $irpbayartoken=number_format($nominal+$iadmin,2,",",".");
    $irpbayartagihan=number_format($itagihan+$iadmin,2,",",".");
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cetak Struk</title>
<meta name="generator" content="WYSIWYG Web Builder 10 - http://www.wysiwygwebbuilder.com">
<link href="Untitled1.css" rel="stylesheet" type="text/css">
<link href="pasca2.css" rel="stylesheet" type="text/css">
</head>
<body>
<table style="position:absolute;left:0px;top:42px;width:266px;height:172px;z-index:0;" cellpadding="0" cellspacing="1" id="Table1">
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">TANGGAL</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo $tanggal ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">IDPEL</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo $idpel ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">NAMA</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo $nama ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">TARIF/DAYA</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo $tarif ?>/<?php echo $daya ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">BLN/TH</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo $bulan ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">ST. METER</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo $meter ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">RP TAG PLN</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: Rp <?php echo $tagihan ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">ADMIN BANK</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: Rp <?php echo $admin ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">RP BAYAR</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: Rp <?php echo $irpbayartagihan ?></span></div>
</td>
</tr>

<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:80px;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">REF</span></div>
</td>
<td colspan="2" style="background-color:transparent;text-align:left;vertical-align:top;height:18px;"><div><span style="color:#000000;font-family:'Arial';font-size:14px;">: <?php echo wordwrap($ref,20,"\n",true) ?></span></div>
</td>
</tr>

</table>
<div id="wb_Text1" style="position:absolute;left:0px;top:0px;width:250px;height:28px;z-index:1;text-align:center;">
<span style="color:#000000;font-family:'Arial';font-size:14px;"><strong>STRUK BUKTI PEMBAYARAN<br>TAGIHAN LISTRIK</strong></span></div>
<div id="wb_Text2" style="position:absolute;left:1px;top:259px;width:249px;height:56px;text-align:center;z-index:2;">
<span style="color:#000000;font-family:'Arial';font-size:14px;">TERIMA KASIH<br>Rincian tagihan dapat dilihat di www.pln.co.id<br>INFORMASI HUB: 123</span></div>

</body>
</html>
<!--<script>
document.onreadystatechange = function() {
  if (document.readyState === 'complete') alert("otomax:print");
}
</script>-->