<html>
<head>
    <title><?php echo @$title ?></title>
    <style type="text/css">
    body {
        font-family: tahoma;
        font-size: 8pt;
    }
    hr { 
        display: block;
        margin-top: 0.5em;
        margin-bottom: 0.5em;
        margin-left: auto;
        margin-right: auto;
        border-style: inset;
        border-width: 1px;
    } 
    .container {
        padding: 10px 15px 10px 15px;
        aspect-ratio: 100 / 29;
    }
    .tabelku {
        width: 100%;
        font-size: 8pt;
        font-family: calibri; 
        border-collapse: collapse;
    }
    .tabelku  td {
        padding-left:5px;
        border-bottom: 1px double black;
    }
    </style>
</head>
<body class="struk" onload="printOut()">
<center>
    <h2>STOK OPNAME</h2>
</center>
<div class="container">
    <table border="0" width="100%">
    <tr>
        <td  width="35%">Tanggal Stok Opname</td>
        <td width="2%">:</td>
        <td><?php echo @$tanggal ?></td>
    </tr>
    <tr>
        <td>Pelaksana</td>
        <td>:</td>
        <td><?php echo @$pegawai ?></td>
    </tr>
    <table>
    <hr>
    <table class="tabelku" border="0">
    <thead>
    <tr>
        <th width="4%">No.</th>
        <th>Kode Barang</th>
        <th>Nama Barang</th>
        <th>Satuan</th>
        <th>Stok Sistem</th>
        <th>Stok Fisik</th>
        <th>Selisih</th>
        <th>Selisih HPP</th>
    </tr>
    </thead>
    <tbody>
    <?php
    $no=1;
    $jumstok=0;
    $jumnyata=0;
    $jumselisih=0;
    $jumhpp=0;
    foreach ($databarang as $hasil) {
        $selisih=$hasil->stok_nyata-$hasil->stok;
        $hppselisih=($hasil->stok_nyata*$hasil->harga_beli)-($hasil->stok*$hasil->harga_beli);
        ?>
        <tr>
            <td><?php echo $no ?></td>
            <td><?php echo $hasil->kode_barang ?></td>
            <td><?php echo $hasil->barang ?></td>
            <td><?php echo $hasil->satuan ?></td>
            <td align="center"><?php echo $hasil->stok ?></td>
            <td align="center"><?php echo $hasil->stok_nyata ?></td>
            <td align="center"><?php echo $selisih ?></td>
            <td align="right"><?php echo number_format($hppselisih,0,',','.') ?></td>
        </tr>
        <?php
        $no++;
        $jumstok=$jumstok+$hasil->stok;
        $jumnyata=$jumnyata+$hasil->stok_nyata;
        $jumselisih=$jumselisih+$selisih;
        $jumhpp=$jumhpp+$hppselisih;
    }
    ?>
    </tbody>
    <tr>
        <th colspan="4">Jumlah</th>
        <th><?php echo $jumstok ?></th>
        <th><?php echo $jumnyata ?></th>
        <th><?php echo $jumselisih ?></th>
        <th style="text-align: right;"><?php echo number_format($jumhpp,0,',','.') ?></th>
    </tr>
    </table>
    Tanggal Update : <?php echo @$tglupdate ?>
</div>
<script type="text/javascript">
    window.print();
</script>
</body>
</html>