<?php $__env->startSection('title', 'Backups'); ?>
<?php $__env->startSection('page_title', 'Database Backups'); ?>
<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
    <li class="breadcrumb-item active">Backups</li>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page_actions'); ?>
    <form method="POST" action="<?php echo e(route('backups.create')); ?>" class="d-inline"><?php echo csrf_field(); ?>
        <button class="btn btn-primary"><i class="bi bi-download me-1"></i>Create Backup Now</button>
    </form>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="row g-3">
        
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header"><i class="bi bi-database me-1"></i>Available Backups (<?php echo e(count($backups)); ?>)</div>
                <div class="card-body p-0">
                    <table class="table table-hover align-middle mb-0">
                        <thead class="table-light"><tr><th>File</th><th>Size</th><th>Created</th><th class="text-end">Actions</th></tr></thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $backups; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="small"><i class="bi bi-file-earmark-zip me-1 text-primary"></i><?php echo e($b['name']); ?></td>
                                    <td class="small"><?php echo e(number_format($b['size'] / 1024, 1)); ?> KB</td>
                                    <td class="small"><?php echo e($b['created_at']->format('d M Y, h:i A')); ?> <span class="text-muted">(<?php echo e($b['created_at']->diffForHumans()); ?>)</span></td>
                                    <td class="text-end">
                                        <a href="<?php echo e(route('backups.download', $b['name'])); ?>" class="btn btn-sm btn-light border" title="Download"><i class="bi bi-download"></i></a>
                                        <form method="POST" action="<?php echo e(route('backups.restore')); ?>" class="d-inline" data-confirm="Restore this backup? This will OVERWRITE all current data with the backup.">
                                            <?php echo csrf_field(); ?><input type="hidden" name="existing" value="<?php echo e($b['name']); ?>">
                                            <button class="btn btn-sm btn-light border text-warning" title="Restore"><i class="bi bi-arrow-counterclockwise"></i></button>
                                        </form>
                                        <form method="POST" action="<?php echo e(route('backups.destroy', $b['name'])); ?>" class="d-inline" data-confirm="Delete this backup file?">
                                            <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-light border text-danger" title="Delete"><i class="bi bi-trash"></i></button>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr><td colspan="4" class="text-center text-muted py-4">No backups yet. Click <b>Create Backup Now</b> to make one.</td></tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>

            
            <div class="card mt-3">
                <div class="card-header"><i class="bi bi-upload me-1"></i>Restore from a File</div>
                <div class="card-body">
                    <div class="alert alert-warning small py-2"><i class="bi bi-exclamation-triangle me-1"></i><b>Warning:</b> restoring replaces ALL current data with the uploaded backup. Make a fresh backup first.</div>
                    <form method="POST" action="<?php echo e(route('backups.restore')); ?>" enctype="multipart/form-data" class="row g-2 align-items-end" data-confirm="Restore from this file? This OVERWRITES all current data.">
                        <?php echo csrf_field(); ?>
                        <div class="col-md-8"><input type="file" name="file" accept=".sql,.txt" class="form-control <?php $__errorArgs = ['file'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" required><?php $__errorArgs = ['file'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?></div>
                        <div class="col-md-4"><button class="btn btn-warning w-100"><i class="bi bi-arrow-counterclockwise me-1"></i>Upload & Restore</button></div>
                    </form>
                </div>
            </div>
        </div>

        
        <div class="col-lg-4">
            <div class="card">
                <div class="card-header"><i class="bi bi-clock-history me-1"></i>Automatic Backup Schedule</div>
                <div class="card-body">
                    <form method="POST" action="<?php echo e(route('backups.schedule')); ?>">
                        <?php echo csrf_field(); ?>
                        <div class="form-check form-switch mb-3">
                            <input type="hidden" name="enabled" value="0">
                            <input type="checkbox" class="form-check-input" id="bkEnabled" name="enabled" value="1" <?php if($settings['enabled']): echo 'checked'; endif; ?>>
                            <label class="form-check-label" for="bkEnabled">Enable automatic backups</label>
                        </div>
                        <div class="mb-3">
                            <label class="form-label small">Frequency</label>
                            <select name="frequency" class="form-select">
                                <option value="daily" <?php if($settings['frequency']==='daily'): echo 'selected'; endif; ?>>Daily (2:00 AM)</option>
                                <option value="weekly" <?php if($settings['frequency']==='weekly'): echo 'selected'; endif; ?>>Weekly (Mondays)</option>
                                <option value="monthly" <?php if($settings['frequency']==='monthly'): echo 'selected'; endif; ?>>Monthly (1st)</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label small">Keep last N backups</label>
                            <input type="number" name="keep" value="<?php echo e($settings['keep']); ?>" min="1" max="365" class="form-control">
                            <div class="form-text">Older backups are auto-deleted.</div>
                        </div>
                        <button class="btn btn-primary w-100"><i class="bi bi-check-lg me-1"></i>Save Schedule</button>
                    </form>
                    <hr>
                    <p class="small text-muted mb-0">
                        <i class="bi bi-info-circle me-1"></i>Automatic backups require a system cron job running
                        <code>php artisan schedule:run</code> every minute on the server. Add this in your hosting panel:
                        <br><code class="small">* * * * * php /path/to/artisan schedule:run</code>
                    </p>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/u385418287/domains/itartificer.com/public_html/sms-erp/resources/views/backups/index.blade.php ENDPATH**/ ?>