<main id="main" class="main">
    <div class="pagetitle">
        <h1>Laporan Stok Opname</h1>
        <nav>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url('beranda') ?>">Beranda</a></li>
                <li class="breadcrumb-item">Laporan</li>
                <li class="breadcrumb-item active">Stok Opname</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">
                        <div class="row g-2">
                            <div class="col-md-3">
                                <label class="form-label">Tanggal</label>
                                <input type="date" class="form-control" id="tanggal" name="tanggal" value="<?php echo @$tanggal ?>" autofocus>
                            </div>
                            <div class="col-md-2">
                                <label class="form-label" style="color: white;">&nbsp;</label>
                                <button type="button" class="btn btn-primary" style="width: 100%;" onclick="tampilkan()"><i class="bi bi-search"></i> Tampilkan</button>
                            </div>
                            <div class="col-md-2">
                            <label class="form-label" style="color: white;">&nbsp;</label>
                                <button type="button" class="btn btn-success" style="width: 100%;" onclick="cetak()"><i class="bi bi-file-excel"></i> Cetak</button>
                            </div>
                        </div>
                    </div>
                    <div class="card-body" id="konten" style="overflow: auto;">
                    
                    </div>
                </div>
            </div>
        </div>
    </section>
</main>
<?php @$this->load->view($footer) ?>
<!-- Page specific script -->
<script type="text/javascript">
$(document).ready(function() {
    tampilkan();
});

function tampilkan() {
    var tanggal=$("#tanggal").val();
    $.ajax({
        url:"<?php echo base_url('laporan/ajax_stokopname') ?>",
        cache:false,
        type:"POST",
        data:{tanggal:tanggal},
        beforeSend: function(){
            $("#konten").html('<center><img src="<?php echo base_url('assets/img/loading.gif') ?>"></center>');
        },
        success:function(result){
            $("#konten").html(result);
        }
    });
}

function cetak() {
    var tanggal=$("#tanggal").val();
    window.open("<?php echo base_url('laporan/xls_stokopname?') ?>tanggal="+tanggal);
}
</script>
<?php @$this->load->view($footerend) ?>
<!-- Page specific script -->