<div class="page_title">
	<h2>Riwayat</h2>
	<p>Riwayat Retur Barang</p>
</div>

<div class="row">
    <div class="col-sm-12">
        <div class="card shadow-none" >
            <div class="card-header">
                <div class="row justify-content-between mt-3">
                    <div class="col-sm-2 mb-2">
                        <select class="form-select w-px-80 select2-nosrc" id="limiter">
                            <option>10</option>
                            <option selected>25</option>
                            <option>50</option>
                            <option>100</option>
                        </select>
                    </div>
                    <div class="col-sm-4 mb-2">
                        <div class="input-group">
                            <input type="date" id="filter_start" 
                                    class="form-control"
                                    data-bs-toggle="tooltip"
                                    title="Masukan filter tgl mulai"
                                    value="<?= date('Y-m-d', strtotime('-1 month')) ?>"
                            >
                            <input type="date" id="filter_end" 
                                    class="form-control"
                                    data-bs-toggle="tooltip"
                                    title="Masukan filter tgl selesai"
                                    value="<?= date('Y-m-d') ?>"
                            >
                        </div>
                    </div>
                </div>
            </div>
            <div class="card-body p-0" id="data">
                
            </div>
        </div>
    </div>
</div>

<script>
    $(function() {
        load_data(1);
    })

    function load_data(page) {
        $.post({
            url: base_url + 'proses/load_riwayat_retur',
            data: {
                start: $('#filter_start').val(),
                end: $('#filter_end').val(),
                limit: $('#limiter').val(),
                active: page,
            },
            dataType: 'html',
            success: data => {
                $('#data').html(data);
                tooltip()
            }
        })
    }

    $(document).on('change', '#limiter, #filter_start, #filter_end', function() {
        load_data(1);
    })

</script>