File manager - Edit - /home/autoph/public_html/projects/document_tracking/public/js/dashboard.js
Back
function toastRNoTime(message, type, btnType){ toastr.options = { "closeButton": false, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } switch (type){ case 'success': toastr.success(message) toastr.options.onHidden = function(){ $('#return_sender').attr("disabled", true); } break; case 'info': toastr.info(message) break; case 'warning': toastr.warning(message) break; case 'error': toastr.error(message) break; } } function toastRWithTime(message, type, btnType){ toastr.options = { "closeButton": false, "debug": false, "newestOnTop": false, "progressBar": true, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "5000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } switch (type){ case 'success': toastr.success(message) break; case 'info': toastr.info(message) break; case 'warning': toastr.warning(message) break; case 'error': toastr.error(message) break; } } $(document).ready(function(){ // Swal.fire({ // position: 'top-end', // icon: 'success', // title: 'You successfully logged in', // showConfirmButton: false, // timer: 2000 // }); //setInterval(loadMessage,10000); var access_token = localStorage.getItem("token"); // if(!localStorage.getItem("token")){ $('#create-document').validate(); if(!access_token){ window.location.assign('/'); } else { $('#filter_messages').on('change', function(){ var status = $('#filter_messages').val(); if(status == "1"){ $("#docshow").empty(); $.ajax({ type: "GET", url:"api/v2/user/fetchDoc?filter=pending", dataType: 'json', // data:"pending", headers:{ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(data){ var notif = 0; console.log(data); if (data.length == 0){ $('#progress_display').show(); } $.each(data.messages, function(key, value){ console.log(data.messages); // $('#progress_display').show(); var id = value.id; var tr = $("<tr>"); tr.append($("<td>").html(value.control_number)); tr.append($("<td>").html(value.document_title)); tr.append($("<td>").html(value.short_desc)); tr.append($("<td>").html(value.long_desc)); tr.append($("<td>").html(moment(value.due_date).format("dddd, MMMM Do YYYY, h:mm a"))); tr.append($("<td>").html(moment(value.created_at).format("dddd, MMMM Do YYYY, h:mm a"))); if(value.sentDocumentCreatedAt === value.sentDocumentUpdatedAt){ notif++; tr.append($("<td>").html('<button style="border:none" disabled><i class="bi bi-exclamation-circle-fill" style="font-size: 1rem; color:red;"></i></button>')); } else { tr.append($("<td>").html('<button style="border:none" disabled><i class="bi bi-envelope-open-fill" style="font-size: 1rem; color:black;"></i></button>')); } tr.append($("<td align='center'><a href='#' data-bs-toggle='modal' data-bs-target='#detailsModalDocument' class='showDoc' id="+ id + "><i class='bi bi-eye-fill'></i></a></td>>")); $("#docshow").append(tr); }); console.log(notif); }, error: function(e){ alert("something went wrong. Please check your credentials"); } }); } else if (status == "2"){ $("#docshow").empty(); $.ajax({ type: "GET", url:"api/v2/user/fetchDoc?filter=closed", dataType: 'json', // data: "closed", headers:{ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(data){ var notif = 0; console.log(data); if (data.length == 0){ $('#progress_display').show(); } $.each(data.messages, function(key, value){ console.log(data.messages); // $('#progress_display').show(); var id = value.id; var tr = $("<tr>"); tr.append($("<td>").html(value.control_number)); tr.append($("<td>").html(value.document_title)); tr.append($("<td>").html(value.short_desc)); tr.append($("<td>").html(value.long_desc)); tr.append($("<td>").html(moment(value.due_date).format("dddd, MMMM Do YYYY, h:mm a"))); tr.append($("<td>").html(moment(value.created_at).format("dddd, MMMM Do YYYY, h:mm a"))); if(value.sentDocumentCreatedAt === value.sentDocumentUpdatedAt){ notif++; tr.append($("<td>").html('<button style="border:none" disabled><i class="bi bi-exclamation-circle-fill" style="font-size: 1rem; color:red;"></i></button>')); } else { tr.append($("<td>").html('<button style="border:none" disabled><i class="bi bi-envelope-open-fill" style="font-size: 1rem; color:black;"></i></button>')); } tr.append($("<td align='center'><a href='#' data-bs-toggle='modal' data-bs-target='#detailsModalDocument' class='showDoc' id="+ id + "><i class='bi bi-eye-fill'></i></a></td>>")); $("#docshow").append(tr); }); console.log(notif); }, error: function(e){ alert("something went wrong. Please check your credentials"); } }); } }) $.ajax({ type: "GET", url:"api/v2/user/fetchDoc", dataType: 'json', headers:{ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(data){ var notif = 0; console.log(data); if (data.length == 0){ $('#progress_display').show(); } $.each(data.messages, function(key, value){ console.log(data.messages); // $('#progress_display').show(); var id = value.id; var tr = $("<tr>"); tr.append($("<td>").html(value.control_number)); tr.append($("<td>").html(value.document_title)); tr.append($("<td>").html(value.short_desc)); tr.append($("<td>").html(value.long_desc)); tr.append($("<td>").html(moment(value.due_date).format("dddd, MMMM Do YYYY, h:mm a"))); tr.append($("<td>").html(moment(value.created_at).format("dddd, MMMM Do YYYY, h:mm a"))); if(value.sentDocumentCreatedAt === value.sentDocumentUpdatedAt){ notif++; tr.append($("<td>").html('<button style="border:none" disabled><i class="bi bi-exclamation-circle-fill" style="font-size: 1rem; color:red;"></i></button>')); } else { tr.append($("<td>").html('<button style="border:none" disabled><i class="bi bi-envelope-open-fill" style="font-size: 1rem; color:black;"></i></button>')); } tr.append($("<td align='center'><a href='#' data-bs-toggle='modal' data-bs-target='#detailsModalDocument' class='showDoc' id="+ id + "><i class='bi bi-eye-fill'></i></a></td>>")); $("#docshow").append(tr); }); console.log(notif); }, error: function(e){ alert("something went wrong. Please check your credentials"); } }); } // $('#filter_messages').on('change', function(e){ // alert("value changed"); // }); $(document).on('click', '.showDoc', function (e){ var id = $(this).attr('id'); $('<input>').attr({type:'hidden', id:'dc_id', name: 'id', value: id}).appendTo('#detailsModalDocument'); $('#remarksDis').empty(); $.ajax({ type: "GET", url: "api/document/" + id + "/edit", headers:{ 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, // beforeSend: function ( ) { // }, success: function(data){ $("#fileAttachment").empty(); // $('<input>').attr({type:'hidden', id:'dcreactor_id', name: 'dcreactor_id', value: id}).appendTo('#detailsModalDocument'); $("#view-document_id").val(data.document.id) $("#view-document_ctr_no").val(data.document.control_number); $("#view-document_title").val(data.document.document_title); $("#view-document_short_description").val(data.document.short_desc); $("#view-document_long_description").val(data.document.long_desc); $("#view-document_due_date").val(moment(data.document.due_date).format("dddd, MMMM Do YYYY, h:mm a")); $("#view-document_creator").val(data.document.creator_id); $("#view-document_creator_name").val(data.creator_name[0].first_name + " " + data.creator_name[1].last_name); $("#document_sender").val(data.return_sender.sender_id); $("#document_sender_name").val(data.return_sender.senderName + " " + data.return_sender.senderSurname); $.each(data.remarks, function(key,value){ // var id = value.id; console.log(value.remarks); var tr = $("<tr>"); tr.append($("<td>").html(value.name)); tr.append($("<td>").html(value.remarks)); tr.append($("<td>").html(moment(value.created_at).format("MMMM D, YYYY h:mm a"))); $("#remarksDis").append(tr); }); var url = JSON.parse(data.document.url); console.log(url); for(i = 0; i<url.length; i++){ console.log(url[i]); var tr = $("<tr>"); var thumbnail = 'files/' + url[i]; var extension = thumbnail.split('.').pop(); extension = extension.toLowerCase(); const image_type = ["jpeg", "jpg", "png", "gif"]; if(!image_type.includes(extension)){ tr.append($("<td>").html('<i class="bi bi-file-text-fill" style="font-size: 40"></i>' )); } else { tr.append($("<td>").html('<img class="d-block img-fluid" style="width:50px; height:50px" src=' + thumbnail+ '>' )); } tr.append($("<td>").html(url[i])); tr.append($("<td align='center'>").html(" <a href='/files/" + url[i] + "' target='_blank'><i class='bi bi-eye-fill'></i></a> <a href='/files/" + url[i] + "' id='dl_file' download='" + url[i] + "'><i class='bi bi-download'></i></a>")); $("#fileAttachment").append(tr); $('dl_file').trigger('click'); } if(data.receiver_id == data.user.id){ $('#receive_file').attr('disabled', false); } else if (data.receiver_id == 0) { $('#receive_file').attr('disabled', true); } }, error: function(e){ alert("no images to show"); } }); }); // $('#view-status_document').on('change', function(){ // if($('#view-status_document').val() == "return"){ // $('#view-recipient_id').attr("disabled", true); // } else if ($('#view-status_document').val() == "receive") { // $('#view-recipient_id').attr("disabled", false); // } // }); for old selector of status $('#return_sender').click(function (e){ docs = new FormData(); docs.append('sender_id', $('#user_cred').val()); docs.append('file_id', $('#view-document_id').val()); docs.append('recipient_id', $('#document_sender').val()); docs.append('status', "returned"); docs.append('remarks', $('#document_remarks').val()); $.ajax({ type: "POST", url: "api/v2/document/return", datatype: "json", data: docs, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ toastRNoTime("document returned", "warning", "return"); // alert("created successfully"); $('#detailsModalDocument').hide('hide'); location.reload(); }, error: function(e){ alert("something went wrong. Please try again"); } }); //toastRNoTime("document returned", "warning", "return"); }); $('#receive_file').click(function (e){ docs = new FormData(); docs.append('sender_id', $('#user_cred').val()); docs.append('file_id', $('#view-document_id').val()); docs.append('status', $('#view-status_document').val()); docs.append('remarks', $('#document_remarks').val()); e.preventDefault(); $.ajax({ type:"POST", url: "api/v2/document/receiveFile", datatype: "json", data: docs, data: docs, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ // alert(response.message); if(response.type == "success"){ toastRNoTime(response.message, "success", "receive"); $('#receive_file').attr("disabled", true); $('#document_redirect').attr("disabled", false); } else if (response.type == "error"){ toastRNoTime(response.message, "error", "error"); } }, error: function(response){ toastRNoTime("document received already", "error", "return"); } }); // $("#recipientModal").modal("show"); }); $('#document_redirect').click(function (e){ $("#recipientModal").modal("show"); $('#recipient_id').on('change', function (){ //alert($('#recipient_id').val()); $('#document_save').click(function (e){ docs = new FormData(); docs.append('sender_id', $('#user_cred').val()); docs.append('file_id', $('#view-document_id').val()); docs.append('status', "in transit"); docs.append('remarks', $('#document_remarks').val()); docs.append('recipient_id', $('#recipient_id').val()); //console.log($('#recipient_id').val()); $.ajax({ type: "POST", url: "api/v2/document/redirectFile", datatype: "json", data: docs, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ toastRNoTime("file forwarded", "success", "receive"); // alert("file forwarded"); $('#detailsModalDocument').hide('hide'); location.reload(); }, error: function(e){ alert("something went wrong. Please try again"); } }); }); }); }); $('#send_chat').click(function(e){ // toastRNoTime("message sent", "success"); chat = new FormData(); chat.append('sender_id',$('#user_cred').val()); chat.append('file_id',$('#view-document_id').val()); chat.append('message',$('#chat_message').val()); $.ajax({ type: "POST", url: "api/v2/user/sendMessage", datatype: "json", data: chat, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ toastRNoTime("message sent", "success"); loadMessage(); $('#chat_message').val('').change(); }, error: function(error){ alert("unable to send message"); } }) }); $('#pills-profile-tab').click(function (e){ loadMessage(); }); function loadMessage (){ $.ajax({ type: "GET", url: "api/v2/user/readMessage?file_id=" + $('#view-document_id').val(), datatype: "json", data: null, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, beforeSend: function(){ $('#messages_container').empty(); // toastRWithTime("fetching messages please standby","warning"); }, success: function(response){ console.log(response); // var messages = " "; // toastRWithTime("loading messages", "success"); $.each(response.message,function(key, value){ var messagepos = " "; var senderClass = "bg-light rounded py-2 px-3 mb-2"; var timepos = " "; col = "col"; if(response.user == value.id){ messagepos = "justify-content-end"; senderClass = "bg-primary rounded py-2 px-3 mb-2"; timepos = "text-align:right"; col = "col-auto"; } $('#messages_container').append(`<div class="row`+ messagepos + " " + senderClass +`" style="padding: 5 5 5;"> `+`<h6 style="`+ timepos +`">`+ value.message +`</h6>` +` </div>` + `<h6 class="row `+ messagepos +`">` + value.first_name + `<p style="`+ timepos +`" ><small>`+ moment(value.created_at).format("MMMM D, YYYY h:mm:ss a") +`</small></p>` + `</h6>`); }); }, error: function(error){ toastRNoTime("unable to read message"); } }); } $('#finalize').on('click', function(e){ e.preventDefault(); Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Confirm' }).then((result) => { if (result.isConfirmed) { docs = new FormData(); docs.append('sender_id', $('#user_cred').val()); docs.append('file_id', $('#view-document_id').val()); docs.append('status', $('#view-status_document').val()); docs.append('remarks', $('#document_remarks').val()); e.preventDefault(); $.ajax({ type:"POST", url: "api/v2/document/finalizeFile", datatype: "json", data: docs, data: docs, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 'Authorization': 'Bearer ' + access_token}, success: function(response){ // alert(response.message); if(response.type == "success"){ Swal.fire( 'Finalized!', 'file has been finalized.', 'success' ) // toastRNoTime(response.message, "success", "receive"); $('#receive_file').attr("disabled", true); $('#return_sender').attr("disabled",true); $('#document_redirect').attr("disabled", true); } else if (response.type == "error"){ toastRNoTime(response.message, "error", "error"); } }, error: function(response){ toastRNoTime("document received already", "error", "return"); } }); } }); }) });
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings