<?php require_once(ROOT_URL.'/includes/asset/asset_functions.php');

switch($_REQUEST['view']){
default:break;
case "edit_attached":require(ROOT_URL.'/includes/asset/asset_edit.php'); break;
case "new_attached":require(ROOT_URL.'/includes/asset/asset_new.php'); break;
}
?>

<script>
const set = '<?= $set?>';
const clientnumber = '<?= $d[0]?>';
const tenant = '<?= $systemUser?>';
const additionalContent = document.getElementById('additionalContent');
const pspCheck = document.getElementById('pspCheck');
const levCheck = document.getElementById('levCheck');
document.addEventListener('DOMContentLoaded', function() {

    // autofill Function
    function autofill(f, s, t) {

        var dest = ROOT_URL + '/includes/asset/asset_options.php?form=' + f + '&source=' + s + '&type=' + t;
        loadModalContent(dest, "popupBox", "modal-xl", 1060, "true", "Auto Fill");
    }



    // Window Resize Handler (Responsive Behavior)
    function adjustArrowIcons() {
        const isSmallScreen = window.innerWidth < 750;
        const arrowElements = document.querySelectorAll('.dirarrow i');

        arrowElements.forEach(arrow => {
            arrow.classList.toggle('fa-arrow-circle-o-right', !isSmallScreen);
            arrow.classList.toggle('fa-arrow-circle-o-down', isSmallScreen);
        });
    }

    adjustArrowIcons(); // Initial adjustment
    window.addEventListener('resize', adjustArrowIcons);

    // resetDD Function
    function resetDD() {
        document.getElementById('clientOpt').value = '';
        document.getElementById('siteOpt').value = '';
        document.getElementById('plantOpt').value = '';
        document.getElementById('confirmbox').style.display = 'none';
    }

    // wsSelect Change Handler (Second document.ready block)
    if (document.getElementById('wsSelect')) { // Check if it exists
        document.getElementById('wsSelect').addEventListener('change', function() {

            // ... (Your event handling logic) ...
            const id = this.value;
            const ws = this.options[this.selectedIndex].text;
            const desc = document.getElementById('desc').options[document.getElementById('desc').selectedIndex].text;
            var dest = `<p>Do you wish to attach <strong>${desc}</strong> to written Scheme <strong>${ws}</strong></p>`
            loadModalContent(dest, "confirmBox", "modal-xl", 1060, "true", "Attach to scheme");


        });
    }
});
</script>