$(document).ready(function() { var oTableTaskLst = $('#tblTaskLst').DataTable({ "dom": 'rt<"bottom text-center"pi><"clear">', "scrollY": "442px", "scrollCollapse": true, "pagingType": "numbers", "processing": true, "serverSide": true, 'responsive': true, 'destroy': true, "columns": [ { "data": null, "orderable": false, "render": function(data, type, row) { var buttons = '
' + action.viewIconButton + '
'; var status = "
" + "
" + "
" + data.status.statusDesc + "
" + "
" + buttons + "
" + "
" + "
" + data.type.description.toUpperCase() + "
" + "
" + data.applicant.toUpperCase() + "
" + "
" + "
" + data.appRefNo + "
" + "
" + data.appDate + "
"; return status; } }, ], "ajax": $.fn.dataTable.pipeline({ "pages": 1, "type": "GET", "url": contextPath + "/taskboard/inbox/paginated", "action": 'xhttp', "cache": false, 'beforeSend': dtRequestHeader, 'dataType': 'json', "dataSrc": dtDataSrc, "data": function(data) { data.globalParam = $("input#globalParam").val(); }, "error": function() { // error handling console.log("error"); } }), "initComplete": function(settings, json) { $('#searchFilter').bind('click', function(e) { oTableTaskLst.columns().search($('input#globalParam').val()).draw(); $(".em-toggle").click(); }); $('#clearFilter').bind('click', function(e) { oTableTaskLst.columns().search($('input#globalParam').val("")).draw(); $(".em-toggle").click(); $('input#globalParam').parent().removeClass("is-filled") }); }, "fnDrawCallback": function(oSettings) { hidePagination(this, "#tblTaskLst"); portalUtil.showMainLoading(false); $("#tblTaskLst thead").remove(); } }); $('#tblTaskLst').dataTable().fnSetFilteringEnterPress(); $('#tblTaskLst tbody').on('click', 'button.view', function() { var d = oTableTaskLst.row($(this).parents('tr')).data(); redirectPath(d); }); $('#tblTaskLst tbody').on('click', 'button.release', function() { var d = oTableTaskLst.row($(this).parents('tr')).data(); Swal.fire({ text: 'Are you sure you want to release the application (' + d.appRefNo + ')?', type: 'question', showCancelButton: true, showConfirmButton: true, cancelButtonText: 'No', confirmButtonText: 'Yes', allowOutsideClick: false, allowEscapeKey: false, cancelButtonColor: '#999999', confirmButtonColor: '#4CAF50' }).then((result) => { if (result.value) { var inputUrl = contextPath + "/taskboard/release"; var dataArr = {}; dataArr.taskMasterId = d.taskMasterId $.ajax({ async: false, global: false, headers: { 'X-CSRF-Token': csrf_token }, type: "POST", action: 'xhttp', url: inputUrl, data: dataArr, success: function(data) { if (data == 'success') { oTableTaskLst.clearPipeline(); oTableTaskLst.ajax.reload(); oTablePoolLst.clearPipeline(); oTablePoolLst.ajax.reload(); portalUtil.showNotification('bottom', 'right', "You have released " + d.appRefNo + " application.", 'success'); } } }); } else if (result.dismiss === swal.DismissReason.cancel) { return false; } }); }); var oTablePoolLst = $('#tblPoolLst').DataTable({ dom: 'rt<"bottom text-center"pi><"clear">', "scrollY": "442px", "scrollCollapse": true, "pagingType": "numbers", "processing": true, "serverSide": true, 'responsive': true, 'destroy': true, "columns": [ { "data": null, "orderable": false, "render": function(data, type, row) { var buttons = '
' + action.viewIconButton + '
'; var status = "
" + "
" + "
" + data.status.statusDesc + "
" + "
" + buttons + "
" + "
" + "
" + data.type.description.toUpperCase() + "
" + "
" + data.applicant.toUpperCase() + "
" + "
" + "
" + data.appRefNo + "
" + "
" + data.appDate + "
"; return status; } }, ], "ajax": $.fn.dataTable.pipeline({ "pages": 1, "type": "GET", "url": contextPath + "/taskboard/pool/paginated", "action": 'xhttp', "cache": false, 'beforeSend': dtRequestHeader, 'dataType': 'json', "dataSrc": dtDataSrc, "data": function(data) { data.globalParam = $("input#globalPoolParam").val(); data.pool = true; }, "error": function() { // error handling console.log("error"); } }), "initComplete": function(settings, json) { $("#tblPoolLst thead").remove(); $('#searchPoolFilter').bind('click', function(e) { oTablePoolLst.columns().search($('input#globalPoolParam').val()).draw(); $(".em-toggle").click(); }); $('#clearPoolFilter').bind('click', function(e) { oTablePoolLst.columns().search($('input#globalPoolParam').val("")).draw(); $(".em-toggle").click(); $('input#globalPoolParam').parent().removeClass("is-filled") }); }, "fnDrawCallback": function(oSettings) { hidePagination(this, "#tblPoolLst"); portalUtil.showMainLoading(false); } }); $('#tblPoolLst').dataTable().fnSetFilteringEnterPress(); $('#tblPoolLst tbody').on('click', 'button.view', function() { var d = oTablePoolLst.row($(this).parents('tr')).data(); redirectPath(d); }); $('#tblPoolLst tbody').on('click', 'button.claim', function() { var d = oTablePoolLst.row($(this).parents('tr')).data(); Swal.fire({ text: 'Are you sure you want to claim the application (' + d.appRefNo + ')?', type: 'question', showCancelButton: true, showConfirmButton: true, cancelButtonText: 'No', confirmButtonText: 'Yes', allowOutsideClick: false, allowEscapeKey: false, cancelButtonColor: '#999999', confirmButtonColor: '#4CAF50' }).then((result) => { if (result.value) { var inputUrl = contextPath + "/taskboard/claim"; var dataArr = {}; dataArr.taskMasterId = d.taskMasterId $.ajax({ async: false, global: false, headers: { 'X-CSRF-Token': csrf_token }, type: "POST", action: 'xhttp', url: inputUrl, data: dataArr, success: function(data) { if (data == 'success') { oTablePoolLst.clearPipeline(); oTablePoolLst.ajax.reload(); oTableTaskLst.clearPipeline(); oTableTaskLst.ajax.reload(); oTableHistoryLst.clearPipeline(); oTableHistoryLst.ajax.reload(); portalUtil.showNotification('bottom', 'right', "You have claimed " + d.appRefNo + " application.", 'success'); } } }); } else if (result.dismiss === swal.DismissReason.cancel) { return false; } }); }); var oTableHistoryLst = $('#tblHistoryLst').DataTable({ dom: 'rt<"bottom text-center"pi><"clear">', "scrollY": "442px", "scrollCollapse": true, "pagingType": "numbers", "processing": true, "serverSide": true, 'responsive': true, 'destroy': true, "columns": [ { "data": null, "orderable": false, "render": function(data, type, row) { var buttons = '
' + action.viewIconButton + '
'; var status = "
" + "
" + "" + data.status.statusDesc + "" + "
" + "
" + buttons + "
" + "
" + data.type.description.toUpperCase() + "
" + "
" + data.applicant.toUpperCase() + "
" + "
" + "
" + data.appRefNo + "
" + "
" + data.appDate + "
"; return status; } }, ], "ajax": $.fn.dataTable.pipeline({ "pages": 1, "type": "GET", "url": contextPath + "/taskboard/history/paginated", "action": 'xhttp', "cache": false, 'beforeSend': dtRequestHeader, 'dataType': 'json', "dataSrc": dtDataSrc, "data": function(data) { data.globalParam = $("#globalParamHistory").val(); data.history = true; }, "error": function() { // error handling console.log("error"); } }), "initComplete": function(settings, json) { $('#searchHistoryFilter').bind('click', function(e) { oTableHistoryLst.columns().search($('input#globalParamHistory').val()).draw(); $(".em-toggle").click(); }); $('#clearHistoryFilter').bind('click', function(e) { oTableHistoryLst.columns().search($('input#globalParamHistory').val("")).draw(); $(".em-toggle").click(); $('input#globalParamHistory').parent().removeClass("is-filled") }); }, "fnDrawCallback": function(oSettings) { hidePagination(this, "#tblHistoryLst"); portalUtil.showMainLoading(false); $("#tblHistoryLst thead").remove(); $('.dataTables_scrollHead').remove(); } }); $('#tblHistoryLst').dataTable().fnSetFilteringEnterPress(); $('#tblHistoryLst tbody').on('click', 'button.view', function() { var d = oTableHistoryLst.row($(this).parents('tr')).data(); redirectPath(d); }); function redirectPath(d) { if (d.type.redirectPath) { var url = contextPath + '/taskboard/workflow'; //d.type.redirectPath; var form = document.createElement("form"); form.setAttribute("method", "GET"); for (let k of Object.keys(d)) { if (d[k] != null) { setAttributes(k, d[k], form); } } form.action = url; document.body.appendChild(form); form.submit(); document.body.removeChild(form); } } function setAttributes(key, val, form) { if (typeof val == 'string' || typeof val == 'number' || typeof val == 'boolean') { $("").attr("type", "hidden") .attr("name", key).attr("value", val) .appendTo(form); } else if (val != null && typeof val == 'object') { for (let s of Object.keys(val)) { setAttributes(key + '.' + s, val[s], form) } } } });