<?= $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-4">
                                <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-4">
                                <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-4 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>
                            <!--     <a href="" class="btn btn-primary" data-toggle="modal" data-target="#cetakTrialbalance">
                                    <span class="icon text-white-50">
                                      <i class="fas fa-fw fa-print"></i>
                                    </span>
                                    <span class="text">Cetak</span>
                                </a> -->
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<div class="row mt-3 mb-4">
    <div class="col-sm">

        <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">
                            Nama Barang : <?= $barang['nama_barang']; ?> ( <?= $barang['id_barang']?> )
                        </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>Nama Pemilik</th>
                            <th>Stok Akhir</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $no = 1; 
                        $total_stok = 0;
                        foreach($result_mutasi as $row) { 
                            $res = base64_encode(json_encode(
                                array('id_user_pemilik' => $row['id_user_pemilik'], 'id_barang' => $row['id_barang'])));
                            ?>
                        <tr>
                            <td><?= $no; ?></td>
                            <td><?= $row['nm_user_pemilik']; ?></td>
                            <td><?= $row['stok_akhir'].' '.$row['nama_satuan']; ?></td>
                            <td>
                                <a href="<?= base_url('barang/mutasi_barang_cabang_by_user/') . $res; ?>" class="btn btn-primary btn-circle btn-sm"><i class="fa fa-file"></i></a>
                            </td>
                        </tr>
                        <?php 
                            $total_stok += $row['stok_akhir'];
                        } ?>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="2" class="text-right">Jumlah</td>
                            <td><?= $total_stok.' '.$satuan['nama_satuan']; ?></td>
                            <td></td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>

    </div>
</div>

