<x-app-layout>
    <x-slot name="header">
        <div class="row">
            <div class="col-6">
                <h4 class="" title><i class="circular icon fa fa-list"></i> {{ __('Payements')  }} </h4>
            </div>
        </div>
    </x-slot>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    {{$dataTable->table()}}
                </div>
            </div>
        </div>  
    </div>
    <div class="modal fade" id="log_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-xl" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">{{ __('Logs Payement') }}</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body" v-if="log_id">
                    <log-activity :id="log_id" model="Payement" />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>


    <x-slot name="after_script">
    <script src="/bower_components/admin-lte/plugins/moment/moment.min.js"></script>
    <script src="/bower_components/admin-lte/plugins/moment/locales.min.js"></script>
        {{$dataTable->scripts()}}
        <script>
                var app = new Vue({
                    el: '#app',
                    data: {
                        table: "payement-table",
                        log_id: null,
                    },
                    mounted:function(){
                        const vm = this; 
                        $(document).on('draw.dt',function(e){
                            vm.$root.load = false;

                            $('.print-link').click(function() {
                                window.open($(this).attr('href'), "_blank",
                                    "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=500,height=400"
                                    );
                                return false;
                            });

                            $('.payement-link').click(function() {
                                axios.put($(this).attr('href')).then(res=>{
                                    vm.reload();
                                })
                                return false;
                            });
                            $('.browse-link').click(function() {
                                vm.log_id = $(this).attr('id');
                                $('#log_modal').modal('show');
                                return false;
                            });

                        });
                    },
                    methods: {
                        
                    }
                })
        </script>
        
    </x-slot>
</x-app-layout>
