<?php
// session_start();
include ('../config/conn.php');
include ('../config/function.php');
?>
<html>

<head>
    <style>
    h2 {
        padding: 0px;
        margin: 0px;
        font-size: 14pt;
    }

    h4 {
        font-size: 12pt;
    }

    text {
        padding: 0px;
    }

    table {
        border-collapse: collapse;
        border: 1px solid #000;
        font-size: 11pt;
    }

    th,
    td {
        border: 1px solid #000;
        padding: 5px;
    }

    table.tab {
        table-layout: auto;
        width: 100%;
    }
    </style>
    <title>Cetak Laporan Barang Keluar</title>
</head>

<body>
    <?php
    $now = date('Y-m-d');
    $query = mysqli_query($con,"SELECT x.*,x1.nama_barang,x1.tipe,x2.nama_merek
    FROM barang_keluar x 
    JOIN barang x1 ON x1.idbarang=x.barang_id 
    JOIN merek x2 ON x2.idmerek=x1.merek_id 
    WHERE x.tanggal='$now' ORDER BY x.idbarang_keluar DESC")or die(mysqli_error($con));
    
    ?>
    <div style="page-break-after:always;text-align:center;margin-top:5%;">
        <div style="line-height:5px;">
            <h2>LAPORAN BARANG KELUAR</h2>
            <h4>SEMUA BARANG KELUAR HARI INI</h4>
        </div>
        <hr style="border-color:black;">
        <table class="tab">
            <tr>
                <th width="20">No</th>
                <th>Tanggal</th>
                <th>Nama Barang</th>
                <th>Merek</th>
                <th>Tipe</th>
                <th>Keterangan</th>
                <th align="center">Jumlah Keluar</th>
                <th>Tanggal BAST</th>
            </tr>
            <?php $n=1; while($row = mysqli_fetch_array($query)): ?>
            <tr>
                <td align="center"><?= $n++.'.'; ?></td>
                <td><?= date('d-m-Y',strtotime($row['tanggal'])); ?></td>
                <td><?= $row['nama_barang']; ?></td>
                <td><?= $row['nama_merek']; ?></td>
                <td><?= $row['tipe']; ?></td>
                <td><?= $row['keterangan']; ?></td>
                <td align="center"><?= $row['jumlah']; ?></td>
                <td><?= date('d-m-Y',strtotime($row['tanggal_bast'])); ?></td>
            </tr>
            <?php endwhile; ?>
        </table>
    </div>
</body>

</html>

<script>
window.print();
</script>