<!DOCTYPE HTML>
<?php 
include('config.php');

if($_GET['post']!=1){

if($po_status==1){
	echo "<script>alert('Transaksi Sudah Di print');window.close()</script>";
	}
	$sql = "UPDATE poheader SET po_status = 1 WHERE po_autoid = '$autoid'";
	if (!$conn->query($sql) === TRUE) { echo "Error: " . $sql . "<br>" . $conn->error;return false;}	
}


$pagename = "Print Pembelian";
?>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo $pagename?></title>
    <?php include('../../common/script_css.php');?>
    <style>
        
        table tr td{font-size:18px !important ;}
    </style>
</head>
<body class="print_body">
<?php include('../../sys/navprint.php')?>

    <table class="table table-borderless" style="width:400px;">
    <tr>
    	<td colspan="4">No : <?php echo $transno?> - <?php echo dtostr($transdate)?></td>
    </tr>
    <tr>
    	<td colspan="4">Nama : <?php echo $supp_name?>
    	<br>
    	_______________________________________
    	</td>
    </tr>
     
    <tr class="bold">
    	<td style="width:100px;">Item</td>
        <td style="width:70px;" class="tr">Harga</td>
        <td style="width:50px;" class="tr">Qty</td>
        <td style="width:80px;" class="tr">Jumlah</td>
    </tr>
    <?php
	$subtotal = 0;
	$i = 0;
	
	$sqldetail = "SELECT * FROM podetail a, mst_product b 
				WHERE a.pm_autoid = b.pm_autoid AND a.po_autoid = '$autoid' ORDER BY a.pod_autoid";
	$detail_con = $conn->query($sqldetail) or die($sqldetail);
	while($rsd = $detail_con->fetch_assoc()){
		$pmdesc = $rsd['pm_name'];
	
		$qty = $rsd['pod_qty'];
		$pm_bprice = $rsd['pod_price'];


		$detail_subtotal = $qty * $pm_bprice;
	
		$pm_autoid = $rsd['pm_autoid'];
	?>
    <tr>
    	<td><?php echo $pmdesc?></td>
        <td class="tr"><?php echo number_format($pm_bprice)?></td>
        <td class="tr"><?php echo $qty?></td>
    	<td class="tr"><?php echo number_format($detail_subtotal)?></td>
    </tr>
    <?php 
	$subtotal =  $subtotal + $detail_subtotal;
	 } ?>
     <tr>
     	<td colspan="4">_______________________________________</td>
     </tr>
    <tr class="bold">
    	<td class="tr" colspan="3">Total</td>
    	<td class="tr"><?php echo number_format($subtotal)?></td>
    </tr>
    <tr>
        <td colspan="4"><p class="my-0"><?php echo date('d/m/Y h:i')?></p></td>
    </tr>
	</table>
	

</body>

</html>