<main id="main" class="main">
    <div class="pagetitle">
        <h1>Purchase Order</h1>
        <nav>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url('beranda') ?>">Beranda</a></li>
                <li class="breadcrumb-item">Transaksi</li>
                <li class="breadcrumb-item active">Purchase Order</li>
            </ol>
        </nav>
    </div>
    <!-- End Page Title -->

    <section class="section">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <a href="<?php echo base_url('transaksi/form_po') ?>" class="btn btn-success"><i class="bi bi-plus"></i> Tambah</a>
                        <button class="btn btn-primary" onclick="represh()"><i class="bi bi-arrow-repeat"></i> Refresh</button>
                    </div>
                    <div class="card-body">
                        <div id="peringatan"></div>
                        <!-- Table with stripped rows -->
                        <table class="table table-bordered datatable" id="tabelku" style="width: 100%;">
                        <thead>
                        <tr>
                            <th scope="col">Tanggal</th>
                            <th scope="col">Kode PO</th>
                            <th scope="col">Nama Suplier</th>
                            <th scope="col">Total Item Barang</th>
                            <th scope="col">Nama Pegawai</th>
                            <th scope="col" width="2%"></th>
                            <th scope="col" width="2%"></th>
                            <th scope="col" width="2%"></th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                        </table>
                        <!-- End Table with stripped rows -->
                    </div>
                </div>
            </div>
        </div>
    </section>
</main>
<!-- End #main -->
<div class="modal fade" id="modalform" tabindex="-1">
    <div class="modal-dialog modal-xl">
        <form method="post" id="formdata"></form>
    </div>
</div>
<!-- modal form -->
<div class="modal fade" id="modalhapus" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h6 class="modal-title">Konfirmasi Hapus</h6>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <h5>Apakah akan menghapus purchase order ini?</h5>
            </div>
            <div class="modal-footer">
                <button type="button" value="" class="btn btn-danger" name="hapus" id="hapus" onclick="hapusdata(this.value)"><i class="bi bi-trash"></i> Hapus</button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><i class="bi bi-x-circle"></i> Batal</button>
            </div>
        </div>
    </div>
</div>
<!-- modal hapus -->
<?php @$this->load->view($footer) ?>
<!-- Page specific script -->
<script type="text/javascript">
$(document).ready(function() {
    $("#tabelku").DataTable({
        "processing":true,
        "serverSide":true,
        "responsive":true,
        "ajax":{
                url:"<?php echo base_url('transaksi/datapo') ?>",
                type:"post",
        },
    });
});

function represh() {
    $("#tabelku").DataTable().draw();
}

function konfirhapus(i) {
    $("#hapus").val(i);
    $("#modalhapus").modal("show");
}

function hapusdata(str) {
    $.ajax({
        url:"<?php echo base_url('transaksi/hapus_po') ?>",
        cache:false,
        type:"POST",
        data:{id:str},
        success:function(result){
            $("#peringatan").html(result);
            $("#modalhapus").modal("hide");
            $("#tabelku").DataTable().draw();
        }
    });
}
</script>
<?php @$this->load->view($footerend) ?>
<!-- Page specific script -->