<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\AppLayout::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <div class="app-main flex-column flex-row-fluid">
        <div class="d-flex flex-column flex-column-fluid">
            <div class="app-toolbar py-3 py-lg-6">
                <div class="app-container container-xxl d-flex flex-stack">
                    <div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
                        <h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">
                            Invoice Management</h1>
                        <?php echo e(Breadcrumbs::render('invoice.index')); ?>

                    </div>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('invoice-add')): ?>
                    <div class="d-flex align-items-center ml-auto gap-2 gap-lg-3">
                        <?php if (isset($component)) { $__componentOriginal71c6471fa76ce19017edc287b6f4508c = $component; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.add-back-button','data' => ['onclick' => 'window.location=\''.e(route('admin.invoice.create')).'\'']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('add-back-button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['onclick' => 'window.location=\''.e(route('admin.invoice.create')).'\'']); ?>
                            <i class="ki-duotone ki-plus fs-2"></i>
                            <span class="indicator-label"><?php echo e(__('Add Invoice')); ?></span>
                         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal71c6471fa76ce19017edc287b6f4508c)): ?>
<?php $component = $__componentOriginal71c6471fa76ce19017edc287b6f4508c; ?>
<?php unset($__componentOriginal71c6471fa76ce19017edc287b6f4508c); ?>
<?php endif; ?>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
            <div class="app-content flex-column-fluid">
                <div class="app-container  container-xxl ">
                    <div class="pb-0 sm:p-8 bg-white shadow sm:rounded-lg">
                        <?php
if (! isset($_instance)) {
    $html = \Livewire\Livewire::mount('invoicetable')->html();
} elseif ($_instance->childHasBeenRendered('zSEuK3j')) {
    $componentId = $_instance->getRenderedChildComponentId('zSEuK3j');
    $componentTag = $_instance->getRenderedChildComponentTagName('zSEuK3j');
    $html = \Livewire\Livewire::dummyMount($componentId, $componentTag);
    $_instance->preserveRenderedChild('zSEuK3j');
} else {
    $response = \Livewire\Livewire::mount('invoicetable');
    $html = $response->html();
    $_instance->logRenderedChild('zSEuK3j', $response->id(), \Livewire\Livewire::getRootElementTagName($html));
}
echo $html;
?>
                    </div>
                </div>
            </div>
        </div>
    </div>
     <?php $__env->slot('scripts', null, []); ?> 
        <script>
        $(document).ready(function () {

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $('.delete').on('click', function () {
                var invoiceId = $(this).data('id');
                var invoiceName = $(this).data('name');

                Swal.fire({
                    title: 'Confirm Deletion',
                    text: 'Are you sure you want to delete invoice "' + invoiceName + '"?',
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonText: 'Yes, delete it!',
                    cancelButtonText: 'Cancel',
                    reverseButtons: true,
                    customClass: {
                        confirmButton: 'btn btn-success',
                        cancelButton: 'btn btn-danger'
                    },
                }).then((result) => {
                    if (result.isConfirmed) {
                        var url = '<?php echo e(route("admin.invoice.destroy", ":id")); ?>';
                        url = url.replace(':id', invoiceId); // Use invoiceId here

                        $.ajax({
                            url: url,
                            type: 'POST',
                            dataType: 'json',
                            data: {
                                '_method': 'DELETE'
                            },
                            success: function(data) {
                                if (data['alert-type'] == 'success') {
                                    toastr.success(data.message);
                                    setTimeout(function () {
                                        location.reload(); // Reload the page after deletion
                                    }, 1000);
                                }
                            },
                            error: function(data) {
                                Swal.fire({
                                    title: 'Oops...',
                                    html:
                                        'Report to admin with the following message <br/>' +
                                        data.responseJSON.message,
                                    icon: 'error',
                                })
                            }
                        });
                    }
                });
            });
        });
        </script>
     <?php $__env->endSlot(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\local.kpb\resources\views/invoice/index.blade.php ENDPATH**/ ?>