<script src="/js/plugins/chosen/chosen.jquery.js"></script>
<script src="/js/plugins/chosen/chosen.ajaxaddition.jquery.js"></script>
<script>
    $(".tabledit-edit-button").on('click', function(e){
        e.preventDefault();
        $("#edit_name").val($(this).attr('data-name'));
        $("#edit_email").val($(this).attr('data-email'));
        $("#edit_status").val($(this).attr('data-status'));
        $("#edit_id").val($(this).attr('data-id'));

        $("#editTeqtivityUser").modal('show');
    });

    $(".delete-button").on("click", function () {
        var id = $(this).attr('data-id');
        var userName = $(this).attr('data-name')+' - '+$(this).attr('data-email');
        $('#confirm-delete').modal('show');
        $('#confirm-delete').attr('data-form', $(this).attr('data-id'));

        $('#confirm-message').html('Are you sure you want to delete ' + userName + ' ? ');
    });

    $(".confirm-delete-button").on("click", function () {
        var formData = $("#" + $('#confirm-delete').attr('data-form')).serialize();
        $.ajax({  
		    type: "POST",  
		    url: '<?php echo e(route('teqtivity-users.check-history-exists')); ?>',  
		    data: formData,  
		    success: function(data) {
				if(data) {
                    $('#confirm-delete').modal('hide');
                    $('#user_id').val($('#confirm-delete').attr('data-form'));
                    $('#changeHistoryUser').modal('show');
                } else {
                    $("#" + $('#confirm-delete').attr('data-form')).submit()
                }                
		    }
		});
    });

    $(".update-user-history-submit").on("click", function () {
        $('#update-user-history-form').submit();
    });

    $('.teq-user-ajax').each(function () {
        $(this).ajaxChosen({
            dataType: 'json',
        }, {
            processItems: function (data) { return data },
            generateUrl: function (q) { return '/get-filter-teqtivity-user?search=' + q +'&current_user_id=' + $('#user_id').val() ; },
        },
            {
                width: "100%"
            }).change(function () {
                $(this).closest('.form-group').next().find('input').focus();
            });
    });
</script><?php /**PATH /var/www/html/nebius/resources/views/settings/teqtivity-users/partials/scripts.blade.php ENDPATH**/ ?>