<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;
    }
    </style>
</head>
<body class="struk" onload="printOut()">
<center>
    <h2>REKAPITULASI SELISIH STOK OPNAME<br>PERIODE <?php echo @strtoupper($awal) ?> SAMPAI <?php echo @strtoupper($akhir) ?></h2>
</center>
<div class="container">
    <table class="tabelku" border="1" cellspacing="0" cellpadding="2">
    <thead>
    <tr>
        <th width="2%" scope="col">No.</th>
        <th scope="col">Tanggal</th>
        <th scope="col">Jumlah Barang</th>
        <th scope="col">HPP Sistem</th>
        <th scope="col">HPP Sebenarnya</th>
        <th scope="col">Selisih HPP</th>
        <th scope="col">Pelaksana</th>
        <th scope="col" width="2%"></th>
    </tr>
    </thead>
    <tbody>
    <?php
    $totalsistem=0;
    $totalnyata=0;
    $totalbarang=0;
    if (@$arropname['tanggal']) {
        $no=1;
        foreach ($arropname['tanggal'] as $key => $value) {
            $sistem=@array_sum($arropname['hrgsistem'][$key]);
            $nyata=@array_sum($arropname['hrgnyata'][$key]);
            $selisih=$nyata-$sistem;
            ?>
            <tr>
                <td><?php echo $no ?></td>
                <td><?php echo tanggalindo($value) ?></td>
                <td align="center"><?php echo @count($arropname['barang'][$key]) ?></td>
                <td align="right"><?php echo number_format($sistem,0,',','.') ?></td>
                <td align="right"><?php echo number_format($nyata,0,',','.') ?></td>
                <td align="right"><?php echo number_format($selisih,0,',','.') ?></td>
                <td><?php echo @$arropname['pegawai'][$key] ?></td>
                <td><a href="<?php echo base_url('stok/cetak_opname?id='.$key) ?>" target="_blank" class="btn btn-xs bg-gradient-secondary"><i class="fa fa-print"></i></a></td>
            </tr>
            <?php
            $totalsistem=$totalsistem+$sistem;
            $totalnyata=$totalnyata+$nyata;
            $totalbarang=$totalbarang+@count($arropname['barang'][$key]);
            $no++;
        }
    }
    $totalselisih=$totalnyata-$totalsistem;
    ?>
    </tbody>
    <tfoot>
    <tr>
        <th colspan="2">Jumlah Total</th>
        <th style="text-align: center;"><?php echo $totalbarang ?></th>
        <th style="text-align: right;"><?php echo number_format($totalsistem,0,',','.') ?></th>
        <th style="text-align: right;"><?php echo number_format($totalnyata,0,',','.') ?></th>
        <th style="text-align: right;"><?php echo number_format($totalselisih,0,',','.') ?></th>
        <th colspan="2"></th>
    </tr>
    </tfoot>
    </table>
</div>
<script type="text/javascript">
    window.print();
</script>
</body>
</html>