
@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.cash_in_out')}}</h3>
                            </div>
                            <div class="pull-right">
                                <a class="button_info get_insert_form"><span
                                            class="fa fa-plus"></span> {{__('administrator.add_cash_in_out')}}</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <br>&nbsp;
            <div class="wrapper-table"  id="data_table">

            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        $(document).ready(function () {
            $(document).on('click', 'a.page-link', function (e) {
                e.preventDefault();
                let url = $(this).attr('href');
                $.ajax({
                    url: url,
                    data: {},
                    dataType: 'html',
                    success(data) {
                        $('#data_table').html(data);
                    }
                });
            });
        });
        $(document).ready(function () {
            getTable();
            $('.get_insert_form').on('click', function () {
                getHtmlForm('{{route('cash-in-cash-out.create')}}', '{{__('administrator.create')}} {{__('administrator.cash_in_out')}}','400px');
            });
            $('#data_table').on('click', '.get_edit_form', function () {
                getHtmlForm($(this).data('href'), '{{__('administrator.edit')}} {{__('administrator.cash_in_out')}}','400px');
            });
        });

        function getTable() {
            $.ajax({
                url: '{{route('cash-in-cash-out.index')}}',
                dataType: 'html',
                method: 'get',
                data: {},
                success: function (data) {
                    $('#data_table').html(data);
                    // $('#data_table').dataTable();
                },
                error(xhr) {
                    alertErrorFormController(xhr);
                }
            });
        }
    </script>
@stop

