@extends(branchMenu())
@section('content')
    <?php Fun::lang()?>
    <div class="page">
        <div class=container-fluid>
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12">
                        <div class="title-add">
                            <div class="pull-left">
                                <h3>{{__('administrator.tracking')}}</h3>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <br>&nbsp;
            <br>
            <div class="top-content">
                <div class="row">
                    <div class="col-sm-12 col-xs-12 form-group ">
                        <div>
                            <div class="col-sm-3 col-md-3">
                                <div class="col-sm-3 col-md-3" style="margin-top: 5px">
                                    {{__('administrator.user')}}
                                </div>
                                <div class="form-group col-sm-9 col-md-9">
                                    {!! Form::select('user_id',$user, null, array('class' => 'form-control select2', 'placeholder' =>__('administrator.please_select'))) !!}
                                </div>
                            </div>
                            <div class="col-sm-3 col-md-3">
                                <div class="col-sm-3 col-md-3" style="margin-top: 5px">
                                    {{__('administrator.warehouse')}}
                                </div>
                                <div class="form-group col-sm-9 col-md-9">
                                    {!! Form::select('warehouse_id',$wh, null, array('class' => 'form-control select2', 'placeholder' =>__('administrator.please_select'))) !!}
                                </div>
                            </div>
                            <div class="col-sm-3 col-md-3">
                                <div class="col-sm-3 col-md-3" style="margin-top: 5px">
                                    {{__('administrator.type')}}
                                </div>
                                <div class="form-group col-sm-9 col-md-9">
                                    {!! Form::select('type',$type, null, array('class' => 'form-control select2', 'placeholder' =>__('administrator.please_select'))) !!}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wrapper-table">
                <table id="print_table" class="table table-striped table-hover">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>{{__('administrator.user')}}</th>
                        <th>{{__('administrator.date')}}</th>
                        <th>{{__('administrator.type')}}</th>
                        <th>{{__('administrator.warehouse')}}</th>
                        <th>{{__('administrator.barcode')}}</th>
                        <th>{{__('administrator.qty')}}</th>
                        <th>{{__('administrator.balance_qty')}}</th>
                        <th>{{__('administrator.description')}}</th>
                    </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        function getTable() {
            let warehouse = $('select[name="warehouse_id"]').val();
            let user_id = $('select[name="user_id"]').val();
            let type = $('select[name="type"]').val();
            $('#print_table').DataTable().destroy();
            $('#print_table').DataTable({
                ordering: false,
                serverSide: true,
                lengthMenu: tbLeng,
                ajax: {
                    url: "",
                    data: {
                        warehouse,
                        user_id,
                        type
                    }
                },
                columns:
                    [
                        {data: 'DT_RowIndex', 'searchable': false},
                        {data: 'user_id', 'searchable': false},
                        {data: 'date', 'searchable': false},
                        {data: 'type', 'searchable': false},
                        {data: 'warehouse_id', 'searchable': false},
                        {data: 'barcode'},
                        {data: 'qty', 'searchable': false},
                        {data: 'last_stock', 'searchable': false},
                        {data: 'note'},

                    ],
                "initComplete": function (settings, json) {
                }
            });
        }

        $(document).ready(function () {
            getTable();
            $('#print_table').on('click','.btn_delete',function () {
                confirmForm($(this).data('href'));
            });
            $('.select2').on('change', function () {
                getTable();
            });
        });
    </script>
@stop
