<div class="row">
    <div class="col-md-12">
        <?php
        $alert = $this->session->flashdata('alert');
        if ($alert) {
        ?>
            <div class="alert alert-<?php echo htmlspecialchars($alert['alert'], ENT_QUOTES, 'UTF-8') ?> alert-dismissible fade show" role="alert">
                <b class="alert-heading fs-5">
                    <i class="<?= ($alert['title'] == 'Ups!' ? 'fas fa-times-circle fs-6 me-1' : 'fas fa-check-circle fs-6 me-1') ?>"></i>
                    <strong><?php echo $alert['title'] ?></strong> <!-- Tidak menggunakan htmlspecialchars di sini untuk mendukung HTML -->
                </b>
                <?php echo $alert['msg'] ?> <!-- Tidak menggunakan htmlspecialchars di sini untuk mendukung HTML -->
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        <?php
            $this->session->unset_userdata('alert');
        }

        $swalalert = $this->session->flashdata('swalalert');
        if ($swalalert) {
        ?>
            <script type="text/javascript">
                $(document).ready(function() {
                    var swalalert = <?= json_encode($swalalert) ?>;
                    var alertIcon = (swalalert.title === 'Gagal!' || swalalert.title === 'Ups!' || swalalert.alert === 'danger') ? 'error' : swalalert.alert;

                    Swal.fire({
                        title: `<?= addslashes($swalalert['title']); ?>`, // Menambahkan addslashes untuk mendukung HTML di judul
                        html: `<?= addslashes($swalalert['msg']); ?>`, // Menggunakan opsi 'html' untuk mendukung teks HTML
                        icon: alertIcon,
                        confirmButtonText: 'Okay',
                        customClass: {
                            confirmButton: 'btn btn-primary',
                        },
                        buttonsStyling: false,
                    });
                });
            </script>
        <?php
            $this->session->unset_userdata('swalalert');
        }
        ?>
    </div>
</div>
