


<script>
 function OpenSetNotesButtonHtml(){return HomeMenuButtons('assets/notes.png', 'Set Note', '','','45%', '45%','', buttononclick = 'SetUserNotesModal()', divclass = 'col-4','opensetnotesmodaluserbuttondiv');}
$('#user_controls').append(OpenSetNotesButtonHtml());


function EraseUserNotesTarget(){
            function ShowConfirmationEraseUserNotesTarget(response){
                if (response){
                    ModalQuickDismiss('Success', 'Note Deleted');
                    hidemodal('SetUserNotesModal');
                }else{
                    ModalQuickDismiss('Failed', 'Unable to Delete Note.');
                }
            }
            AjaxDo('?admin/user/note/delete',{targethash:currenttarget},ShowConfirmationEraseUserNotesTarget,null,'POST',false);
        }

function UpdateUserNotesTarget(){
let newnotevalue  = $('#SetUserNotesContentTextArea').val();
if (!newnotevalue){ModalQuickDismiss('Failed', 'No Content. Note was not updated.'); return false;}

function NoteUpdateConfirmationTarget(response){
if (!response){
    ModalQuickDismiss('Failed', 'Unable to Update Notes'); return false;
}else{
    ModalQuickDismiss('Updated', 'Notes Updated.');
    hidemodal('SetUserNotesModal');return true;
}
}
 AjaxDo('?admin/user/note/update',{targethash:currenttarget, newnotecontent: newnotevalue},NoteUpdateConfirmationTarget,null,'POST',false);

}


    function SetUserNotesModal() {
        let modalbody = `<textarea id="SetUserNotesContentTextArea" class="form-control" rows="4" cols="50">
                        </textarea>`;

        


        let modalfooter = `<button class="btn btn-primary" onclick="UpdateUserNotesTarget()">Update</button><button class="btn  btn-danger" onclick="EraseUserNotesTarget();">Clear</button>`;
        CreateAndShowModal('SetUserNotesModal', 'Set Notes For User', modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header');
        $('#SetUserNotesContentTextArea').load('?admin/user/note/content',{targethash:currenttarget});
    }

</script>