<section class="content-header">
    <div class="container-fluid">
        <div id="flash" data-flash="<?= $this->session->flashdata('success'); ?>"></div>
        <div class="row ">
            <div class="col-sm-12">
                <h1>LAP.KEUANGAN - Hutang. Sparepart </h1>
            </div>
        </div>
    </div>
</section>

<div id="flash" data-flash="<?= $this->session->flashdata('success'); ?>"></div>

<section class="content">

    <!-- start pencarian -->
    <div class="container-fluid">
        <form action="" method="get">
            <div class="row mb-3 ">
                <div class="col-12">
                    <?php if (isset($_GET['tgl'])) {
                        $tgl = $_GET['tgl'];
                    } else {
                        $tgl = null;
                    } ?>
                    <div class="input-group align-center">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><i class="fas fa-warehouse"></i></span>
                        </div>
                        <input id="datepickerbulan" placeholder="Pilih Tanggal Arsip" name="tgl" type="text" class="form-control " value="<?= $tgl = $tgl ? $tgl : date('m / Y') ?>" autocomplete="off">

                        <div style="width: 100px" class="input-group-prepend">
                            <button type="submit" class="btn btn-outline-secondary w-100">Pilih</button>
                        </div>
                    </div>
                </div>
        </form>
    </div>
    <!-- ending pencarian -->

    <div class="row">
        <!-- Pendapatan Harian -->
        <div class="col-12 col-md-6 col-sm-6">
            <div class="card border-left-primary ">
                <div class="card-body">
                    <div class="row no-gutters align-items-center">
                        <div class="col mr-2">
                            <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Pemb.Sparepart (&nbsp;<?= $tgl ?>&nbsp;)</div>
                            <div class="h5 mb-0 font-weight-bold text-gray-800"><?= indo_currency($totpesbrg) ?>
                            </div>
                        </div>
                        <div class="col-auto">
                            <i class="fas fa-box fa-2x text-gray-300"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <!-- Pendapatan Harian -->
        <div class="col-12 col-md-6 col-sm-6 mb-2">
            <div class="card border-left-primary ">
                <div class="card-body">
                    <div class="row no-gutters align-items-center">
                        <div class="col mr-2">
                            <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Harga Up Pemb.Sparepart (&nbsp;<?= $tgl ?>&nbsp;)</div>
                            <div class="h5 mb-0 font-weight-bold text-gray-800"><?= indo_currency($totpesbrgup) ?>
                            </div>
                        </div>
                        <div class="col-auto">
                            <i class="fas fa-box fa-2x text-gray-300"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12 col-md-6 col-sm-6 ">
            <div class="card card-outline card-secondary p-2">

                <table id="example2" class="table  table-hover table-sm">
                    <thead>
                        <tr>
                            <th class="text-left">Cek</th>
                            <th class="text-left">Nama Barang</th>
                            <th class="text-left">Qty</th>
                            <th class="text-left">HargaM</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        if ($rowx->num_rows() > 0) {
                            foreach ($rowx->result() as $am => $data) {
                        ?>
                                <tr>

                                    <td>
                                        <?= $data->dateup == 0 ?
                                            '
                                        <button class="btn btn-sm btn-success disabled">
                                            <i class="fas fa-eye-slash"></i>
                                        </button>
                                        '
                                            :
                                            '
                                        <button class="btn btn-sm btn-primary disabled">
                                        <i class="fas fa-eye"></i>
                                    </button>
                                        '
                                        ?>
                                    </td>
                                    <td class="text-left "><?= $data->name_brg ?></td>
                                    <td class="text-left text-uppercase"><?= $data->stok_brg ?></td>
                                    <td class="text-left text-uppercase"><?= $data->hargam_brg ?></td>
                                </tr>
                        <?php
                            }
                        } else {
                            echo '<tr>
                                <td colspan="8" class="text-center"> Tidak Ada Data Sparepart Yang Tersedia </td>
                                </tr>';
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>

        <div class="col-12 col-md-6 col-sm-6 ">
            <div class="card card-outline card-primary p-2">

                <table id="example2" class="table  table-hover table-sm  ">
                    <thead>
                        <tr class="text-center">
                            <th class="text-left">Qty</th>
                            <th class="text-left">Har.Up</th>
                            <th class="text-left">Status</th>
                            <th class="text-left">Date</th>


                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        if ($rowx->num_rows() > 0) {
                            foreach ($rowx->result() as $am => $data) {
                        ?>
                                <tr class="text-center">
                                    <td class="text-left text-uppercase"><?= $data->stok_brgup ?></td>
                                    <td class="text-left text-uppercase"><?= $data->hargam_brgup ?></td>
                                    <td>
                                        <?= $data->dateup == 0 ?
                                            "
                                        <button class='btn btn-sm btn-success'>
   
                                            <i class='fas fa-calendar-check'>  </i>
                                            "
                                            :
                                            "
                                            <button class='btn btn-sm btn-primary'>
   
                                                <i class='fas fa-calendar-check'> </i>
    
                                            "
                                        ?>
                                        </button>
                                    </td>
                                    <td class="text-left text-uppercase"><?= $data->tanggal_brg ?></td>

                                </tr>
                        <?php
                            }
                        } else {
                            echo '<tr>
                                <td colspan="8" class="text-center"> Tidak Ada Data Sparepart Yang Tersedia </td>
                                </tr>';
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>


    <!-- Modal Pesan Barang
    <form action="<?= base_url('Lapkeucabpart/updateharbrgoffice'); ?>" method="post">
        <div class="modal fade bd-example-modal-lg" id="exampleModalCenter1" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered " role="document">
                <div class="modal-content">
                    <div class="modal-body">
                        <div class='row'>
                            <input id="pesanbrgdetail" type="hidden" name="t_pesanbrg_detail" value="">

                            <div class='col-12 col-md-6 col-sm-6 mb-2 '>
                                <div class="input-group align-center">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">Modal KM </span>
                                    </div>
                                    <input id="hargam" name="harga_m" value="" class="form-control " type="text">
                                </div>
                            </div>

                            <div class='col-12 col-md-6 col-sm-6 mb-2 '>
                                <div class="input-group align-center">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">Modal Cab </span>
                                    </div>
                                    <input id="hargaup" name="harga_up" value="" class="form-control " type="text">
                                </div>
                            </div>

                            <div class='col-12 col-md-12 col-sm-12 '>
                                <div class="input-group align-center">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">QTY </span>
                                    </div>
                                    <input id="jumlahbrg" name="jumlah_brg" value="" class="form-control " type="text">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-warning w-100">Update Harga Modal</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
-->
</section>

<script src="<?php echo base_url(); ?>/assets/dist/js/jquery-2.1.1.js"></script>
<script>
    $(document).ready(function() {
        $(document).on('click', '#select', function() {
            var t_pesanbrg_detail = $(this).data('t_pesanbrg_detail');
            var harga_up = $(this).data('harga_up');
            var harga_m = $(this).data('harga_m');
            var jumlah_brg = $(this).data('jumlah_brg');
            $('#hargam').val(harga_m);
            $('#jumlahbrg').val(jumlah_brg);
            $('#hargaup').val(harga_up);

            $('#pesanbrgdetail').val(t_pesanbrg_detail);
        })
    })
</script>