myMedisys/tomcatfiles/mymedisys-frontend/WEB-INF/classes/scripts/registration/registration-list.js

107 lines
3.7 KiB
JavaScript
Raw Normal View History

2023-09-06 05:56:42 +05:30
$(document).ready(function() {
var oTableDqLst = $('#tblDqLst').DataTable({
"processing": true,
"serverSide": true,
'responsive': true,
'destroy' : true,
'sDom': 'lrtip',
"columns": [
{ "data": null, "searchable" : false, "orderable" : false },
{ "data": "status.statusCd", "orderable" : false,
"render": function ( data, type, row ) {
var status = "-", statusDesc;
if(data) {
var color = "badge-primary";
if(data == 'APR') {
color = "badge-success";
statusDesc = "APPROVED";
} else if(data == 'DQC') {
color = "badge-info";
statusDesc = "DATA QUALITY CHECK";
} else {
color = "badge-danger";
statusDesc = "REJECTED";
}
status = "<span class='badge " + color + "'>" + statusDesc + "</span>";
}
return status;
}
},
{ "data": "regRefNo" },
{ "data": "regNo" },
{ "data": "regName", "render": function (data, type, row) {
return data.toUpperCase() || "-";
},
},
{ "data": "email",
"render": function (data, type, row) {
return data || "-";
},
},
{ "data": "contactNo",
"render": function (data, type, row) {
return data || "-";
},
},
{ "data": null, className: 'td-actions text-right', "orderable" : false,
"render": function ( data, type, row ) {
var buttons = action.viewButton;
if(row.status.statusCd == 'DQC') {
buttons = action.editButton;
}
return buttons;
}
},
],
"ajax": $.fn.dataTable.pipeline({
"pages" : 1,
"type" : "GET",
"url": contextPath + "/dataQuality/list/paginated",
"action": 'xhttp',
'beforeSend': dtRequestHeader,
"dataSrc": dtDataSrc,
"data": function ( data ) {
data.regName = $("input#companyName1").val();
data.regRefNo = $("input#rocNumber1").val();
data.status = $('#statusCd1').val();
},
"error": function(e) {
console.log("error: " + e);
}
}),
"initComplete": function(settings, json) {
$('#searchFilter').bind('click', function(e) {
portalUtil.showMainLoading(true);
oTableDqLst
.column(3).search($('input#rocNumber1').val())
.column(5).search($('input#companyName1').val())
.column(2).search($('#statusCd1').val())
oTableDqLst.draw();
$(".em-toggle").click();
});
$('#clearFilter').bind('click', function(e) {
$('input#companyName1').val("")
$('input#rocNumber1').val("")
oTableDqLst.columns().search("").draw();
$(".em-toggle").click();
});
},
"fnDrawCallback": function ( oSettings ) {processRowNum(oSettings); hidePagination(this,"#tblDqLst");portalUtil.showMainLoading(false);}
});
$('#tblDqLst').dataTable().fnSetFilteringEnterPress();
$('#tblDqLst tbody').on( 'click', 'button.view', function () {
var d = oTableDqLst.row( $(this).parents('tr') ).data();
location.href = contextPath + "/dataQuality/getDetails?regNo="+ d.regNo ;
});
$('#tblDqLst tbody').on( 'click', 'button.edit', function () {
var d = oTableDqLst.row( $(this).parents('tr') ).data();
location.href = contextPath + "/dataQuality/getDetails?regNo=" + d.regNo;
});
});