<?php

//employee_as_admin_checkbox_js.ctp

?>

<script>
    var EPLOYEE_ACCESS_CONTROLLER_ID = '<?php echo EPLOYEE_ACCESS_CONTROLLER_ID ?>'
    var EPLOYEE_MESSAGING_CONTROLLER_ID = '<?php echo EPLOYEE_MESSAGING_CONTROLLER_ID ?>'
    var STAISTICS_CONTROLLER_ID = '<?php echo STAISTICS_CONTROLLER_ID ?>'

    function checkAllCheckbox(elem){
        $('.permissionBox input[type=checkbox]').prop('checked',false)
        var employee_access_checkbox = $(`.permissionBox input[type=checkbox][value="${EPLOYEE_ACCESS_CONTROLLER_ID}"]`);
        employee_access_checkbox.prop('checked',false).attr('disabled',true)
        $('input[name="is_show_all_clients"]').prop('checked',false)
        $('input[name="has_analysis_analyzer"]').prop('checked',false)
        $(`.permissionBox input[type=checkbox][value="${STAISTICS_CONTROLLER_ID}"]`)
            .not(`input[name="has_velocity"]`)
            .prop('checked',true);
        if($(elem).prop('checked')){
            $('.permissionBox input[type=checkbox]')
                .prop('checked',true)
            $('input[name="is_show_all_clients"]').prop('checked',true)
            $('input[name="has_analysis_analyzer"]').prop('checked',true)
            employee_access_checkbox.attr('disabled',false)
        }
    }
</script>
