<?php
/**
 * Page Footer Template
 */
?>
<?php if (SessionManager::isLoggedIn()): ?>
        </main>
    </div>
</div>
<?php endif; ?>

<script>
function toggleSidebar() {
    document.body.classList.toggle('sidebar-collapsed');
}
document.querySelectorAll('.alert').forEach(function(el) {
    setTimeout(function() { el.style.opacity = '0'; setTimeout(function() { el.remove(); }, 300); }, 5000);
});
document.querySelectorAll('[data-confirm]').forEach(function(el) {
    el.addEventListener('click', function(e) {
        if (!confirm(el.getAttribute('data-confirm'))) e.preventDefault();
    });
});

// Load DataTables JS and init
const datatablesScript = document.createElement('script');
datatablesScript.src = 'https://cdn.datatables.net/2.1.5/js/dataTables.js';
datatablesScript.onload = function() {
    const responsiveScript = document.createElement('script');
    responsiveScript.src = 'https://cdn.datatables.net/responsive/3.0.2/js/dataTables.responsive.js';
    responsiveScript.onload = function() {
        const appScript = document.createElement('script');
        appScript.src = '<?= APP_URL ?>/assets/js/items_datatables.js';
        document.head.appendChild(appScript);
    };
    document.head.appendChild(responsiveScript);
};
document.head.appendChild(datatablesScript);

</script>
</body>
</html>
