<nav class="sidebar">
    <div class="sidebar-header">
        <a href="#" id="brand" class="sidebar-brand">
            <span id="brandName" style="font-size: 18px; font-weight: bold;"></span>
        </a>
        <div class=" sidebar-toggler not-active">
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>
    <div class="sidebar-body">
        <ul class="nav">
            <li class="nav-item nav-category">Main</li>
            <li class="nav-item">
                <a href="<?= base_url('Home/index') ?>" class="nav-link">
                    <i class="link-icon" data-feather="home"></i>
                    <span class="link-title">Dashboard</span>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" data-bs-toggle="collapse" href="#masterdata" role="button" aria-expanded="false" aria-controls="masterdata">
                    <i class="link-icon" data-feather="hard-drive"></i>
                    <span class="link-title">Master Data</span>
                    <i class="link-arrow" data-feather="chevron-down"></i>
                </a>
                <div class="collapse" id="masterdata">
                    <ul class="nav sub-menu">
                        <li class="nav-item">
                            <a href="<?= base_url('Pasien'); ?>" class="nav-link">Data Pasien </a>
                        </li>
                        <li class="nav-item">
                            <a href="<?= base_url('Dokter'); ?>" class="nav-link">Data Dokter</a>
                        </li>
                        <li class="nav-item">
                            <a href="<?= base_url('obat'); ?>" class="nav-link">Data Obat</a>
                        </li>
                        <li class="nav-item">
                            <a href="<?= base_url('MasterTindakan'); ?>" class="nav-link">Data Tindakan</a>
                        </li>
                    </ul>
                </div>
            </li>

            <li class="nav-item">
                <a href="<?= base_url('kunjungan') ?>" class="nav-link">
                    <i class="link-icon" data-feather="database"></i>
                    <span class="link-title">Kunjungan</span>
                </a>
            </li>

            <li class="nav-item">
                <a href="<?= base_url('Rekammedis') ?>" class="nav-link">
                    <i class="link-icon" data-feather="archive"></i>
                    <span class="link-title">Rekammedis</span>
                </a>
            </li>

            <li class="nav-item">
                <a href="<?= base_url('tindakan') ?>" class="nav-link">
                    <i class="link-icon" data-feather="gift"></i>
                    <span class="link-title">Tindakan</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="<?= base_url('ResepObat') ?>" class="nav-link">
                    <i class="link-icon" data-feather="award"></i>
                    <span class="link-title">Resep Obat</span>
                </a>
            </li>

            <li class="nav-item">
                <a href="<?= base_url('pembayaran') ?>" class="nav-link">
                    <i class="link-icon" data-feather="shopping-cart"></i>
                    <span class="link-title">Pembayaran</span>
                </a>
            </li>

            <!-- <li class="nav-item">
                <a class="nav-link" data-bs-toggle="collapse" href="#laporan" role="button" aria-expanded="false" aria-controls="laporan">
                    <i class="link-icon" data-feather="hard-drive"></i>
                    <span class="link-title">Laporan</span>
                    <i class="link-arrow" data-feather="chevron-down"></i>
                </a>
                <div class="collapse" id="laporan">
                    <ul class="nav sub-menu">
                        <li class="nav-item">
                            <a href="<?= base_url('laporan/bookings'); ?>" class="nav-link">Laporan Bookings </a>
                        </li>

                    </ul>
                </div>
            </li> -->

            <li class="nav-item">
                <a class="nav-link" data-bs-toggle="collapse" href="#settings" role="button" aria-expanded="false" aria-controls="settings">
                    <i class="link-icon" data-feather="settings"></i>
                    <span class="link-title">Settings </span>
                    <i class="link-arrow" data-feather="chevron-down"></i>
                </a>
                <div class="collapse" id="settings">
                    <ul class="nav sub-menu">
                        <li class="nav-item">
                            <a href="<?= base_url('/Settings') ?>" class="nav-link">Data Settings</a>
                        </li>
                    </ul>
                </div>
            </li>


        </ul>
    </div>
</nav>

<script>
    $(document).ready(function() {
        var level = "<?= session()->get('level'); ?>"; // Ambil level admin dari sesi

        $.ajax({
            url: "<?= base_url('/settings/getSettings') ?>/" + level,
            type: "GET",
            dataType: "json",
            success: function(response) {
                if (response.success && response.settings && response.settings.nama_aplikasi) {
                    // Update nama_aplikasi merek
                    $('#brandName').text(response.settings.nama_aplikasi + "");
                } else {
                    console.error("Pengaturan tidak ditemukan!");
                }
            },
            error: function() {
                console.error("Failed to fetch settings data!");
            }
        });
    });
</script>