<?= $this->extend('layout/template') ?>

<?= $this->section('content') ?>

<div class="container-fluid">

    <?php if (session()->getFlashdata('success')) : ?>
        <div class="alert alert-success">
            <i class="fas fa-check"></i>
            <?= session()->getFlashdata('success') ?>
        </div>
    <?php endif; ?>

    <?php if (session()->getFlashdata('error')) : ?>
        <div class="alert alert-danger">
            <i class="fas fa-times"></i>
            <?= session()->getFlashdata('error') ?>
        </div>
    <?php endif; ?>

    <div class="row">

        <!-- Backup -->
        <div class="col-md-6">
            <div class="card shadow-sm">
                <div class="card-header bg-dark text-white">
                    <h4 class="mb-0">
                        <i class="fas fa-download"></i>
                        Backup Data
                    </h4>
                </div>
                <div class="card-body text-center">
                    <i class="fas fa-file-archive fa-5x text-muted mb-3"></i>
                    <p class="text-muted">Download backup data aplikasi ke perangkat kamu. Simpan file ini sebagai cadangan.</p>
                    <a href="<?= base_url('pengaturan/backup/download') ?>" class="btn btn-dark btn-lg">
                        <i class="fas fa-download"></i> Backup Data
                    </a>
                </div>
            </div>
        </div>

        <!-- Restore -->
        <div class="col-md-6">
            <div class="card shadow-sm">
                <div class="card-header bg-info text-white">
                    <h4 class="mb-0">
                        <i class="fas fa-upload"></i>
                        Restore Data
                    </h4>
                </div>
                <div class="card-body text-center">
                    <i class="fas fa-upload fa-5x text-muted mb-3"></i>
                    <p class="text-muted">Upload file backup yang sudah kamu simpan untuk mengembalikan data. <strong>Data yang ada saat ini akan ditimpa!</strong></p>
                    <form action="<?= base_url('pengaturan/backup/restore') ?>" method="post" enctype="multipart/form-data">
                        <?= csrf_field() ?>
                        <div class="mb-3">
                            <input type="file" name="file_restore" class="form-control" required>
                        </div>
                        <button type="submit" class="btn btn-info btn-lg" onclick="return confirm('Yakin ingin merestore data? Semua data yang ada saat ini akan ditimpa!')">
                            <i class="fas fa-upload"></i> Restore Data
                        </button>
                    </form>
                </div>
            </div>
        </div>

    </div>

    <div class="mt-3">
        <a href="<?= base_url('pengaturan') ?>" class="btn btn-secondary">
            <i class="fas fa-arrow-left"></i> Kembali
        </a>
    </div>

</div>

<?= $this->endSection() ?>
