document.addEventListener('DOMContentLoaded', function() {
    window.toggleCheckbox = function(value) {
        console.log("toggleCheckbox called with value:", value);

        // Logique pour désactiver/activer les checkboxes
        const achatsCheckboxes = document.querySelectorAll('#achatsOptions input[type=checkbox]');
        const ventesCheckboxes = document.querySelectorAll('#ventesOptions input[type=checkbox]');

        if (value === 'achats') {
            achatsCheckboxes.forEach(checkbox => checkbox.disabled = false);
            ventesCheckboxes.forEach(checkbox => {
                checkbox.checked = false;
                checkbox.disabled = true;
            });
        } else if (value === 'ventes') {
            achatsCheckboxes.forEach(checkbox => {
                checkbox.checked = false;
                checkbox.disabled = true;
            });
            ventesCheckboxes.forEach(checkbox => checkbox.disabled = false);
        }

        // Log pour voir l'état des checkboxes
        console.log("Achats checkboxes disabled:", achatsCheckboxes[0].disabled);
        console.log("Ventes checkboxes disabled:", ventesCheckboxes[0].disabled);
    };
});