<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?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): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="d-flex align-items-center justify-content-between gap-3">
            <h2 class="h4 mb-0">Delete Log</h2>
            <a href="<?php echo e(route('admin.customers.index')); ?>" class="btn btn-outline-primary"><i class="fas fa-arrow-left"></i> Customer List</a>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="card shadow-sm border-0">
        <div class="card-body">
            <form method="GET" class="row g-2 align-items-center mb-3">
                <div class="col-12 col-md-6 col-lg-4">
                    <div class="input-group">
                        <span class="input-group-text bg-white"><i class="fas fa-search text-muted"></i></span>
                        <input type="search" name="q" value="<?php echo e($search); ?>" class="form-control" placeholder="Code, name, phone or username">
                        <button class="btn btn-primary" type="submit">Search</button>
                    </div>
                </div>
                <?php if($search !== ''): ?>
                    <div class="col-auto"><a href="<?php echo e(route('admin.customers.deleted')); ?>" class="btn btn-outline-secondary">Clear</a></div>
                <?php endif; ?>
            </form>

            <div class="alert alert-warning d-flex align-items-start gap-2 py-2 px-3">
                <i class="fas fa-info-circle mt-1"></i>
                <span>Restore returns the customer and queues the complete MikroTik PPPoE setup. Permanent delete cannot be undone.</span>
            </div>

            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead><tr><th>Customer ID</th><th>Customer Name</th><th>Phone</th><th>PPPoE Username</th><th>Package</th><th>MikroTik</th><th>Deleted At</th><th class="text-end">Action</th></tr></thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr id="deleted-customer-<?php echo e($customer->id); ?>">
                                <td><span class="btn btn-sm btn-outline-secondary fw-semibold"><?php echo e($customer->customer_code); ?></span></td>
                                <td class="fw-semibold"><?php echo e($customer->name); ?></td>
                                <td><?php echo e($customer->contact_phone ?: '—'); ?></td>
                                <td><code><?php echo e($customer->ip_address ?: '—'); ?></code></td>
                                <td><?php echo e($customer->package?->name ?: '—'); ?></td>
                                <td><?php echo e($customer->mikrotik?->name ?: 'Software only'); ?></td>
                                <td class="text-nowrap"><?php echo e($customer->deleted_at?->format('d M Y, h:i A')); ?></td>
                                <td class="text-end">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-sm btn-outline-success restore-customer" data-url="<?php echo e(route('admin.customers.restore', $customer->id)); ?>" data-name="<?php echo e($customer->name); ?>">Restore</button>
                                        <button type="button" class="btn btn-sm btn-outline-danger force-delete-customer" data-url="<?php echo e(route('admin.customers.force-delete', $customer->id)); ?>" data-name="<?php echo e($customer->name); ?>">Permanent Delete</button>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr><td colspan="8" class="text-center text-muted py-5"><i class="fas fa-trash-restore fa-2x mb-2 d-block"></i>No deleted customer found.</td></tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <div class="mt-3"><?php echo e($customers->links()); ?></div>
        </div>
    </div>

    <?php $__env->startPush('scripts'); ?>
        <script>
            document.addEventListener('DOMContentLoaded', function () {
                $(document).on('click', '.restore-customer', function () {
                    const button = $(this);
                    Swal.fire({title: 'Restore customer?', text: button.data('name') + ' will return to the customer list and MikroTik setup will be queued.', icon: 'question', showCancelButton: true, confirmButtonText: 'Yes, restore', confirmButtonColor: '#198754'}).then(function (result) {
                        if (!result.isConfirmed) return;
                        button.prop('disabled', true);
                        axios.patch(button.data('url')).then(function (response) {
                            button.closest('tr').remove();
                            showToast(response.data.message, 'success');
                        }).catch(function (error) {
                            button.prop('disabled', false);
                            showToast(error.response?.data?.message || 'Customer could not be restored.', 'error');
                        });
                    });
                });

                $(document).on('click', '.force-delete-customer', function () {
                    const button = $(this);
                    Swal.fire({title: 'Permanently delete?', html: '<strong>' + $('<div>').text(button.data('name')).html() + '</strong> and all related billing data will be deleted. This cannot be undone.', icon: 'error', showCancelButton: true, confirmButtonText: 'Delete permanently', confirmButtonColor: '#dc3545'}).then(function (result) {
                        if (!result.isConfirmed) return;
                        button.prop('disabled', true);
                        axios.delete(button.data('url')).then(function (response) {
                            button.closest('tr').remove();
                            showToast(response.data.message, 'success');
                        }).catch(function (error) {
                            button.prop('disabled', false);
                            showToast(error.response?.data?.message || 'Permanent deletion failed.', 'error');
                        });
                    });
                });
            });
        </script>
    <?php $__env->stopPush(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH D:\herd\billing\laravel-app\resources\views/admin/customers/deleted.blade.php ENDPATH**/ ?>