<?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([]); ?>

<div class="container-fluid">
    <div class="card">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">Backups</h5>
            <div>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('backup.manage')): ?>
                    <button id="create-backup" class="btn btn-primary btn-sm">Create Backup</button>
                <?php endif; ?>
            </div>
        </div>
        <div class="card-body">
            <table id="backups-table" class="table table-striped table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Filename</th>
                        <th>Status</th>
                        <th>Size</th>
                        <th>Created At</th>
                        <th>Actions</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
$(function() {
    var table = $('#backups-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: {
            url: '<?php echo e(route("admin.backups.data")); ?>',
            type: 'GET'
        },
        columns: [
            { data: 'id', name: 'id' },
            { data: 'filename', name: 'filename' },
            { data: 'status', name: 'status' },
            { data: 'size', name: 'size' },
            { data: 'created_at', name: 'created_at' },
            { data: 'operations', name: 'operations', orderable: false, searchable: false },
        ]
    });

    $('#create-backup').on('click', function() {
        $.ajax({
            url: '<?php echo e(route("admin.backups.store")); ?>',
            method: 'POST',
            headers: { 'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>' },
            success: function(res) {
                alert('Backup job queued');
                table.ajax.reload();
            },
            error: function() { alert('Failed to start backup'); }
        });
    });

    $('#backups-table').on('click', '.js-download-backup', function() {
        var id = $(this).data('id');
        window.location = '<?php echo e(url('admin/backups')); ?>/' + id + '/download';
    });

    $('#backups-table').on('click', '.js-delete-backup', function() {
        var id = $(this).data('id');
        if (!confirm('Delete backup?')) return;
        $.ajax({
            url: '<?php echo e(url('admin/backups')); ?>/' + id,
            method: 'DELETE',
            headers: { 'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>' },
            success: function() { table.ajax.reload(); },
            error: function() { alert('Failed to delete'); }
        });
    });
});
</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\backups.blade.php ENDPATH**/ ?>