
@extends(branchMenu())
@section('content')
    <?php Fun::lang()?>
    <div class="container-fluid">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class="row">
                    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                        <h3>{{__('administrator.tailor_due')}}</h3>
                    </div>
                </div>
                <div class="container-fluid" style="background: white; padding:10px">
                    <div class="row">
                        {!! Form::open(['class'=>'form_data']) !!}
                        <div class="col-sm-3 col-md-3">
                            <div class="col-sm-3 col-md-3" style="margin-top: 5px">
                                {{__('administrator.tailor')}}
                            </div>
                            <div class="form-group col-sm-9 col-md-9">
                                {!! Form::select('tailor_id', getTailor('ert')->pluck('name','id') , null , ['placeholder'=>__('administrator.please_select'),'class' => 'form-control select2']) !!}
                            </div>
                        </div>
                        <div class="col-sm-3 col-md-3">
                            <div class="col-sm-3 col-md-3" style="margin-top: 5px">
                                {{__('administrator.date')}}
                            </div>
                            <div class="form-group col-sm-9 col-md-9">
                                <input type="text" class="form-control date_picker" name="date"
                                       value="">
                            </div>
                        </div>
                        <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 form-group">
                            <div class="col-sm-12">
                                <button type="button"
                                        class="button_info pull-right submit_search">{{__('administrator.search')}}</button>
                            </div>
                        </div>
                        {!! Form::close() !!}
                    </div>
                    <div class="table-responsive">
                        <table id="table" class="table table-hover" style="white-space: nowrap">
                            <thead>
                            <tr>
                                <th width="5%">#</th>
                                <th>{{__('administrator.date')}}</th>
                                <th>{{__('administrator.invoice')}}</th>
                                <th>{{__('administrator.user')}}</th>
                                <th>{{__('administrator.tailor')}}</th>
                                <th>{{__('administrator.amount')}}</th>
                            </tr>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                    </div>
                </div>

            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        let $table = $('#table');
        $(document).ready(function () {
            getTable();
            $('.submit_search').on('click', function () {
                getTable();
            });
        });
        function getTable() {
            $table.DataTable().destroy();
            $table.DataTable({

                searching: false,
                ordering: false,
                processing: false,
                serverSide: true,
                lengthMenu: [20, 30, 50, 100, 200, 500, 1000],
                ajax: {
                    url: "{{ route('tailor-due')}}?"+$('.form_data').serialize(),
                },
                columns:
                    [
                        {data: 'DT_RowIndex', 'searchable': false},
                        {data: 'payment_date'},
                        {data: 'invoice_number'},
                        {data: 'payment_by'},
                        {data: 'tailor1'},
                        {data: 'paid_amount'},
                    ],
                "initComplete": function (settings, json) {

                }

            });
        }
    </script>
@endsection
