<?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 Masuk</title>
</head>

<body>
    <?php
    $query = mysqli_query($con,"SELECT x.*,x1.nama_barang,x1.tipe,x2.nama_merek,x3.nama_satuan
    FROM barang_masuk x 
    JOIN barang x1 ON x1.idbarang=x.barang_id 
    JOIN merek x2 ON x2.idmerek=x1.merek_id 
    JOIN satuan x3 ON x3.id_satuan=x.satuan_id
    WHERE x.tanggal
    ORDER BY x.idbarang_masuk 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 MASUK</h2>
        </div>
        <hr style="border-color:black;">
        <table class="tab">
            <tr>
                <th width="20">NO</th>
                <th>TANGGAL</th>
                <th>TANGGAL PO</th>
                <th>NO PO</th>
                <th>PROJECT NAME</th>
                <th>NAMA BARANG</th>
                <th>MEREK</th>
                <th>TIPE</th>
                <th>JUMLAH MASUK</th>
                <th>SATUAN</th>
                <th>KETERANGAN</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><?= date('d-m-Y',strtotime($row['tanggal_po'])); ?></td>
                <td><?= $row['no_po']; ?></td>
                <td><?= $row['project_name']; ?></td>
                <td><?= $row['nama_barang']; ?></td>
                <td><?= $row['nama_merek']; ?></td>
                <td><?= $row['tipe']; ?></td>
                <td><?= $row['jumlah']; ?></td>
                <td><?= $row['nama_satuan']; ?></td>
                <td><?= $row['keterangan']; ?></td>
                
            </tr>
            <?php endwhile; ?>
        </table>
    </div>
</body>

</html>

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