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

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

<div class="container-fluid">

    <div class="card shadow-sm">
        <div class="card-header bg-danger text-white">
            <h4 class="mb-0">
                <i class="fas fa-print"></i>
                Pengaturan Cetak
            </h4>
        </div>
        <div class="card-body">

            <?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; ?>

            <form action="<?= base_url('pengaturan/cetak') ?>" method="post">
                <?= csrf_field() ?>
                <input type="hidden" name="id" value="<?= esc($pengaturan['id'] ?? '') ?>">

                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Ukuran Kertas</label>
                            <select name="ukuran_kertas" class="form-control" required>
                                <option value="A4" <?= (isset($pengaturan['ukuran_kertas']) && $pengaturan['ukuran_kertas'] == 'A4') ? 'selected' : '' ?>>A4 (210 x 297 mm)</option>
                                <option value="F4" <?= (isset($pengaturan['ukuran_kertas']) && $pengaturan['ukuran_kertas'] == 'F4') ? 'selected' : '' ?>>F4 (215 x 330 mm)</option>
                            </select>
                            <small class="text-muted">Ukuran kertas untuk cetak laporan</small>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Footer Cetak</label>
                            <textarea name="footer_cetak" class="form-control" rows="4"><?= esc($pengaturan['footer_cetak'] ?? 'Terima Kasih') ?></textarea>
                            <small class="text-muted">Teks footer yang muncul di bagian bawah laporan</small>
                        </div>
                    </div>
                </div>

                <hr>

                <button type="submit" class="btn btn-danger">
                    <i class="fas fa-save"></i> Simpan Pengaturan
                </button>

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

        </div>
    </div>

</div>

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