

<?php if(auth('backend')->user()->can('add-item')): ?>
        <a href="#add-item-room" data-toggle="modal" class="btn btn-success" id="btn-add-item-room" data-room="<?php echo e($roomId); ?>"
           style="float: right">Thêm tài sản</a>
        <?php endif; ?>



<table class="table table-striped table-bordered table-hover" id="items-table">
    <thead>
    <tr style="background-color: #5376B9; color: white">
        <th>STT</th>
        <th>Tên </th>
        <th>Số lượng </th>
        <th>Mã tài sản </th>
        <th>Mã tham chiếu</th>
        <th>Người giao</th>
        <th>Người nhận</th>
        <th style="width: 10%;">Thao tác</th>
    </tr>
    </thead>
    <tfoot>
    <tr>
        <th></th>
        <th><input type="text" class="form-control"></th>
        <th><input type="text" class="form-control"></th>
        <th><input type="text" class="form-control"></th>
        <th><input type="text" class="form-control"></th>
        <th><input type="text" class="form-control"></th>
        <th><input type="text" class="form-control"></th>
        <th style="width: 10%;"></th>
    </tr>
    </tfoot>
</table>
<script>
    var item_table;
    $('#items-table tfoot th').each(function (index) {
        if (index != 0 && index != 3) {
            $(this).html('<input type="text" class="form-control" />');
        }
    });
    item_table = $('#items-table').DataTable({
        "bDestroy": true,
        processing: true,
        searching: true,
        "aaSorting": [],
        serverSide: true,
        ajax: {
            url: '<?php echo url('admin2/room/item.data'); ?>',
            data: {
                room_id: '<?php echo e($roomId); ?>'
            }
        },
        columns: [

            {data: 'DT_Row_Index', name: 'DT_Row_Index', orderable: false, searchable: false},
            {data: 'name', name: 'name'},
            {data: 'number', name: 'number'},
            {data: 'code', name: 'code'},
            {data: 'reference', name: 'reference'},
            {data: 'mover', name: 'mover'},
            {data: 'receiver', name: 'receiver'},
            {data: 'action', name: 'action', 'orderable': false, searchable: false},
        ],
    });


    item_table.columns().every(function (index) {
        if (index !== 0) {
            var that = this;
            $('input', this.footer()).on('keyup change', function () {
                if (that.search() !== this.value) {
                    that
                        .search(this.value)
                        .draw();
                }
            });
        }
    });
</script>