diff --git a/payroll/static/payroll/action.js b/payroll/static/payroll/action.js index a3954c677..e91a9ac89 100644 --- a/payroll/static/payroll/action.js +++ b/payroll/static/payroll/action.js @@ -328,10 +328,11 @@ $("#deletePayslipBulk").click(function (e) { languageCode = code; var confirmMessage = deletePayslipMessages[languageCode]; var textMessage = noRowMessages[languageCode]; + var checkedRows = $(".payslip-checkbox").filter(":checked"); ids = []; ids.push($("#selectedPayslip").attr("data-ids")); ids = JSON.parse($("#selectedPayslip").attr("data-ids")); - if (ids.length === 0) { + if (ids.length === 0 & checkedRows.length === 0) { Swal.fire({ text: textMessage, icon: "warning", @@ -347,6 +348,18 @@ $("#deletePayslipBulk").click(function (e) { confirmButtonText: "Confirm", }).then(function (result) { if (result.isConfirmed) { + if (ids.length === 0) { + e.preventDefault(); + ids=[] + checkedRows.each(function(){ + ids.push($(this).attr("id")); + }) + } else if(checkedRows.length === 0) { + e.preventDefault(); + ids = []; + ids.push($("#selectedPayslip").attr("data-ids")); + ids = JSON.parse($("#selectedPayslip").attr("data-ids")); + } $.ajax({ type: "POST", url: "/payroll/payslip-bulk-delete", diff --git a/payroll/templates/payroll/payslip/group_payslips.html b/payroll/templates/payroll/payslip/group_payslips.html index d319d1b5d..fae96eea2 100644 --- a/payroll/templates/payroll/payslip/group_payslips.html +++ b/payroll/templates/payroll/payslip/group_payslips.html @@ -35,12 +35,14 @@