<?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");
$exe0 = mysqli_query($conn,"SELECT * FROM produk where kode = '$jenis'");

while($record = mysqli_fetch_array($exe0)){
    $nominal=$record['nominal']*1000;  
}
  
$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);
    
	$ref=$para[0];
    $nama=$para[1];
    $tarif=$para[2];
    $daya=$para[3];
    $ippn=0;
    $ippj=0;
    $kwh=$para[4];
    $admin = number_format($iadmin,2,",",".");
   if ($kwh=='0')
    {
        $ippn=str_replace('.','',$para[4]);
        $ippj=str_replace('.','',$para[5]);
        $kwh=$para[6];
    }
    $ppn = number_format($ippn,2,",",".");
    $ppj = number_format($ippj,2,",",".");
	$irptoken=number_format($nominal-$ippn-$ippj,2,",",".");
    $irpbayartoken=number_format($nominal+$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="token1.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
<table style="position:absolute;left:100px;top:61px;width:708px;height:127px;z-index:0;" cellpadding="0" cellspacing="1" id="Table1">
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:108px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">TANGGAL</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:296px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: <?php echo $tanggal ?></span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:132px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">ADMIN BANK</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:62px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: Rp</span></div>
</td>
<td style="background-color:transparent;text-align:right;vertical-align:top;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;"><?php echo $admin ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:108px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">NO METER</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:296px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: <?php echo $idpel ?></span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:132px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">MATERAI</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:62px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: Rp</span></div>
</td>
<td style="background-color:transparent;text-align:right;vertical-align:top;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">0,00</span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:108px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">NAMA</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:296px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: <?php echo $nama ?></span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:132px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">PPN</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:62px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: Rp</span></div>
</td>
<td style="background-color:transparent;text-align:right;vertical-align:top;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;"><?php echo $ppn ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:108px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">TARIF</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:296px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: <?php echo $tarif ?></span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:132px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">PPJ</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:62px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: Rp</span></div>
</td>
<td style="background-color:transparent;text-align:right;vertical-align:top;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;"><?php echo $ppj ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:108px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">DAYA</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:296px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: <?php echo $daya ?></span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:132px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">RP TOKEN</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:62px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: Rp</span></div>
</td>
<td style="background-color:transparent;text-align:right;vertical-align:top;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;"><?php echo $irptoken ?></span></div>
</td>
</tr>
<tr>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:108px;height:22px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">RP BAYAR</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:296px;height:22px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">: Rp&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <?php echo $irpbayartoken ?></span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:132px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">JML KWH</span></div>
</td>
<td style="background-color:transparent;text-align:left;vertical-align:top;width:62px;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;">:</span></div>
</td>
<td style="background-color:transparent;text-align:right;vertical-align:top;height:20px;"><div><span style="color:#000000;font-family:'Courier New';font-size:16px;"><?php echo $kwh ?></span></div>
</td>
</tr>

</table>
<div id="wb_Text1" style="position:absolute;left:100px;top:3px;width:718px;height:31px;z-index:1;text-align:left;">
<span style="color:#000000;font-family:'Courier New';font-size:27px;"><strong>STRUK BUKTI PEMBELIAN PLN PRABAYAR</strong></span></div>
<div id="wb_Text2" style="position:absolute;left:85px;top:253px;width:738px;height:51px;text-align:center;z-index:2;">
<span style="color:#000000;font-family:'Courier New';font-size:15px;">TERIMA KASIH<br>&quot;Rincian tagihan dapat dilihat di www.pln.co.id atau PLN terdekat&quot;<br>INFORMASI HUB: 123<br><br><hr></span></div>

<div id="wb_Text3" style="position:absolute;left:100px;top:204px;width:614px;height:31px;z-index:3;text-align:left;">
<span style="color:#000000;font-family:'Courier New';font-size:27px;"><strong>TOKEN: <?php echo $ref ?></strong></span></div>
</div>
</body>
</html>
<body onload="window.print()">
