<?php include 'inc/inventory_menu.php'; ?>

<div class="row">
    <div class="col-md-12">
        <?php
        $filter_config = [
            [
                'type' => 'text',
                'name' => 'q',
                'label' => lang('search'),
                'placeholder' => lang('search_by') . ' ' . __('item_name'),
                'column' => 'col-md-3'
            ],


            [
                'type' => 'dropdown',
                'name' => 'priority',
                'label' => lang('priority'),
                'data' =>   [
                    [
                        'id' => 'urgent',
                        'name' => lang('urgent')
                    ],
                    [
                        'id' => 'high',
                        'name' => lang('high')
                    ],
                    [
                        'id' => 'normal',
                        'name' => lang('normal')
                    ],

                ],
                'value' => 'id',
                'text' => 'name',
                'placeholder' => lang('all'),
                'column' => 'col-md-2'
            ],
            [
                'type' => 'dropdown',
                'name' => 'status',
                'label' => lang('status'),
                'data' =>   [
                    [
                        'id' => 'pending',
                        'name' => lang('pending')
                    ],
                    [
                        'id' => 'approve',
                        'name' => lang('approve')
                    ],
                    [
                        'id' => 'cancel',
                        'name' => lang('cancel')
                    ],
                ],
                'value' => 'id',
                'text' => 'name',
                'placeholder' => lang('all'),
                'column' => 'col-md-2'
            ]
        ];
        $this->load->view('backend/common/filter_page', ['filter_config' => $filter_config]);
        ?>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header px-17">
                <h3 class="card-title flex-1"><i class="fa-solid fa-cart-flatbed"></i>&nbsp; <?= lang('current_inventory') ?></h3>
            </div>
            <div class="card-body">
                <?php $this->load->view('backend/inventory/request_table'); ?>
            </div>
        </div>
    </div>
</div>


<script>
    $(document).on('change', '.request_select', function(s) {
        s.preventDefault();
        var url = $(this).val();

        $.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            data: {
                'csrf_test_name': csrf_value
            },
            success: function(json) {
                console.log(json);
                if (json.success) {
                    location.reload();
                }
            }
        })
    })
</script>