<?= $this->session->flashdata('pesan'); ?>

<div class="row mt-3 mb-4">
    <div class="col-sm">
        <div class="card border-bottom-primary shadow">
            <div class="col-sm">
                <div class="mt-2 mb-2">
                    <div class="card-body">
                        <form action="" method="post" class="form-inline">
                            <div class="form-group col-sm-3">
                                <label for="bln" class="col-sm-5 col-form-label">Tanggal Awal</label>
                                <div class="col-sm-7">
                                  <input type="date" class="form-control" id="tgl_awal" name="tgl_awal" value="<?= $tglAwal; ?>">
                                </div>
                            </div>
                            <div class="form-group col-sm-3">
                                <label for="tahun" class="col-sm-5 col-form-label">Tanggal Akhir</label>
                                <div class="col-sm-7">
                                  <input type="date" class="form-control" id="tgl_akhir" name="tgl_akhir" value="<?= $tglAkhir; ?>">
                                </div>
                            </div>
                            <div class="form-group col-sm-3">
                                <label for="bln" class="col-sm-5 col-form-label">Berdasarkan</label>
                                <div class="col-sm-7">
                                    <select name="stts" id="stts" class="custom-select">
                                            <option value="">Pilih Status</option>
                                            <option value="1" <?= ($stts == 1) ? "selected" : null; ?>>Menampilkan Semua Barang</option>
                                            <option value="2" <?= ($stts == 2) ? "selected" : null; ?>>Perubahan Stok Akhir</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group col-sm-3 justify-content-center">
                                <button type="submit" class="btn btn-primary mr-3">
                                    <span class="icon text-white-50">
                                      <i class="fas fa-fw fa-filter"></i>
                                    </span>
                                    <span class="text">Filter</span>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="card shadow-sm border-bottom-primary">
    <div class="card-header bg-white py-3">
        <div class="row">
            <div class="col">
                <h4 class="h5 align-middle m-0 font-weight-bold text-primary">
                      Laporan Stok Harian ( <?= ($stts == 1) ? "Menampilkan Semua Barang" : "Perubahan Stok Akhir"; ?> )
                </h4>
            </div>

        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-striped w-100 dt-responsive nowrap" id="dataTable">
            <thead>
                <tr>
                    <th>No. </th>
                    <th>ID Barang</th>
                    <th>Nama Barang</th>
                    <th>Stok Awal</th>
                    <th>Masuk</th>
                    <th>Keluar</th>
                    <th>Stok Akhir</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                $i = 1;
                foreach($dt_transaksi as $row) { ?>
                <tr>
                    <td><?= $i++; ?></td>
                    <td><?= $row['id_barang']; ?></td>
                    <td><?= $row['nm_barang']; ?></td>
                    <td><?= $row['stok_awal']; ?></td>
                    <td><?= $row['stok_masuk']; ?></td>
                    <td><?= $row['stok_keluar']; ?></td>
                    <td><?= $row['stok_akhir']; ?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
</div>
