<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> {{ __('Tickets') }} </h4>
            </div>
            
            <div class="col-6">
                <a v-on:click="create()" class="btn btn-primary btn-sm float-right" href="#"><i class="fas fa-plus-circle"></i> {{ __('Create') }}</a>
            </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 Tickets') }}</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="Ticket" />
                </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',
                mixins: [],
                data: {
                    table: "ticket-table",
                    log_id: null,
                },
                mounted: function() {
                    const vm = this;
                    $(document).on('draw.dt', function(e) {
                        vm.$root.load = false;
                        $('.refund-link').click(function() {
                            axios.post($(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;
                        });

                    });
                }
            })
        </script>
        <script>
          function hideModal(){
                     $(".modal-backdrop").remove();
                }   

        </script>

    </x-slot>
</x-app-layout>